Commit c158e0fa 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!50
parents e996d315 62382e6d
# Changelog
## [1.11.0] - 2020-11-27
* added enforcement parameter into search claims method
## [1.10.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
* updated Gradle Wrapper to version 5.6.4
theGroup=ee.sm.ti.teis
theVersion=1.10.0
theVersion=1.11.0
pluginVersion=1.2.0
commonsVersion=1.14.0
officeApiGatewayVersion=1.14.0
officeApiGatewayVersion=1.15.0
......@@ -210,8 +210,32 @@ public class ClaimsGwListenerTest extends PaymentsAppTestBase implements Listene
assertThat(response.getPayload().getContent()).isEmpty();
}
@Test
void getClaims_enforcementTrue_onlyClaimsWithEnforcementsReturned_success() {
requestMetaDTO.setPrivileges(singletonList(TI_VIEW_PAYMENTS.name()));
request = composeClaimsRequest(null, null, null, null, null,
true, requestMetaDTO);
ClaimsResponse response = listener.getClaims(request);
assertThat(response.getPayload().getSize()).isGreaterThanOrEqualTo(6);
assertThat(response.getPayload().getContent().stream()
.allMatch(claim -> claim.getEnforcement() != null))
.isTrue();
assertThat(response.getPayload().getContent().stream()
.noneMatch(claim -> claim.getId().equals(UUID.fromString("0f8680d3-6bea-4540-ae61-58e4793ffc30"))))
.isTrue();
}
@NotNull
private ClaimsRequest composeClaimsRequest(Boolean all, LocalDate deadlineUntil, UUID employerId, String reference,
UUID dataObjectId, RequestMetaDTO requestMetaDTO) {
return composeClaimsRequest(all, deadlineUntil, employerId, reference, dataObjectId, null, requestMetaDTO);
}
@NotNull
private ClaimsRequest composeClaimsRequest(Boolean all, LocalDate deadlineUntil, UUID employerId, String reference, UUID dataObjectId, RequestMetaDTO requestMetaDTO) {
private ClaimsRequest composeClaimsRequest(Boolean all, LocalDate deadlineUntil, UUID employerId, String reference,
UUID dataObjectId, Boolean enforcement, RequestMetaDTO requestMetaDTO) {
ClaimsRequest claimsRequest = new ClaimsRequest();
ClaimSearchFilterDto searchFilter = new ClaimSearchFilterDto();
searchFilter.setAll(all);
......@@ -219,6 +243,7 @@ public class ClaimsGwListenerTest extends PaymentsAppTestBase implements Listene
searchFilter.setEmployerId(employerId);
searchFilter.setReference(reference);
searchFilter.setDataObjectId(dataObjectId);
searchFilter.setEnforcement(enforcement);
Parameters parameters = new Parameters(searchFilter);
claimsRequest.setPayload(parameters, requestMetaDTO);
return claimsRequest;
......
......@@ -14,5 +14,3 @@ spring:
rabbitmq:
template:
reply-timeout: 500 # Timeout for `sendAndReceive()` operations.
# jpa:
# show-sql: true
......@@ -14,6 +14,7 @@ import ee.sm.ti.teis.exceptions.TeisResourceNotFoundException;
import ee.sm.ti.teis.payments.claim.entity.ClaimEntity;
import ee.sm.ti.teis.payments.claim.entity.QClaimEntity;
import ee.sm.ti.teis.payments.claim.entity.QDataObjectReferenceEntity;
import ee.sm.ti.teis.payments.claim.entity.QEnforcementEntity;
import ee.sm.ti.teis.payments.claim.repository.ClaimRepository;
import ee.sm.ti.teis.servicerequest.RequestMetaDTO;
import org.springframework.beans.factory.annotation.Qualifier;
......@@ -40,6 +41,7 @@ public class ClaimDataService {
private static final QClaimEntity claim = QClaimEntity.claimEntity;
private static final QPersonView personView = QPersonView.personView;
private static final QEnforcementEntity enforcement = QEnforcementEntity.enforcementEntity;
private static final QDataObjectReferenceEntity dataObjectReference = QDataObjectReferenceEntity.dataObjectReferenceEntity;
private static final OrderSpecifier<?> defaultSort = new OrderSpecifier<>(Order.DESC, claim.issuedDate);
......@@ -71,7 +73,6 @@ public class ClaimDataService {
baseQuery.offset(searchFilter.getSize() * (searchFilter.getPage() - 1L));
return new PageImpl<>(baseQuery.fetch(), pageRequest, totalCount);
}
public ClaimEntity getClaim(UUID id) {
......@@ -166,6 +167,11 @@ public class ClaimDataService {
.from(dataObjectReference).where(dataObjectReference.dataObjectId.eq(searchFilter.getDataObjectId())
.and(dataObjectReference.objectStatus.eq(CURRENT)))));
}
if (isTrue(searchFilter.getEnforcement())) {
baseQuery.innerJoin(enforcement).on(enforcement.claim.id.eq(claim.id))
.where(enforcement.objectStatus.eq(CURRENT));
}
}
private void claimsQuerySorting(JPAQuery<ClaimEntity> baseQuery, PageRequest pageRequest) {
......
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