Commit 72d55f4e authored by Enriko Käsper's avatar Enriko Käsper
Browse files

Merge branch 'develop' into 'master'

Release: merge 'develop' into 'master' created by Enriko Käsper

See merge request teis/xroad-gateway!47
parents 6cf46f5a 5e616150
# Changelog
## [1.6.0] - 2020-10-30
* updated Spring Boot framework to version 2.3.4.RELEASE
* updated teis-gradle-plugin version to latest which contains different Gradle dependency configuration sets (functionalities) and therefore Gradle configuration was stripped down from microservice configuration
* updated Gradle Wrapper to version 5.6.4
\ No newline at end of file
......@@ -58,10 +58,8 @@ allprojects {
apply from: this.getClass().getClassLoader().getResource('teis.test-sonar.gradle')
dependencies {
// TeIS
compile "ee.sm.ti.teis:common-api-gateway-lib:${commonApiGatewayVersion}"
compile "ee.sm.ti.teis:service-common-lib:${commonsVersion}"
compile "ee.sm.ti.teis:domain-request-lib:${commonsVersion}"
compile "ee.sm.ti.teis:domain-cache-lib:${commonsVersion}"
}
}
theGroup=ee.sm.ti.teis
theVersion=1.5.0
commonsVersion=1.13.0
commonApiGatewayVersion=1.5.1
pluginVersion=1.1.1
mapstructVersion=1.3.0.Final
querydslVersion=4.1.3
httpClientVersion=4.5.12
theVersion=1.6.0
commonsVersion=1.14.0
commonApiGatewayVersion=1.14.0
pluginVersion=1.2.0
jaxbVersion=2.3.3
......@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://repo.tehik.ee/artifactory/gradle-distributions/gradle-5.2.1-all.zip
distributionUrl=https\://repo.tehik.ee/artifactory/gradle-distributions/gradle-5.6.4-bin.zip
......@@ -7,41 +7,24 @@ description = """xroad-gateway"""
functionalities {
microservice
database
redis
}
apply from: this.getClass().getClassLoader().getResource('teis.integrationTest.gradle')
apply from: this.getClass().getClassLoader().getResource('teis.microservice.gradle')
dependencies {
// Spring
compile "org.springframework.boot:spring-boot-starter-web"
compile "org.springframework.boot:spring-boot-starter-amqp"
compile "org.springframework.boot:spring-boot-starter-aop"
compile "org.springframework.boot:spring-boot-starter-data-jpa"
compile 'org.springframework.boot:spring-boot-starter-actuator'
compile 'org.springframework.boot:spring-boot-starter-data-redis'
compile 'org.springframework.boot:spring-boot-starter-web-services'
compile 'org.springframework.boot:spring-boot-starter-security'
compile 'org.springframework.security:spring-security-config'
compile "org.apache.httpcomponents:httpclient:${httpClientVersion}"
compile "com.sun.xml.bind:jaxb-impl:${jaxbVersion}"
compile 'com.sun.xml.bind:jaxb-core:2.3.0.1'
implementation "org.mapstruct:mapstruct:${mapstructVersion}"
compile("com.querydsl:querydsl-core:${querydslVersion}")
compile("com.querydsl:querydsl-jpa:${querydslVersion}")
// Annotation processors
annotationProcessor(
"com.querydsl:querydsl-apt:${querydslVersion}:jpa",
"org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.2.Final",
"javax.annotation:javax.annotation-api:1.3.2",
"org.mapstruct:mapstruct-processor:${mapstructVersion}"
)
// Tests
testAnnotationProcessor "org.mapstruct:mapstruct-processor:${mapstructVersion}"
implementation 'org.springframework.boot:spring-boot-starter-web-services'
implementation "org.apache.httpcomponents:httpclient:4.5.13"
implementation "com.sun.xml.bind:jaxb-impl:${jaxbVersion}"
implementation 'com.sun.xml.bind:jaxb-core:2.3.0.1'
integTestImplementation 'org.springframework.boot:spring-boot-starter-web-services'
integTestImplementation "org.springframework.boot:spring-boot-starter-data-redis:2.3.4.RELEASE"
integTestImplementation "org.apache.httpcomponents:httpclient:4.5.13"
integTestImplementation "com.sun.xml.bind:jaxb-impl:${jaxbVersion}"
integTestImplementation 'com.sun.xml.bind:jaxb-core:2.3.0.1'
xjc "javax.xml.bind:jaxb-api:${jaxbVersion}"
xjc "com.sun.xml.bind:jaxb-impl:${jaxbVersion}"
......
......@@ -23,17 +23,17 @@ import java.io.IOException;
public abstract class XroadGatewayAppTestBase {
private static final GenericContainer redisContainer;
private static final GenericContainer rabbitMQContainer;
private static final GenericContainer<?> rabbitMQContainer;
// to speed up tests, lets use static container, it is used in all test classes that are executed inside one Spring Context
static {
rabbitMQContainer = new GenericContainer("rabbitmq:latest").withExposedPorts(5672);
rabbitMQContainer = new GenericContainer<>("rabbitmq:latest").withExposedPorts(5672);
rabbitMQContainer.start();
redisContainer = new GenericContainer<>("redis:5.0.5-alpine").withExposedPorts(6379);
redisContainer.start();
}
protected void clearRabbitCache() {
protected void clearRedisCache() {
try {
redisContainer.execInContainer("redis-cli", "flushall");
} catch (IOException | InterruptedException e) {
......
......@@ -17,12 +17,18 @@ import org.springframework.beans.factory.annotation.Autowired;
import java.util.UUID;
import static ee.sm.ti.teis.servicerequest.UserType.OFFICIAL_USER;
import static ee.sm.ti.teis.utils.TestUtils.createRequestMeta;
import static ee.sm.ti.teis.xroadgateway.ar.ArMsListener.ArRepresentativesResponse;
import static java.util.Collections.emptyList;
import static java.util.UUID.randomUUID;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
public class ArMsListenerTest extends XroadGatewayAppTestBase {
private static final RequestMetaDTO REQUEST_META_DTO = createRequestMeta(randomUUID().toString(), OFFICIAL_USER,
randomUUID().toString(), emptyList());
private static final String EMPLOYER_ID = "f1e5abf2-9f24-45c2-b5e3-2d6bd05d33e4";
@Autowired
......@@ -35,7 +41,7 @@ public class ArMsListenerTest extends XroadGatewayAppTestBase {
void getCompanyRepresentativesFromAR() {
ArRepresentatives arEmployerData = ArRepresentatives.builder().id(UUID.fromString(EMPLOYER_ID)).build();
ArRepresentativesRequest request = new ArRepresentativesRequest();
request.setPayload(arEmployerData, new RequestMetaDTO());
request.setPayload(arEmployerData, REQUEST_META_DTO);
ArRepresentativesResponse response = arMsListener.getCompanyRepresentativesFromAR(request);
assertThat(response.getPayload().getRepresentatives().get(0).getIndividualPerson().getFirstName()).isEqualTo("Ivan");
assertThat(response.getPayload().getRepresentatives().get(0).getIndividualPerson().getLastName()).isEqualTo("Sidorov");
......@@ -45,7 +51,7 @@ public class ArMsListenerTest extends XroadGatewayAppTestBase {
void getCompanyRepresentativesFromARAsync() {
ArRepresentatives arEmployerData = ArRepresentatives.builder().id(UUID.fromString(EMPLOYER_ID)).build();
ArRepresentativesAsyncRequest request = new ArRepresentativesAsyncRequest();
request.setPayload(arEmployerData, new RequestMetaDTO());
request.setPayload(arEmployerData, REQUEST_META_DTO);
assertDoesNotThrow(() -> arMsListener.getCompanyRepresentativesFromARAsync(request));
}
......@@ -53,7 +59,7 @@ public class ArMsListenerTest extends XroadGatewayAppTestBase {
void getCompanyRepresentativesFromAR_viaRabbitTemplate() {
ArRepresentatives arEmployerData = ArRepresentatives.builder().id(UUID.fromString(EMPLOYER_ID)).build();
ArRepresentativesRequest request = new ArRepresentativesRequest();
request.setPayload(arEmployerData, new RequestMetaDTO());
request.setPayload(arEmployerData, REQUEST_META_DTO);
ArRepresentativesResponse response = (ArRepresentativesResponse) msRabbitTemplate.convertSendAndReceive(request.routingKey(), request);
assertThat(response.getPayload().getRepresentatives().get(0).getIndividualPerson().getFirstName()).isEqualTo("Ivan");
assertThat(response.getPayload().getRepresentatives().get(0).getIndividualPerson().getLastName()).isEqualTo("Sidorov");
......@@ -63,7 +69,7 @@ public class ArMsListenerTest extends XroadGatewayAppTestBase {
void getCompanyFromAR() {
ArLegalPerson arEmployerData = ArLegalPerson.builder().legalPerson(LegalPerson.builder().regCode("118899928").build()).build();
ArCompanyRequest request = new ArCompanyRequest();
request.setPayload(arEmployerData, new RequestMetaDTO());
request.setPayload(arEmployerData, REQUEST_META_DTO);
ArCompanyResponse response = arMsListener.getCompanyFromAR(request);
assertThat(response.getPayload().getLegalPerson().getName()).isEqualTo("Kommipood");
assertThat(response.getPayload().getLegalPerson().getRegCode()).isEqualTo("118899928");
......@@ -73,7 +79,7 @@ public class ArMsListenerTest extends XroadGatewayAppTestBase {
void getCompanyFromAR_returnsError_when_regCodeNotProvided() {
ArLegalPerson arEmployerData = ArLegalPerson.builder().legalPerson(LegalPerson.builder().name("kukimuki").build()).build();
ArCompanyRequest request = new ArCompanyRequest();
request.setPayload(arEmployerData, new RequestMetaDTO());
request.setPayload(arEmployerData, REQUEST_META_DTO);
ArCompanyResponse response = arMsListener.getCompanyFromAR(request);
assertThat(response.getError().getCode()).isEqualTo("400");
}
......@@ -83,7 +89,7 @@ public class ArMsListenerTest extends XroadGatewayAppTestBase {
ArLegalPersonDetails arEmployerData = new ArLegalPersonDetails();
arEmployerData.setId("68a0fc51-f7ff-4b4b-8461-b81a9540a7c2");
QueueConfig.ArCompanyDetailsRequest request = new QueueConfig.ArCompanyDetailsRequest();
request.setPayload(arEmployerData, new RequestMetaDTO());
request.setPayload(arEmployerData, REQUEST_META_DTO);
ArMsListener.ArCompanyDetailsResponse response = arMsListener.getCompanyDetailsFromAR(request);
assertThat(response.getPayload().getLegalPerson().getName()).isEqualTo("Närilised AS");
assertThat(response.getPayload().getLegalPerson().getRegCode()).isEqualTo("25217341");
......
......@@ -12,18 +12,24 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import static ee.sm.ti.teis.servicerequest.UserType.OFFICIAL_USER;
import static ee.sm.ti.teis.utils.TestUtils.createRequestMeta;
import static java.util.Collections.emptyList;
import static java.util.UUID.randomUUID;
import static org.assertj.core.api.Assertions.assertThat;
public class CacheBrowserTestListenerTest extends XroadGatewayAppTestBase {
private static final String EMPLOYEES_FROM_TOR = "getNumberOfEmployeesFromTOR";
private static final RequestMetaDTO REQUEST_META_DTO = createRequestMeta(randomUUID().toString(), OFFICIAL_USER,
randomUUID().toString(), emptyList());
@Autowired
CacheBrowserTestListener cacheBrowserTestListener;
@BeforeEach
void setUp() {
clearRabbitCache();
clearRedisCache();
}
@Test
......@@ -36,7 +42,7 @@ public class CacheBrowserTestListenerTest extends XroadGatewayAppTestBase {
String legalPersonId = "45a4d30a-0df4-4777-9ff1-f4c237391920";
UpdateXroadGatewayCacheRequest updateRequest = new UpdateXroadGatewayCacheRequest();
String json = "[{\"legalPerson\": {\"id\": \"" + legalPersonId + "\"}, \"totalNumberOfEmployees\": 3}]";
updateRequest.setPayload(new UpdateXroadGatewayCacheRequest.Parameters(EMPLOYEES_FROM_TOR, json),new RequestMetaDTO());
updateRequest.setPayload(new UpdateXroadGatewayCacheRequest.Parameters(EMPLOYEES_FROM_TOR, json), REQUEST_META_DTO);
cacheBrowserTestListener.updateCache(updateRequest);
checkThatValueIsCached(legalPersonId);
......@@ -47,13 +53,13 @@ public class CacheBrowserTestListenerTest extends XroadGatewayAppTestBase {
String legalPersonId = "45a4d30a-0df4-4777-9ff1-f4c237391920";
UpdateXroadGatewayCacheRequest updateRequest = new UpdateXroadGatewayCacheRequest();
String json = "[{\"legalPerson\": {\"id\": \"" + legalPersonId + "\"}, \"totalNumberOfEmployees\": 3}]";
updateRequest.setPayload(new UpdateXroadGatewayCacheRequest.Parameters(EMPLOYEES_FROM_TOR, json),new RequestMetaDTO());
updateRequest.setPayload(new UpdateXroadGatewayCacheRequest.Parameters(EMPLOYEES_FROM_TOR, json), REQUEST_META_DTO);
cacheBrowserTestListener.updateCache(updateRequest);
checkThatValueIsCached(legalPersonId);
DeleteXroadGatewayCacheRequest deleteRequest = new DeleteXroadGatewayCacheRequest();
deleteRequest.setPayload(new DeleteXroadGatewayCacheRequest.Parameters(EMPLOYEES_FROM_TOR, legalPersonId),new RequestMetaDTO());
deleteRequest.setPayload(new DeleteXroadGatewayCacheRequest.Parameters(EMPLOYEES_FROM_TOR, legalPersonId), REQUEST_META_DTO);
cacheBrowserTestListener.deleteCache(deleteRequest);
checkThatValueIsNotCached(legalPersonId);
......@@ -73,7 +79,7 @@ public class CacheBrowserTestListenerTest extends XroadGatewayAppTestBase {
private XroadGatewayResponse sendXroadGatewayRequest(String legalPersonId) throws JsonProcessingException {
XroadGatewayCacheRequest request = new XroadGatewayCacheRequest();
request.setPayload(new XroadGatewayCacheRequest.Parameters(EMPLOYEES_FROM_TOR, legalPersonId),new RequestMetaDTO());
request.setPayload(new XroadGatewayCacheRequest.Parameters(EMPLOYEES_FROM_TOR, legalPersonId), REQUEST_META_DTO);
return cacheBrowserTestListener.getCache(request);
}
......
......@@ -23,7 +23,7 @@ import static org.mockito.Mockito.doReturn;
class EmtakGwListenerTest extends XroadGatewayAppTestBase {
private static final RequestMetaDTO requestMetaDTO = RequestMetaDTO.builder().requestId(UUID.randomUUID().toString()).build();
private static final RequestMetaDTO REQUEST_META_DTO = RequestMetaDTO.builder().requestId(UUID.randomUUID().toString()).build();
@Autowired
EmtakGwListener emtakGwListener;
......@@ -46,7 +46,7 @@ class EmtakGwListenerTest extends XroadGatewayAppTestBase {
EmtakXroadRequest.Parameters payload = new EmtakXroadRequest.Parameters();
payload.setStartDate(LocalDate.of(2019, 5, 20));
payload.setEndDate(LocalDate.of(2019, 8, 20));
request.setPayload(payload, new RequestMetaDTO());
request.setPayload(payload, REQUEST_META_DTO);
XroadResponse emtakCodes = emtakGwListener.getEmtakChanges(request);
List emtakList = objectMapper.readValue(emtakCodes.getPayload(), List.class);
......@@ -58,7 +58,7 @@ class EmtakGwListenerTest extends XroadGatewayAppTestBase {
void get_400_error_with_no_start_date_given() throws IOException {
EmtakXroadRequest request = new EmtakXroadRequest();
EmtakXroadRequest.Parameters payload = new EmtakXroadRequest.Parameters();
request.setPayload(payload, new RequestMetaDTO());
request.setPayload(payload, REQUEST_META_DTO);
XroadResponse emtakCodes = emtakGwListener.getEmtakChanges(request);
......@@ -74,7 +74,7 @@ class EmtakGwListenerTest extends XroadGatewayAppTestBase {
.getEmtaks();
EmtakItemsXroadRequest request = new EmtakItemsXroadRequest();
request.setRequestMetaDTO(requestMetaDTO);
request.setRequestMetaDTO(REQUEST_META_DTO);
XroadResponse emtakCodes = emtakGwListener.getEmtaks(request);
List emtakList = objectMapper.readValue(emtakCodes.getPayload(), List.class);
......
......@@ -44,7 +44,7 @@ class TorListenerTest extends XroadGatewayAppTestBase {
when(personService.getLegalPerson(any(), any())).thenReturn(legalPerson);
when(torXroadService.getNumberOfEmployees(any())).thenReturn(
TorNrOfEmployees.builder().legalPerson(legalPerson).totalNumberOfEmployees(5).build());
clearRabbitCache();
clearRedisCache();
requestMetaDTO = createRequestMeta(LEGAL_PERSON1_ID, UserType.OFFICIAL_USER, null, of("TI_VIEW_COMPANIES"));
}
......
......@@ -12,11 +12,17 @@ import org.springframework.beans.factory.annotation.Autowired;
import java.util.UUID;
import static ee.sm.ti.teis.servicerequest.UserType.OFFICIAL_USER;
import static ee.sm.ti.teis.utils.TestUtils.createRequestMeta;
import static java.util.Collections.emptyList;
import static java.util.UUID.randomUUID;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
public class TorMsListenerTest extends XroadGatewayAppTestBase {
private static final RequestMetaDTO REQUEST_META_DTO = createRequestMeta(randomUUID().toString(), OFFICIAL_USER,
randomUUID().toString(), emptyList());
private static final String EMPLOYER_ID = "f1e5abf2-9f24-45c2-b5e3-2d6bd05d33e4";
@Autowired
......@@ -29,7 +35,7 @@ public class TorMsListenerTest extends XroadGatewayAppTestBase {
void getEmployeesFromTor() {
TorEmployees torEmployerData = TorEmployees.builder().id(UUID.fromString(EMPLOYER_ID)).build();
TorEmployeesRequest request = new TorEmployeesRequest();
request.setPayload(torEmployerData, new RequestMetaDTO());
request.setPayload(torEmployerData, REQUEST_META_DTO);
TorEmployeesResponse response = torMsListener.getEmployeesFromTor(request);
assertThat(response.getPayload().getEmployees().get(0).getIndividualPerson().getFirstName()).isEqualTo("Ivan");
assertThat(response.getPayload().getEmployees().get(0).getIndividualPerson().getLastName()).isEqualTo("Sidorov");
......@@ -39,7 +45,7 @@ public class TorMsListenerTest extends XroadGatewayAppTestBase {
void getEmployeesFromTorAsync() {
TorEmployees torEmployerData = TorEmployees.builder().id(UUID.fromString(EMPLOYER_ID)).build();
TorEmployeesAsyncRequest request = new TorEmployeesAsyncRequest();
request.setPayload(torEmployerData, new RequestMetaDTO());
request.setPayload(torEmployerData, REQUEST_META_DTO);
assertDoesNotThrow(() -> torMsListener.getEmployeesFromTorAsync(request));
}
......@@ -47,7 +53,7 @@ public class TorMsListenerTest extends XroadGatewayAppTestBase {
void getCompanyRepresentativesFromAR_viaRabbitTemplate() {
TorEmployees torEmployerData = TorEmployees.builder().id(UUID.fromString(EMPLOYER_ID)).build();
TorEmployeesRequest request = new TorEmployeesRequest();
request.setPayload(torEmployerData, new RequestMetaDTO());
request.setPayload(torEmployerData, REQUEST_META_DTO);
TorEmployeesResponse response = (TorEmployeesResponse) msRabbitTemplate.convertSendAndReceive(request.routingKey(), request);
assertThat(response.getPayload().getEmployees().get(0).getIndividualPerson().getFirstName()).isEqualTo("Ivan");
assertThat(response.getPayload().getEmployees().get(0).getIndividualPerson().getLastName()).isEqualTo("Sidorov");
......
......@@ -6,8 +6,8 @@ spring:
password: guest
datasource:
url: jdbc:postgresql://localhost:5432/xroad_gateway
username: teisdb_owner
password: teisdb_owner_pwd
username: teisdb_user
password: teisdb_user_pwd
liquibase:
user: teisdb_owner
password: teisdb_owner_pwd
......
......@@ -27,7 +27,7 @@ spring:
parameters:
db_app_username: ${DB_APP_USERNAME:teis}
jpa:
database-platform: org.hibernate.dialect.PostgreSQL82Dialect
database-platform: org.hibernate.dialect.PostgreSQL10Dialect
properties:
hibernate:
jdbc:
......@@ -55,6 +55,8 @@ management:
info.enabled: true
teis:
datasource:
packages-to-scan: ee.sm.ti.teis
system:
name: xroad-gateway
rabbit:
......@@ -64,7 +66,8 @@ teis:
ms-exchange-reply-timeout: ${RABBIT_TEMPLATE_MS_EXCHANGE_REPLY_TIMEOUT:5000}
cs-exchange-name: cache_exchange
od-exchange-name: od-disabled
cache: classifierItems
cache:
queues: classifierItems
xroad-cache:
data-directory: data
name-prefix: xroadgw__
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment