aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/at
diff options
context:
space:
mode:
authorChristof Rabensteiner <christof.rabensteiner@iaik.tugraz.at>2019-07-09 11:13:35 +0200
committerChristof Rabensteiner <christof.rabensteiner@iaik.tugraz.at>2019-07-09 11:13:35 +0200
commit8e36fa01ea42d282eacdc78d6749daf9ae1ede9c (patch)
treeee691b4ec4a522c0b35c8251d3422702b90d2073 /src/test/java/at
parentd8c668bbca31a835c387a3d52293c9938c424f58 (diff)
downloadmoa-zs-8e36fa01ea42d282eacdc78d6749daf9ae1ede9c.tar.gz
moa-zs-8e36fa01ea42d282eacdc78d6749daf9ae1ede9c.tar.bz2
moa-zs-8e36fa01ea42d282eacdc78d6749daf9ae1ede9c.zip
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.
Diffstat (limited to 'src/test/java/at')
-rw-r--r--src/test/java/at/gv/egiz/moazs/ITMzsServiceTest.java2
-rw-r--r--src/test/java/at/gv/egiz/moazs/SafeResponseToFileSinkTest.java12
-rw-r--r--src/test/java/at/gv/egiz/moazs/SingleThreadedDeliveryPipelineTest.java18
3 files changed, 14 insertions, 18 deletions
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);