Commit cafa0230 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/payments-service!52
parents c158e0fa c79b6529
# Changelog
## [1.12.0] - 2020-12-14
* added functionality to exclude claims without enforcement from getClaims() query via request enforcement flag.
## [1.11.0] - 2020-11-27
* added enforcement parameter into search claims method
......
theGroup=ee.sm.ti.teis
theVersion=1.11.0
theVersion=1.12.0
pluginVersion=1.2.0
commonsVersion=1.14.0
officeApiGatewayVersion=1.15.0
......@@ -218,7 +218,7 @@ public class ClaimsGwListenerTest extends PaymentsAppTestBase implements Listene
ClaimsResponse response = listener.getClaims(request);
assertThat(response.getPayload().getSize()).isGreaterThanOrEqualTo(6);
assertThat(response.getPayload().getContent().size()).isGreaterThanOrEqualTo(4);
assertThat(response.getPayload().getContent().stream()
.allMatch(claim -> claim.getEnforcement() != null))
.isTrue();
......@@ -227,6 +227,26 @@ public class ClaimsGwListenerTest extends PaymentsAppTestBase implements Listene
.isTrue();
}
@Test
void getClaims_enforcementFalse_onlyClaimsWithoutEnforcementsReturned_success() {
requestMetaDTO.setPrivileges(singletonList(TI_VIEW_PAYMENTS.name()));
request = composeClaimsRequest(null, null, null, null, null,
false, requestMetaDTO);
ClaimsResponse response = listener.getClaims(request);
assertThat(response.getPayload().getContent().size()).isGreaterThanOrEqualTo(19);
assertThat(response.getPayload().getContent().stream()
.allMatch(claim -> claim.getEnforcement() == null))
.isTrue();
assertThat(response.getPayload().getContent().stream()
.anyMatch(claim -> claim.getId().equals(UUID.fromString("79f71595-4121-4257-aea9-5dc58e34861c"))))
.isTrue();
assertThat(response.getPayload().getContent().stream()
.noneMatch(claim -> claim.getId().equals(UUID.fromString("bfa0a43f-0b42-434d-ba71-a5013685cf89"))))
.isTrue();
}
@NotNull
private ClaimsRequest composeClaimsRequest(Boolean all, LocalDate deadlineUntil, UUID employerId, String reference,
UUID dataObjectId, RequestMetaDTO requestMetaDTO) {
......
......@@ -33,6 +33,7 @@ import static ee.sm.ti.teis.servicerequest.UserType.PERSON;
import static ee.sm.ti.teis.types.enums.ClaimStatusType.VALID;
import static ee.sm.ti.teis.types.enums.ObjectStatus.CURRENT;
import static java.math.BigDecimal.ZERO;
import static org.apache.commons.lang3.BooleanUtils.isFalse;
import static org.apache.commons.lang3.BooleanUtils.isTrue;
import static org.springframework.util.StringUtils.isEmpty;
......@@ -171,6 +172,8 @@ public class ClaimDataService {
if (isTrue(searchFilter.getEnforcement())) {
baseQuery.innerJoin(enforcement).on(enforcement.claim.id.eq(claim.id))
.where(enforcement.objectStatus.eq(CURRENT));
} else if (isFalse(searchFilter.getEnforcement())) {
baseQuery.where(claim.enforcements.isEmpty());
}
}
......
......@@ -47,7 +47,8 @@ VALUES ('0f8680d3-6bea-4540-ae61-58e4793ffc30', '20bffead-a063-467e-a4b1-d55bf53
('79bf04ab-bafb-4a52-ac20-87fc1e589f5a', '13c32867-b082-48a3-907a-b930f0164d2c', '6b68de81-37be-4613-b7c4-f226107978e5', '2020-02-14', 500.00, '2020-05-15', 'Payment details test ref 2', 'ref 2 Payment details test', null, 'VALID', 20.00, 'CURRENT', 'test payment description 333'),
('bfa0a43f-0b42-434d-ba71-a5013685cf89', '13c32867-b082-48a3-907a-b930f0164d2c', '6b68de81-37be-4613-b7c4-f226107978e5', '2020-02-14', 500.00, '2020-05-15', 'Payment details test ref 2', 'ref 2 Payment details test', null, 'VALID', 20.00, 'CURRENT', 'test payment description 333'),
('3b8fbb68-33f2-43a5-97fc-35e9d0767538', '13c32867-b082-48a3-907a-b930f0164d2c', '6b68de81-37be-4613-b7c4-f226107978e5', '2020-02-14', 500.00, '2020-05-15', 'Payment details test ref 2', 'ref 2 Payment details test', null, 'VALID', 20.00, 'CURRENT', 'test payment description 333'),
('4565f867-94be-4fe1-907d-5aa1f34766bb', '13c32867-b082-48a3-907a-b930f0164d2c', '6b68de81-37be-4613-b7c4-f226107978e5', '2020-02-14', 500.00, '2020-05-15', 'Payment details test ref 2', 'ref 2 Payment details test', null, 'VALID', 20.00, 'CURRENT', 'test payment description 333');
('4565f867-94be-4fe1-907d-5aa1f34766bb', '13c32867-b082-48a3-907a-b930f0164d2c', '6b68de81-37be-4613-b7c4-f226107978e5', '2020-02-14', 500.00, '2020-05-15', 'Payment details test ref 2', 'ref 2 Payment details test', null, 'VALID', 20.00, 'CURRENT', 'test payment description 333'),
('79f71595-4121-4257-aea9-5dc58e34861c', '13c32867-b082-48a3-907a-b930f0164d2c', '6b68de81-37be-4613-b7c4-f226107978e5', '2020-02-14', 500.00, '2020-05-15', 'Payment details test ref 2', 'ref 2 Payment details test', null, 'VALID', 20.00, 'CURRENT', 'test payment description 333');
INSERT INTO enforcement (id, claim_id, start_date, object_status)
VALUES ('95aed995-6357-40cf-b675-419c5d91512e', 'e63b9fd5-ea40-49de-b233-1563bd5d44aa', '2020-04-03', 'CURRENT'),
......
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