diff --git a/alfa-service/src/main/java/de/ozgcloud/alfa/collaboration/Collaboration.java b/alfa-service/src/main/java/de/ozgcloud/alfa/collaboration/Collaboration.java index b062636d2f66051bde94792e7904d7d40a67acba..09e1c53d132549eeb068c144d03835d801ee05e8 100644 --- a/alfa-service/src/main/java/de/ozgcloud/alfa/collaboration/Collaboration.java +++ b/alfa-service/src/main/java/de/ozgcloud/alfa/collaboration/Collaboration.java @@ -1,25 +1,16 @@ package de.ozgcloud.alfa.collaboration; -import com.fasterxml.jackson.annotation.JsonIgnore; +public interface Collaboration { -import de.ozgcloud.alfa.common.LinkedResource; -import de.ozgcloud.alfa.common.command.CommandBody; -import lombok.Builder; -import lombok.Getter; + String getVorgangId(); -@Getter -@Builder -public class Collaboration implements CommandBody { + String getCollaborationVorgangId(); - @JsonIgnore - private String vorgangId; - @JsonIgnore - private String collaborationVorgangId; + String getTitel(); - private String titel; - private String beschreibung; - private int collaborationLevel; + String getBeschreibung(); - @LinkedResource(controllerClass = OrganisationsEinheitController.class) - private String zustaendigeStelle; + long getCollaborationLevel(); + + String getZustaendigeStelle(); } diff --git a/alfa-service/src/main/java/de/ozgcloud/alfa/collaboration/CollaborationMapper.java b/alfa-service/src/main/java/de/ozgcloud/alfa/collaboration/CollaborationMapper.java index f56d7f855207cc7b74af2423e916722e417dfbde..eaaf9988dc719a28ae25be0010a7f6b99754af37 100644 --- a/alfa-service/src/main/java/de/ozgcloud/alfa/collaboration/CollaborationMapper.java +++ b/alfa-service/src/main/java/de/ozgcloud/alfa/collaboration/CollaborationMapper.java @@ -9,5 +9,7 @@ import de.ozgcloud.collaboration.request.GrpcCollaborationRequest; @Mapper(unmappedTargetPolicy = ReportingPolicy.ERROR, nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS) interface CollaborationMapper { - Collaboration fromGrpc(GrpcCollaborationRequest request, String vorgangId); + OrganisationsEinheitCollaboration fromOrganisationsEinheitRequest(GrpcCollaborationRequest request, String vorgangId); + + FachstelleCollaboration fromFachstelleRequest(GrpcCollaborationRequest request, String vorgangId); } diff --git a/alfa-service/src/main/java/de/ozgcloud/alfa/collaboration/CollaborationRemoteService.java b/alfa-service/src/main/java/de/ozgcloud/alfa/collaboration/CollaborationRemoteService.java index 1389d21221c861966c3b65efb75b9adcb9ff2c70..325c0aa03274b059dbed2a9cf70bc27c60de623d 100644 --- a/alfa-service/src/main/java/de/ozgcloud/alfa/collaboration/CollaborationRemoteService.java +++ b/alfa-service/src/main/java/de/ozgcloud/alfa/collaboration/CollaborationRemoteService.java @@ -32,6 +32,12 @@ public class CollaborationRemoteService { } private Function<GrpcCollaborationRequest, Collaboration> getCollaborationMapperForVorgang(String vorgangId) { - return request -> collaborationMapper.fromGrpc(request, vorgangId); + return request -> isFachstelle(request) + ? collaborationMapper.fromFachstelleRequest(request, vorgangId) + : collaborationMapper.fromOrganisationsEinheitRequest(request, vorgangId); + } + + private boolean isFachstelle(GrpcCollaborationRequest request) { + return Long.valueOf(4).equals(request.getCollaborationLevel()); } } diff --git a/alfa-service/src/main/java/de/ozgcloud/alfa/collaboration/FachstelleCollaboration.java b/alfa-service/src/main/java/de/ozgcloud/alfa/collaboration/FachstelleCollaboration.java new file mode 100644 index 0000000000000000000000000000000000000000..5a4dabfeef4046606754daf0d8abf7f76b7ba139 --- /dev/null +++ b/alfa-service/src/main/java/de/ozgcloud/alfa/collaboration/FachstelleCollaboration.java @@ -0,0 +1,25 @@ +package de.ozgcloud.alfa.collaboration; + +import com.fasterxml.jackson.annotation.JsonIgnore; + +import de.ozgcloud.alfa.common.LinkedResource; +import de.ozgcloud.alfa.common.command.CommandBody; +import lombok.Builder; +import lombok.Getter; + +@Getter +@Builder +public class FachstelleCollaboration implements CommandBody, Collaboration { + + @JsonIgnore + private String vorgangId; + @JsonIgnore + private String collaborationVorgangId; + + private String titel; + private String beschreibung; + private long collaborationLevel; + + @LinkedResource(controllerClass = FachstelleController.class) + private String zustaendigeStelle; +} diff --git a/alfa-service/src/main/java/de/ozgcloud/alfa/collaboration/OrganisationsEinheitCollaboration.java b/alfa-service/src/main/java/de/ozgcloud/alfa/collaboration/OrganisationsEinheitCollaboration.java new file mode 100644 index 0000000000000000000000000000000000000000..00e7b26902aa3aeb7cf95c2eaea12b1a8a2b61c7 --- /dev/null +++ b/alfa-service/src/main/java/de/ozgcloud/alfa/collaboration/OrganisationsEinheitCollaboration.java @@ -0,0 +1,25 @@ +package de.ozgcloud.alfa.collaboration; + +import com.fasterxml.jackson.annotation.JsonIgnore; + +import de.ozgcloud.alfa.common.LinkedResource; +import de.ozgcloud.alfa.common.command.CommandBody; +import lombok.Builder; +import lombok.Getter; + +@Getter +@Builder +public class OrganisationsEinheitCollaboration implements CommandBody, Collaboration { + + @JsonIgnore + private String vorgangId; + @JsonIgnore + private String collaborationVorgangId; + + private String titel; + private String beschreibung; + private long collaborationLevel; + + @LinkedResource(controllerClass = OrganisationsEinheitController.class) + private String zustaendigeStelle; +} diff --git a/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/CollaborationControllerTest.java b/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/CollaborationControllerTest.java index 71f1d8153365c3971e4333b3a7bc48789ba34447..019c4b4491ba4bc242adc17d9acd2e5df3a2d741 100644 --- a/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/CollaborationControllerTest.java +++ b/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/CollaborationControllerTest.java @@ -42,14 +42,14 @@ class CollaborationControllerTest { @Nested class TestGetAllByVorgangId { - private final Collaboration collaboration = CollaborationTestFactory.create(); + private final Collaboration collaboration = OrganisationsEinheitCollaborationTestFactory.create(); @SneakyThrows @Test void shouldCallCollaborationService() { performRequest(); - verify(service).getCollaborations(CollaborationTestFactory.VORGANG_ID); + verify(service).getCollaborations(OrganisationsEinheitCollaborationTestFactory.VORGANG_ID); } @Nested @@ -59,20 +59,20 @@ class CollaborationControllerTest { @BeforeEach void mock() { - when(service.getCollaborations(CollaborationTestFactory.VORGANG_ID)).thenReturn(collaborations); + when(service.getCollaborations(OrganisationsEinheitCollaborationTestFactory.VORGANG_ID)).thenReturn(collaborations); } @Test void shouldCallAssembler() { performRequest(); - verify(assembler).toCollectionModel(collaborations, CollaborationTestFactory.VORGANG_ID); + verify(assembler).toCollectionModel(collaborations, OrganisationsEinheitCollaborationTestFactory.VORGANG_ID); } @SneakyThrows @Test void shouldReturnStatusOk() { - when(assembler.toCollectionModel(collaborations, CollaborationTestFactory.VORGANG_ID)) + when(assembler.toCollectionModel(collaborations, OrganisationsEinheitCollaborationTestFactory.VORGANG_ID)) .thenReturn(CollectionModel.of(Collections.singletonList(EntityModel.of(collaboration)))); var response = performRequest(); @@ -85,7 +85,7 @@ class CollaborationControllerTest { @BeforeEach void mockAssembler() { - when(assembler.toCollectionModel(collaborations, CollaborationTestFactory.VORGANG_ID)) + when(assembler.toCollectionModel(collaborations, OrganisationsEinheitCollaborationTestFactory.VORGANG_ID)) .thenReturn(CollectionModel.of(Collections.singletonList(EntityModel.of(collaboration)))); } @@ -110,7 +110,7 @@ class CollaborationControllerTest { void shouldHaveTitel() { var response = performRequest(); - response.andExpect(jsonPath("$.content[0].titel").value(CollaborationTestFactory.TITEL)); + response.andExpect(jsonPath("$.content[0].titel").value(OrganisationsEinheitCollaborationTestFactory.TITEL)); } @SneakyThrows @@ -120,7 +120,7 @@ class CollaborationControllerTest { System.out.println(response.andReturn().getResponse().getContentAsString()); - response.andExpect(jsonPath("$.content[0].beschreibung").value(CollaborationTestFactory.BESCHREIBUNG)); + response.andExpect(jsonPath("$.content[0].beschreibung").value(OrganisationsEinheitCollaborationTestFactory.BESCHREIBUNG)); } @SneakyThrows @@ -129,7 +129,7 @@ class CollaborationControllerTest { var expectedLink = UriComponentsBuilder .fromUriString("http://localhost") .path(OrganisationsEinheitController.PATH) - .pathSegment(CollaborationTestFactory.ZUSTAENDIGE_STELLE) + .pathSegment(OrganisationsEinheitCollaborationTestFactory.ZUSTAENDIGE_STELLE) .build(); var response = performRequest(); @@ -142,7 +142,7 @@ class CollaborationControllerTest { @SneakyThrows private ResultActions performRequest() { - return mockMvc.perform(get(CollaborationController.PATH + "/" + CollaborationTestFactory.VORGANG_ID + "/collaborations")); + return mockMvc.perform(get(CollaborationController.PATH + "/" + OrganisationsEinheitCollaborationTestFactory.VORGANG_ID + "/collaborations")); } } } diff --git a/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/CollaborationMapperTest.java b/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/CollaborationMapperTest.java index fb895d9fa43334e6cf72b3a96583749d60fc59d0..3bafe806234b057a7fc3f71260979ca0b246b8d0 100644 --- a/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/CollaborationMapperTest.java +++ b/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/CollaborationMapperTest.java @@ -13,13 +13,26 @@ class CollaborationMapperTest { private CollaborationMapper mapper = Mappers.getMapper(CollaborationMapper.class); @Nested - class TestFromRequest { + class TestFromOrganisationsEinheitRequest { @Test void shouldMap() { - var collaboration = mapper.fromGrpc(GrpcCollaborationRequestTestFactory.create(), CollaborationTestFactory.VORGANG_ID); + var collaboration = mapper.fromOrganisationsEinheitRequest(GrpcCollaborationRequestForOrganisationsEinheitTestFactory.create(), + OrganisationsEinheitCollaborationTestFactory.VORGANG_ID); - assertThat(collaboration).usingRecursiveComparison().isEqualTo(CollaborationTestFactory.create()); + assertThat(collaboration).usingRecursiveComparison().isEqualTo(OrganisationsEinheitCollaborationTestFactory.create()); + } + } + + @Nested + class TestFromFachstelleRequest { + + @Test + void shouldMap() { + var collaboration = mapper.fromFachstelleRequest(GrpcCollaborationRequestForFachstelleTestFactory.create(), + FachstelleCollaborationTestFactory.VORGANG_ID); + + assertThat(collaboration).usingRecursiveComparison().isEqualTo(FachstelleCollaborationTestFactory.create()); } } } diff --git a/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/CollaborationModelAssemblerTest.java b/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/CollaborationModelAssemblerTest.java index 42ccdb43a2d39ed2bf5f6f71874eec71e57d36ed..9d8d09e3a20f3b30e8f84e2af8a0e016b7579252 100644 --- a/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/CollaborationModelAssemblerTest.java +++ b/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/CollaborationModelAssemblerTest.java @@ -37,31 +37,61 @@ class CollaborationModelAssemblerTest { class TestToModel { private static final String REL_ZUSTAENDIGE_STELLE = "zustaendigeStelle"; - private final Collaboration collaboration = CollaborationTestFactory.create(); - @Test - void shouldHaveContent() { - var entityModel = callAssembler(); + @Nested + class OnOrganisationsEinheitCollaboration { - assertThat(entityModel.getContent()).isEqualTo(collaboration); - } + private final OrganisationsEinheitCollaboration collaboration = OrganisationsEinheitCollaborationTestFactory.create(); - @Test - void shouldHaveLinkToOrganisationsEinheit() { - var entityModel = callAssembler(); + @Test + void shouldHaveContent() { + var entityModel = callAssembler(); + + assertThat(entityModel.getContent()).isEqualTo(collaboration); + } + + @Test + void shouldHaveLinkToOrganisationsEinheit() { + var entityModel = callAssembler(); - assertThat(entityModel.getLink(REL_ZUSTAENDIGE_STELLE)).get().extracting(Link::getHref) - .isEqualTo(OrganisationsEinheitController.PATH + "/" + OrganisationsEinheitTestFactory.ID); + assertThat(entityModel.getLink(REL_ZUSTAENDIGE_STELLE)).get().extracting(Link::getHref) + .isEqualTo(OrganisationsEinheitController.PATH + "/" + OrganisationsEinheitTestFactory.ID); + } + + private EntityModel<Collaboration> callAssembler() { + return assembler.toModel(collaboration); + } } - private EntityModel<Collaboration> callAssembler() { - return assembler.toModel(collaboration); + @Nested + class OnFachstelleCollaboration { + + private final FachstelleCollaboration collaboration = FachstelleCollaborationTestFactory.create(); + + @Test + void shouldHaveContent() { + var entityModel = callAssembler(); + + assertThat(entityModel.getContent()).isEqualTo(collaboration); + } + + @Test + void shouldHaveLinkToFachstelle() { + var entityModel = callAssembler(); + + assertThat(entityModel.getLink(REL_ZUSTAENDIGE_STELLE)).get().extracting(Link::getHref) + .isEqualTo(FachstelleController.PATH + "/" + FachstelleTestFactory.ID); + } + + private EntityModel<Collaboration> callAssembler() { + return assembler.toModel(collaboration); + } } } @Nested class TestToCollectionModel { - private final Collaboration collaboration = CollaborationTestFactory.create(); + private final Collaboration collaboration = FachstelleCollaborationTestFactory.create(); @Nested class OnNonEmptyCollaborationList { diff --git a/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/CollaborationRemoteServiceTest.java b/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/CollaborationRemoteServiceTest.java index 8d1203d6a6bbe83eeb38c1513eed98e257fee9dd..35460205434ae786ff43485c893559d3e9c209dd 100644 --- a/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/CollaborationRemoteServiceTest.java +++ b/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/CollaborationRemoteServiceTest.java @@ -11,6 +11,7 @@ import org.mockito.Mock; import org.mockito.Spy; import de.ozgcloud.collaboration.request.CollaborationRequestServiceGrpc.CollaborationRequestServiceBlockingStub; +import de.ozgcloud.collaboration.request.GrpcCollaborationRequest; import de.ozgcloud.collaboration.request.GrpcFindRequestsRequest; class CollaborationRemoteServiceTest { @@ -26,16 +27,20 @@ class CollaborationRemoteServiceTest { @Nested class TestGetCollaborations { - public static final String VORGANG_ID = CollaborationTestFactory.VORGANG_ID; + public static final String VORGANG_ID = FachstelleCollaborationTestFactory.VORGANG_ID; private final GrpcFindRequestsRequest searchRequest = GrpcFindRequestsRequestTestFactory.create(); - private final Collaboration collaboration = CollaborationTestFactory.create(); + private final GrpcCollaborationRequest organisationsEinheitRequest = GrpcCollaborationRequestForOrganisationsEinheitTestFactory.create(); + private final GrpcCollaborationRequest fachstelleRequest = GrpcCollaborationRequestForFachstelleTestFactory.create(); + private final OrganisationsEinheitCollaboration organisationsEinheitCollaboration = OrganisationsEinheitCollaborationTestFactory.create(); + private final FachstelleCollaboration fachstelleCollaboration = FachstelleCollaborationTestFactory.create(); @BeforeEach void init() { doReturn(searchRequest).when(service).buildSearchRequest(VORGANG_ID); when(stub.findRequests(searchRequest)).thenReturn(GrpcFindRequestsResponseTestFactory.create()); - when(mapper.fromGrpc(GrpcFindRequestsResponseTestFactory.REQUEST, VORGANG_ID)).thenReturn(collaboration); + when(mapper.fromOrganisationsEinheitRequest(organisationsEinheitRequest, VORGANG_ID)).thenReturn(organisationsEinheitCollaboration); + when(mapper.fromFachstelleRequest(fachstelleRequest, VORGANG_ID)).thenReturn(fachstelleCollaboration); } @Test @@ -53,17 +58,24 @@ class CollaborationRemoteServiceTest { } @Test - void shouldMapToCollaboration() { + void shouldMapOrganisationsEinheitRequest() { service.getCollaborations(VORGANG_ID).toList(); - verify(mapper).fromGrpc(GrpcFindRequestsResponseTestFactory.REQUEST, VORGANG_ID); + verify(mapper).fromOrganisationsEinheitRequest(GrpcFindRequestsResponseTestFactory.ORGANISATIONS_EINHEIT_REQUEST, VORGANG_ID); + } + + @Test + void shouldMapFachstelleRequest() { + service.getCollaborations(VORGANG_ID).toList(); + + verify(mapper).fromFachstelleRequest(GrpcFindRequestsResponseTestFactory.FACHSTELLE_REQUEST, VORGANG_ID); } @Test void shouldReturnCollaborations() { var collaborations = service.getCollaborations(VORGANG_ID).toList(); - assertThat(collaborations).containsExactly(collaboration); + assertThat(collaborations).containsExactlyInAnyOrder(organisationsEinheitCollaboration, fachstelleCollaboration); } } diff --git a/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/CollaborationServiceTest.java b/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/CollaborationServiceTest.java index 2659c7fce3f402080694a5b38cdd0fe11f3507f1..f2efcfa93d9cf2d49f903e50733133e1f71c8f01 100644 --- a/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/CollaborationServiceTest.java +++ b/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/CollaborationServiceTest.java @@ -33,7 +33,7 @@ class CollaborationServiceTest { @Test void shouldReturnCollaboration() { - var collaboration = CollaborationTestFactory.create(); + var collaboration = FachstelleCollaborationTestFactory.create(); when(remoteService.getCollaborations(id)).thenReturn(Stream.of(collaboration)); var returnedCollaboration = callService(); @@ -60,7 +60,7 @@ class CollaborationServiceTest { @Test void shouldReturnTrue() { - var collaboration = CollaborationTestFactory.create(); + var collaboration = FachstelleCollaborationTestFactory.create(); when(remoteService.getCollaborations(id)).thenReturn(Stream.of(collaboration)); var hasCollaboration = callService(); diff --git a/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/FachstelleCollaborationTestFactory.java b/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/FachstelleCollaborationTestFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..cb55dbe7db7012f0e49b39f33265fdf2f67cd5fb --- /dev/null +++ b/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/FachstelleCollaborationTestFactory.java @@ -0,0 +1,32 @@ +package de.ozgcloud.alfa.collaboration; + +import java.util.UUID; + +import com.thedeanda.lorem.LoremIpsum; + +import de.ozgcloud.alfa.collaboration.FachstelleCollaboration.FachstelleCollaborationBuilder; + +public class FachstelleCollaborationTestFactory { + + public static final String VORGANG_ID = UUID.randomUUID().toString(); + public static final String COLLABORATION_VORGANG_ID = UUID.randomUUID().toString(); + public static final long COLLABORATION_LEVEL = 4L; + public static final String TITEL = LoremIpsum.getInstance().getWords(7); + public static final String BESCHREIBUNG = LoremIpsum.getInstance().getParagraphs(2, 5); + public static final String ZUSTAENDIGE_STELLE = FachstelleTestFactory.ID; + + public static FachstelleCollaboration create() { + return createBuilder() + .build(); + } + + private static FachstelleCollaborationBuilder createBuilder() { + return FachstelleCollaboration.builder() + .vorgangId(VORGANG_ID) + .collaborationVorgangId(COLLABORATION_VORGANG_ID) + .collaborationLevel(COLLABORATION_LEVEL) + .titel(TITEL) + .beschreibung(BESCHREIBUNG) + .zustaendigeStelle(ZUSTAENDIGE_STELLE); + } +} diff --git a/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/GrpcCollaborationRequestForFachstelleTestFactory.java b/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/GrpcCollaborationRequestForFachstelleTestFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..6df288e13363ec4240ece9029c4a44d2083c9960 --- /dev/null +++ b/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/GrpcCollaborationRequestForFachstelleTestFactory.java @@ -0,0 +1,29 @@ +package de.ozgcloud.alfa.collaboration; + +import java.util.UUID; + +import de.ozgcloud.collaboration.request.GrpcCollaborationRequest; + +class GrpcCollaborationRequestForFachstelleTestFactory { + + public static final String ID = UUID.randomUUID().toString(); + public static final String COLLABORATION_VORGANG_ID = FachstelleCollaborationTestFactory.COLLABORATION_VORGANG_ID; + public static final String TITEL = FachstelleCollaborationTestFactory.TITEL; + public static final String BESCHREIBUNG = FachstelleCollaborationTestFactory.BESCHREIBUNG; + public static final String ZUSTAENDIGE_STELLE = FachstelleCollaborationTestFactory.ZUSTAENDIGE_STELLE; + + public static GrpcCollaborationRequest create() { + return createBuilder() + .setCollaborationLevel(FachstelleCollaborationTestFactory.COLLABORATION_LEVEL) + .build(); + } + + public static GrpcCollaborationRequest.Builder createBuilder() { + return GrpcCollaborationRequest.newBuilder() + .setId(ID) + .setCollaborationVorgangId(COLLABORATION_VORGANG_ID) + .setTitel(TITEL) + .setBeschreibung(BESCHREIBUNG) + .setZustaendigeStelle(ZUSTAENDIGE_STELLE); + } +} diff --git a/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/GrpcCollaborationRequestForOrganisationsEinheitTestFactory.java b/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/GrpcCollaborationRequestForOrganisationsEinheitTestFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..0b4c49eb4190eda26bf99afcc5b13e75a60364f3 --- /dev/null +++ b/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/GrpcCollaborationRequestForOrganisationsEinheitTestFactory.java @@ -0,0 +1,29 @@ +package de.ozgcloud.alfa.collaboration; + +import java.util.UUID; + +import de.ozgcloud.collaboration.request.GrpcCollaborationRequest; + +class GrpcCollaborationRequestForOrganisationsEinheitTestFactory { + + public static final String ID = UUID.randomUUID().toString(); + public static final String COLLABORATION_VORGANG_ID = OrganisationsEinheitCollaborationTestFactory.COLLABORATION_VORGANG_ID; + public static final String TITEL = OrganisationsEinheitCollaborationTestFactory.TITEL; + public static final String BESCHREIBUNG = OrganisationsEinheitCollaborationTestFactory.BESCHREIBUNG; + public static final String ZUSTAENDIGE_STELLE = OrganisationsEinheitCollaborationTestFactory.ZUSTAENDIGE_STELLE; + + public static GrpcCollaborationRequest create() { + return createBuilder() + .setCollaborationLevel(OrganisationsEinheitCollaborationTestFactory.COLLABORATION_LEVEL) + .build(); + } + + public static GrpcCollaborationRequest.Builder createBuilder() { + return GrpcCollaborationRequest.newBuilder() + .setId(ID) + .setCollaborationVorgangId(COLLABORATION_VORGANG_ID) + .setTitel(TITEL) + .setBeschreibung(BESCHREIBUNG) + .setZustaendigeStelle(ZUSTAENDIGE_STELLE); + } +} diff --git a/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/GrpcCollaborationRequestTestFactory.java b/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/GrpcCollaborationRequestTestFactory.java deleted file mode 100644 index 06a2cc47ac10d89d39d46fefb93f8bb350e56ee8..0000000000000000000000000000000000000000 --- a/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/GrpcCollaborationRequestTestFactory.java +++ /dev/null @@ -1,28 +0,0 @@ -package de.ozgcloud.alfa.collaboration; - -import java.util.UUID; - -import de.ozgcloud.collaboration.request.GrpcCollaborationRequest; - -class GrpcCollaborationRequestTestFactory { - - public static final String ID = UUID.randomUUID().toString(); - public static final String COLLABORATION_VORGANG_ID = CollaborationTestFactory.COLLABORATION_VORGANG_ID; - public static final String TITEL = CollaborationTestFactory.TITEL; - public static final String BESCHREIBUNG = CollaborationTestFactory.BESCHREIBUNG; - public static final String ZUSTAENDIGE_STELLE = CollaborationTestFactory.ZUSTAENDIGE_STELLE; - - public static GrpcCollaborationRequest create() { - return createBuilder() - .build(); - } - - private static GrpcCollaborationRequest.Builder createBuilder() { - return GrpcCollaborationRequest.newBuilder() - .setId(ID) - .setCollaborationVorgangId(COLLABORATION_VORGANG_ID) - .setTitel(TITEL) - .setBeschreibung(BESCHREIBUNG) - .setZustaendigeStelle(ZUSTAENDIGE_STELLE); - } -} diff --git a/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/GrpcFindRequestsResponseTestFactory.java b/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/GrpcFindRequestsResponseTestFactory.java index 981baf5e98cbe2177770bca59322685bd4284f36..96e730a5276df08265625689378559a272fcac0d 100644 --- a/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/GrpcFindRequestsResponseTestFactory.java +++ b/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/GrpcFindRequestsResponseTestFactory.java @@ -5,13 +5,14 @@ import de.ozgcloud.collaboration.request.GrpcFindRequestsResponse; class GrpcFindRequestsResponseTestFactory { - public static final GrpcCollaborationRequest REQUEST = GrpcCollaborationRequestTestFactory.create(); + public static final GrpcCollaborationRequest ORGANISATIONS_EINHEIT_REQUEST = GrpcCollaborationRequestForOrganisationsEinheitTestFactory.create(); + public static final GrpcCollaborationRequest FACHSTELLE_REQUEST = GrpcCollaborationRequestForFachstelleTestFactory.create(); public static GrpcFindRequestsResponse create() { return createBuilder().build(); } public static GrpcFindRequestsResponse.Builder createBuilder() { - return GrpcFindRequestsResponse.newBuilder().addRequests(REQUEST); + return GrpcFindRequestsResponse.newBuilder().addRequests(ORGANISATIONS_EINHEIT_REQUEST).addRequests(FACHSTELLE_REQUEST); } } diff --git a/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/CollaborationTestFactory.java b/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/OrganisationsEinheitCollaborationTestFactory.java similarity index 61% rename from alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/CollaborationTestFactory.java rename to alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/OrganisationsEinheitCollaborationTestFactory.java index 9959f1a2b18e38db081c5bb62847213b3353a81f..5a21747edd2000bcb4dab54ea871d757b2603d71 100644 --- a/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/CollaborationTestFactory.java +++ b/alfa-service/src/test/java/de/ozgcloud/alfa/collaboration/OrganisationsEinheitCollaborationTestFactory.java @@ -4,25 +4,27 @@ import java.util.UUID; import com.thedeanda.lorem.LoremIpsum; -import de.ozgcloud.alfa.collaboration.Collaboration.CollaborationBuilder; +import de.ozgcloud.alfa.collaboration.OrganisationsEinheitCollaboration.OrganisationsEinheitCollaborationBuilder; -public class CollaborationTestFactory { +public class OrganisationsEinheitCollaborationTestFactory { public static final String VORGANG_ID = UUID.randomUUID().toString(); public static final String COLLABORATION_VORGANG_ID = UUID.randomUUID().toString(); + public static final long COLLABORATION_LEVEL = 1L; public static final String TITEL = LoremIpsum.getInstance().getWords(7); public static final String BESCHREIBUNG = LoremIpsum.getInstance().getParagraphs(2, 5); public static final String ZUSTAENDIGE_STELLE = OrganisationsEinheitTestFactory.ID; - public static Collaboration create() { + public static OrganisationsEinheitCollaboration create() { return createBuilder() .build(); } - private static CollaborationBuilder createBuilder() { - return Collaboration.builder() + private static OrganisationsEinheitCollaborationBuilder createBuilder() { + return OrganisationsEinheitCollaboration.builder() .vorgangId(VORGANG_ID) .collaborationVorgangId(COLLABORATION_VORGANG_ID) + .collaborationLevel(COLLABORATION_LEVEL) .titel(TITEL) .beschreibung(BESCHREIBUNG) .zustaendigeStelle(ZUSTAENDIGE_STELLE);