aboutsummaryrefslogtreecommitdiff
path: root/src/test/java
diff options
context:
space:
mode:
authorChristof Rabensteiner <christof.rabensteiner@iaik.tugraz.at>2019-05-09 16:12:08 +0200
committerChristof Rabensteiner <christof.rabensteiner@iaik.tugraz.at>2019-05-09 16:15:45 +0200
commita95679d191c2ac9cd4d61a5848240163e1676495 (patch)
tree57baff67ff870e1130f75027bc097d5c6de4307b /src/test/java
parentf27ff5780d98e747742140c526fb1e3469bb5748 (diff)
downloadmoa-zs-a95679d191c2ac9cd4d61a5848240163e1676495.tar.gz
moa-zs-a95679d191c2ac9cd4d61a5848240163e1676495.tar.bz2
moa-zs-a95679d191c2ac9cd4d61a5848240163e1676495.zip
Reactivate and Fix Unit Tests
- Relax Validation for now by only validating incoming requests.
Diffstat (limited to 'src/test/java')
-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 {