Commit 1d7b63ac authored by Kristel Meikas's avatar Kristel Meikas
Browse files

Merge branch 'TEIS-1318' into 'develop'

TEIS-1318: added functionality for accepting DELETE risk assessment requests

Closes TEIS-1318

See merge request teis/common-api-gateway!128
parents 1c4e8b29 b06c197d
package ee.sm.ti.teis.commongateway.riskassessment.riskassessment.request;
import ee.sm.ti.teis.AbstractDTO;
import ee.sm.ti.teis.ErrorDTO;
import java.util.UUID;
public class DeleteRiskAssessmentRequest extends AbstractDTO<UUID, ErrorDTO> {
public static final String ROUTING_KEY = "api.DeleteRiskAssessmentRequest";
@Override
public String routingKey() {
return ROUTING_KEY;
}
}
package ee.sm.ti.teis.commongateway.riskassessment.riskassessment.response;
import ee.sm.ti.teis.AbstractDTO;
import ee.sm.ti.teis.ErrorDTO;
public class DeleteRiskAssessmentResponse extends AbstractDTO<Void, ErrorDTO> {
public static final String ROUTING_KEY = "api.DeleteRiskAssessmentResponse";
@Override
public String routingKey() {
return ROUTING_KEY;
}
}
......@@ -53,4 +53,10 @@ class RiskAssessmentControllerTest extends CommonApiGatewayTestBase {
() -> controller.updateStatus(randomUUID(), new UpdateRiskAssessmentStatusDto(), new RequestMetaDTO()));
}
@Test
void delete_test() {
assertThrows(NoResponseFromRabbitException.class,
() -> controller.delete(randomUUID(), new RequestMetaDTO()));
}
}
package ee.sm.ti.teis.commongateway.riskassessment.riskassessment;
import ee.sm.ti.teis.commongateway.riskassessment.riskassessment.dto.CreateRiskAssessmentDto;
import ee.sm.ti.teis.commongateway.riskassessment.riskassessment.dto.RiskAssessmentConclusionDto;
import ee.sm.ti.teis.commongateway.riskassessment.riskassessment.dto.RiskAssessmentPublicDto;
import ee.sm.ti.teis.commongateway.riskassessment.riskassessment.dto.UpdateRiskAssessmentStatusDto;
import ee.sm.ti.teis.commongateway.riskassessment.riskassessment.dto.UpdateRiskAssessmentTitleDto;
import ee.sm.ti.teis.commongateway.riskassessment.riskassessment.request.CreateRiskAssessmentPublicRequest;
import ee.sm.ti.teis.commongateway.riskassessment.riskassessment.request.GetRiskAssessmentPublicRequest;
import ee.sm.ti.teis.commongateway.riskassessment.riskassessment.request.GetRiskAssessmentsPublicRequest;
import ee.sm.ti.teis.commongateway.riskassessment.riskassessment.request.RiskAssessmentBusinessTypePublicRequest;
import ee.sm.ti.teis.commongateway.riskassessment.riskassessment.request.RiskAssessmentConclusionPublicRequest;
import ee.sm.ti.teis.commongateway.riskassessment.riskassessment.request.RiskAssessmentRiskFactorAssessmentPublicRequest;
import ee.sm.ti.teis.commongateway.riskassessment.riskassessment.request.UpdateRiskAssessmentStatusPublicRequest;
import ee.sm.ti.teis.commongateway.riskassessment.riskassessment.request.UpdateRiskAssessmentTitlePublicRequest;
import ee.sm.ti.teis.commongateway.riskassessment.riskassessment.dto.*;
import ee.sm.ti.teis.commongateway.riskassessment.riskassessment.request.*;
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.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import java.util.List;
......@@ -143,4 +125,13 @@ public class RiskAssessmentController extends TeisBaseController {
return service.updateStatus(request);
}
@ApiOperation(value = "${teis.api.risk-assessments.risk-assessment.delete}")
@DeleteMapping("{id}")
public void delete(@PathVariable UUID id, @ApiIgnore RequestMetaDTO requestMetaDTO) {
DeleteRiskAssessmentRequest request = new DeleteRiskAssessmentRequest();
request.setPayload(id, requestMetaDTO);
service.delete(request);
}
}
......@@ -2,22 +2,8 @@ package ee.sm.ti.teis.commongateway.riskassessment.riskassessment;
import ee.sm.ti.teis.commongateway.riskassessment.riskassessment.dto.RiskAssessmentConclusionDto;
import ee.sm.ti.teis.commongateway.riskassessment.riskassessment.dto.RiskAssessmentPublicDto;
import ee.sm.ti.teis.commongateway.riskassessment.riskassessment.request.CreateRiskAssessmentPublicRequest;
import ee.sm.ti.teis.commongateway.riskassessment.riskassessment.request.GetRiskAssessmentPublicRequest;
import ee.sm.ti.teis.commongateway.riskassessment.riskassessment.request.GetRiskAssessmentsPublicRequest;
import ee.sm.ti.teis.commongateway.riskassessment.riskassessment.request.RiskAssessmentBusinessTypePublicRequest;
import ee.sm.ti.teis.commongateway.riskassessment.riskassessment.request.RiskAssessmentConclusionPublicRequest;
import ee.sm.ti.teis.commongateway.riskassessment.riskassessment.request.RiskAssessmentRiskFactorAssessmentPublicRequest;
import ee.sm.ti.teis.commongateway.riskassessment.riskassessment.request.UpdateRiskAssessmentStatusPublicRequest;
import ee.sm.ti.teis.commongateway.riskassessment.riskassessment.request.UpdateRiskAssessmentTitlePublicRequest;
import ee.sm.ti.teis.commongateway.riskassessment.riskassessment.response.CreateRiskAssessmentPublicResponse;
import ee.sm.ti.teis.commongateway.riskassessment.riskassessment.response.GetRiskAssessmentPublicResponse;
import ee.sm.ti.teis.commongateway.riskassessment.riskassessment.response.GetRiskAssessmentsPublicResponse;
import ee.sm.ti.teis.commongateway.riskassessment.riskassessment.response.RiskAssessmentBusinessTypePublicResponse;
import ee.sm.ti.teis.commongateway.riskassessment.riskassessment.response.RiskAssessmentConclusionPublicResponse;
import ee.sm.ti.teis.commongateway.riskassessment.riskassessment.response.RiskAssessmentRiskFactorAssessmentPublicResponse;
import ee.sm.ti.teis.commongateway.riskassessment.riskassessment.response.UpdateRiskAssessmentStatusPublicResponse;
import ee.sm.ti.teis.commongateway.riskassessment.riskassessment.response.UpdateRiskAssessmentTitlePublicResponse;
import ee.sm.ti.teis.commongateway.riskassessment.riskassessment.request.*;
import ee.sm.ti.teis.commongateway.riskassessment.riskassessment.response.*;
import ee.sm.ti.teis.gatewaycommon.error.NoResponseFromRabbitException;
import lombok.RequiredArgsConstructor;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
......@@ -110,4 +96,15 @@ public class RiskAssessmentProcessingService {
throw new NoResponseFromRabbitException(request.getRequestMetaDTO().getRequestId());
}
public void delete(DeleteRiskAssessmentRequest requestDTO) {
DeleteRiskAssessmentResponse response =
(DeleteRiskAssessmentResponse) gwRabbitTemplate.convertSendAndReceive(requestDTO.routingKey(), requestDTO);
if (response != null) {
response.processResponse();
return;
}
throw new NoResponseFromRabbitException(requestDTO.getRequestMetaDTO().getRequestId());
}
}
......@@ -134,5 +134,6 @@ teis.api.risk-assessments.risk-assessment.get-business-types: Teenus väljastab
teis.api.risk-assessments.risk-assessment.update-status: Teenus muudab riskianalüüsi staatust.
teis.api.risk-assessments.risk-assessment.get-by-id: Teenus väljastab riskianalüüsi andmeobjekti.
teis.api.risk-assessments.risk-assessment.get-risk-factor-assessments: Teenus väljastab riskianalüüsi raames antud ohu hinnangute andmed oos hinnatavate ohtude kirjeldustega.
teis.api.risk-assessments.risk-assessment.delete: Teenus kustutab riskianalüüsi. Teenust kasutab iseteenindus, et kustutada ekslikult loodud riskianalüüs. Kustutada ei saa kinnitatud riskianalüüsi.
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