diff --git a/xta-adapter/src/test/java/de/ozgcloud/eingang/xta/XtaITCase.java b/xta-adapter/src/test/java/de/ozgcloud/eingang/xta/XtaITCase.java index 4770ddad2845ba6cc98cb9b477fa0755ba066270..425ee370f3eecd52d381a0e17c9dd5ee3d175622 100644 --- a/xta-adapter/src/test/java/de/ozgcloud/eingang/xta/XtaITCase.java +++ b/xta-adapter/src/test/java/de/ozgcloud/eingang/xta/XtaITCase.java @@ -51,17 +51,26 @@ class XtaITCase { class TestRunGetXtaMessages { @BeforeEach void setup() { - // Mock 'start vorgang creation' + mockStartVorgangCreation(); + mockUploadBinaryFiles(); + mockFinishVorgangCreation(); + } + + private void mockStartVorgangCreation() { stubFor( unaryMethod(VorgangServiceGrpc.getStartCreationMethod()) .willReturn(GrpcCreateVorgangResponse.getDefaultInstance()) ); - // Mock 'upload binary files' + } + + private void mockUploadBinaryFiles() { stubFor( clientStreamingMethod(BinaryFileServiceGrpc.getUploadBinaryFileAsStreamMethod()) .willReturn(GrpcUploadBinaryFileResponse.getDefaultInstance()) ); - // Mock 'finish vorgang creation' + } + + private void mockFinishVorgangCreation() { stubFor( unaryMethod(VorgangServiceGrpc.getFinishCreationMethod()) .willReturn(GrpcFinishCreationResponse.getDefaultInstance()) @@ -71,31 +80,38 @@ class XtaITCase { @AfterEach void teardown() { try { - // Expect one Vorgang to be created (start and finish) - verifyThat( - calledMethod(VorgangServiceGrpc.getStartCreationMethod()) - .withRequest(GrpcCreateVorgangRequest::hasEingang), - times(1) - ); - verifyThat( - calledMethod(VorgangServiceGrpc.getFinishCreationMethod()), - times(1) - ); - // Expect upload of two xml representations: xdomea.xml and antrag.xml - verifyThat( - calledMethod(BinaryFileServiceGrpc.getUploadBinaryFileAsStreamMethod()) - .withRequestsContaining(request -> - request.hasMetadata() && - request.getMetadata().getContentType().contains("xml") - ), - times(2) - ); + expectOneVorgangCreateAndFinishCall(); + expectUploadCallForXmlRepresentations(); } finally { xtaMocker.teardownServer(); resetMappings(); } } + private void expectOneVorgangCreateAndFinishCall() { + verifyThat( + calledMethod(VorgangServiceGrpc.getStartCreationMethod()) + .withRequest(GrpcCreateVorgangRequest::hasEingang), + times(1) + ); + verifyThat( + calledMethod(VorgangServiceGrpc.getFinishCreationMethod()), + times(1) + ); + } + + private void expectUploadCallForXmlRepresentations() { + // Expect two xml representations: xdomea.xml and antrag.xml + verifyThat( + calledMethod(BinaryFileServiceGrpc.getUploadBinaryFileAsStreamMethod()) + .withRequestsContaining(request -> + request.hasMetadata() && + request.getMetadata().getContentType().contains("xml") + ), + times(2) + ); + } + @DisplayName("should have three representations with pdf") @TestZipFileNamesWithPdf void shouldHaveThreeRepresentationsWithPdf(String zipFileName) {