aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/at
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/at')
-rw-r--r--src/test/java/at/gv/egiz/moazs/App2MzsServiceTest.java57
1 files changed, 38 insertions, 19 deletions
diff --git a/src/test/java/at/gv/egiz/moazs/App2MzsServiceTest.java b/src/test/java/at/gv/egiz/moazs/App2MzsServiceTest.java
index f13a4dd..2924bf2 100644
--- a/src/test/java/at/gv/egiz/moazs/App2MzsServiceTest.java
+++ b/src/test/java/at/gv/egiz/moazs/App2MzsServiceTest.java
@@ -2,6 +2,7 @@ package at.gv.egiz.moazs;
import at.gv.egiz.moazs.pipeline.DeliveryPipeline;
import at.gv.egiz.moazs.repository.DeliveryRepository;
+import at.gv.zustellung.msg.xsd.DeliveryRequestStatusType;
import at.gv.zustellung.msg.xsd.DeliveryRequestStatusType.DeliveryRequestStatusTypeBuilder;
import at.gv.zustellung.msg.xsd.DeliveryRequestStatusType.Success.SuccessBuilder;
import org.junit.Test;
@@ -16,13 +17,19 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import org.springframework.test.context.junit4.SpringRunner;
+import javax.xml.datatype.DatatypeConfigurationException;
+import javax.xml.datatype.DatatypeFactory;
+import javax.xml.datatype.XMLGregorianCalendar;
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.file.Paths;
+import java.util.GregorianCalendar;
+import static at.gv.zustellung.msg.xsd.DeliveryRequestStatusType.Success.successBuilder;
+import static at.gv.zustellung.msg.xsd.DeliveryRequestStatusType.deliveryRequestStatusTypeBuilder;
import static java.net.http.HttpClient.Version;
import static org.junit.Assert.assertEquals;
@@ -48,17 +55,29 @@ public class App2MzsServiceTest {
public DeliveryPipeline deliveryPipelineThatAlwaysSucceeds() {
return appDeliveryId -> {
- var success = new SuccessBuilder()
+ var success = successBuilder()
+ .withDeliverySystem("Test Delivery System")
+ .withZSDeliveryID("ZD-Delivery-ID")
.withAppDeliveryID(appDeliveryId)
+ .withDeliveryTimestamp(genTimeStamp())
.build();
- var status = new DeliveryRequestStatusTypeBuilder()
+ var status = deliveryRequestStatusTypeBuilder()
.withSuccess(success)
.build();
repository.add(status);
};
}
+
+ private XMLGregorianCalendar genTimeStamp() {
+ try {
+ return DatatypeFactory.newInstance().newXMLGregorianCalendar(new GregorianCalendar());
+ } catch (DatatypeConfigurationException e) {
+ throw new RuntimeException("ups");
+ }
+
+ }
}
@Test
@@ -79,23 +98,23 @@ public class App2MzsServiceTest {
assertEquals(500, response.statusCode());
}
-// @Test
-// public void rejectFormallyIncorrectDeliveryRequest() throws IOException, InterruptedException {
-// var response = sendDeliveryRequestFile("formallyIncorrectDeliveryRequest.soap");
-// assertEquals(500, response.statusCode());
-// }
-//
-// @Test
-// public void rejectRequestWithoutAppDeliveryID() throws IOException, InterruptedException {
-// var response = sendDeliveryRequestFile("missingAppDeliveryId.soap");
-// assertEquals(500, response.statusCode());
-// }
-//
-// @Test
-// public void rejectRequestWithoutMetaData() throws IOException, InterruptedException {
-// var response = sendDeliveryRequestFile("missingMetaData.soap");
-// assertEquals(500, response.statusCode());
-// }
+ @Test
+ public void rejectFormallyIncorrectDeliveryRequest() throws IOException, InterruptedException {
+ var response = sendDeliveryRequestFile("formallyIncorrectDeliveryRequest.soap");
+ assertEquals(500, response.statusCode());
+ }
+
+ @Test
+ public void rejectRequestWithoutAppDeliveryID() throws IOException, InterruptedException {
+ var response = sendDeliveryRequestFile("missingAppDeliveryId.soap");
+ assertEquals(500, response.statusCode());
+ }
+
+ @Test
+ public void rejectRequestWithoutMetaData() throws IOException, InterruptedException {
+ var response = sendDeliveryRequestFile("missingMetaData.soap");
+ assertEquals(500, response.statusCode());
+ }
private HttpResponse<String> sendDeliveryRequestFile(String fileName) throws IOException, InterruptedException {