diff --git a/src/main/helm/templates/network_policy.yaml b/src/main/helm/templates/network_policy.yaml index e5b2c533cc56546800a78f562d1d17fefe4403f9..b49c282354091844db32a2ab99d7e25d93ccba78 100644 --- a/src/main/helm/templates/network_policy.yaml +++ b/src/main/helm/templates/network_policy.yaml @@ -59,10 +59,10 @@ spec: - from: - namespaceSelector: matchLabels: - kubernetes.io/metadata.name: {{((.Values.ozgcloud).antragraum).antragsraumProxyNamespace | default "antragsraum-proxy"}} + kubernetes.io/metadata.name: {{((.Values.ozgcloud).antragraum).antragraumProxyNamespace | default "antragraum-proxy"}} podSelector: matchLabels: - component: antragsraum-proxy + component: antragraum-proxy {{- end }} - from: diff --git a/src/test/helm/deployment_antragraum_test.yaml b/src/test/helm/deployment_antragraum_test.yaml index 29ed00d4c4d008336993014f6b2defd03378fc51..4502b67d7001df5d768cb105168a6681f2c8917c 100644 --- a/src/test/helm/deployment_antragraum_test.yaml +++ b/src/test/helm/deployment_antragraum_test.yaml @@ -35,7 +35,7 @@ set: bezeichner: helm imagePullSecret: test-image-pull-secret tests: - - it: should set antragsraum values + - it: should set antragraum values set: ozgcloud: antragraum: @@ -69,7 +69,7 @@ tests: name: ozgcloud_antragraum_decryptionCertificate value: "file:/keystore/bayernid/bayern-id.crt" - - it: should not generate antragsraum config if disabled + - it: should not generate antragraum config if disabled set: ozgcloud.antragraum.enabled: false asserts: @@ -114,7 +114,7 @@ tests: name: bayernid-certificate mountPath: "/keystore/bayernid" readOnly: true - - it: should not set volumeMounts if antragsraum is disabled + - it: should not set volumeMounts if antragraum is disabled set: ozgcloud.antragraum.enabled: false asserts: @@ -140,7 +140,7 @@ tests: secret: secretName: bayernid-certificate optional: false - - it: should not have volumes if antragsraum is disabled + - it: should not have volumes if antragraum is disabled set: ozgcloud.antragraum.enabled: false asserts: diff --git a/src/test/helm/network_policy_test.yaml b/src/test/helm/network_policy_test.yaml index 8c72186be1545a2ce6c85d8df72f4d8d1e73838a..618dba7961d5776726e0c51387ae466a5036a409 100644 --- a/src/test/helm/network_policy_test.yaml +++ b/src/test/helm/network_policy_test.yaml @@ -154,10 +154,10 @@ tests: from: - namespaceSelector: matchLabels: - kubernetes.io/metadata.name: antragsraum-proxy + kubernetes.io/metadata.name: antragraum-proxy podSelector: matchLabels: - component: antragsraum-proxy + component: antragraum-proxy - it: should set ingress rule for antragraum-proxy if antragraum is enabled set: @@ -166,7 +166,7 @@ tests: ozgcloud: antragraum: enabled: true - antragsraumProxyNamespace: antragsraum-proxy + antragraumProxyNamespace: antragraum-proxy asserts: - contains: path: spec.ingress @@ -174,10 +174,10 @@ tests: from: - namespaceSelector: matchLabels: - kubernetes.io/metadata.name: antragsraum-proxy + kubernetes.io/metadata.name: antragraum-proxy podSelector: matchLabels: - component: antragsraum-proxy + component: antragraum-proxy - it: should not add ingress rule for antragraum if antragraum is disabled diff --git a/vorgang-manager-base/src/main/java/de/ozgcloud/vorgang/callcontext/CallContextHandleInterceptor.java b/vorgang-manager-base/src/main/java/de/ozgcloud/vorgang/callcontext/CallContextHandleInterceptor.java index 56e9cdb76596b9f4132f18412dd9e15ee981161c..b1d1284370c5c43bc3d8430634efd86acd627238 100644 --- a/vorgang-manager-base/src/main/java/de/ozgcloud/vorgang/callcontext/CallContextHandleInterceptor.java +++ b/vorgang-manager-base/src/main/java/de/ozgcloud/vorgang/callcontext/CallContextHandleInterceptor.java @@ -95,7 +95,7 @@ class CallContextHandleInterceptor implements ServerInterceptor { } void doSurroundOn(Runnable runnable) { - try (CloseableThreadContext.Instance ctc = CloseableThreadContext.put(REQUEST_ID_KEY, requestId)) { + try (var ctc = CloseableThreadContext.put(REQUEST_ID_KEY, requestId)) { startSecurityContext(); runnable.run(); } finally { diff --git a/vorgang-manager-base/src/test/java/de/ozgcloud/vorgang/callcontext/CallContextTestFactory.java b/vorgang-manager-base/src/test/java/de/ozgcloud/vorgang/callcontext/CallContextTestFactory.java index a51e03e3c90e2a91f798d3afd15c06c0a35739ca..416274956e461d0d905b68ee9064b60cf072cd76 100644 --- a/vorgang-manager-base/src/test/java/de/ozgcloud/vorgang/callcontext/CallContextTestFactory.java +++ b/vorgang-manager-base/src/test/java/de/ozgcloud/vorgang/callcontext/CallContextTestFactory.java @@ -26,8 +26,6 @@ package de.ozgcloud.vorgang.callcontext; import static de.ozgcloud.vorgang.callcontext.CallContextHandleInterceptor.*; import static de.ozgcloud.vorgang.callcontext.UserTestFactory.*; -import java.util.Map; -import java.util.Set; import java.util.UUID; import de.ozgcloud.common.grpc.GrpcUtil; @@ -51,16 +49,6 @@ public class CallContextTestFactory { .client(CLIENT); } - // TODO Pruefen, ob die Methode noch gebraucht wird - public static Map<String, Object> createContextMap() { - return Map.of( - KEY_USER_ID, UserTestFactory.ID, - KEY_USER_NAME, UserTestFactory.NAME, - KEY_CLIENT_NAME, CLIENT, - KEY_ACCESS_LIMITED_ORGAID, Set.of(UserTestFactory.ORGANISATORISCHE_EINHEITEN_ID), - KEY_REQUEST_ID, REQUEST_ID); - } - public static Metadata createMetadata() { var result = new Metadata(); result.put(GrpcUtil.HEADER_KEY_USER_ID, ID.getBytes()); diff --git a/vorgang-manager-base/src/test/java/de/ozgcloud/vorgang/callcontext/TestCallContextAttachingInterceptor.java b/vorgang-manager-base/src/test/java/de/ozgcloud/vorgang/callcontext/TestCallContextAttachingInterceptor.java index 518fc07f0a7a81f2a930d357184230ead2c04d43..33bb5dda35074ead65218e2891ba93b5c8e49cde 100644 --- a/vorgang-manager-base/src/test/java/de/ozgcloud/vorgang/callcontext/TestCallContextAttachingInterceptor.java +++ b/vorgang-manager-base/src/test/java/de/ozgcloud/vorgang/callcontext/TestCallContextAttachingInterceptor.java @@ -47,7 +47,7 @@ public class TestCallContextAttachingInterceptor implements ClientInterceptor { final class TestCallContextAttachingClientCall<ReqT, RespT> extends SimpleForwardingClientCall<ReqT, RespT> { - protected TestCallContextAttachingClientCall(ClientCall<ReqT, RespT> delegate) { + private TestCallContextAttachingClientCall(ClientCall<ReqT, RespT> delegate) { super(delegate); } diff --git a/vorgang-manager-interface/src/main/protobuf/vorgang.model.proto b/vorgang-manager-interface/src/main/protobuf/vorgang.model.proto index 76157a12e40b638a00ca020bfde221706b1cc3ef..b1c4bad8c989562a34bd0f821ed472b28a0cebcf 100644 --- a/vorgang-manager-interface/src/main/protobuf/vorgang.model.proto +++ b/vorgang-manager-interface/src/main/protobuf/vorgang.model.proto @@ -199,11 +199,11 @@ message GrpcVorgangQueryExpression { message GrpcCreateCollaborationVorgangRequest { oneof request { - GrpcCollaborationRequest collaborationRequest = 1; + GrpcCreateCollaborationRequestData requestData = 1; } } -message GrpcCollaborationRequest { +message GrpcCreateCollaborationRequestData { string vorgangId = 1; int32 collaborationLevel = 2; string zustaendigeStelle = 3; diff --git a/vorgang-manager-server/pom.xml b/vorgang-manager-server/pom.xml index 0c6f535369777e48782044894c76fc00eb140673..f39cb7b31a2d078a77419f5c508e0ebd51ff1f68 100644 --- a/vorgang-manager-server/pom.xml +++ b/vorgang-manager-server/pom.xml @@ -58,7 +58,7 @@ <nachrichten-manager.version>2.14.0-OZG-6944-Zugriff-auf-Anhaenge-SNAPSHOT</nachrichten-manager.version> <ozgcloud-starter.version>0.12.0</ozgcloud-starter.version> <notification-manager.version>2.12.0-SNAPSHOT</notification-manager.version> - <collaboration-manager.version>0.4.0-OZG-6944-resolve-bean-conflict-SNAPSHOT</collaboration-manager.version> + <collaboration-manager.version>0.4.0-SNAPSHOT</collaboration-manager.version> <zip.version>2.11.5</zip.version> <jsoup.version>1.15.3</jsoup.version> diff --git a/vorgang-manager-server/src/main/java/de/ozgcloud/vorgang/collaboration/CreateCollaborationVorgangRequestMapper.java b/vorgang-manager-server/src/main/java/de/ozgcloud/vorgang/collaboration/CreateCollaborationVorgangRequestMapper.java index 28c23c3d257a9bc371fcd54dd1eaed57cd2166a7..e7d98214f47767f8e504319062e735e1f1542162 100644 --- a/vorgang-manager-server/src/main/java/de/ozgcloud/vorgang/collaboration/CreateCollaborationVorgangRequestMapper.java +++ b/vorgang-manager-server/src/main/java/de/ozgcloud/vorgang/collaboration/CreateCollaborationVorgangRequestMapper.java @@ -27,11 +27,11 @@ import org.mapstruct.Mapper; import org.mapstruct.Mapping; import org.mapstruct.ReportingPolicy; -import de.ozgcloud.vorgang.vorgang.GrpcCollaborationRequest; +import de.ozgcloud.vorgang.vorgang.GrpcCreateCollaborationRequestData; @Mapper(unmappedTargetPolicy = ReportingPolicy.WARN) public interface CreateCollaborationVorgangRequestMapper { @Mapping(target = "vorgang", ignore = true) - CreateCollaborationVorgangRequest mapFrom(GrpcCollaborationRequest grpcCollaborationRequest); + CreateCollaborationVorgangRequest mapFrom(GrpcCreateCollaborationRequestData grpcCollaborationRequest); } diff --git a/vorgang-manager-server/src/main/java/de/ozgcloud/vorgang/common/errorhandling/ExceptionHandler.java b/vorgang-manager-server/src/main/java/de/ozgcloud/vorgang/common/errorhandling/ExceptionHandler.java index 356ec36f45ceee2bd5dcbd91180b9ea20b54d23a..bb28f0f25b66a1cc2d6065009c4df9b259270fa4 100644 --- a/vorgang-manager-server/src/main/java/de/ozgcloud/vorgang/common/errorhandling/ExceptionHandler.java +++ b/vorgang-manager-server/src/main/java/de/ozgcloud/vorgang/common/errorhandling/ExceptionHandler.java @@ -33,6 +33,7 @@ import io.grpc.Metadata; import io.grpc.Metadata.Key; import io.grpc.Status; import io.grpc.StatusException; +import io.grpc.StatusRuntimeException; import lombok.extern.log4j.Log4j2; import net.devh.boot.grpc.server.advice.GrpcAdvice; import net.devh.boot.grpc.server.advice.GrpcExceptionHandler; @@ -89,6 +90,11 @@ public class ExceptionHandler { return Status.INTERNAL.withDescription(e.getMessage()).withCause(e.getCause()); } + @GrpcExceptionHandler + public StatusRuntimeException passThroughStatusRuntimeException(StatusRuntimeException e) { + return e; + } + @GrpcExceptionHandler public StatusException handleRuntimeException(RuntimeException e) { var exceptionId = createExceptionId(); diff --git a/vorgang-manager-server/src/main/java/de/ozgcloud/vorgang/vorgang/VorgangGrpcService.java b/vorgang-manager-server/src/main/java/de/ozgcloud/vorgang/vorgang/VorgangGrpcService.java index 3adf3dcf4bf4b7d352039c64292abffdfe1068dc..986a7ce668c786d3612d7bdbe1267013bc24aadc 100644 --- a/vorgang-manager-server/src/main/java/de/ozgcloud/vorgang/vorgang/VorgangGrpcService.java +++ b/vorgang-manager-server/src/main/java/de/ozgcloud/vorgang/vorgang/VorgangGrpcService.java @@ -116,8 +116,8 @@ class VorgangGrpcService extends VorgangServiceGrpc.VorgangServiceImplBase { public void createCollaborationVorgang(GrpcCreateCollaborationVorgangRequest request, StreamObserver<GrpcCreateCollaborationVorgangResponse> responseObserver) { GrpcCreateCollaborationVorgangResponse response; - if (request.hasCollaborationRequest()) { - response = createCollaborationVorgang(request.getCollaborationRequest()); + if (request.hasRequestData()) { + response = createCollaborationVorgang(request.getRequestData()); } else { throw new CreateCollaborationVorgangBadRequestException("Cannot create collaboration vorgang. Collaboration request is empty."); } @@ -125,12 +125,12 @@ class VorgangGrpcService extends VorgangServiceGrpc.VorgangServiceImplBase { responseObserver.onCompleted(); } - GrpcCreateCollaborationVorgangResponse createCollaborationVorgang(GrpcCollaborationRequest request) { + GrpcCreateCollaborationVorgangResponse createCollaborationVorgang(GrpcCreateCollaborationRequestData request) { var collaborationVorgang = collaborationService.createCollaborationVorgang(buildCreateCollaborationVorgangRequest(request)); return buildCreateCollaborationVorgangResponse(collaborationVorgang); } - CreateCollaborationVorgangRequest buildCreateCollaborationVorgangRequest(GrpcCollaborationRequest request) { + CreateCollaborationVorgangRequest buildCreateCollaborationVorgangRequest(GrpcCreateCollaborationRequestData request) { var vorgang = vorgangService.getById(request.getVorgangId()); return createCollaborationVorgangRequestMapper.mapFrom(request).toBuilder().vorgang(vorgang).build(); } diff --git a/vorgang-manager-server/src/test/java/de/ozgcloud/document/bescheid/BescheidITCase.java b/vorgang-manager-server/src/test/java/de/ozgcloud/document/bescheid/BescheidITCase.java index 5f9bec61745025e6d3fc35bd87c3cebad27b631b..a376c15ff6b445389fec85a2e0c42e058d136174 100644 --- a/vorgang-manager-server/src/test/java/de/ozgcloud/document/bescheid/BescheidITCase.java +++ b/vorgang-manager-server/src/test/java/de/ozgcloud/document/bescheid/BescheidITCase.java @@ -87,6 +87,7 @@ import de.ozgcloud.vorgang.vorgang.VorgangTestFactory; "grpc.client.vorgang-manager.address=in-process:test", "grpc.client.nachrichten-manager.address=in-process:test", "grpc.client.command-manager.address=in-process:test", + "grpc.client.pluto.address=in-process:test", "ozgcloud.feature.bescheid.enable-dummy-document-processor=true", }) @DataITCase diff --git a/vorgang-manager-server/src/test/java/de/ozgcloud/vorgang/collaboration/CollaborationITCase.java b/vorgang-manager-server/src/test/java/de/ozgcloud/vorgang/collaboration/CollaborationITCase.java index e7f7398fa4d406da54607ebb88fb4c66280d6835..2a9d8659032b1ea7aa719ebab32e5f1570c3d361 100644 --- a/vorgang-manager-server/src/test/java/de/ozgcloud/vorgang/collaboration/CollaborationITCase.java +++ b/vorgang-manager-server/src/test/java/de/ozgcloud/vorgang/collaboration/CollaborationITCase.java @@ -24,6 +24,7 @@ package de.ozgcloud.vorgang.collaboration; import static org.assertj.core.api.Assertions.*; +import static org.assertj.core.api.InstanceOfAssertFactories.*; import static org.awaitility.Awaitility.*; import static org.junit.jupiter.api.Assertions.fail; import static org.mockito.ArgumentMatchers.*; @@ -33,9 +34,11 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.List; import java.util.Map; +import java.util.UUID; import java.util.concurrent.TimeUnit; import org.bson.types.ObjectId; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; @@ -53,12 +56,18 @@ import org.springframework.data.mongodb.gridfs.GridFsTemplate; import org.springframework.test.annotation.DirtiesContext; import com.google.protobuf.ByteString; +import com.thedeanda.lorem.LoremIpsum; import de.ozgcloud.apilib.user.OzgCloudUserId; import de.ozgcloud.apilib.user.OzgCloudUserProfile; import de.ozgcloud.apilib.user.OzgCloudUserProfileService; +import de.ozgcloud.collaboration.CollaborationRequest; import de.ozgcloud.collaboration.CollaborationServiceGrpc.CollaborationServiceBlockingStub; import de.ozgcloud.collaboration.GrpcGetFileContentRequest; +import de.ozgcloud.collaboration.request.CollaborationRequestId; +import de.ozgcloud.collaboration.request.CollaborationRequestServiceGrpc.CollaborationRequestServiceBlockingStub; +import de.ozgcloud.collaboration.request.GrpcFindRequestsRequest; +import de.ozgcloud.collaboration.request.GrpcGetRequestRequest; import de.ozgcloud.command.Command; import de.ozgcloud.command.CommandStatus; import de.ozgcloud.common.errorhandling.TechnicalException; @@ -67,6 +76,7 @@ import de.ozgcloud.nachrichten.postfach.PostfachAddress; import de.ozgcloud.nachrichten.postfach.PostfachNachricht; import de.ozgcloud.nachrichten.postfach.PostfachRemoteService; import de.ozgcloud.vorgang.attached_item.VorgangAttachedItem; +import de.ozgcloud.vorgang.attached_item.VorgangAttachedItemTestFactory; import de.ozgcloud.vorgang.callcontext.CallContext; import de.ozgcloud.vorgang.callcontext.TestCallContextAttachingInterceptor; import de.ozgcloud.vorgang.callcontext.WithMockCustomUser; @@ -78,10 +88,13 @@ import de.ozgcloud.vorgang.files.GridFsTestFactory; import de.ozgcloud.vorgang.files.OzgFileTestFactory; import de.ozgcloud.vorgang.servicekonto.PostfachAddressTestFactory; import de.ozgcloud.vorgang.servicekonto.ServiceKontoTestFactory; +import de.ozgcloud.vorgang.vorgang.EingangTestFactory; import de.ozgcloud.vorgang.vorgang.Vorgang; import de.ozgcloud.vorgang.vorgang.VorgangHead; import de.ozgcloud.vorgang.vorgang.VorgangTestFactory; import de.ozgcloud.vorgang.vorgang.ZustaendigeStelleTestFactory; +import io.grpc.Status; +import io.grpc.StatusRuntimeException; import net.devh.boot.grpc.client.inject.GrpcClient; @SpringBootTest(properties = { @@ -89,7 +102,9 @@ import net.devh.boot.grpc.client.inject.GrpcClient; "grpc.client.vorgang-manager.address=in-process:test", "grpc.client.ozgcloud-command-manager.address=in-process:test", "grpc.client.file-manager.address=in-process:test", - "grpc.client.inProcess.address=in-process:test" + "grpc.client.vorgang-attached-item.address=in-process:test", + "grpc.client.inProcess.address=in-process:test", + "grpc.client.pluto.address=in-process:test" }) @DataITCase @WithMockCustomUser @@ -98,7 +113,7 @@ class CollaborationITCase { private static final String FIELD_COLLABORATION_VORGANG_ID = "collaborationVorgangId"; private static final String TITEL = "Collaboration Vorgang"; - private static final String ANFRAGE = "Anfrage"; + private static final String BESCHREIBUNG = "Beschreibung der Anfrage"; @Autowired private CommandService commandService; @@ -174,7 +189,7 @@ class CollaborationITCase { private byte[] downloadBinaryFile(ObjectId fileId) { var request = GrpcGetFileContentRequest.newBuilder() .setId(fileId.toHexString()).build(); - var it = prepareBinaryFileServiceBlockingStub().getFileContent(request); + var it = getServiceStub().getFileContent(request); var content = new ByteArrayOutputStream(); while (it.hasNext()) { ByteString chunkContent = it.next().getFileContent(); @@ -188,7 +203,7 @@ class CollaborationITCase { return content.toByteArray(); } - private CollaborationServiceBlockingStub prepareBinaryFileServiceBlockingStub() { + private CollaborationServiceBlockingStub getServiceStub() { return collaborationStub.withInterceptors(new TestCallContextAttachingInterceptor()); } } @@ -201,7 +216,7 @@ class CollaborationITCase { .order("CREATE_COLLABORATION_REQUEST") .bodyObject(Map.of( "titel", TITEL, - "anfrage", ANFRAGE, + "beschreibung", BESCHREIBUNG, "collaborationLevel", collaborationLevel, "zustaendigeStelle", ZustaendigeStelleTestFactory.ORGANISATIONSEINHEIT_ID)) .build(); @@ -215,7 +230,7 @@ class CollaborationITCase { } private void waitUntilCommandHasStatus(String commandId, CommandStatus status) { - await().atMost(60, TimeUnit.SECONDS).until( + await().atMost(600, TimeUnit.SECONDS).until( () -> mongoOperations.findById(commandId, Command.class), command -> command.getStatus() == status); } @@ -309,4 +324,126 @@ class CollaborationITCase { assertThat(loadCollaborationRequest(vorgangId)).isEmpty(); } } + + @DisplayName("Collaboration requests") + @Nested + class TestCollaborationRequests { + + @GrpcClient("inProcess") + private CollaborationRequestServiceBlockingStub collaborationRequestStub; + + public static final String ID_STR = UUID.randomUUID().toString(); + public static final CollaborationRequestId ID = CollaborationRequestId.from(ID_STR); + + public static final String TITEL = LoremIpsum.getInstance().getWords(5); + public static final String BESCHREIBUNG = LoremIpsum.getInstance().getWords(10); + public static final String ZUSTAENDIGE_STELLE = UUID.randomUUID().toString(); + public static final String COLLABORATION_VORGANG_ID = UUID.randomUUID().toString(); + public static final int COLLABORATION_lEVEL = 1; + + private final Vorgang vorgang = VorgangTestFactory.create(); + + private final Map<String, Object> collaborationRequestItem = Map.of(CollaborationRequest.PROPERTY_ID, ID_STR, + CollaborationRequest.PROPERTY_COMMAND_ID, CommandTestFactory.ID, + CollaborationRequest.PROPERTY_VORGANG_ID, VorgangTestFactory.ID, + CollaborationRequest.PROPERTY_COLLABORATION_VORGANG_ID, COLLABORATION_VORGANG_ID, + CollaborationRequest.PROPERTY_COLLABORATION_LEVEL, String.valueOf(COLLABORATION_lEVEL), + CollaborationRequest.PROPERTY_CREATED_BY, CommandTestFactory.CREATED_BY, + CollaborationRequest.PROPERTY_TITEL, TITEL, + CollaborationRequest.PROPERTY_BESCHREIBUNG, BESCHREIBUNG, + CollaborationRequest.PROPERTY_ZUSTAENDIGE_STELLE, ZUSTAENDIGE_STELLE); + + private final VorgangAttachedItem vorgangAttachedItem = VorgangAttachedItemTestFactory.createBuilder() + .id(null) + .vorgangId(VorgangTestFactory.ID) + .version(0) + .client("AlfaTestClient") + .itemName("CollaborationRequest") + .deleted(false) + .item(collaborationRequestItem) + .build(); + + private VorgangAttachedItem savedCollaborationRequest; + + @BeforeEach + void init() { + mongoOperations.save(vorgang); + savedCollaborationRequest = mongoOperations.save(vorgangAttachedItem); + } + + @DisplayName("Get Request") + @Nested + class TestGetRequest { + + @Test + void shouldReturnNotFoundExceptionOnNonExisting() { + var id = UUID.randomUUID().toString(); + var request = GrpcGetRequestRequest.newBuilder().setId(id).build(); + var serviceStub = getServiceStub(); + + assertThatThrownBy(() -> serviceStub.getRequest(request)) + .isInstanceOf(StatusRuntimeException.class) + .hasMessageContaining("NOT_FOUND") + .hasMessageContaining(id); + } + + @Test + void shouldReturnExistingCollaborationRequest() { + var response = getServiceStub().getRequest(GrpcGetRequestRequest.newBuilder().setId(savedCollaborationRequest.getId()).build()); + + assertThat(response.getRequest()).satisfies(grpcCollaborationRequest -> { + assertThat(grpcCollaborationRequest.getId()).isEqualTo(savedCollaborationRequest.getId()); + assertThat(grpcCollaborationRequest.getTitel()).isEqualTo(TITEL); + assertThat(grpcCollaborationRequest.getBeschreibung()).isEqualTo(BESCHREIBUNG); + assertThat(grpcCollaborationRequest.getZustaendigeStelle()).isEqualTo(ZUSTAENDIGE_STELLE); + assertThat(grpcCollaborationRequest.getCollaborationLevel()).isEqualTo(COLLABORATION_lEVEL); + assertThat(grpcCollaborationRequest.getCreatedBy()).isEqualTo(CommandTestFactory.CREATED_BY); + }); + } + + @DisplayName("Should throw access denied exception on non matching organisationsEinheitId") + @Test + void shouldThrowAccessDeniedException() { + var vorgangId = mongoOperations.save(buildVorgang()).getId(); + savedCollaborationRequest = mongoOperations.save(vorgangAttachedItem.toBuilder().vorgangId(vorgangId).build()); + var request = GrpcGetRequestRequest.newBuilder().setId(savedCollaborationRequest.getId()).build(); + var serviceStub = getServiceStub(); + + var exception = Assertions.assertThrows(StatusRuntimeException.class, () -> serviceStub.getRequest(request)); + assertThat(exception.getStatus().getCode()).isEqualTo(Status.Code.PERMISSION_DENIED); + } + + private Vorgang buildVorgang() { + return VorgangTestFactory.createBuilder().id(null).version(0).clearEingangs() + .eingang(EingangTestFactory.createBuilder() + .zustaendigeStelle(ZustaendigeStelleTestFactory.createBuilder().organisationseinheitenId("other").build()) + .build()) + .build(); + } + } + + @DisplayName("Find requests") + @Nested + class TestFindRequests { + + @Test + void shouldReturnExistingCollaborationRequests() { + var response = getServiceStub().findRequests(GrpcFindRequestsRequest.newBuilder().setVorgangId(VorgangTestFactory.ID).build()); + + assertThat(response.getRequestsList()).hasSize(1); + assertThat(response.getRequestsList().getFirst().getId()).isEqualTo(savedCollaborationRequest.getId()); + } + + @Test + void shouldReturnEmptyListOnNotMatchingVorgangId() { + var response = getServiceStub().findRequests(GrpcFindRequestsRequest.newBuilder().setVorgangId(vorgangId).build()); + + assertThat(response.getRequestsList()).isEmpty(); + } + } + + private CollaborationRequestServiceBlockingStub getServiceStub() { + return collaborationRequestStub.withInterceptors(new TestCallContextAttachingInterceptor()); + } + } } \ No newline at end of file diff --git a/vorgang-manager-server/src/test/java/de/ozgcloud/vorgang/collaboration/CreateCollaborationVorgangRequestMapperTest.java b/vorgang-manager-server/src/test/java/de/ozgcloud/vorgang/collaboration/CreateCollaborationVorgangRequestMapperTest.java index 45e76253f7a9e06bd7c221d1a7e4c0a56e46ae32..813820f57598e988451867b6f263cf84da1c5d45 100644 --- a/vorgang-manager-server/src/test/java/de/ozgcloud/vorgang/collaboration/CreateCollaborationVorgangRequestMapperTest.java +++ b/vorgang-manager-server/src/test/java/de/ozgcloud/vorgang/collaboration/CreateCollaborationVorgangRequestMapperTest.java @@ -34,7 +34,7 @@ class CreateCollaborationVorgangRequestMapperTest { @Test void shouldMapFromGrpc() { - var result = mapper.mapFrom(GrpcCollaborationRequestTestFactory.create()); + var result = mapper.mapFrom(GrpcCreateCollaborationRequestDataTestFactory.create()); assertThat(result).usingRecursiveComparison().ignoringFields("vorgang").isEqualTo(CreateCollaborationVorgangRequestTestFactory.create()); } diff --git a/vorgang-manager-server/src/test/java/de/ozgcloud/vorgang/collaboration/GrpcCollaborationRequestTestFactory.java b/vorgang-manager-server/src/test/java/de/ozgcloud/vorgang/collaboration/GrpcCreateCollaborationRequestDataTestFactory.java similarity index 80% rename from vorgang-manager-server/src/test/java/de/ozgcloud/vorgang/collaboration/GrpcCollaborationRequestTestFactory.java rename to vorgang-manager-server/src/test/java/de/ozgcloud/vorgang/collaboration/GrpcCreateCollaborationRequestDataTestFactory.java index e46337e88b4364406238abb4ae3bfa0cece7ecae..139b28a5ce95adaf82e99e464cc31c36bb67424f 100644 --- a/vorgang-manager-server/src/test/java/de/ozgcloud/vorgang/collaboration/GrpcCollaborationRequestTestFactory.java +++ b/vorgang-manager-server/src/test/java/de/ozgcloud/vorgang/collaboration/GrpcCreateCollaborationRequestDataTestFactory.java @@ -23,18 +23,18 @@ */ package de.ozgcloud.vorgang.collaboration; -import de.ozgcloud.vorgang.vorgang.GrpcCollaborationRequest; +import de.ozgcloud.vorgang.vorgang.GrpcCreateCollaborationRequestData; import de.ozgcloud.vorgang.vorgang.VorgangTestFactory; import de.ozgcloud.vorgang.vorgang.ZustaendigeStelleTestFactory; -public class GrpcCollaborationRequestTestFactory { +public class GrpcCreateCollaborationRequestDataTestFactory { - public static GrpcCollaborationRequest create() { + public static GrpcCreateCollaborationRequestData create() { return createBuilder().build(); } - public static GrpcCollaborationRequest.Builder createBuilder() { - return GrpcCollaborationRequest.newBuilder() + public static GrpcCreateCollaborationRequestData.Builder createBuilder() { + return GrpcCreateCollaborationRequestData.newBuilder() .setVorgangId(VorgangTestFactory.ID) .setZustaendigeStelle(ZustaendigeStelleTestFactory.ORGANISATIONSEINHEIT_ID) .setCollaborationLevel(CreateCollaborationVorgangRequestTestFactory.COLLABORATION_LEVEL); diff --git a/vorgang-manager-server/src/test/java/de/ozgcloud/vorgang/vorgang/VorgangEventListenerITCase.java b/vorgang-manager-server/src/test/java/de/ozgcloud/vorgang/vorgang/VorgangEventListenerITCase.java index dd53e295f92b52ceec3d8c84936d367a8cc8efd7..269f31f0df733254ec0f7a6de31b87c1b9fe3c3f 100644 --- a/vorgang-manager-server/src/test/java/de/ozgcloud/vorgang/vorgang/VorgangEventListenerITCase.java +++ b/vorgang-manager-server/src/test/java/de/ozgcloud/vorgang/vorgang/VorgangEventListenerITCase.java @@ -10,6 +10,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.boot.test.mock.mockito.SpyBean; @@ -32,10 +33,10 @@ import de.ozgcloud.vorgang.files.FileService; @ITCase @SpringBootTest(properties = { - "ozgcloud.processors[0].address: http://test1", - "ozgcloud.processors[0].name: processor1", - "ozgcloud.processors[0].forms[0].formEngineName: formEngineTest1", - "ozgcloud.processors[0].forms[0].formId: ID1" + "ozgcloud.processors[0].address=http://test1", + "ozgcloud.processors[0].name=processor1", + "ozgcloud.processors[0].forms[0].formEngineName=formEngineTest1", + "ozgcloud.processors[0].forms[0].formId=ID1" }) class VorgangEventListenerITCase { @@ -61,6 +62,7 @@ class VorgangEventListenerITCase { @MockBean private ProcessorService vorgagnProcessorService; @MockBean + @Qualifier("processorManager_OzgCloudCommandService") private OzgCloudVorgangService ozgCloudVorgangService; @MockBean private ProcessorVorgangMapper processorVorgangMapper; diff --git a/vorgang-manager-server/src/test/java/de/ozgcloud/vorgang/vorgang/VorgangGrpcServiceTest.java b/vorgang-manager-server/src/test/java/de/ozgcloud/vorgang/vorgang/VorgangGrpcServiceTest.java index e555f66338c6679e81c68b4aa0a2dbcdb483f2b4..124e90200536ff3aabcd41325efa75b5ac4afdd8 100644 --- a/vorgang-manager-server/src/test/java/de/ozgcloud/vorgang/vorgang/VorgangGrpcServiceTest.java +++ b/vorgang-manager-server/src/test/java/de/ozgcloud/vorgang/vorgang/VorgangGrpcServiceTest.java @@ -47,7 +47,7 @@ import de.ozgcloud.vorgang.collaboration.CreateCollaborationVorgangBadRequestExc import de.ozgcloud.vorgang.collaboration.CreateCollaborationVorgangRequest; import de.ozgcloud.vorgang.collaboration.CreateCollaborationVorgangRequestMapper; import de.ozgcloud.vorgang.collaboration.CreateCollaborationVorgangRequestTestFactory; -import de.ozgcloud.vorgang.collaboration.GrpcCollaborationRequestTestFactory; +import de.ozgcloud.vorgang.collaboration.GrpcCreateCollaborationRequestDataTestFactory; import de.ozgcloud.vorgang.collaboration.GrpcCreateCollaborationVorgangResponseTestFactory; import io.grpc.stub.StreamObserver; @@ -349,11 +349,11 @@ class VorgangGrpcServiceTest { @Nested class TestCollaborationRequest { - private static final GrpcCollaborationRequest GRPC_COLLABORATION_REQUEST = GrpcCollaborationRequestTestFactory.create(); + private static final GrpcCreateCollaborationRequestData GRPC_COLLABORATION_REQUEST = GrpcCreateCollaborationRequestDataTestFactory.create(); private static final GrpcCreateCollaborationVorgangRequest REQUEST = GrpcCreateCollaborationVorgangRequest.newBuilder() - .setCollaborationRequest(GRPC_COLLABORATION_REQUEST).build(); - private static final GrpcCreateCollaborationVorgangResponse GRPC_COLLABORATION_RESPONSE = - GrpcCreateCollaborationVorgangResponseTestFactory.create(); + .setRequestData(GRPC_COLLABORATION_REQUEST).build(); + private static final GrpcCreateCollaborationVorgangResponse GRPC_COLLABORATION_RESPONSE = GrpcCreateCollaborationVorgangResponseTestFactory + .create(); @Mock private StreamObserver<GrpcCreateCollaborationVorgangResponse> responseObserver; @@ -413,8 +413,9 @@ class VorgangGrpcServiceTest { @Nested class TestCreateCollaborationVorgang { - private static final GrpcCollaborationRequest GRPC_COLLABORATION_REQUEST = GrpcCollaborationRequestTestFactory.create(); - private static final CreateCollaborationVorgangRequest CREATE_COLLABORATION_VORGANG_REQUEST = CreateCollaborationVorgangRequestTestFactory.create(); + private static final GrpcCreateCollaborationRequestData GRPC_COLLABORATION_REQUEST = GrpcCreateCollaborationRequestDataTestFactory.create(); + private static final CreateCollaborationVorgangRequest CREATE_COLLABORATION_VORGANG_REQUEST = CreateCollaborationVorgangRequestTestFactory + .create(); private static final Vorgang COLLABORATION_VORGANG = VorgangTestFactory.create(); @BeforeEach @@ -462,8 +463,9 @@ class VorgangGrpcServiceTest { @Nested class TestBuildCreateCollaborationVorgangRequest { - private static final GrpcCollaborationRequest GRPC_COLLABORATION_REQUEST = GrpcCollaborationRequestTestFactory.create(); - private static final CreateCollaborationVorgangRequest CREATE_COLLABORATION_VORGANG_REQUEST = CreateCollaborationVorgangRequestTestFactory.create(); + private static final GrpcCreateCollaborationRequestData GRPC_COLLABORATION_REQUEST = GrpcCreateCollaborationRequestDataTestFactory.create(); + private static final CreateCollaborationVorgangRequest CREATE_COLLABORATION_VORGANG_REQUEST = CreateCollaborationVorgangRequestTestFactory + .create(); private static final Vorgang VORGANG = VorgangTestFactory.create(); @BeforeEach