Commit 77adbcc5 authored by handolukats's avatar handolukats
Browse files

TEIS-1320 added patch risk factor assessment description controller

parent e02e59f7
package ee.sm.ti.teis.commongateway.riskassessments.riskfactorassessment.dto;
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 UpdateRiskFactorAssessmentDescriptionPublicDto {
@NotNull
private UUID id;
private String name;
private String description;
}
package ee.sm.ti.teis.commongateway.riskassessments.riskfactorassessment.request;
import ee.sm.ti.teis.AbstractDTO;
import ee.sm.ti.teis.ErrorDTO;
import ee.sm.ti.teis.commongateway.riskassessments.riskfactorassessment.dto.UpdateRiskFactorAssessmentDescriptionPublicDto;
public class UpdateRiskFactorAssessmentDescriptionPublicRequest extends AbstractDTO<UpdateRiskFactorAssessmentDescriptionPublicDto, ErrorDTO> {
public static final String ROUTING_KEY = "api.UpdateRiskFactorAssessmentDescriptionPublicRequest";
@Override
public String routingKey() {
return ROUTING_KEY;
}
}
package ee.sm.ti.teis.commongateway.riskassessments.riskfactorassessment.response;
import ee.sm.ti.teis.AbstractDTO;
import ee.sm.ti.teis.ErrorDTO;
import ee.sm.ti.teis.commongateway.riskassessments.riskfactorassessment.dto.RiskFactorAssessmentPublicLightDto;
public class UpdateRiskFactorAssessmentDescriptionPublicResponse extends AbstractDTO<RiskFactorAssessmentPublicLightDto, ErrorDTO> {
public static final String ROUTING_KEY = "api.UpdateRiskFactorAssessmentDescriptionPublicResponse";
@Override
public String routingKey() {
return ROUTING_KEY;
}
}
......@@ -2,6 +2,7 @@ package ee.sm.ti.teis.commongateway.riskassessments.riskfactorassessment;
import ee.sm.ti.teis.commongateway.CommonApiGatewayTestBase;
import ee.sm.ti.teis.commongateway.riskassessments.riskfactorassessment.dto.CreateRiskFactorAssessmentDto;
import ee.sm.ti.teis.commongateway.riskassessments.riskfactorassessment.dto.UpdateRiskFactorAssessmentDescriptionPublicDto;
import ee.sm.ti.teis.commongateway.riskassessments.riskfactorassessment.dto.UpdateRiskFactorAssessmentRiskExistsPublicDto;
import ee.sm.ti.teis.gatewaycommon.error.NoResponseFromRabbitException;
import ee.sm.ti.teis.servicerequest.RequestMetaDTO;
......@@ -38,4 +39,10 @@ class RiskFactorAssessmentControllerTest extends CommonApiGatewayTestBase {
assertThrows(NoResponseFromRabbitException.class, () -> controller.getRiskFactorAssessment(randomUUID(), new RequestMetaDTO()));
}
@Test
void updateDescription_badRequest() {
assertThrows(NoResponseFromRabbitException.class,
() -> controller.updateDescription(randomUUID(), new UpdateRiskFactorAssessmentDescriptionPublicDto(), new RequestMetaDTO()));
}
}
......@@ -3,10 +3,12 @@ package ee.sm.ti.teis.commongateway.riskassessments.riskfactorassessment;
import ee.sm.ti.teis.commongateway.riskassessments.riskfactorassessment.dto.CreateRiskFactorAssessmentDto;
import ee.sm.ti.teis.commongateway.riskassessments.riskfactorassessment.dto.RiskFactorAssessmentPublicDto;
import ee.sm.ti.teis.commongateway.riskassessments.riskfactorassessment.dto.RiskFactorAssessmentPublicLightDto;
import ee.sm.ti.teis.commongateway.riskassessments.riskfactorassessment.dto.UpdateRiskFactorAssessmentDescriptionPublicDto;
import ee.sm.ti.teis.commongateway.riskassessments.riskfactorassessment.dto.UpdateRiskFactorAssessmentRiskExistsPublicDto;
import ee.sm.ti.teis.commongateway.riskassessments.riskfactorassessment.request.CreateRiskFactorAssessmentRequest;
import ee.sm.ti.teis.commongateway.riskassessments.riskfactorassessment.request.DeleteRiskFactorAssessmentPublicRequest;
import ee.sm.ti.teis.commongateway.riskassessments.riskfactorassessment.request.RiskFactorAssessmentPublicRequest;
import ee.sm.ti.teis.commongateway.riskassessments.riskfactorassessment.request.UpdateRiskFactorAssessmentDescriptionPublicRequest;
import ee.sm.ti.teis.commongateway.riskassessments.riskfactorassessment.request.UpdateRiskFactorAssessmentRiskExistsPublicRequest;
import ee.sm.ti.teis.gatewaycommon.controller.TeisBaseController;
import ee.sm.ti.teis.servicerequest.RequestMetaDTO;
......@@ -14,7 +16,14 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.DeleteMapping;
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.RestController;
import springfox.documentation.annotations.ApiIgnore;
import java.util.UUID;
......@@ -82,4 +91,21 @@ public class RiskFactorAssessmentController extends TeisBaseController {
return service.getRiskFactorAssessment(request);
}
@ApiOperation(value = "${teis.api.risk-assessments.risk-factor-assessment.update-description}",
response = RiskFactorAssessmentPublicLightDto.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")})
@PatchMapping("{id}/risk-exists")
public RiskFactorAssessmentPublicLightDto updateDescription(@PathVariable UUID id,
@RequestBody UpdateRiskFactorAssessmentDescriptionPublicDto dto,
@ApiIgnore RequestMetaDTO requestMetaDTO) {
UpdateRiskFactorAssessmentDescriptionPublicRequest request = new UpdateRiskFactorAssessmentDescriptionPublicRequest();
dto.setId(id);
request.setPayload(dto, requestMetaDTO);
return service.updateDescription(request);
}
}
......@@ -5,10 +5,12 @@ import ee.sm.ti.teis.commongateway.riskassessments.riskfactorassessment.dto.Risk
import ee.sm.ti.teis.commongateway.riskassessments.riskfactorassessment.request.CreateRiskFactorAssessmentRequest;
import ee.sm.ti.teis.commongateway.riskassessments.riskfactorassessment.request.DeleteRiskFactorAssessmentPublicRequest;
import ee.sm.ti.teis.commongateway.riskassessments.riskfactorassessment.request.RiskFactorAssessmentPublicRequest;
import ee.sm.ti.teis.commongateway.riskassessments.riskfactorassessment.request.UpdateRiskFactorAssessmentDescriptionPublicRequest;
import ee.sm.ti.teis.commongateway.riskassessments.riskfactorassessment.request.UpdateRiskFactorAssessmentRiskExistsPublicRequest;
import ee.sm.ti.teis.commongateway.riskassessments.riskfactorassessment.response.CreateRiskFactorAssessmentResponse;
import ee.sm.ti.teis.commongateway.riskassessments.riskfactorassessment.response.DeleteRiskFactorAssessmentPublicResponse;
import ee.sm.ti.teis.commongateway.riskassessments.riskfactorassessment.response.RiskFactorAssessmentPublicResponse;
import ee.sm.ti.teis.commongateway.riskassessments.riskfactorassessment.response.UpdateRiskFactorAssessmentDescriptionPublicResponse;
import ee.sm.ti.teis.commongateway.riskassessments.riskfactorassessment.response.UpdateRiskFactorAssessmentRiskExistsPublicResponse;
import ee.sm.ti.teis.gatewaycommon.error.NoResponseFromRabbitException;
import lombok.RequiredArgsConstructor;
......@@ -60,4 +62,15 @@ public class RiskFactorAssessmentProcessingService {
throw new NoResponseFromRabbitException(request.getRequestMetaDTO().getRequestId());
}
public RiskFactorAssessmentPublicLightDto updateDescription(UpdateRiskFactorAssessmentDescriptionPublicRequest request) {
UpdateRiskFactorAssessmentDescriptionPublicResponse response =
(UpdateRiskFactorAssessmentDescriptionPublicResponse) gwRabbitTemplate.convertSendAndReceive(request.routingKey(), request);
if (response != null) {
return response.processResponse();
}
throw new NoResponseFromRabbitException(request.getRequestMetaDTO().getRequestId());
}
}
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