From 5d125d6167a57517296c8c8ea5bdd2366b9f9191 Mon Sep 17 00:00:00 2001 From: Christof Rabensteiner Date: Tue, 20 Aug 2019 13:02:03 +0200 Subject: Replace Thread.sleep with Await --- .../at/gv/egiz/moazs/preprocess/ConfigUtil.java | 2 +- src/test/java/at/gv/egiz/moazs/ITEndToEndTest.java | 24 ++++++++++------------ 2 files changed, 12 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/main/java/at/gv/egiz/moazs/preprocess/ConfigUtil.java b/src/main/java/at/gv/egiz/moazs/preprocess/ConfigUtil.java index ec7b7c8..48c1605 100644 --- a/src/main/java/at/gv/egiz/moazs/preprocess/ConfigUtil.java +++ b/src/main/java/at/gv/egiz/moazs/preprocess/ConfigUtil.java @@ -398,7 +398,7 @@ public class ConfigUtil { return customHeaders .stream() .collect(toMap( - h -> h.getName(), + CustomHTTPHeaderType::getName, h -> List.of(h.getValue()))); } diff --git a/src/test/java/at/gv/egiz/moazs/ITEndToEndTest.java b/src/test/java/at/gv/egiz/moazs/ITEndToEndTest.java index fd2e629..29b7b53 100644 --- a/src/test/java/at/gv/egiz/moazs/ITEndToEndTest.java +++ b/src/test/java/at/gv/egiz/moazs/ITEndToEndTest.java @@ -12,6 +12,8 @@ import at.gv.zustellung.msg.xsd.DeliveryRequestStatusType; import at.gv.zustellung.msg.xsd.DeliveryRequestType; import at.gv.zustellung.tnvz.xsd.TNVZServicePort; import org.apache.commons.io.FileUtils; +import org.awaitility.Awaitility; +import org.awaitility.Duration; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -45,6 +47,7 @@ import static at.gv.zustellung.msg.xsd.DeliveryRequestStatusType.deliveryRequest import static java.net.http.HttpResponse.BodyHandlers.ofString; import static org.apache.commons.io.FileUtils.readFileToString; import static org.assertj.core.api.Assertions.assertThat; +import static org.awaitility.Awaitility.await; import static org.mockito.Mockito.*; @RunWith(SpringRunner.class) @@ -165,10 +168,10 @@ public class ITEndToEndTest { DELIVERY_SYSTEM, zsDeliveryID, appDeliveryID, GZ_WATERMARK, timestamp }); sendMsgResponse(msgStatus); - Thread.sleep(100); - verify(APP).forwardStatus(any()); - assertStatusWrittenToFileSystem(saveSinkFolder, statusResponseID); - assertStatusWasLogged(); + await().untilAsserted(() -> { + verify(APP).forwardStatus(any()); + assertStatusWrittenToFileSystem(saveSinkFolder, statusResponseID); + }); // zusemsg sends async notification var notificationResponseID = NotificationResponse.getResponseID(appDeliveryID); @@ -176,10 +179,10 @@ public class ITEndToEndTest { DELIVERY_SYSTEM, zsDeliveryID, appDeliveryID, GZ_WATERMARK, timestamp, timestamp }); sendMsgResponse(notification); - Thread.sleep(100); - verify(APP).forwardNotification(any()); - assertStatusWrittenToFileSystem(saveSinkFolder, notificationResponseID); - assertStatusWasLogged(); + await().untilAsserted(() -> { + verify(APP).forwardNotification(any()); + assertStatusWrittenToFileSystem(saveSinkFolder, notificationResponseID); + }); } @@ -215,11 +218,6 @@ public class ITEndToEndTest { } } - private void assertStatusWasLogged() { - //todo - } - - private String formatFile(String templateFile, String... values) throws IOException { var path = basePath + templateFile; var templateString = FileUtils.readFileToString(new File(path), StandardCharsets.UTF_8); -- cgit v1.2.3