Commit e9f53fb5 authored by Kristel Meikas's avatar Kristel Meikas
Browse files

Merge branch 'develop' into 'master'

Release: merge 'develop' into 'master' created by Kristel Meikas

See merge request teis/payments-service!58
parents 6e33f711 e5a5dae1
......@@ -4,6 +4,8 @@ stages:
- deploy
- cve-test
image: docker.repo.tehik.ee/gradle:jdk17
variables:
USE_POSTGRES: "true"
USE_RABBIT: "true"
......
# Changelog
## [2.0.0] - 2022-08-12
* Upgraded to java 17, gradle 7.4.2, spring boot 2.6.8 and others; uses TEIS Gradle plugin 2.3.0
## [1.15.0] - 2022-03-28
* TEIS-2791: implemented functionality for updating classifier item, individual and legal person caches in batches
......
......@@ -19,31 +19,26 @@ buildscript {
}
}
apply plugin: 'ee.sm.ti.teis'
allprojects {
group = "${theGroup}"
version = "${theVersion}"
apply from: this.getClass().getClassLoader().getResource('teis.sonarqube.gradle')
}
subprojects {
apply plugin: 'ee.sm.ti.teis'
functionalities {
base
}
repositories {
mavenLocal()
maven {
url "${gradle.ext.artifactoryUrl}/${gradle.ext.artifactoryRepoKey}"
credentials {
username = "${gradle.ext.artifactoryUser}"
password = "${gradle.ext.artifactoryPass}"
}
}
jcenter()
}
group = "${theGroup}"
version = "${theVersion}"
sourceCompatibility = 11
targetCompatibility = 11
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
jar {
manifest {
......@@ -52,11 +47,5 @@ allprojects {
}
}
apply from: this.getClass().getClassLoader().getResource('teis.test-sonar.gradle')
dependencies {
compile "ee.sm.ti.teis:service-common-lib:${commonsVersion}"
compile "ee.sm.ti.teis:office-api-gateway-lib:${officeApiGatewayVersion}"
compile "ee.sm.ti.teis:domain-cache-lib:${commonsVersion}"
}
}
\ No newline at end of file
apply from: this.getClass().getClassLoader().getResource('teis.test-jacoco.gradle')
}
theGroup=ee.sm.ti.teis
theVersion=1.15.0
pluginVersion=1.5.0
commonsVersion=1.33.0
officeApiGatewayVersion=1.33.0
theVersion=2.0.0
pluginVersion=2.3.0
commonsVersion=2.6.0
officeApiGatewayVersion=2.5.0
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://repo.tehik.ee/artifactory/gradle-distributions/gradle-5.6.4-bin.zip
distributionUrl=https\://repo.tehik.ee/artifactory/gradle-distributions/gradle-7.4.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
......@@ -8,11 +8,11 @@ functionalities {
apply from: this.getClass().getClassLoader().getResource('teis.integrationTest.gradle')
apply from: this.getClass().getClassLoader().getResource('teis.microservice.gradle')
dependencies {
implementation "ee.sm.ti.teis:service-common-lib:${commonsVersion}"
implementation "ee.sm.ti.teis:office-api-gateway-lib:${officeApiGatewayVersion}"
implementation "ee.sm.ti.teis:domain-cache-lib:${commonsVersion}"
}
// Define the main class for the application
mainClassName = 'ee.sm.ti.teis.PaymentsServiceApp'
test {
testLogging {
events "passed", "skipped", "failed"
}
}
......@@ -18,19 +18,14 @@ import org.springframework.beans.factory.annotation.Autowired;
import java.util.Optional;
import java.util.UUID;
import static ee.sm.ti.teis.servicerequest.UserType.OFFICIAL_USER;
import static ee.sm.ti.teis.types.enums.RolePrivilegeCode.*;
import static ee.sm.ti.teis.utils.TestUtils.assertResponseForbidden;
import static ee.sm.ti.teis.utils.TestUtils.createRequestMeta;
import static ee.sm.ti.teis.utils.TestUtils.createRandomOfficialUser;
import static java.util.Collections.emptyList;
import static java.util.Collections.singletonList;
import static java.util.UUID.randomUUID;
import static org.assertj.core.api.Assertions.assertThat;
public class ClaimOfficeGwListenerTest extends PaymentsAppTestBase {
private static final String COMPANY_ID = "6b68de81-37be-4613-b7c4-f226107978e5";
private static final UUID CLAIM_ID = UUID.fromString("e63b9fd5-ea40-49de-b233-1563bd5d44aa");
class ClaimDefinitionOfficeGwListenerTest extends PaymentsAppTestBase {
@Autowired
ClaimDefinitionOfficeGwListener listener;
......@@ -43,8 +38,7 @@ public class ClaimOfficeGwListenerTest extends PaymentsAppTestBase {
@BeforeEach
void setUp() {
requestMetaDTO = createRequestMeta(UUID.randomUUID().toString(), OFFICIAL_USER, randomUUID().toString(),
emptyList());
requestMetaDTO = createRandomOfficialUser(emptyList());
updateRequest = new UpdateClaimDefinitionRequest();
request = new ClaimDefinitionsRequest();
request.setRequestMetaDTO(requestMetaDTO);
......@@ -52,7 +46,7 @@ public class ClaimOfficeGwListenerTest extends PaymentsAppTestBase {
}
@Test
public void getClaimDefinitions_invalid_privilege() {
void getClaimDefinitions_invalid_privilege() {
requestMetaDTO.setPrivileges(singletonList(EX_VIEW_PAYMENTS.name()));
request.setRequestMetaDTO(requestMetaDTO);
......@@ -61,7 +55,7 @@ public class ClaimOfficeGwListenerTest extends PaymentsAppTestBase {
}
@Test
public void getClaimDefinitions_success() {
void getClaimDefinitions_success() {
requestMetaDTO.setPrivileges(singletonList(TI_MANAGE_PAYMENTS_DEFINITIONS.name()));
request.setRequestMetaDTO(requestMetaDTO);
......@@ -71,7 +65,7 @@ public class ClaimOfficeGwListenerTest extends PaymentsAppTestBase {
}
@Test
public void updateClaimDefinitions_success() {
void updateClaimDefinitions_success() {
requestMetaDTO.setPrivileges(singletonList(TI_MANAGE_PAYMENTS_DEFINITIONS.name()));
ClaimDefinitionDto dto = ClaimDefinitionDto.builder()
.id(UUID.fromString("13c32867-b082-48a3-907a-b930f0164d2c"))
......@@ -87,7 +81,7 @@ public class ClaimOfficeGwListenerTest extends PaymentsAppTestBase {
}
@Test
public void updateClaimDefinitions_invalid_privilege() {
void updateClaimDefinitions_invalid_privilege() {
requestMetaDTO.setPrivileges(singletonList(TI_MANAGE_PAYMENTS.name()));
ClaimDefinitionDto dto = ClaimDefinitionDto.builder()
.id(UUID.fromString("13c32867-b082-48a3-907a-b930f0164d2c"))
......
......@@ -11,6 +11,7 @@ import ee.sm.ti.teis.commongateway.persons.person.dto.PersonDto;
import ee.sm.ti.teis.domain.admin.UrlPath;
import ee.sm.ti.teis.domain.task.Task;
import ee.sm.ti.teis.payments.serviceclient.TaskServiceClient.CreateTaskMsResponse;
import ee.sm.ti.teis.serviceclient.admin.PathServiceClient.GetPathResponseMessage;
import ee.sm.ti.teis.servicerequest.RequestMetaDTO;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
......@@ -21,7 +22,6 @@ import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.UUID;
import static ee.sm.ti.teis.payments.serviceclient.PathServiceClient.GetPathResponseMessage;
import static ee.sm.ti.teis.servicerequest.UserType.OFFICIAL_USER;
import static ee.sm.ti.teis.types.enums.ClaimStatusType.CANCELED;
import static ee.sm.ti.teis.types.enums.ClaimStatusType.VALID;
......@@ -37,10 +37,11 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doReturn;
public class CreateClaimGwListenerTest extends PaymentsAppTestBase {
class CreateClaimGwListenerTest extends PaymentsAppTestBase {
private static final String CREATE_PAYMENT_REFERENCE = "Create payment reference";
private static final UUID EMPLOYER_ID = UUID.fromString("6b68de81-37be-4613-b7c4-f226107978e5");
private static final String VALID_CLAIM_DEFINITION_CODE = "CREATE_PAYMENT";
private static final UUID EMPLOYER_ID = UUID.fromString("6b68de81-37be-4613-b7c4-f226107978e5");
@Autowired
ClaimGwListener listener;
......@@ -107,29 +108,14 @@ public class CreateClaimGwListenerTest extends PaymentsAppTestBase {
assertThat(dto.getPath()).isEqualTo("/url");
ClaimDefinitionDto definition = dto.getClaimDefinition();
assertThat(definition.getId()).isEqualTo(UUID.fromString("20bffead-a063-467e-a4b1-d55bf53944b5"));
assertThat(definition.getCode()).isEqualTo(VALID_CLAIM_DEFINITION_CODE);
assertThat(definition.getTitle()).isEqualTo("Create payment");
assertThat(definition.getBankAccounts()).isEqualTo("EE123123213453543");
assertThat(definition.getReceiverName()).isEqualTo("TEHIK");
assertThat(definition.getPaymentDescription()).isEqualTo("payment description 123");
assertThat(definition.getPaymentReference()).isEqualTo(CREATE_PAYMENT_REFERENCE);
assertThat(definition.getDataObjectType().getId()).isEqualTo(CLAIM_PAYMENT.getId());
assertThat(definition.getDataObjectType().getCode()).isEqualTo(CLAIM_PAYMENT.getCode());
assertThat(definition.getObjectStatus()).isEqualTo(CURRENT);
assertClaimDefinition(definition);
PersonDto employer = dto.getEmployer();
assertThat(employer.getId()).isEqualTo(EMPLOYER_ID);
assertThat(employer.getPersonType()).isEqualTo(L);
assertThat(employer.getLegalPerson()).isNotNull();
assertThat(employer.getIndividualPerson()).isNull();
assertThat(employer.getLegalPerson().getName()).isEqualTo("Kasemaa Investments OÜ");
assertThat(employer.getLegalPerson().getRegCode()).isEqualTo("10827700");
assertThat(employer.getLegalPerson().getCountryId()).isEqualTo("COUNTRY__EE");
assertEmployer(employer);
}
@Test
public void create_minimumData_success() {
void create_minimumData_success() {
payload.setClaimDefinition(ClaimDefinitionDto.builder().code(VALID_CLAIM_DEFINITION_CODE).build());
payload.setDeadlineDate(LocalDate.now());
payload.setAmount(BigDecimal.valueOf(123L));
......@@ -147,4 +133,28 @@ public class CreateClaimGwListenerTest extends PaymentsAppTestBase {
assertThat(domain.getDataObjectReferences()).isNotNull();
assertThat(domain.getDataObjectReferences()).isEmpty();
}
private void assertClaimDefinition(ClaimDefinitionDto definition) {
assertThat(definition.getId()).isEqualTo(UUID.fromString("20bffead-a063-467e-a4b1-d55bf53944b5"));
assertThat(definition.getCode()).isEqualTo(VALID_CLAIM_DEFINITION_CODE);
assertThat(definition.getTitle()).isEqualTo("Create payment");
assertThat(definition.getBankAccounts()).isEqualTo("EE123123213453543");
assertThat(definition.getReceiverName()).isEqualTo("TEHIK");
assertThat(definition.getPaymentDescription()).isEqualTo("payment description 123");
assertThat(definition.getPaymentReference()).isEqualTo(CREATE_PAYMENT_REFERENCE);
assertThat(definition.getDataObjectType().getId()).isEqualTo(CLAIM_PAYMENT.getId());
assertThat(definition.getDataObjectType().getCode()).isEqualTo(CLAIM_PAYMENT.getCode());
assertThat(definition.getObjectStatus()).isEqualTo(CURRENT);
}
private void assertEmployer(PersonDto employer) {
assertThat(employer.getId()).isEqualTo(EMPLOYER_ID);
assertThat(employer.getPersonType()).isEqualTo(L);
assertThat(employer.getLegalPerson()).isNotNull();
assertThat(employer.getIndividualPerson()).isNull();
assertThat(employer.getLegalPerson().getName()).isEqualTo("Kasemaa Investments OÜ");
assertThat(employer.getLegalPerson().getRegCode()).isEqualTo("10827700");
assertThat(employer.getLegalPerson().getCountryId()).isEqualTo("COUNTRY__EE");
}
}
......@@ -10,6 +10,7 @@ import ee.sm.ti.teis.domain.person.Person;
import ee.sm.ti.teis.domain.task.Task;
import ee.sm.ti.teis.payments.claim.config.ClaimQueueConfig.CreateClaimMsRequest;
import ee.sm.ti.teis.payments.serviceclient.TaskServiceClient.CreateTaskMsResponse;
import ee.sm.ti.teis.serviceclient.admin.PathServiceClient.GetPathResponseMessage;
import ee.sm.ti.teis.servicecommon.test.ListenerCreateRequestTestBase;
import ee.sm.ti.teis.servicerequest.RequestMetaDTO;
import org.junit.jupiter.api.BeforeEach;
......@@ -22,7 +23,6 @@ import java.time.LocalDate;
import java.util.UUID;
import static ee.sm.ti.teis.payments.claim.config.ClaimQueueConfig.CreateClaimMsResponse;
import static ee.sm.ti.teis.payments.serviceclient.PathServiceClient.GetPathResponseMessage;
import static ee.sm.ti.teis.servicerequest.UserType.OFFICIAL_USER;
import static ee.sm.ti.teis.types.enums.ClaimStatusType.CANCELED;
import static ee.sm.ti.teis.types.enums.ClaimStatusType.VALID;
......@@ -38,12 +38,12 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doReturn;
public class CreateClaimMsListenerTest extends PaymentsAppTestBase implements ListenerCreateRequestTestBase {
class CreateClaimMsListenerTest extends PaymentsAppTestBase implements ListenerCreateRequestTestBase {
private static final String FIELD_NAME = "fieldName";
private static final String VALID_CLAIM_DEFINITION_CODE = "CREATE_PAYMENT";
private static final UUID EMPLOYER_ID = UUID.fromString("6b68de81-37be-4613-b7c4-f226107978e5");
private static final String CREATE_PAYMENT_REFERENCE = "Create payment reference";
private static final UUID EMPLOYER_ID = UUID.fromString("6b68de81-37be-4613-b7c4-f226107978e5");
@Autowired
ClaimMsListener listener;
......@@ -135,26 +135,10 @@ public class CreateClaimMsListenerTest extends PaymentsAppTestBase implements Li
assertThat(dataObjectReference.getDataObjectType().getId()).isEqualTo(CLAIM_PAYMENT.getId());
ClaimDefinition definition = domain.getClaimDefinition();
assertThat(definition.getId()).isEqualTo(UUID.fromString("20bffead-a063-467e-a4b1-d55bf53944b5"));
assertThat(definition.getCode()).isEqualTo(VALID_CLAIM_DEFINITION_CODE);
assertThat(definition.getTitle()).isEqualTo("Create payment");
assertThat(definition.getBankAccounts()).isEqualTo("EE123123213453543");
assertThat(definition.getReceiverName()).isEqualTo("TEHIK");
assertThat(definition.getPaymentDescription()).isEqualTo("payment description 123");
assertThat(definition.getPaymentReference()).isEqualTo(CREATE_PAYMENT_REFERENCE);
assertThat(definition.getDataObjectType().getId()).isEqualTo("OBJECT_TYPE__CLAIM_PAYMENT");
assertThat(definition.getObjectStatus()).isEqualTo(CURRENT);
assertClaimDefinition(definition);
Person employer = domain.getEmployer();
assertThat(employer.getId()).isEqualTo(EMPLOYER_ID);
assertThat(employer.getPersonType()).isEqualTo(L);
assertThat(employer.getLegalPerson()).isNotNull();
assertThat(employer.getIndividualPerson()).isNull();
assertThat(employer.getLegalPerson().getName()).isEqualTo("Kasemaa Investments OÜ");
assertThat(employer.getLegalPerson().getRegCode()).isEqualTo("10827700");
assertThat(employer.getLegalPerson().getCountryId()).isEqualTo("COUNTRY__EE");
assertThat(employer.getLegalPerson().getFullName()).isEqualTo("Kasemaa Investments OÜ 10827700");
assertThat(employer.getLegalPerson().getPersonType()).isEqualTo(L);
assertEmployer(employer);
}
@Override
......@@ -338,7 +322,7 @@ public class CreateClaimMsListenerTest extends PaymentsAppTestBase implements Li
}
@Test
public void create_paymentDescriptionMissing_definitionDescriptionMapped_success() {
void create_paymentDescriptionMissing_definitionDescriptionMapped_success() {
payload.setClaimDefinition(ClaimDefinition.builder().code(VALID_CLAIM_DEFINITION_CODE).build());
payload.setDeadlineDate(LocalDate.now());
payload.setAmount(BigDecimal.valueOf(123L));
......@@ -357,7 +341,7 @@ public class CreateClaimMsListenerTest extends PaymentsAppTestBase implements Li
}
@Test
public void create_paymentDescriptionExists_getsMapped_success() {
void create_paymentDescriptionExists_getsMapped_success() {
payload.setClaimDefinition(ClaimDefinition.builder().code(VALID_CLAIM_DEFINITION_CODE).build());
payload.setDeadlineDate(LocalDate.now());
payload.setAmount(BigDecimal.valueOf(123L));
......@@ -375,4 +359,29 @@ public class CreateClaimMsListenerTest extends PaymentsAppTestBase implements Li
assertThat(domain.getPaymentReference()).isEqualTo(CREATE_PAYMENT_REFERENCE);
assertThat(domain.getPaymentDescription()).isEqualTo("test payment description 321");
}
private void assertClaimDefinition(ClaimDefinition definition) {
assertThat(definition.getId()).isEqualTo(UUID.fromString("20bffead-a063-467e-a4b1-d55bf53944b5"));
assertThat(definition.getCode()).isEqualTo(VALID_CLAIM_DEFINITION_CODE);
assertThat(definition.getTitle()).isEqualTo("Create payment");
assertThat(definition.getBankAccounts()).isEqualTo("EE123123213453543");
assertThat(definition.getReceiverName()).isEqualTo("TEHIK");
assertThat(definition.getPaymentDescription()).isEqualTo("payment description 123");
assertThat(definition.getPaymentReference()).isEqualTo(CREATE_PAYMENT_REFERENCE);
assertThat(definition.getDataObjectType().getId()).isEqualTo("OBJECT_TYPE__CLAIM_PAYMENT");
assertThat(definition.getObjectStatus()).isEqualTo(CURRENT);
}
private void assertEmployer(Person employer) {
assertThat(employer.getId()).isEqualTo(EMPLOYER_ID);
assertThat(employer.getPersonType()).isEqualTo(L);
assertThat(employer.getLegalPerson()).isNotNull();
assertThat(employer.getIndividualPerson()).isNull();
assertThat(employer.getLegalPerson().getName()).isEqualTo("Kasemaa Investments OÜ");
assertThat(employer.getLegalPerson().getRegCode()).isEqualTo("10827700");
assertThat(employer.getLegalPerson().getCountry().getId()).isEqualTo("COUNTRY__EE");
assertThat(employer.getLegalPerson().getFullName()).isEqualTo("Kasemaa Investments OÜ 10827700");
assertThat(employer.getLegalPerson().getPersonType()).isEqualTo(L);
}
}
package ee.sm.ti.teis.payments.claim.listener;
import ee.sm.ti.teis.ErrorDTO;
import ee.sm.ti.teis.PaymentsAppTestBase;
import ee.sm.ti.teis.domain.payments.claim.DeleteClaim;
import ee.sm.ti.teis.payments.claim.config.ClaimQueueConfig.DeleteClaimMsRequest;
import ee.sm.ti.teis.payments.claim.config.ClaimQueueConfig.DeleteClaimMsResponse;
import ee.sm.ti.teis.payments.claim.entity.ClaimEntity;
import ee.sm.ti.teis.payments.claim.repository.ClaimRepository;
import ee.sm.ti.teis.payments.claim.service.ClaimNotifyService;
import ee.sm.ti.teis.servicecommon.test.ListenerDeleteRequestTestBase;
import ee.sm.ti.teis.servicerequest.RequestMetaDTO;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.MockBean;
import java.util.UUID;
import static ee.sm.ti.teis.payments.claim.ClaimErrorCode.CLAIMS_1001;
import static ee.sm.ti.teis.types.enums.ObjectStatus.CURRENT;
import static ee.sm.ti.teis.types.enums.ObjectStatus.DELETED;
import static ee.sm.ti.teis.utils.TestUtils.assertResponseNotFound;
import static ee.sm.ti.teis.utils.TestUtils.createRandomOfficialUser;
import static java.util.Collections.emptyList;
import static java.util.UUID.randomUUID;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.*;
class DeleteClaimMsListenerTest extends PaymentsAppTestBase implements ListenerDeleteRequestTestBase {
private static final UUID CLAIM_ID = UUID.fromString("42224203-740a-4af4-ba71-3ef7c5440f54");
private static final UUID CLAIM_WITH_RECONCILIATION_ID = UUID.fromString("e63b9fd5-ea40-49de-b233-1563bd5d44aa");
private static final UUID DELETED_CLAIM_ID = UUID.fromString("e5663924-f3fb-4380-9e92-04e858374f3d");
private static final UUID DATA_OBJECT_ID = UUID.fromString("f526dcef-21fd-4727-baea-9425becdf981");
@Autowired
ClaimMsListener listener;
@Autowired
ClaimRepository repository;
@MockBean
ClaimNotifyService claimNotifyService;
private DeleteClaim payload;
private DeleteClaimMsRequest request;
private DeleteClaimMsResponse response;
private RequestMetaDTO requestMetaDTO;
@BeforeEach
void setUp() {
requestMetaDTO = createRandomOfficialUser(emptyList());
payload = new DeleteClaim();
request = new DeleteClaimMsRequest();
request.setPayload(payload, requestMetaDTO);
}
@Override
public void missingRequiredPrivilege_forbidden() {
// not applicable
}
@Override
public void wrongUserType_forbidden() {
// not applicable
}
@Override
@Test
public void delete_idNotExists_notFound() {
payload.setId(randomUUID());
request.setPayload(payload, requestMetaDTO);
response = listener.delete(request);
assertResponseNotFound(response.getError());
}
@Override
@Test
public void delete_objectStatusDeleted_success() {
payload.setId(DELETED_CLAIM_ID);
request.setPayload(payload, requestMetaDTO);
response = listener.delete(request);
assertThat(response.getError()).isNull();
verify(claimNotifyService, never()).claimDeleted(anyString(), any(), any());
}
@Override
@Test
public void delete_verifyObjectStatusDeletedInDatabase_success() {
payload.setId(CLAIM_ID);
request.setPayload(payload, requestMetaDTO);
ClaimEntity claim = repository.findCurrentById(CLAIM_ID).orElse(null);
assertThat(claim).isNotNull();
assertThat(claim.getId()).isEqualTo(CLAIM_ID);
assertThat(claim.getObjectStatus()).isEqualTo(CURRENT);
response = listener.delete(request);
assertThat(response.getError()).isNull();
claim = repository.findCurrentById(CLAIM_ID).orElse(null);
assertThat(claim).isNull();
claim = repository.findByIdAndObjectStatus(CLAIM_ID, DELETED).orElse(null);
assertThat(claim).isNotNull();
assertThat(claim.getId()).isEqualTo(CLAIM_ID);
assertThat(claim.getObjectStatus()).isEqualTo(DELETED);
verify(claimNotifyService).claimDeleted(anyString(), any(), any());
}
@Test
void delete_deleteByDataObjectId_success() {
payload.setDataObjectId(DATA_OBJECT_ID);
request.setPayload(payload, requestMetaDTO);
response = listener.delete(request);
assertThat(response.getError()).isNull();
verify(claimNotifyService, times(2)).claimDeleted(anyString(), any(), any());
}
@Test
void delete_claimHasReconciliation_throwsTeisBusinessException() {
payload.setId(CLAIM_WITH_RECONCILIATION_ID);
request.setPayload(payload, requestMetaDTO);
response = listener.delete(request);
ErrorDTO error = response.getError();
assertThat(error.getCode()).isEqualTo(CLAIMS_1001.getCode());
}
}
......@@ -30,7 +30,7 @@ import static java.util.Collections.singletonList;
import static java.util.UUID.randomUUID;
import static org.assertj.core.api.Assertions.assertThat;
public class ClaimGwListenerTest extends PaymentsAppTestBase implements ListenerGetObjectRequestTestBase {
class GetClaimGwListenerTest extends PaymentsAppTestBase implements ListenerGetObjectRequestTestBase {
private static final String COMPANY_ID = "6b68de81-37be-4613-b7c4-f226107978e5";
private static final UUID CLAIM_ID = UUID.fromString("e63b9fd5-ea40-49de-b233-1563bd5d44aa");
......@@ -100,6 +100,42 @@ public class ClaimGwListenerTest extends PaymentsAppTestBase implements Listener
assertThat(dto.getPaymentDescription()).isEqualTo("test payment description 421");
ClaimDefinitionDto definition = dto.getClaimDefinition();
assertClaimDefinition(definition);
PersonDto person = dto.getEmployer();
assertEmployer(dto, person);
assertReconciliations(dto);
}
@Override
@Test
public void missingRequiredPrivilege_forbidden() {
request.setPayload(UUID.randomUUID(), requestMetaDTO);
ClaimResponse response = listener.getClaim(request);
assertResponseForbidden(response.getError());
}
@Override
public void wrongUserType_forbidden() {
// not applicable
}
@Test
void getClaim_userTypePerson_notCompanyRepresentative_forbidden() {
requestMetaDTO.setUserType(PERSON);
requestMetaDTO.setCompanyId(UUID.randomUUID().toString());
requestMetaDTO.setPrivileges(singletonList(EX_VIEW_PAYMENTS.name()));
request.setPayload(CLAIM_ID, requestMetaDTO);
ClaimResponse response = listener.getClaim(request);
assertResponseForbidden(response.getError());
}