Commit 7aa971e3 authored by Kristel Meikas's avatar Kristel Meikas
Browse files

TEIS-1494: fixed handling of test controller request parameters

parent 1021f676
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 ee.sm.ti.teis.types.enums.AuthorityType;
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 AuthorityPermissionTestControllerTest extends CommonApiGatewayTestBase {
......@@ -17,7 +18,7 @@ class AuthorityPermissionTestControllerTest extends CommonApiGatewayTestBase {
@Test
void validateAuthorityPermission_test() {
assertThrows(NoResponseFromRabbitException.class, () ->
controller.validate(new ValidateAuthorityPermissionDto(), new RequestMetaDTO()));
controller.validate(randomUUID(), randomUUID(), AuthorityType.OH, new RequestMetaDTO()));
}
}
......@@ -5,17 +5,20 @@ import ee.sm.ti.teis.commongateway.representative.authoritypermission.dto.Valida
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 ee.sm.ti.teis.types.enums.AuthorityType;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;
import java.util.UUID;
@Profile({"dev", "test", "local", "integtest"})
@RestController
@RequestMapping("representatives/authority-permissions")
......@@ -28,8 +31,16 @@ public class AuthorityPermissionTestController extends TeisBaseController {
@ApiResponses(value = {
@ApiResponse(code = 400, message = "Sisend ei vasta nõuetele")})
@GetMapping("validate")
public AuthorityPermissionExistsDto validate(@RequestBody ValidateAuthorityPermissionDto dto, @ApiIgnore RequestMetaDTO requestMetaDTO) {
public AuthorityPermissionExistsDto validate(@RequestParam(name = "personId", required = true) UUID personId,
@RequestParam(name = "grantorId", required = true) UUID grantorId,
@RequestParam(name = "authorityType", required = true) AuthorityType authorityType,
@ApiIgnore RequestMetaDTO requestMetaDTO) {
ValidateAuthorityPermissionRequest request = new ValidateAuthorityPermissionRequest();
ValidateAuthorityPermissionDto dto = ValidateAuthorityPermissionDto.builder()
.personId(personId)
.grantorId(grantorId)
.authorityType(authorityType)
.build();
request.setPayload(dto, requestMetaDTO);
return service.validate(request);
......
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