Commit af666ba4 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!193
parents 64133891 bbd06bf9
# Changelog
## [1.26.0] - 2021-06-14
* TEIS-2199: added API endpoint and request and response objects for testing getting officials from sequence.
* TEIS-2186: added API endpoint for getting drivers' inspection object by procedural act.
* TEIS-2186: added API endpoint for creating drivers' inspection objects, added test API endpoint for confirming proceeding and procedural act existence.
* TEIS-2109: improved integration tests, removed deprecated *ProcessingService files.
## [1.25.0] - 2021-05-31
* TEIS-2109: added "addFilters = false" flag for @AutoConfigureMockMvc annotation to be used for integration tests.
......
package ee.sm.ti.teis.officegateway.driversinspections.driversinspection.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 CreateDriversInspectionDto {
@NotNull
private UUID proceduralActId;
}
package ee.sm.ti.teis.officegateway.driversinspections.driversinspection.dto;
import ee.sm.ti.teis.commongateway.classifier.ClassifierItemLightDto;
import ee.sm.ti.teis.types.enums.ObjectStatus;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.UUID;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class DriversInspectionOfficeDto {
private UUID id;
private UUID proceedingId;
private UUID proceduralActId;
private ClassifierItemLightDto status;
private ObjectStatus objectStatus;
}
package ee.sm.ti.teis.officegateway.driversinspections.driversinspection.request;
import ee.sm.ti.teis.AbstractDTO;
import ee.sm.ti.teis.ErrorDTO;
import ee.sm.ti.teis.officegateway.driversinspections.driversinspection.dto.CreateDriversInspectionDto;
public class CreateDriversInspectionRequest extends AbstractDTO<CreateDriversInspectionDto, ErrorDTO> {
public static final String ROUTING_KEY = "api.CreateDriversInspectionRequest";
@Override
public String routingKey() {
return ROUTING_KEY;
}
}
package ee.sm.ti.teis.officegateway.driversinspections.driversinspection.request;
import ee.sm.ti.teis.AbstractDTO;
import ee.sm.ti.teis.ErrorDTO;
import java.util.UUID;
public class DriversInspectionByProceduralActRequest extends AbstractDTO<UUID, ErrorDTO> {
public static final String ROUTING_KEY = "api.DriversInspectionByProceduralActRequest";
@Override
public String routingKey() {
return ROUTING_KEY;
}
}
package ee.sm.ti.teis.officegateway.driversinspections.driversinspection.response;
import ee.sm.ti.teis.AbstractDTO;
import ee.sm.ti.teis.ErrorDTO;
import ee.sm.ti.teis.officegateway.driversinspections.driversinspection.dto.DriversInspectionOfficeDto;
public class CreateDriversInspectionResponse extends AbstractDTO<DriversInspectionOfficeDto, ErrorDTO> {
public static final String ROUTING_KEY = "api.CreateDriversInspectionResponse";
@Override
public String routingKey() {
return ROUTING_KEY;
}
}
\ No newline at end of file
package ee.sm.ti.teis.officegateway.driversinspections.driversinspection.response;
import ee.sm.ti.teis.AbstractDTO;
import ee.sm.ti.teis.ErrorDTO;
import ee.sm.ti.teis.officegateway.driversinspections.driversinspection.dto.DriversInspectionOfficeDto;
public class DriversInspectionByProceduralActResponse extends AbstractDTO<DriversInspectionOfficeDto, ErrorDTO> {
public static final String ROUTING_KEY = "api.DriversInspectionByProceduralActResponse";
@Override
public String routingKey() {
return ROUTING_KEY;
}
}
package ee.sm.ti.teis.officegateway.official.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.UUID;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class OfficialUserInSequenceDto {
private UUID officialUserId;
private String firstName;
private String lastName;
}
package ee.sm.ti.teis.officegateway.official.request;
import ee.sm.ti.teis.AbstractDTO;
import ee.sm.ti.teis.ErrorDTO;
public class GetOfficialFromSequenceTestRequest extends AbstractDTO<String, ErrorDTO> {
public static final String ROUTING_KEY = "api.GetOfficialFromSequenceTestRequest";
@Override
public String routingKey() {
return ROUTING_KEY;
}
}
package ee.sm.ti.teis.officegateway.official.response;
import ee.sm.ti.teis.AbstractDTO;
import ee.sm.ti.teis.ErrorDTO;
import ee.sm.ti.teis.officegateway.official.dto.OfficialUserInSequenceDto;
public class GetOfficialFromSequenceTestResponse extends AbstractDTO<OfficialUserInSequenceDto, ErrorDTO> {
public static final String ROUTING_KEY = "api.GetOfficialFromSequenceTestResponse";
@Override
public String routingKey() {
return ROUTING_KEY;
}
}
package ee.sm.ti.teis.officegateway.proceedings.proceduralact.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ProceedingAndProceduralActExistDto {
private Boolean confirmed;
}
package ee.sm.ti.teis.officegateway.proceedings.proceduralact.request;
import ee.sm.ti.teis.AbstractDTO;
import ee.sm.ti.teis.ErrorDTO;
import java.util.UUID;
public class GetProceedingByProceduralActRequest extends AbstractDTO<UUID, ErrorDTO> {
public static final String ROUTING_KEY = "api.GetProceedingByProceduralActRequest";
@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 java.util.UUID;
public class GetProceedingByProceduralActResponse extends AbstractDTO<UUID, ErrorDTO> {
public static final String ROUTING_KEY = "api.GetProceedingByProceduralActResponse";
@Override
public String routingKey() {
return ROUTING_KEY;
}
}
package ee.sm.ti.teis.officegateway.driversinspections.driversinspection;
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.driversinspections.driversinspection.dto.CreateDriversInspectionDto;
import ee.sm.ti.teis.officegateway.driversinspections.driversinspection.dto.DriversInspectionOfficeDto;
import ee.sm.ti.teis.officegateway.driversinspections.driversinspection.request.CreateDriversInspectionRequest;
import ee.sm.ti.teis.officegateway.driversinspections.driversinspection.request.DriversInspectionByProceduralActRequest;
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 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 DriversInspectionControllerTest extends OfficeApiGatewayTestBase {
private static final String BASE_URL = "/drivers-inspections/";
@Autowired
MockMvcUtil mockMvcUtil;
@Test
void create_success() {
when(requestProcessingService.sendAndReceive(any(CreateDriversInspectionRequest.class)))
.thenReturn(new DriversInspectionOfficeDto());
mockMvcUtil.testPost(BASE_URL, new CreateDriversInspectionDto(), new TypeReference<DriversInspectionOfficeDto>() {
});
verify(requestProcessingService).sendAndReceive(any(CreateDriversInspectionRequest.class));
}
@Test
void getByProceduralAct_success() {
when(requestProcessingService.sendAndReceive(any(DriversInspectionByProceduralActRequest.class)))
.thenReturn(new DriversInspectionOfficeDto());
parameters.add("proceduralActId", randomUUID().toString());
mockMvcUtil.testGet(BASE_URL, parameters, new TypeReference<DriversInspectionOfficeDto>() {
});
verify(requestProcessingService).sendAndReceive(any(DriversInspectionByProceduralActRequest.class));
}
}
package ee.sm.ti.teis.officegateway.official;
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.official.controller.OfficesController;
import ee.sm.ti.teis.servicerequest.RequestMetaDTO;
import ee.sm.ti.teis.officegateway.official.dto.OfficeDto;
import ee.sm.ti.teis.officegateway.official.request.OfficesRequest;
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 org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@WithMockUser(roles = MOCK_ROLE)
public class OfficesControllerTest extends OfficeApiGatewayTestBase {
private static final RequestMetaDTO REQUEST_META_DTO = RequestMetaDTO.builder().requestId(UUID.randomUUID().toString()).build();
@Autowired
OfficesController controller;
MockMvcUtil mockMvcUtil;
@Test
void findOffices_test() {
assertThrows(NoResponseFromRabbitException.class, () -> controller.getOffices(REQUEST_META_DTO));
void findOffices_success() {
when(requestProcessingService.sendAndReceive(any(OfficesRequest.class)))
.thenReturn(List.of(new OfficeDto()));
mockMvcUtil.testGet("/offices", null, new TypeReference<List<OfficeDto>>() {
});
verify(requestProcessingService).sendAndReceive(any(OfficesRequest.class));
}
}
package ee.sm.ti.teis.officegateway.official;
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.official.controller.OfficialsController;
import ee.sm.ti.teis.officegateway.official.dto.OfficialUserDto;
import ee.sm.ti.teis.officegateway.official.dto.OfficialUserUpdateData;
import ee.sm.ti.teis.servicerequest.RequestMetaDTO;
import ee.sm.ti.teis.officegateway.official.request.OfficialUserRequest;
import ee.sm.ti.teis.officegateway.official.request.OfficialUsersRequest;
import ee.sm.ti.teis.officegateway.official.request.UpdateOfficialUserRequest;
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)
class OfficialsControllerTest extends OfficeApiGatewayTestBase {
private static final UUID OFFICIAL_USER_ID = UUID.fromString("3dac227f-a8af-4771-8d8b-01409ac7fef0");
private static final RequestMetaDTO REQUEST_META_DTO = RequestMetaDTO.builder().requestId(UUID.randomUUID().toString()).build();
private static final String BASE_URL = "/officials/";
@Autowired
OfficialsController officialsController;
MockMvcUtil mockMvcUtil;
@Test
void findOfficialUser_test() {
assertThrows(NoResponseFromRabbitException.class, () -> officialsController.getOfficialUser(OFFICIAL_USER_ID, REQUEST_META_DTO));
void getOfficialUser_success() {
when(requestProcessingService.sendAndReceive(any(OfficialUserRequest.class)))
.thenReturn(new OfficialUserDto());
mockMvcUtil.testGet(BASE_URL + randomUUID(), null, new TypeReference<OfficialUserDto>() {
});
verify(requestProcessingService).sendAndReceive(any(OfficialUserRequest.class));
}
@Test
void findOfficialUsers_test() {
assertThrows(NoResponseFromRabbitException.class,
() -> officialsController.getOfficialUsers("36609107656", OFFICIAL_USER_ID, "CURRENT", REQUEST_META_DTO));
void getOfficialUsers_success() {
when(requestProcessingService.sendAndReceive(any(OfficialUsersRequest.class)))
.thenReturn(List.of(new OfficialUserDto()));
mockMvcUtil.testGet(BASE_URL, null, new TypeReference<List<OfficialUserDto>>() {
});
verify(requestProcessingService).sendAndReceive(any(OfficialUsersRequest.class));
}
@Test
void patchOfficialUser_test() {
OfficialUserUpdateData userUpdateData = new OfficialUserUpdateData();
userUpdateData.setOfficialsGroupId(OFFICIAL_USER_ID);
void update_success() {
when(requestProcessingService.sendAndReceive(any(UpdateOfficialUserRequest.class)))
.thenReturn(new OfficialUserDto());
mockMvcUtil.testPatch(BASE_URL + randomUUID() + "/official-group", new OfficialUserUpdateData(),
new TypeReference<OfficialUserDto>() {
});
assertThrows(NoResponseFromRabbitException.class, () -> officialsController.update(OFFICIAL_USER_ID, userUpdateData, REQUEST_META_DTO));
verify(requestProcessingService).sendAndReceive(any(UpdateOfficialUserRequest.class));
}
}
package ee.sm.ti.teis.officegateway.official;
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.official.controller.OfficialsGroupsController;
import ee.sm.ti.teis.officegateway.official.dto.OfficialUserDto;
import ee.sm.ti.teis.officegateway.official.dto.OfficialsGroupData;
import ee.sm.ti.teis.servicerequest.RequestMetaDTO;
import ee.sm.ti.teis.officegateway.official.dto.OfficialsGroupDto;
import ee.sm.ti.teis.officegateway.official.request.*;
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 java.util.Collections.emptyList;
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)
class OfficialsGroupsControllerTest extends OfficeApiGatewayTestBase {
private static final RequestMetaDTO REQUEST_META_DTO = RequestMetaDTO.builder().requestId(UUID.randomUUID().toString()).build();
private static final String BASE_URL = "/officials-groups/";
@Autowired
OfficialsGroupsController groupsController;
@Autowired
MockMvcUtil mockMvcUtil;
@Test
void findOfficialsGroups_test() {
assertThrows(NoResponseFromRabbitException.class, () -> groupsController.getOfficialsGroups(null, REQUEST_META_DTO));
void getOfficialsGroups_success() {
when(requestProcessingService.sendAndReceive(any(OfficialsGroupsRequest.class)))
.thenReturn(List.of(new OfficialsGroupDto()));
mockMvcUtil.testGet(BASE_URL, null, new TypeReference<List<OfficialsGroupDto>>() {
});
verify(requestProcessingService).sendAndReceive(any(OfficialsGroupsRequest.class));
}
@Test
void findOfficialGroups_test() {
assertThrows(NoResponseFromRabbitException.class, () -> groupsController.getOfficialsGroup(null, REQUEST_META_DTO));
void getOfficialGroup_success() {
when(requestProcessingService.sendAndReceive(any(OfficialsGroupRequest.class)))
.thenReturn(new OfficialsGroupDto());
mockMvcUtil.testGet(BASE_URL + randomUUID(), null, new TypeReference<OfficialsGroupDto>() {
});
verify(requestProcessingService).sendAndReceive(any(OfficialsGroupRequest.class));
}
@Test
void createOfficialsGroups_test() {
assertThrows(NoResponseFromRabbitException.class, () -> groupsController.create(new OfficialsGroupData(), REQUEST_META_DTO));
void create_success() {
when(requestProcessingService.sendAndReceive(any(CreateOfficialsGroupRequest.class)))
.thenReturn(new OfficialsGroupDto());
mockMvcUtil.testPost(BASE_URL, new OfficialsGroupData(), new TypeReference<OfficialsGroupDto>() {
});
verify(requestProcessingService).sendAndReceive(any(CreateOfficialsGroupRequest.class));
}
@Test
void deleteOfficialsGroups_test() {
assertThrows(NoResponseFromRabbitException.class, () -> groupsController.delete(null, REQUEST_META_DTO));
void update_success() {
when(requestProcessingService.sendAndReceive(any(UpdateOfficialsGroupRequest.class)))
.thenReturn(new OfficialsGroupDto());
mockMvcUtil.testPut(BASE_URL + randomUUID(), new OfficialsGroupData(), new TypeReference<OfficialsGroupDto>() {
});
verify(requestProcessingService).sendAndReceive(any(UpdateOfficialsGroupRequest.class));
}
@Test
void updateOfficialsGroups_test() {
assertThrows(
NoResponseFromRabbitException.class,
() -> groupsController.update(UUID.randomUUID(), new OfficialsGroupData(), REQUEST_META_DTO));
void delete_success() {
mockMvcUtil.testDelete(BASE_URL + randomUUID());
verify(requestProcessingService).sendAndReceive(any(DeleteOfficialsGroupRequest.class));
}
@Test
void addOfficialsToGroup_test() {
assertThrows(NoResponseFromRabbitException.class, () -> groupsController.addOfficialsToGroup(null, emptyList(), REQUEST_META_DTO));
void addOfficialsToGroup_success() {
when(requestProcessingService.sendAndReceive(any(AddOfficialsGroupMembersRequest.class)))
.thenReturn(List.of(new OfficialUserDto()));
mockMvcUtil.testPost(BASE_URL + randomUUID() + "/officials", List.of(randomUUID()), new TypeReference<List<OfficialUserDto>>() {
});
verify(requestProcessingService).sendAndReceive(any(AddOfficialsGroupMembersRequest.class));
}
@Test
void deleteOfficialFromGroup_test() {
assertThrows(NoResponseFromRabbitException.class, () -> groupsController.deleteOfficialFromGroup(null, null, REQUEST_META_DTO));
void deleteOfficialFromGroup_success() {