Skip to content

Commit

Permalink
Migrate tests to JUnit5 (#626)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tristan-WorkGH authored Oct 23, 2024
1 parent 8ab26ab commit f0d4664
Show file tree
Hide file tree
Showing 60 changed files with 1,736 additions and 2,688 deletions.
56 changes: 12 additions & 44 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@

<properties>
<gridsuite-dependencies.version>34</gridsuite-dependencies.version>
<log4j2-mock-version>0.0.2</log4j2-mock-version>
<testcontainers.version>1.18.3</testcontainers.version>
<liquibase-hibernate-package>org.gridsuite.study.server</liquibase-hibernate-package>
<mockwebserver3.version>5.0.0-alpha.14</mockwebserver3.version>
<apache.httpclient.version>5.3</apache.httpclient.version>
<!-- FIXME: powsybl-ws-commons version is overridden. To be removed at next gridsuite-dependencies.version upgrade -->
<powsybl-ws-commons.version>1.15.0</powsybl-ws-commons.version>
Expand Down Expand Up @@ -86,6 +85,13 @@
<dependencyManagement>
<dependencies>
<!-- overrides of imports -->
<dependency><!-- To remove when integrate in next release of gridsuite-dependencies or powsybl-ws-dependencies -->
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp-bom</artifactId>
<version>${mockwebserver3.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!-- FIXME: powsybl-ws-commons version is overridden. To be removed at next gridsuite-dependencies.version upgrade -->
<dependency>
<groupId>com.powsybl</groupId>
Expand Down Expand Up @@ -121,17 +127,6 @@
</dependency>

<!-- project specific dependencies -->
<dependency>
<groupId>de.dentrassi.elasticsearch</groupId>
<artifactId>log4j2-mock</artifactId>
<version>${log4j2-mock-version}</version>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>elasticsearch</artifactId>
<version>${testcontainers.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down Expand Up @@ -214,12 +209,6 @@
<artifactId>liquibase-core</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
<version>${apache.httpclient.version}</version>
</dependency>
<!-- PostgreSQL -->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
Expand Down Expand Up @@ -268,27 +257,7 @@
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>mockwebserver</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<artifactId>mockwebserver3-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -313,12 +282,12 @@
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>elasticsearch</artifactId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>de.dentrassi.elasticsearch</groupId>
<artifactId>log4j2-mock</artifactId>
<groupId>org.testcontainers</groupId>
<artifactId>elasticsearch</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -327,5 +296,4 @@
<scope>test</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@ public ImpactType getType() {
return ImpactType.SIMPLE;
}

@Override
public boolean isSimple() {
return true;
}

@Override
public boolean isCollection() {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public abstract class AbstractNodeInfoEntity extends AbstractManuallyAssignedIde
@Column(name = "idNode", insertable = false, updatable = false)
private UUID idNode; // don't bother with getter/setter since the `idNode` reference handles everything

@Override
public UUID getId() {
return idNode;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

package org.gridsuite.study.server.service;

/**
Expand All @@ -13,7 +12,6 @@

import org.apache.commons.lang3.StringUtils;
import org.gridsuite.study.server.RemoteServicesProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpMethod;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
Expand All @@ -34,7 +32,6 @@ public class ActionsService {

private String actionsServerBaseUri;

@Autowired
public ActionsService(RemoteServicesProperties remoteServicesProperties, RestTemplate restTemplate) {
this.actionsServerBaseUri = remoteServicesProperties.getServiceUri("actions-server");
this.restTemplate = restTemplate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

package org.gridsuite.study.server.service;

/**
Expand All @@ -14,7 +13,6 @@
import org.gridsuite.study.server.StudyException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpMethod;
import org.springframework.stereotype.Service;
Expand All @@ -37,7 +35,6 @@ public class CaseService {

private static final Logger LOGGER = LoggerFactory.getLogger(CaseService.class);

@Autowired
public CaseService(@Value("${powsybl.services.case-server.base-uri:http://case-server/}") String caseServerBaseUri, RestTemplate restTemplate) {
this.caseServerBaseUri = caseServerBaseUri;
this.restTemplate = restTemplate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

package org.gridsuite.study.server.service;

import com.fasterxml.jackson.core.JsonProcessingException;
Expand All @@ -23,7 +22,6 @@
import org.gridsuite.study.server.service.shortcircuit.ShortCircuitService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.messaging.Message;
import org.springframework.stereotype.Service;
Expand Down Expand Up @@ -68,7 +66,6 @@ public class ConsumerService {
private final StudyRepository studyRepository;
private final ShortCircuitService shortCircuitService;

@Autowired
public ConsumerService(ObjectMapper objectMapper,
NotificationService notificationService,
StudyService studyService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

package org.gridsuite.study.server.service;

import org.gridsuite.study.server.RemoteServicesProperties;
import org.gridsuite.study.server.StudyException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
Expand Down Expand Up @@ -45,7 +43,6 @@ public String getBaseUri() {
return baseUri;
}

@Autowired
public FilterService(RemoteServicesProperties remoteServicesProperties, RestTemplate restTemplate) {
this.baseUri = remoteServicesProperties.getServiceUri("filter-server");
this.restTemplate = restTemplate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

package org.gridsuite.study.server.service;

/**
Expand All @@ -13,7 +12,6 @@

import org.apache.commons.lang3.StringUtils;
import org.gridsuite.study.server.RemoteServicesProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.util.UriComponentsBuilder;
Expand All @@ -31,7 +29,6 @@ public class GeoDataService {

private String geoDataServerBaseUri;

@Autowired
public GeoDataService(RemoteServicesProperties remoteServicesProperties, RestTemplate restTemplate) {
this.geoDataServerBaseUri = remoteServicesProperties.getServiceUri("geo-data-server");
this.restTemplate = restTemplate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

package org.gridsuite.study.server.service;

import com.fasterxml.jackson.core.JsonProcessingException;
Expand All @@ -15,7 +14,6 @@
import org.gridsuite.study.server.dto.*;
import org.gridsuite.study.server.repository.StudyEntity;
import org.gridsuite.study.server.service.common.AbstractComputationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.data.domain.Sort;
import org.springframework.http.*;
Expand Down Expand Up @@ -48,7 +46,6 @@ public class LoadFlowService extends AbstractComputationService {
private final NetworkModificationTreeService networkModificationTreeService;
private String loadFlowServerBaseUri;

@Autowired
public LoadFlowService(RemoteServicesProperties remoteServicesProperties,
NetworkModificationTreeService networkModificationTreeService,
NetworkService networkStoreService, ObjectMapper objectMapper,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

package org.gridsuite.study.server.service;

/**
Expand All @@ -16,7 +15,6 @@
import org.gridsuite.study.server.StudyException;
import org.gridsuite.study.server.dto.IdentifiableInfos;
import org.gridsuite.study.server.dto.InfoTypeParameters;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
Expand Down Expand Up @@ -45,7 +43,6 @@ public class NetworkMapService {

private String networkMapServerBaseUri;

@Autowired
public NetworkMapService(RemoteServicesProperties remoteServicesProperties, RestTemplate restTemplate) {
this.networkMapServerBaseUri = remoteServicesProperties.getServiceUri("network-map-server");
this.restTemplate = restTemplate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.gridsuite.study.server.repository.nonevacuatedenergy.NonEvacuatedEnergyParametersEntity;
import org.gridsuite.study.server.repository.nonevacuatedenergy.NonEvacuatedEnergyStageDefinitionEntity;
import org.gridsuite.study.server.repository.nonevacuatedenergy.NonEvacuatedEnergyStagesSelectionEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
Expand Down Expand Up @@ -78,7 +77,6 @@ public class NonEvacuatedEnergyService {

private final NetworkModificationTreeService networkModificationTreeService;

@Autowired
NonEvacuatedEnergyService(RemoteServicesProperties remoteServicesProperties,
NetworkModificationTreeService networkModificationTreeService,
ObjectMapper objectMapper,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import org.gridsuite.study.server.dto.sensianalysis.SensitivityAnalysisCsvFileInfos;
import org.gridsuite.study.server.dto.sensianalysis.SensitivityFactorsIdsByGroup;
import org.gridsuite.study.server.repository.StudyEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.*;
import org.springframework.stereotype.Service;
import org.springframework.web.client.HttpStatusCodeException;
Expand Down Expand Up @@ -55,7 +54,6 @@ public class SensitivityAnalysisService {

private final NetworkModificationTreeService networkModificationTreeService;

@Autowired
SensitivityAnalysisService(RemoteServicesProperties remoteServicesProperties,
NetworkModificationTreeService networkModificationTreeService,
RestTemplate restTemplate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,19 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

package org.gridsuite.study.server.service;

import org.gridsuite.study.server.RemoteServicesProperties;
import org.gridsuite.study.server.dto.UserProfileInfos;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.HttpStatusCodeException;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.util.UriComponentsBuilder;

import java.util.Optional;

import static org.gridsuite.study.server.StudyConstants.*;
import static org.gridsuite.study.server.StudyConstants.DELIMITER;
import static org.gridsuite.study.server.StudyConstants.USER_ADMIN_API_VERSION;
import static org.gridsuite.study.server.StudyException.Type.GET_USER_PROFILE_FAILED;
import static org.gridsuite.study.server.utils.StudyUtils.handleHttpError;

Expand All @@ -32,7 +31,6 @@ public class UserAdminService {
private final RestTemplate restTemplate;
private String userAdminServerBaseUri;

@Autowired
public UserAdminService(RemoteServicesProperties remoteServicesProperties, RestTemplate restTemplate) {
this.userAdminServerBaseUri = remoteServicesProperties.getServiceUri("user-admin-server");
this.restTemplate = restTemplate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

package org.gridsuite.study.server.service;

import com.fasterxml.jackson.core.JsonProcessingException;
Expand All @@ -16,7 +15,6 @@
import org.gridsuite.study.server.dto.NodeReceiver;
import org.gridsuite.study.server.dto.VoltageInitStatus;
import org.gridsuite.study.server.dto.voltageinit.parameters.VoltageInitParametersInfos;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.*;
import org.springframework.stereotype.Service;
import org.springframework.web.client.HttpStatusCodeException;
Expand Down Expand Up @@ -53,7 +51,6 @@ public class VoltageInitService {

private final RestTemplate restTemplate;

@Autowired
public VoltageInitService(RemoteServicesProperties remoteServicesProperties,
NetworkModificationTreeService networkModificationTreeService,
RestTemplate restTemplate,
Expand Down
Loading

0 comments on commit f0d4664

Please sign in to comment.