Commit 64133891 authored by Siiri Tann's avatar Siiri Tann
Browse files

Merge branch 'develop' into 'master'

Release: merge 'develop' into 'master' created by Siiri Tann

See merge request teis/office-api-gateway!188
parents c87f6f2f 83a0fb29
# Changelog
## [1.25.0] - 2021-05-31
* TEIS-2109: added "addFilters = false" flag for @AutoConfigureMockMvc annotation to be used for integration tests.
improved integration tests.
* TEIS-2082: added emailRecipient field to RoleDefinitionDto. Deleted deprecated class
RoleDefinitionProcessingService.java.
* TEIS-2064: added new fields to procedural act data object.
* TEIS-2047: added new fields to procedural act minutes.
* TEIS-408: new endpoint for updating proceduralActTopic's inspectionOutcome. Moved proceduralActTopics to separate
controller.
* TEIS-407: added new endpoint for updating procedural act topics.
## [1.24.0] - 2021-05-03
* TEIS-409: updated procedural act inspection topic fields
......
package ee.sm.ti.teis.officegateway.docgen.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotBlank;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class GenerateDocumentDto {
@NotBlank
private String templateId;
private String fileName;
private String outputFormat;
@NotBlank
private String jsonData;
private String objectType;
}
......@@ -2,13 +2,9 @@ package ee.sm.ti.teis.officegateway.docgen.request;
import ee.sm.ti.teis.AbstractDTO;
import ee.sm.ti.teis.ErrorDTO;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import ee.sm.ti.teis.officegateway.docgen.dto.GenerateDocumentDto;
import static ee.sm.ti.teis.officegateway.docgen.request.GenerateDocumentRequest.Parameters;
public class GenerateDocumentRequest extends AbstractDTO<Parameters, ErrorDTO> {
public class GenerateDocumentRequest extends AbstractDTO<GenerateDocumentDto, ErrorDTO> {
public static final String ROUTING_KEY = "api.GenerateDocumentRequest";
......@@ -17,15 +13,4 @@ public class GenerateDocumentRequest extends AbstractDTO<Parameters, ErrorDTO> {
return ROUTING_KEY;
}
@Data
@AllArgsConstructor
@NoArgsConstructor
public static class Parameters {
private String templateId;
private String fileName;
private String jsonData;
private String outputFormat;
private String objectType;
}
}
......@@ -49,6 +49,8 @@ public class ProceduralActDto {
@Builder.Default
private List<ProceduralActLocationDto> proceduralActLocations = new ArrayList<>();
private Boolean advanceNotice;
private Boolean conductedAct;
private String reasonOfNotConductedAct;
private ObjectStatus objectStatus;
}
......@@ -36,5 +36,7 @@ public class ProceduralActMinutes {
private List<ViolationDto> violations;
@NotNull
private String proceduralActOfficialUsers;
private Boolean conductedAct;
private String reasonOfNotConductedAct;
}
package ee.sm.ti.teis.officegateway.proceedings.proceduralact.request;
import ee.sm.ti.teis.AbstractDTO;
import ee.sm.ti.teis.ErrorDTO;
import ee.sm.ti.teis.commongateway.classifier.ClassifierItemLightDto;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.UUID;
public class UpdateProceduralActInspectionTopicOutcomeRequest extends AbstractDTO<UpdateProceduralActInspectionTopicOutcomeRequest.Parameters, ErrorDTO> {
public static final String ROUTING_KEY = "api.UpdateProceduralActInspectionTopicOutcomeRequest";
@Override
public String routingKey() {
return ROUTING_KEY;
}
@Data
@AllArgsConstructor
@NoArgsConstructor
public static class Parameters {
private UUID topicId;
private ClassifierItemLightDto inspectionTopicOutcome;
}
}
package ee.sm.ti.teis.officegateway.proceedings.proceduralact.request;
import ee.sm.ti.teis.AbstractDTO;
import ee.sm.ti.teis.ErrorDTO;
import ee.sm.ti.teis.commongateway.classifier.ClassifierItemLightDto;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
import java.util.UUID;
public class UpdateProceduralActInspectionTopicsRequest extends AbstractDTO<UpdateProceduralActInspectionTopicsRequest.Parameters, ErrorDTO> {
public static final String ROUTING_KEY = "api.UpdateProceduralActInspectionTopicsRequest";
@Override
public String routingKey() {
return ROUTING_KEY;
}
@Data
@AllArgsConstructor
@NoArgsConstructor
public static class Parameters {
private UUID id;
private List<ClassifierItemLightDto> inspectionTopicCodes;
}
}
package ee.sm.ti.teis.officegateway.proceedings.proceduralact.response;
import ee.sm.ti.teis.AbstractDTO;
import ee.sm.ti.teis.ErrorDTO;
import ee.sm.ti.teis.officegateway.proceedings.proceduralact.dto.ProceduralActInspectionTopicDto;
public class UpdateProceduralActInspectionTopicOutcomeResponse extends AbstractDTO<ProceduralActInspectionTopicDto, ErrorDTO> {
public static final String ROUTING_KEY = "api.UpdateProceduralActInspectionTopicOutcomeResponse";
@Override
public String routingKey() {
return ROUTING_KEY;
}
}
package ee.sm.ti.teis.officegateway.proceedings.proceduralact.response;
import ee.sm.ti.teis.AbstractDTO;
import ee.sm.ti.teis.ErrorDTO;
import ee.sm.ti.teis.officegateway.proceedings.proceduralact.dto.ProceduralActInspectionTopicDto;
import java.util.List;
public class UpdateProceduralActInspectionTopicsResponse extends AbstractDTO<List<ProceduralActInspectionTopicDto>, ErrorDTO> {
public static final String ROUTING_KEY = "api.UpdateProceduralActInspectionTopicsResponse";
@Override
public String routingKey() {
return ROUTING_KEY;
}
}
......@@ -11,6 +11,7 @@ import java.util.List;
import java.util.UUID;
public class UpdateProceedingInspectionTopicRequest extends AbstractDTO<UpdateProceedingInspectionTopicRequest.Parameters, ErrorDTO> {
public static final String ROUTING_KEY = "api.UpdateProceedingInspectionTopicRequest";
@Override
......
......@@ -41,6 +41,7 @@ public class RoleDefinitionDto {
private String excludedRoleOverlap;
private Long defaultValidityPeriod;
private Boolean locationLink;
private Boolean emailRecipient;
private ObjectStatus objectStatus;
}
......@@ -2,15 +2,18 @@ package ee.sm.ti.teis.officegateway;
import ee.sm.ti.teis.OfficeApiGateway;
import ee.sm.ti.teis.gatewaycommon.config.JacksonIntegTestConfig;
import ee.sm.ti.teis.gatewaycommon.rabbit.RequestProcessingService;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.util.LinkedMultiValueMap;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.junit.jupiter.Testcontainers;
......@@ -22,7 +25,13 @@ import org.testcontainers.junit.jupiter.Testcontainers;
@ContextConfiguration(initializers = {OfficeApiGatewayTestBase.Initializer.class}, classes = JacksonIntegTestConfig.class)
public abstract class OfficeApiGatewayTestBase {
protected LinkedMultiValueMap<String, String> parameters = new LinkedMultiValueMap<>();
private static final GenericContainer<?> rabbitMQContainer;
public static final String MOCK_ROLE = "OFFICIAL_USER";
@MockBean
public RequestProcessingService requestProcessingService;
// to speed up tests, lets use static container, it is used in all test classes that are executed inside one Spring Context
static {
......
package ee.sm.ti.teis.officegateway.classifiers;
import ee.sm.ti.teis.gatewaycommon.error.NoResponseFromRabbitException;
import com.fasterxml.jackson.core.type.TypeReference;
import ee.sm.ti.teis.gatewaycommon.MockMvcUtil;
import ee.sm.ti.teis.officegateway.OfficeApiGatewayTestBase;
import ee.sm.ti.teis.officegateway.classifiers.dto.ClassifierItemLinkOfficeDto;
import ee.sm.ti.teis.officegateway.classifiers.dto.PatchClassifierDefinitionDto;
import ee.sm.ti.teis.officegateway.classifiers.dto.PatchClassifierItemDto;
import ee.sm.ti.teis.officegateway.classifiers.dto.ShiftClassifierDirectionDto;
import ee.sm.ti.teis.servicerequest.RequestMetaDTO;
import ee.sm.ti.teis.officegateway.classifiers.dto.*;
import ee.sm.ti.teis.officegateway.classifiers.request.*;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.test.context.support.WithMockUser;
import static java.util.Collections.emptyList;
import java.util.List;
import static ee.sm.ti.teis.officegateway.OfficeApiGatewayTestBase.MOCK_ROLE;
import static java.util.UUID.randomUUID;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@WithMockUser(roles = MOCK_ROLE)
public class ClassifiersControllerTest extends OfficeApiGatewayTestBase {
private static final RequestMetaDTO REQUEST_META_DTO = RequestMetaDTO.builder().requestId(randomUUID().toString()).build();
@Autowired
ClassifiersController controller;
MockMvcUtil mockMvcUtil;
@Test
void getClassifierDefinitions_test() {
assertThrows(NoResponseFromRabbitException.class, () ->
controller.getClassifierDefinitions(REQUEST_META_DTO));
void getClassifierDefinitions_success() {
when(requestProcessingService.sendAndReceive(any(ClassifierDefinitionsOfficeRequest.class)))
.thenReturn(List.of(new ClassifierDefinitionDto()));
mockMvcUtil.testGet("/classifier-definitions", null, new TypeReference<List<ClassifierDefinitionDto>>() {
});
verify(requestProcessingService).sendAndReceive(any(ClassifierDefinitionsOfficeRequest.class));
}
@Test
void getClassifierDefinition_test() {
assertThrows(NoResponseFromRabbitException.class, () ->
controller.getClassifierDefinition(null, REQUEST_META_DTO));
void getClassifierDefinition_success() {
when(requestProcessingService.sendAndReceive(any(ClassifierDefinitionOfficeRequest.class)))
.thenReturn(new ClassifierDefinitionDto());
mockMvcUtil.testGet("/classifier-definitions/" + randomUUID(), null, new TypeReference<ClassifierDefinitionDto>() {
});
verify(requestProcessingService).sendAndReceive(any(ClassifierDefinitionOfficeRequest.class));
}
@Test
void createClassifierItem_test() {
assertThrows(NoResponseFromRabbitException.class, () ->
controller.createClassifierItem(null, REQUEST_META_DTO));
void patchClassifierDefinition_success() {
when(requestProcessingService.sendAndReceive(any(PatchClassifierDefinitionOfficeRequest.class)))
.thenReturn(new ClassifierDefinitionDto());
mockMvcUtil.testPatch("/classifier-definitions/" + randomUUID() + "/default-value", new PatchClassifierDefinitionDto(),
new TypeReference<ClassifierDefinitionDto>() {
});
verify(requestProcessingService).sendAndReceive(any(PatchClassifierDefinitionOfficeRequest.class));
}
@Test
void patchClassifierItem_test() {
assertThrows(NoResponseFromRabbitException.class, () ->
controller.patchClassifierItem("id", PatchClassifierItemDto.builder().build(), REQUEST_META_DTO));
void createClassifierItem_success() {
when(requestProcessingService.sendAndReceive(any(CreateClassifierItemRequest.class)))
.thenReturn(new ClassifierItemOfficeDto());
mockMvcUtil.testPost("/classifier-items", new ClassifierItemOfficeDto(), new TypeReference<ClassifierItemOfficeDto>() {
});
verify(requestProcessingService).sendAndReceive(any(CreateClassifierItemRequest.class));
}
@Test
void deleteClassifierItem_test() {
assertThrows(NoResponseFromRabbitException.class, () ->
controller.deleteClassifierItem("id", REQUEST_META_DTO));
void patchClassifierItem_success() {
when(requestProcessingService.sendAndReceive(any(PatchClassifierItemRequest.class)))
.thenReturn(new ClassifierItemOfficeDto());
mockMvcUtil.testPatch("/classifier-items/" + randomUUID() + "/name", new PatchClassifierItemDto(), new TypeReference<ClassifierItemOfficeDto>() {
});
verify(requestProcessingService).sendAndReceive(any(PatchClassifierItemRequest.class));
}
@Test
void deleteClassifierLink_test() {
assertThrows(NoResponseFromRabbitException.class, () ->
controller.deleteClassifierLink(randomUUID(), REQUEST_META_DTO));
void deleteClassifierItem_success() {
mockMvcUtil.testDelete("/classifier-items/" + randomUUID());
verify(requestProcessingService).sendAndReceive(any(DeleteClassifierItemRequest.class));
}
@Test
void postClassifierAttributes_test() {
assertThrows(NoResponseFromRabbitException.class, () ->
controller.postClassifierAttributes(emptyList(), REQUEST_META_DTO));
void deleteClassifierLink_success() {
mockMvcUtil.testDelete("/classifier-items/item-link/" + randomUUID());
verify(requestProcessingService).sendAndReceive(any(DeleteClassifierItemLinkRequest.class));
}
@Test
void shiftClassifier_test() {
assertThrows(NoResponseFromRabbitException.class, () ->
controller.shiftClassifier(randomUUID().toString(), new ShiftClassifierDirectionDto(), REQUEST_META_DTO));
void postClassifierAttributes_success() {
when(requestProcessingService.sendAndReceive(any(CreateClassifierAttributesRequest.class)))
.thenReturn(List.of(new ClassifierAttributeValueDto()));
mockMvcUtil.testPost("/classifier-items/attributes", List.of(new ClassifierAttributeValueDto()), new TypeReference<List<ClassifierAttributeValueDto>>() {
});
verify(requestProcessingService).sendAndReceive(any(CreateClassifierAttributesRequest.class));
}
@Test
void patchClassifierDefinition_test() {
assertThrows(NoResponseFromRabbitException.class, () ->
controller.patchClassifierDefinition(randomUUID().toString(), new PatchClassifierDefinitionDto(), REQUEST_META_DTO));
void postClassifierLink_success() {
when(requestProcessingService.sendAndReceive(any(CreateClassifierItemLinkRequest.class)))
.thenReturn(new ClassifierItemLinkOfficeDto());
mockMvcUtil.testPost("/classifier-items/item-link/", new ClassifierItemLinkOfficeDto(), new TypeReference<ClassifierItemLinkOfficeDto>() {
});
verify(requestProcessingService).sendAndReceive(any(CreateClassifierItemLinkRequest.class));
}
@Test
void postClassifierLink_test() {
assertThrows(NoResponseFromRabbitException.class, () ->
controller.postClassifierLink(new ClassifierItemLinkOfficeDto(), REQUEST_META_DTO));
void shiftClassifier_success() {
when(requestProcessingService.sendAndReceive(any(ShiftClassifierItemRequest.class)))
.thenReturn(List.of(new ClassifierItemOfficeDto()));
mockMvcUtil.testPatch("/classifier-items/test/seq-no", new ShiftClassifierDirectionDto(), new TypeReference<List<ClassifierItemOfficeDto>>() {
});
verify(requestProcessingService).sendAndReceive(any(ShiftClassifierItemRequest.class));
}
}
package ee.sm.ti.teis.officegateway.docgen;
import ee.sm.ti.teis.gatewaycommon.error.NoResponseFromRabbitException;
import ee.sm.ti.teis.officegateway.OfficeApiGatewayTestBase;
import ee.sm.ti.teis.servicerequest.RequestMetaDTO;
import ee.sm.ti.teis.officegateway.docgen.request.UploadDocTemplateRequest;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.security.test.context.support.WithMockUser;
import org.springframework.test.web.servlet.MockMvc;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static ee.sm.ti.teis.officegateway.OfficeApiGatewayTestBase.MOCK_ROLE;
import static java.util.UUID.randomUUID;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.verify;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.multipart;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@WithMockUser(roles = MOCK_ROLE)
class DocGenControllerTest extends OfficeApiGatewayTestBase {
@Autowired
DocGenController controller;
MockMvc mockMvc;
@Test
void uploadTemplate_badRequest() {
assertThrows(NoResponseFromRabbitException.class, () ->
controller.uploadTemplate(new MockMultipartFile("test", "test-file".getBytes()), "", new RequestMetaDTO()));
void uploadTemplate_success() throws Exception {
mockMvc.perform(multipart("/templates/upload")
.file(new MockMultipartFile("templateFile", "blah".getBytes()))
.param("templateId", randomUUID().toString()))
.andExpect(status().isOk());
verify(requestProcessingService).sendAndReceive(any(UploadDocTemplateRequest.class));
}
}
package ee.sm.ti.teis.officegateway.docgen;
import com.fasterxml.jackson.core.type.TypeReference;
import ee.sm.ti.teis.commongateway.file.FileMetadataDto;
import ee.sm.ti.teis.gatewaycommon.MockMvcUtil;
import ee.sm.ti.teis.gatewaycommon.error.NoResponseFromRabbitException;
import ee.sm.ti.teis.officegateway.OfficeApiGatewayTestBase;
import ee.sm.ti.teis.officegateway.docgen.dto.GenerateDocumentDto;
import ee.sm.ti.teis.officegateway.docgen.request.GenerateDocumentRequest;
import ee.sm.ti.teis.servicerequest.RequestMetaDTO;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.test.context.support.WithMockUser;
import static ee.sm.ti.teis.officegateway.OfficeApiGatewayTestBase.MOCK_ROLE;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@WithMockUser(roles = MOCK_ROLE)
class DocGenTestControllerTest extends OfficeApiGatewayTestBase {
@Autowired
MockMvcUtil mockMvcUtil;
@Autowired
DocGenTestController controller;
......@@ -20,8 +33,13 @@ class DocGenTestControllerTest extends OfficeApiGatewayTestBase {
}
@Test
void generate_badRequest() {
assertThrows(NoResponseFromRabbitException.class, () ->
controller.generate("", "", "", "", "", new RequestMetaDTO()));
void generate_success() {
when(requestProcessingService.sendAndReceive(any(GenerateDocumentRequest.class)))
.thenReturn(new FileMetadataDto());
mockMvcUtil.testPost("/templates/generate", new GenerateDocumentDto(), new TypeReference<FileMetadataDto>() {
});
verify(requestProcessingService).sendAndReceive(any(GenerateDocumentRequest.class));
}
}
package ee.sm.ti.teis.officegateway.messages.messagedefinition;
import ee.sm.ti.teis.gatewaycommon.error.NoResponseFromRabbitException;
import com.fasterxml.jackson.core.type.TypeReference;
import ee.sm.ti.teis.gatewaycommon.MockMvcUtil;
import ee.sm.ti.teis.officegateway.OfficeApiGatewayTestBase;
import ee.sm.ti.teis.officegateway.messages.messagedefinition.dto.CreateMessageDefinitionDto;
import ee.sm.ti.teis.officegateway.messages.messagedefinition.dto.MessageDefinitionDto;
import ee.sm.ti.teis.officegateway.messages.messagedefinition.dto.UpdateMessageDefinitionDto;
import ee.sm.ti.teis.servicerequest.RequestMetaDTO;
import ee.sm.ti.teis.officegateway.messages.messagedefinition.request.CreateMessageDefinitionRequest;
import ee.sm.ti.teis.officegateway.messages.messagedefinition.request.DeleteMessageDefinitionRequest;
import ee.sm.ti.teis.officegateway.messages.messagedefinition.request.MessageDefinitionsRequest;
import ee.sm.ti.teis.officegateway.messages.messagedefinition.request.UpdateMessageDefinitionRequest;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.test.context.support.WithMockUser;
import java.util.UUID;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static ee.sm.ti.teis.officegateway.OfficeApiGatewayTestBase.MOCK_ROLE;
import static java.util.UUID.randomUUID;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@WithMockUser(roles = MOCK_ROLE)
public class MessageDefinitionControllerTest extends OfficeApiGatewayTestBase {
private static final String BASE_URL = "/message-definitions/";
@Autowired
MessageDefinitionController controller;
MockMvcUtil mockMvcUtil;
@Test
void create_badRequest() {
assertThrows(NoResponseFromRabbitException.class, () -> controller.create(new CreateMessageDefinitionDto(), new RequestMetaDTO()));
void create_success() {
when(requestProcessingService.sendAndReceive(any(CreateMessageDefinitionRequest.class)))
.thenReturn(new MessageDefinitionDto());
mockMvcUtil.testPost(BASE_URL, new CreateMessageDefinitionDto(), new TypeReference<MessageDefinitionDto>() {
});
verify(requestProcessingService).sendAndReceive(any(CreateMessageDefinitionRequest.class));
}