Commit 1021f676 authored by Hando Lukats's avatar Hando Lukats
Browse files

Merge branch 'TEIS-1494' into 'develop'

TEIS-1494: added TEST controller for accepting authority permissions validation requests

Closes TEIS-1494

See merge request teis/common-api-gateway!131
parents eb8b7b72 53a55a54
package ee.sm.ti.teis.commongateway.representative.authoritypermission.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotNull;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class AuthorityPermissionExistsDto {
@NotNull
private boolean permissionExists;
}
package ee.sm.ti.teis.commongateway.representative.authoritypermission.dto;
import ee.sm.ti.teis.types.enums.AuthorityType;
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 ValidateAuthorityPermissionDto {
@NotNull
private UUID personId;
@NotNull
private UUID grantorId;
@NotNull
private AuthorityType authorityType;
}
package ee.sm.ti.teis.commongateway.representative.authoritypermission.request;
import ee.sm.ti.teis.AbstractDTO;
import ee.sm.ti.teis.ErrorDTO;
import ee.sm.ti.teis.commongateway.representative.authoritypermission.dto.ValidateAuthorityPermissionDto;
public class ValidateAuthorityPermissionRequest extends AbstractDTO<ValidateAuthorityPermissionDto, ErrorDTO> {
public static final String ROUTING_KEY = "api.ValidateAuthorityPermissionRequest";
@Override
public String routingKey() {
return ROUTING_KEY;
}
}
package ee.sm.ti.teis.commongateway.representative.authoritypermission.response;
import ee.sm.ti.teis.AbstractDTO;
import ee.sm.ti.teis.ErrorDTO;
import ee.sm.ti.teis.commongateway.representative.authoritypermission.dto.AuthorityPermissionExistsDto;
public class ValidateAuthorityPermissionResponse extends AbstractDTO<AuthorityPermissionExistsDto, ErrorDTO> {
public static final String ROUTING_KEY = "api.ValidateAuthorityPermissionResponse";
@Override
public String routingKey() {
return ROUTING_KEY;
}
}
package ee.sm.ti.teis.commongateway.representative.authoritypermission;
import ee.sm.ti.teis.commongateway.CommonApiGatewayTestBase;
import ee.sm.ti.teis.commongateway.representative.authoritypermission.dto.ValidateAuthorityPermissionDto;
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 static org.junit.jupiter.api.Assertions.assertThrows;
class AuthorityPermissionTestControllerTest extends CommonApiGatewayTestBase {
@Autowired
AuthorityPermissionTestController controller;
@Test
void validateAuthorityPermission_test() {
assertThrows(NoResponseFromRabbitException.class, () ->
controller.validate(new ValidateAuthorityPermissionDto(), new RequestMetaDTO()));
}
}
package ee.sm.ti.teis.commongateway.representative.authoritypermission;
import ee.sm.ti.teis.commongateway.representative.authoritypermission.dto.AuthorityPermissionExistsDto;
import ee.sm.ti.teis.commongateway.representative.authoritypermission.request.ValidateAuthorityPermissionRequest;
import ee.sm.ti.teis.commongateway.representative.authoritypermission.response.ValidateAuthorityPermissionResponse;
import ee.sm.ti.teis.gatewaycommon.error.NoResponseFromRabbitException;
import lombok.RequiredArgsConstructor;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;
@Service
@RequiredArgsConstructor
public class AuthorityPermissionProcessingService {
private final RabbitTemplate gwRabbitTemplate;
public AuthorityPermissionExistsDto validate(ValidateAuthorityPermissionRequest request) {
ValidateAuthorityPermissionResponse response =
(ValidateAuthorityPermissionResponse) gwRabbitTemplate.convertSendAndReceive(request.routingKey(), request);
if (response != null) {
return response.processResponse();
}
throw new NoResponseFromRabbitException(request.getRequestMetaDTO().getRequestId());
}
}
package ee.sm.ti.teis.commongateway.representative.authoritypermission;
import ee.sm.ti.teis.commongateway.representative.authoritypermission.dto.AuthorityPermissionExistsDto;
import ee.sm.ti.teis.commongateway.representative.authoritypermission.dto.ValidateAuthorityPermissionDto;
import ee.sm.ti.teis.commongateway.representative.authoritypermission.request.ValidateAuthorityPermissionRequest;
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.GetMapping;
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;
@Profile({"dev", "test", "local", "integtest"})
@RestController
@RequestMapping("representatives/authority-permissions")
@RequiredArgsConstructor
public class AuthorityPermissionTestController extends TeisBaseController {
private final AuthorityPermissionProcessingService service;
@ApiOperation(value = "${teis.api.representatives.authority-permissions.validate}", response = AuthorityPermissionExistsDto.class)
@ApiResponses(value = {
@ApiResponse(code = 400, message = "Sisend ei vasta nõuetele")})
@GetMapping("validate")
public AuthorityPermissionExistsDto validate(@RequestBody ValidateAuthorityPermissionDto dto, @ApiIgnore RequestMetaDTO requestMetaDTO) {
ValidateAuthorityPermissionRequest request = new ValidateAuthorityPermissionRequest();
request.setPayload(dto, requestMetaDTO);
return service.validate(request);
}
}
......@@ -143,4 +143,4 @@ teis.api.risk-assessments.risk-statement-assessment.patch-description: Teenus sa
teis.api.risk-assessments.risk-statement-assessment.create: Teenus salvestab täiendava abinõu rakendamise andmed. Teenust kasutab iseteenindus, et salvestada kasutaja sisestatud täiendava abinõu rakendamise andmed.
teis.api.risk-assessments.risk-statement-assessment.delete: Teenus kustutab abinõu rakendamise väite kohta antud vastuse. Teenust kasutab iseteenindus, et kasutaja saaks kustutada ekslikult lisatud andmeobjekti.
teis.api.representatives.authority-permissions.validate: Test-teenus võimaldab kontrollida, kas ettevõttel on ligipääsu õigus teatud ettevõtte andmetele (nt kas töötervishoiu arst omab ligipääsu teatud ettevõtte andmetele).
theGroup=ee.sm.ti.teis
//commonApiGatewayVersion=forSearch ^commonApiGatewayVersion=.*?-SNAPSHOT
theVersion=1.11.0-SNAPSHOT
commonsVersion=1.9.0
commonsVersion=1.11.0-SNAPSHOT
pluginVersion=1.1.1
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