Commit 2241e11f authored by Jürgen Hannus's avatar Jürgen Hannus
Browse files

Merge branch 'develop' into 'master'

Release: merge 'develop' into 'master' created by Jürgen Hannus

See merge request teis/admin-service!33
parents 830fc7e4 b5dcd34e
# Changelog
## [1.13.0] - 2021-01-22
* added new object type RISK_FACTOR_ASSESSMENT and RISK_ASSESSMENT path mappings
## [1.12.0] - 2020-12-14
* added file parameters into OFFICE scope and increased file max upload size.
......
theGroup=ee.sm.ti.teis
theVersion=1.12.0
theVersion=1.13.0
pluginVersion=1.2.0
commonsVersion=1.16.0
commonApiGatewayVersion=1.16.0
commonsVersion=1.18.0
commonApiGatewayVersion=1.18.0
......@@ -6,7 +6,6 @@ import ee.sm.ti.teis.commongateway.admin.GetPathRequest;
import ee.sm.ti.teis.commongateway.admin.GetPathResponse;
import ee.sm.ti.teis.commongateway.admin.PathDto;
import ee.sm.ti.teis.servicerequest.RequestMetaDTO;
import ee.sm.ti.teis.types.enums.classifier.ObjectType;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -15,6 +14,7 @@ import java.util.ArrayList;
import java.util.UUID;
import static ee.sm.ti.teis.servicerequest.UserType.OFFICIAL_USER;
import static ee.sm.ti.teis.types.enums.classifier.ObjectType.*;
import static ee.sm.ti.teis.utils.TestUtils.createRequestMeta;
import static java.util.Collections.emptyList;
import static java.util.UUID.randomUUID;
......@@ -24,16 +24,18 @@ public class PathListenerTest extends AdminAppTestBase {
private static final String PATH_END = "general";
private static final String AUTH_PROCEEDINGS_URL = "/auth/proceedings/";
private static final String AUTH_RISK_ASSESSMENT_URL = "/auth/risk-assessments/";
@Autowired
private PathListener pathListener;
PathListener pathListener;
private GetPathRequest request;
private PathDto payload;
GetPathRequest request;
PathDto payload;
@BeforeEach
void setUp() {
RequestMetaDTO requestMetaDTO = createRequestMeta(randomUUID().toString(), OFFICIAL_USER, randomUUID().toString(), emptyList());
RequestMetaDTO requestMetaDTO = createRequestMeta(randomUUID().toString(), OFFICIAL_USER,
randomUUID().toString(), emptyList());
payload = new PathDto();
request = new GetPathRequest();
request.setPayload(payload, requestMetaDTO);
......@@ -43,7 +45,7 @@ public class PathListenerTest extends AdminAppTestBase {
void proceedingsPath() {
UUID proceedingId = UUID.randomUUID();
payload.setDataObjectReferences(new ArrayList<>());
payload.getDataObjectReferences().add(DataObjectReferenceDto.builder().objectType(ObjectType.PROCEEDING).id(proceedingId).build());
payload.getDataObjectReferences().add(DataObjectReferenceDto.builder().objectType(PROCEEDING).id(proceedingId).build());
payload.setPathEnd(PATH_END);
GetPathResponse response = pathListener.getPath(request);
......@@ -55,7 +57,7 @@ public class PathListenerTest extends AdminAppTestBase {
void claimsPath() {
UUID claimId = UUID.randomUUID();
payload.setDataObjectReferences(new ArrayList<>());
payload.getDataObjectReferences().add(DataObjectReferenceDto.builder().objectType(ObjectType.CLAIM_PAYMENT).id(claimId).build());
payload.getDataObjectReferences().add(DataObjectReferenceDto.builder().objectType(CLAIM_PAYMENT).id(claimId).build());
payload.setPathEnd(PATH_END);
GetPathResponse response = pathListener.getPath(request);
......@@ -68,13 +70,14 @@ public class PathListenerTest extends AdminAppTestBase {
UUID actId = UUID.randomUUID();
UUID proceedingId = UUID.randomUUID();
payload.setDataObjectReferences(new ArrayList<>());
payload.getDataObjectReferences().add(DataObjectReferenceDto.builder().objectType(ObjectType.PROCEDURAL_ACT).id(actId).build());
payload.getDataObjectReferences().add(DataObjectReferenceDto.builder().objectType(ObjectType.PROCEEDING).id(proceedingId).build());
payload.getDataObjectReferences().add(DataObjectReferenceDto.builder().objectType(PROCEDURAL_ACT).id(actId).build());
payload.getDataObjectReferences().add(DataObjectReferenceDto.builder().objectType(PROCEEDING).id(proceedingId).build());
payload.setPathEnd(PATH_END);
GetPathResponse response = pathListener.getPath(request);
assertThat(response.getPayload()).isEqualTo(AUTH_PROCEEDINGS_URL + proceedingId.toString() + "/acts/" + actId.toString() + "/" + PATH_END);
assertThat(response.getPayload()).isEqualTo(AUTH_PROCEEDINGS_URL + proceedingId.toString() + "/acts/" +
actId.toString() + "/" + PATH_END);
}
@Test
......@@ -82,13 +85,14 @@ public class PathListenerTest extends AdminAppTestBase {
UUID violationId = UUID.randomUUID();
UUID proceedingId = UUID.randomUUID();
payload.setDataObjectReferences(new ArrayList<>());
payload.getDataObjectReferences().add(DataObjectReferenceDto.builder().objectType(ObjectType.VIOLATION).id(violationId).build());
payload.getDataObjectReferences().add(DataObjectReferenceDto.builder().objectType(ObjectType.PROCEEDING).id(proceedingId).build());
payload.getDataObjectReferences().add(DataObjectReferenceDto.builder().objectType(VIOLATION).id(violationId).build());
payload.getDataObjectReferences().add(DataObjectReferenceDto.builder().objectType(PROCEEDING).id(proceedingId).build());
payload.setPathEnd(PATH_END);
GetPathResponse response = pathListener.getPath(request);
assertThat(response.getPayload()).isEqualTo(AUTH_PROCEEDINGS_URL + proceedingId.toString() + "/violations/" + violationId.toString() + "/general");
assertThat(response.getPayload()).isEqualTo(AUTH_PROCEEDINGS_URL + proceedingId.toString() + "/violations/" +
violationId.toString() + "/" + PATH_END);
}
@Test
......@@ -96,13 +100,35 @@ public class PathListenerTest extends AdminAppTestBase {
UUID violationActId = UUID.randomUUID();
UUID proceedingId = UUID.randomUUID();
payload.setDataObjectReferences(new ArrayList<>());
payload.getDataObjectReferences().add(DataObjectReferenceDto.builder().objectType(ObjectType.VIOLATION_ACT).id(violationActId).build());
payload.getDataObjectReferences().add(DataObjectReferenceDto.builder().objectType(ObjectType.PROCEEDING).id(proceedingId).build());
payload.getDataObjectReferences().add(DataObjectReferenceDto.builder().objectType(VIOLATION_ACT).id(violationActId).build());
payload.getDataObjectReferences().add(DataObjectReferenceDto.builder().objectType(PROCEEDING).id(proceedingId).build());
payload.setPathEnd(PATH_END);
GetPathResponse response = pathListener.getPath(request);
assertThat(response.getPayload()).isEqualTo(AUTH_PROCEEDINGS_URL + proceedingId.toString() + "/violationAct/" + violationActId.toString() + "/general");
assertThat(response.getPayload()).isEqualTo(AUTH_PROCEEDINGS_URL + proceedingId.toString() + "/violationAct/" +
violationActId.toString() + "/" + PATH_END);
}
@Test
void riskAssessmentPath_success() {
UUID riskAssessmentId = UUID.randomUUID();
UUID riskFactorAssessmentId = UUID.randomUUID();
payload.setDataObjectReferences(new ArrayList<>());
payload.getDataObjectReferences().add(DataObjectReferenceDto.builder()
.objectType(RISK_ASSESSMENT)
.id(riskAssessmentId)
.build());
payload.getDataObjectReferences().add(DataObjectReferenceDto.builder()
.objectType(RISK_FACTOR_ASSESSMENT)
.id(riskFactorAssessmentId)
.build());
payload.setPathEnd(PATH_END);
GetPathResponse response = pathListener.getPath(request);
assertThat(response.getPayload()).isEqualTo(AUTH_RISK_ASSESSMENT_URL + riskAssessmentId.toString() +
"/assessment/" + riskFactorAssessmentId.toString() + "/" + PATH_END);
}
}
......@@ -21,15 +21,18 @@ public class PathComposeService {
private static final String PROCEEDING_PATH = "proceedings";
private static final String VIOLATION_PATH = "violations";
private static final String PROCEDURAL_ACTS_PATH = "acts";
private static final String CLAIM_PAYMENT_PATH = "claims";
private static final String PROCEDURAL_ACT_PATH = "acts";
private static final String VIOLATION_ACT_PATH = "violationAct";
private static final String CLAIM_PAYMENT_PATH = "claims";
private static final String RISK_ASSESSMENT_PATH = "risk-assessments";
private static final String ASSESSMENT_PATH = "assessment";
private static final String PATH_DELIMITER = "/";
private final PathMapper mapper;
@Value("${teis.baseurl-official}")
private String baseUrlOffical;
private String baseUrlOfficial;
@Value("${teis.baseurl-public}")
private String baseUrlPublic;
@Value("${teis.url-part-auth:}")
......@@ -54,11 +57,14 @@ public class PathComposeService {
path += PATH_DELIMITER + VIOLATION_PATH + PATH_DELIMITER + getRefWithType(pathDto, VIOLATION).getId();
} else if (hasType(pathDto, PROCEDURAL_ACT)) {
path = PATH_DELIMITER + PROCEEDING_PATH + PATH_DELIMITER + getRefWithType(pathDto, PROCEEDING).getId();
path += PATH_DELIMITER + PROCEDURAL_ACTS_PATH + PATH_DELIMITER + getRefWithType(pathDto, PROCEDURAL_ACT).getId();
path += PATH_DELIMITER + PROCEDURAL_ACT_PATH + PATH_DELIMITER + getRefWithType(pathDto, PROCEDURAL_ACT).getId();
} else if (hasType(pathDto, PROCEEDING)) {
path = PATH_DELIMITER + PROCEEDING_PATH + PATH_DELIMITER + getRefWithType(pathDto, PROCEEDING).getId();
} else if (hasType(pathDto, CLAIM_PAYMENT)) {
path = PATH_DELIMITER + CLAIM_PAYMENT_PATH + PATH_DELIMITER + getRefWithType(pathDto, CLAIM_PAYMENT).getId();
} else if (hasType(pathDto, RISK_ASSESSMENT) || hasType(pathDto, RISK_FACTOR_ASSESSMENT)) {
path = PATH_DELIMITER + RISK_ASSESSMENT_PATH + PATH_DELIMITER + getRefWithType(pathDto, RISK_ASSESSMENT).getId();
path += PATH_DELIMITER + ASSESSMENT_PATH + PATH_DELIMITER + getRefWithType(pathDto, RISK_FACTOR_ASSESSMENT).getId();
}
if (path.length() > 0) {
path = appendUrl(pathDto, path);
......@@ -80,6 +86,9 @@ public class PathComposeService {
if (hasType(pathDto, VIOLATION_ACT) && !hasType(pathDto, PROCEEDING)) {
return false;
}
if (hasType(pathDto, RISK_FACTOR_ASSESSMENT) && !hasType(pathDto, RISK_ASSESSMENT)) {
return false;
}
for (DataObjectReferenceDto ref : pathDto.getDataObjectReferences()) {
long count = pathDto.getDataObjectReferences().stream()
.filter(o -> o.getObjectType().equals(ref.getObjectType()))
......@@ -107,7 +116,7 @@ public class PathComposeService {
.filter(o -> o.getObjectType().equals(objectType))
.findFirst()
.orElseThrow(() -> new TeisResourceNotFoundException("Data object reference with type " +
objectType.getId() + "not found"));
objectType.getId() + " not found"));
}
private String appendUrl(PathDto pathDto, String path) {
......@@ -119,7 +128,7 @@ public class PathComposeService {
}
if (pathDto.getDomain() != null) {
if (OFFICIAL == pathDto.getDomain()) {
path = baseUrlOffical + path;
path = baseUrlOfficial + path;
} else if (PUBLIC == pathDto.getDomain()) {
path = baseUrlPublic + path;
}
......
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