Commit ef1261f5 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/common-api-gateway!182
parents c0a755bc b538efc6
......@@ -6,6 +6,8 @@ import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.UUID;
public class ViolationActsPublicRequest extends AbstractDTO<ViolationActsPublicRequest.Parameters, ErrorDTO> {
public static final String ROUTING_KEY = "api.ViolationActsPublicRequest";
......@@ -18,8 +20,8 @@ public class ViolationActsPublicRequest extends AbstractDTO<ViolationActsPublicR
@AllArgsConstructor
@NoArgsConstructor
public static class Parameters {
private String proceedingId;
private String violationId;
private UUID proceedingId;
private UUID violationId;
}
}
......@@ -32,4 +32,5 @@ public class RiskAssessmentPublicDto {
private ObjectStatus objectStatus;
private List<AssessedBusinessTypePublicDto> assessedBusinessTypes;
private List<RiskFactorAssessmentPublicDto> riskFactorAssessments;
private Boolean uploadedByOfficial;
}
package ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.dto;
import ee.sm.ti.teis.types.enums.TaskStatusType;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotNull;
import java.util.UUID;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class UpdateRiskStatementAssessmentTaskStatusDto {
@NotNull
private UUID id;
@NotNull
private TaskStatusType status;
}
package ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.request;
import ee.sm.ti.teis.AbstractDTO;
import ee.sm.ti.teis.ErrorDTO;
import ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.dto.UpdateRiskStatementAssessmentTaskStatusDto;
public class UpdateRiskStatementAssessmentTaskStatusRequest extends AbstractDTO<UpdateRiskStatementAssessmentTaskStatusDto,
ErrorDTO> {
public static final String ROUTING_KEY = "api.UpdateRiskStatementAssessmentTaskStatusRequest";
@Override
public String routingKey() {
return ROUTING_KEY;
}
}
package ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.response;
import ee.sm.ti.teis.AbstractDTO;
import ee.sm.ti.teis.ErrorDTO;
import ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.dto.RiskStatementAssessmentActionPublicDto;
public class UpdateRiskStatementAssessmentTaskStatusResponse extends AbstractDTO<RiskStatementAssessmentActionPublicDto,
ErrorDTO> {
public static final String ROUTING_KEY = "api.UpdateRiskStatementAssessmentTaskStatusResponse";
@Override
public String routingKey() {
return ROUTING_KEY;
}
}
package ee.sm.ti.teis.commongateway.auditlog;
import ee.sm.ti.teis.commongateway.CommonApiGatewayTestBase;
import ee.sm.ti.teis.commongateway.auditlog.dto.AuditLogItemDto;
import ee.sm.ti.teis.commongateway.auditlog.dto.AuditLogItemExistsDto;
import ee.sm.ti.teis.gatewaycommon.error.NoResponseFromRabbitException;
import ee.sm.ti.teis.servicerequest.RequestMetaDTO;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.UUID;
import static java.util.UUID.randomUUID;
import static org.junit.jupiter.api.Assertions.assertThrows;
class AuditLogTestControllerTest extends CommonApiGatewayTestBase {
private static final RequestMetaDTO requestMetaDTO = RequestMetaDTO.builder().requestId(UUID.randomUUID().toString()).build();
private static final RequestMetaDTO requestMetaDTO = RequestMetaDTO.builder().requestId(randomUUID().toString()).build();
@Autowired
AuditLogTestController controller;
@Test
void createAuditLogItem_test() {
void createAuditLogItem_badRequest() {
AuditLogItemDto logItemDto = AuditLogItemDto.builder().build();
assertThrows(NoResponseFromRabbitException.class, () -> controller.createAuditLogItem(logItemDto, requestMetaDTO));
assertThrows(NoResponseFromRabbitException.class, () ->
controller.createAuditLogItem(logItemDto, requestMetaDTO));
}
@Test
void getAuditLogItems_badRequest() {
assertThrows(NoResponseFromRabbitException.class, () ->
controller.getAuditLogItems(null, null, requestMetaDTO));
}
@Test
void getAuditLogItems_test() {
assertThrows(NoResponseFromRabbitException.class, () -> controller.getAuditLogItems(null, null, requestMetaDTO));
void auditLogItemExists_badRequest() {
assertThrows(NoResponseFromRabbitException.class, () ->
controller.auditLogItemExists(new AuditLogItemExistsDto(), requestMetaDTO));
}
}
package ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment;
import ee.sm.ti.teis.commongateway.CommonApiGatewayTestBase;
import ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.dto.CreateRiskStatementAssessmentPublicDto;
import ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.dto.PatchRiskStatementAssessmentDescriptionPublicDto;
import ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.dto.RiskStatementAssessmentPublicDto;
import ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.dto.UpdateRiskStatementAssessmentActionPublicDto;
import ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.dto.*;
import ee.sm.ti.teis.gatewaycommon.error.NoResponseFromRabbitException;
import ee.sm.ti.teis.servicerequest.RequestMetaDTO;
import org.junit.jupiter.api.Test;
......@@ -48,4 +45,10 @@ class RiskStatementAssessmentControllerTest extends CommonApiGatewayTestBase {
new UpdateRiskStatementAssessmentActionPublicDto(), new RequestMetaDTO()));
}
@Test
void updateTaskStatus_badRequest() {
assertThrows(NoResponseFromRabbitException.class, () -> controller.updateTaskStatus(randomUUID(),
new UpdateRiskStatementAssessmentTaskStatusDto(), new RequestMetaDTO()));
}
}
......@@ -47,4 +47,16 @@ public class TaskActionPlanControllerTest extends CommonApiGatewayTestBase {
assertThrows(NoResponseFromRabbitException.class, () ->
controller.updateStatus(randomUUID(), new UpdateTaskActionPlanStatusDto(), new RequestMetaDTO()));
}
@Test
void getTaskReferences_badRequest() {
assertThrows(NoResponseFromRabbitException.class, () ->
controller.getTaskReferences(new RequestMetaDTO()));
}
@Test
void getTaskResponsiblePersons_badRequest() {
assertThrows(NoResponseFromRabbitException.class, () ->
controller.getTaskResponsiblePersons(new RequestMetaDTO()));
}
}
......@@ -7,6 +7,7 @@ import ee.sm.ti.teis.servicerequest.RequestMetaDTO;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import static java.util.UUID.randomUUID;
import static org.junit.jupiter.api.Assertions.assertThrows;
class ViolationActControllerTest extends CommonApiGatewayTestBase {
......@@ -17,13 +18,13 @@ class ViolationActControllerTest extends CommonApiGatewayTestBase {
@Test
void getViolations_badRequest() {
assertThrows(NoResponseFromRabbitException.class, () ->
controller.getViolationActs("", "", new RequestMetaDTO()));
controller.getViolationActs(randomUUID(), randomUUID(), new RequestMetaDTO()));
}
@Test
void getViolation_badRequest() {
assertThrows(NoResponseFromRabbitException.class, () ->
controller.getViolationAct("", new RequestMetaDTO()));
controller.getViolationAct(randomUUID(), new RequestMetaDTO()));
}
}
......@@ -7,8 +7,6 @@ import ee.sm.ti.teis.commongateway.messages.message.request.CreateMessageFileRef
import ee.sm.ti.teis.gatewaycommon.controller.TeisBaseController;
import ee.sm.ti.teis.servicerequest.RequestMetaDTO;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Profile;
import org.springframework.web.bind.annotation.*;
......@@ -35,10 +33,6 @@ public class AdminForTestingController extends TeisBaseController {
}
@ApiOperation(value = "${teis.api.messages.message.post-message-file-references}", response = FileReferenceDto.class)
@ApiResponses(value = {
@ApiResponse(code = 400, message = "Sisendi parameetrid ei vasta nõuetele"),
@ApiResponse(code = 403, message = "Kasutajal ei ole õigust andmeobjekti pärida"),
@ApiResponse(code = 404, message = "Sisendis esitatud andmetega objekti ei eksisteeri")})
@PostMapping("message/{id}/file-references")
public List<FileReferenceDto> createFileReferences(@PathVariable UUID id,
@RequestBody List<MessageFileReferenceDto> dtoList, RequestMetaDTO requestMetaDTO) {
......
......@@ -7,6 +7,7 @@ import org.springframework.stereotype.Service;
import java.util.UUID;
@Service
@Deprecated(since = "1.19.0-SNAPSHOT", forRemoval = true)
public class AdminForTestingProcessingService {
private final RabbitTemplate gwRabbitTemplate;
......
......@@ -8,6 +8,7 @@ import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
@Service
@Deprecated(since = "1.19.0-SNAPSHOT", forRemoval = true)
@RequiredArgsConstructor
public class DeadlineProcessingService {
......
......@@ -6,6 +6,7 @@ import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;
@Service
@Deprecated(since = "1.19.0-SNAPSHOT", forRemoval = true)
@RequiredArgsConstructor
public class FeatureFlagProcessingService {
......
......@@ -5,6 +5,7 @@ import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;
@Service
@Deprecated(since = "1.19.0-SNAPSHOT", forRemoval = true)
public class PathProcessingService {
private final RabbitTemplate gwRabbitTemplate;
......
package ee.sm.ti.teis.commongateway.auditlog;
import ee.sm.ti.teis.gatewaycommon.error.NoResponseFromRabbitException;
import lombok.RequiredArgsConstructor;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
@RequiredArgsConstructor
public class AuditLogProcessingService {
private final RabbitTemplate gwRabbitTemplate;
AuditLogItemDto createAuditLogItem(CreateAuditLogItemRequest request) {
CreateAuditLogItemResponse response = (CreateAuditLogItemResponse) gwRabbitTemplate.convertSendAndReceive(request.routingKey(), request);
if (response != null) {
return response.processResponse();
}
throw new NoResponseFromRabbitException(request.getRequestMetaDTO().getRequestId());
}
List<AuditLogItemDto> getAuditLogItems(AuditLogItemsRequest request) {
AuditLogItemsResponse response = (AuditLogItemsResponse) gwRabbitTemplate.convertSendAndReceive(request.routingKey(), request);
if (response != null) {
return response.processResponse();
}
throw new NoResponseFromRabbitException(request.getRequestMetaDTO().getRequestId());
}
}
package ee.sm.ti.teis.commongateway.auditlog;
import ee.sm.ti.teis.commongateway.auditlog.dto.AuditLogItemDto;
import ee.sm.ti.teis.commongateway.auditlog.dto.AuditLogItemExistsDto;
import ee.sm.ti.teis.commongateway.auditlog.dto.AuditLogItemExistsResponseDto;
import ee.sm.ti.teis.commongateway.auditlog.request.AuditLogItemExistsRequest;
import ee.sm.ti.teis.commongateway.auditlog.request.AuditLogItemsRequest;
import ee.sm.ti.teis.commongateway.auditlog.request.AuditLogItemsRequest.Parameters;
import ee.sm.ti.teis.commongateway.auditlog.request.CreateAuditLogItemRequest;
import ee.sm.ti.teis.gatewaycommon.controller.TeisBaseController;
import ee.sm.ti.teis.gatewaycommon.rabbit.RequestProcessingService;
import ee.sm.ti.teis.servicerequest.RequestMetaDTO;
import io.swagger.annotations.*;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Profile;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/auditlogs")
@RequestMapping("auditlogs")
@Profile({"dev", "test", "local", "integtest"})
@RequiredArgsConstructor
public class AuditLogTestController extends TeisBaseController {
private final AuditLogProcessingService processingService;
private final RequestProcessingService service;
@ApiOperation(value = "${teis.api.messages.post-auditlog}", response = AuditLogItemDto.class)
@PostMapping(produces = MediaType.APPLICATION_JSON_VALUE)
public AuditLogItemDto createAuditLogItem(@RequestBody AuditLogItemDto item, RequestMetaDTO requestMetaDTO) {
@ApiOperation(value = "${teis.api.messages.post-audit-log}", response = AuditLogItemDto.class)
@PostMapping
public AuditLogItemDto createAuditLogItem(@RequestBody AuditLogItemDto dto, RequestMetaDTO requestMetaDTO) {
CreateAuditLogItemRequest request = new CreateAuditLogItemRequest();
request.setPayload(new CreateAuditLogItemRequest.Parameters(item), requestMetaDTO);
request.setPayload(dto, requestMetaDTO);
return processingService.createAuditLogItem(request);
return (AuditLogItemDto) service.sendAndReceive(request);
}
@ApiOperation(value = "${teis.api.messages.get-auditlog}", response = AuditLogItemDto.class)
@ApiOperation(value = "${teis.api.messages.get-audit-log}", response = AuditLogItemDto.class)
@ApiImplicitParams({
@ApiImplicitParam(name = "parentDataObjectId", value = "${teis.api.messages.get-auditlog-parentObjectId}"),
@ApiImplicitParam(name = "dataObjectId", value = "${teis.api.messages.get-auditlog-dataObjectId}")
})
@ApiResponses(@ApiResponse(code = 400, message = "Sisend ei vasta nõuetele."))
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
@GetMapping
public List<AuditLogItemDto> getAuditLogItems(
@RequestParam(name = "parentDataObjectId", required = false) String parentObjectId,
@RequestParam(name = "dataObjectId", required = false) String dataObjectId,
RequestMetaDTO requestMetaDTO) {
RequestMetaDTO requestMetaDTO) {
AuditLogItemsRequest request = new AuditLogItemsRequest();
request.setPayload(new AuditLogItemsRequest.Parameters(parentObjectId, dataObjectId), requestMetaDTO);
request.setPayload(new Parameters(parentObjectId, dataObjectId), requestMetaDTO);
return processingService.getAuditLogItems(request);
return (List<AuditLogItemDto>) service.sendAndReceive(request);
}
@ApiOperation(value = "${teis.api.messages.audit-log-exists}", response = Boolean.class)
@GetMapping("check")
public AuditLogItemExistsResponseDto auditLogItemExists(@RequestBody AuditLogItemExistsDto dto, RequestMetaDTO requestMetaDTO) {
AuditLogItemExistsRequest request = new AuditLogItemExistsRequest();
request.setPayload(dto, requestMetaDTO);
return (AuditLogItemExistsResponseDto) service.sendAndReceive(request);
}
}
......@@ -6,8 +6,6 @@ import ee.sm.ti.teis.servicerequest.RequestMetaDTO;
import ee.sm.ti.teis.types.enums.classifier.LinkedItems;
import ee.sm.ti.teis.types.enums.classifier.RelationType;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
......@@ -22,9 +20,6 @@ public class ClassifierController extends TeisBaseController {
private final ClassifierProcessingService classifierProcessingService;
@ApiOperation(value = "${teis.api.messages.get-classifier-items}", response = String.class)
@ApiResponses(value = {
@ApiResponse(code = 404, message = "Sisendis esitatud andmetega klassifikaatorit ei eksisteeri")
})
@GetMapping(value = "classifier-items", produces = MediaType.APPLICATION_JSON_VALUE)
public List<ClassifierItemDto> getClassifiers(ClassifierItemSearchFilterDto searchFilterDto, RequestMetaDTO requestMetaDTO) {
ClassifierItemsRequest request = new ClassifierItemsRequest();
......@@ -34,9 +29,6 @@ public class ClassifierController extends TeisBaseController {
}
@ApiOperation(value = "${teis.api.messages.get-classifier}", response = String.class)
@ApiResponses(value = {
@ApiResponse(code = 404, message = "Sisendis esitatud andmetega klassifikaatorit ei eksisteeri")
})
@GetMapping(value = "classifier-items/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
public ClassifierItemDto getClassifier(
@PathVariable(name = "id") String id,
......@@ -49,9 +41,6 @@ public class ClassifierController extends TeisBaseController {
}
@ApiOperation(value = "${teis.api.messages.get-classifier-default-value}")
@ApiResponses(value = {
@ApiResponse(code = 404, message = "Sisendis esitatud andmetega klassifikaatorit ei eksisteeri")
})
@GetMapping(value = "classifier-definitions/{definitionId}/default-value", produces = MediaType.APPLICATION_JSON_VALUE)
public ClassifierItemDto getDefinition(
@PathVariable(name = "definitionId") String definitionId, RequestMetaDTO requestMetaDTO) {
......
......@@ -8,6 +8,7 @@ import org.springframework.stereotype.Service;
import java.util.List;
@Service
@Deprecated(since = "1.19.0-SNAPSHOT", forRemoval = true)
@RequiredArgsConstructor
public class ClassifierProcessingService {
......
......@@ -6,6 +6,7 @@ import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;
@Service
@Deprecated(since = "1.19.0-SNAPSHOT", forRemoval = true)
@RequiredArgsConstructor
public class DUMonitorProcessingService {
......
package ee.sm.ti.teis.commongateway.file;
import ee.sm.ti.teis.commongateway.parameter.ParameterDto;
import ee.sm.ti.teis.commongateway.parameter.ParameterProcessingService;
import ee.sm.ti.teis.commongateway.parameter.ParametersRequest;
import ee.sm.ti.teis.commongateway.parameter.dto.ParameterDto;
import ee.sm.ti.teis.commongateway.parameter.request.ParametersRequest;
import ee.sm.ti.teis.exceptions.TeisResourceNotFoundException;
import ee.sm.ti.teis.servicerequest.RequestMetaDTO;
import ee.sm.ti.teis.types.enums.FileParameterType;
......
Markdown is supported
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