From 8e36fa01ea42d282eacdc78d6749daf9ae1ede9c Mon Sep 17 00:00:00 2001 From: Christof Rabensteiner Date: Tue, 9 Jul 2019 11:13:35 +0200 Subject: Refactor: Merge BinaryRepository into DeliveryRepository - Reason: Components, which rely on one of those, usually also rely on the other, so merging them reduces amount of dependencies. - Frame operations in DeliveryRepository API as "store" and "retrieve" operations. - Rename: Convert *Id in local variable names to upper case. --- src/test/java/at/gv/egiz/moazs/ITMzsServiceTest.java | 2 +- .../at/gv/egiz/moazs/SafeResponseToFileSinkTest.java | 12 ++++++------ .../egiz/moazs/SingleThreadedDeliveryPipelineTest.java | 18 +++++++----------- 3 files changed, 14 insertions(+), 18 deletions(-) (limited to 'src/test/java/at') diff --git a/src/test/java/at/gv/egiz/moazs/ITMzsServiceTest.java b/src/test/java/at/gv/egiz/moazs/ITMzsServiceTest.java index 22aa03f..a93c720 100644 --- a/src/test/java/at/gv/egiz/moazs/ITMzsServiceTest.java +++ b/src/test/java/at/gv/egiz/moazs/ITMzsServiceTest.java @@ -64,7 +64,7 @@ public class ITMzsServiceTest { .withSuccess(success) .build(); - repository.add(new RequestStatusResponse(status)); + repository.store(new RequestStatusResponse(status)); }; } diff --git a/src/test/java/at/gv/egiz/moazs/SafeResponseToFileSinkTest.java b/src/test/java/at/gv/egiz/moazs/SafeResponseToFileSinkTest.java index 9092dfb..c85c601 100644 --- a/src/test/java/at/gv/egiz/moazs/SafeResponseToFileSinkTest.java +++ b/src/test/java/at/gv/egiz/moazs/SafeResponseToFileSinkTest.java @@ -1,7 +1,7 @@ package at.gv.egiz.moazs; import at.gv.egiz.moazs.process.SafeResponseToFileSink; -import at.gv.egiz.moazs.repository.BinaryRepository; +import at.gv.egiz.moazs.repository.DeliveryRepository; import at.gv.egiz.moazs.scheme.Marshaller; import at.gv.egiz.moazs.scheme.RequestStatusResponse; import org.apache.commons.io.FileUtils; @@ -36,7 +36,7 @@ public class SafeResponseToFileSinkTest { private final String root = "./target/tmp/SafeResponseToFileSinkTestOut"; @Mock - private BinaryRepository repository; + private DeliveryRepository repository; @Mock private Marshaller marshaller; @@ -90,15 +90,15 @@ public class SafeResponseToFileSinkTest { private RequestStatusResponse setupMocks(String fileContent) { - var appDeliveryId = "app-delivery-id"; - var responseId = RequestStatusResponse.getResponseID(appDeliveryId); + var appDeliveryID = "app-delivery-id"; + var responseID = RequestStatusResponse.getResponseID(appDeliveryID); - when(repository.get(responseId)) + when(repository.retrieveBinaryResponse(responseID)) .thenReturn(of(fileContent.getBytes(StandardCharsets.UTF_8))); when(marshaller.marshallXml(any())).thenReturn(fileContent); var success = successBuilder() - .withAppDeliveryID(appDeliveryId) + .withAppDeliveryID(appDeliveryID) .build(); var status = deliveryRequestStatusTypeBuilder() diff --git a/src/test/java/at/gv/egiz/moazs/SingleThreadedDeliveryPipelineTest.java b/src/test/java/at/gv/egiz/moazs/SingleThreadedDeliveryPipelineTest.java index 4154db9..e245eb1 100644 --- a/src/test/java/at/gv/egiz/moazs/SingleThreadedDeliveryPipelineTest.java +++ b/src/test/java/at/gv/egiz/moazs/SingleThreadedDeliveryPipelineTest.java @@ -3,8 +3,6 @@ package at.gv.egiz.moazs; import at.gv.egiz.moazs.process.DeliveryPipeline; import at.gv.egiz.moazs.process.SingleThreadedDeliveryPipeline; import at.gv.egiz.moazs.client.TnvzHelper; -import at.gv.egiz.moazs.repository.BinaryRepository; -import at.gv.egiz.moazs.repository.InMemoryBinaryRepository; import at.gv.egiz.moazs.scheme.*; import at.gv.egiz.moazs.client.ClientFactory; import at.gv.egiz.moazs.repository.DeliveryRepository; @@ -39,8 +37,7 @@ import static org.mockito.Mockito.*; @RunWith(MockitoJUnitRunner.class) public class SingleThreadedDeliveryPipelineTest { - private DeliveryRepository repository = new InMemoryDeliveryRepository(); - private BinaryRepository binaryRepository = new InMemoryBinaryRepository(30); + private DeliveryRepository repository = new InMemoryDeliveryRepository(100); @Mock private TnvzHelper tnvzHelper; @@ -67,7 +64,6 @@ public class SingleThreadedDeliveryPipelineTest { public void setup() { pipeline = new SingleThreadedDeliveryPipeline( repository, - binaryRepository, tnvzHelper, converter, clientFactory, @@ -82,7 +78,7 @@ public class SingleThreadedDeliveryPipelineTest { pipeline.processRequest(appDeliveryID); verifyZeroInteractions(tnvzHelper); - var response = repository.getResponse(getResponseID(appDeliveryID)).get(); + var response = repository.retrieveResponse(getResponseID(appDeliveryID)).get(); var actualStatus = (DeliveryRequestStatusType) response.getResponse(); assertThat(actualStatus).isEqualTo(expectedStatus); @@ -98,7 +94,7 @@ public class SingleThreadedDeliveryPipelineTest { pipeline.processRequest(appDeliveryID); var responseID = getResponseID(appDeliveryID); - var response = repository.getResponse(responseID).get(); + var response = repository.retrieveResponse(responseID).get(); var status = (DeliveryRequestStatusType) response.getResponse(); var actualCode = status.getError().getErrorInfo().getCode(); @@ -113,7 +109,7 @@ public class SingleThreadedDeliveryPipelineTest { var expectedStatus = setupMocks(appDeliveryID, true); pipeline.processRequest(appDeliveryID); - var response = repository.getResponse(getResponseID(appDeliveryID)).get(); + var response = repository.retrieveResponse(getResponseID(appDeliveryID)).get(); var actualStatus = (DeliveryRequestStatusType) response.getResponse(); assertThat(actualStatus).isEqualTo(expectedStatus); @@ -126,7 +122,7 @@ public class SingleThreadedDeliveryPipelineTest { doThrow(moaZSException("Signature Invalid!")).when(verifier).verify(any()); pipeline.processRequest(appDeliveryID); - var response = repository.getResponse(getResponseID(appDeliveryID)).get(); + var response = repository.retrieveResponse(getResponseID(appDeliveryID)).get(); var status = (DeliveryRequestStatusType) response.getResponse(); var actualCode = status.getError().getErrorInfo().getCode(); @@ -141,8 +137,8 @@ public class SingleThreadedDeliveryPipelineTest { var status = setupStatus(appDeliveryId); var signedStatus = new byte[0]; var identification = IdentificationType.identificationTypeBuilder().build(); - repository.add(mzsRequest); - binaryRepository.add(getResponseID(appDeliveryId), signedStatus); + repository.store(mzsRequest); + repository.store(getResponseID(appDeliveryId), signedStatus); when(converter.convert(eq(mzsRequest) )).thenReturn(msgRequest); when(converter.convert(eq(mzsRequest), any())).thenReturn(msgRequest); -- cgit v1.2.3