aboutsummaryrefslogtreecommitdiffstats
path: root/examples/examples-myfirstpolicy/src
diff options
context:
space:
mode:
authorLiam Fallon <liam.fallon@est.tech>2020-03-04 13:32:27 +0000
committerGerrit Code Review <gerrit@onap.org>2020-03-04 13:32:27 +0000
commita9b60303e7e3699cc4df904144592ea6a9b6c586 (patch)
tree1b710f2f899598d3032a6485db54c2e4a8cc92a2 /examples/examples-myfirstpolicy/src
parent9f17d75f75dd087a58822dcc5aa2821267aa2193 (diff)
parent153ad0056c3928116d28eb7e1bb14c4a04a76fc2 (diff)
Merge "replace test sleep() with awaitality package"
Diffstat (limited to 'examples/examples-myfirstpolicy/src')
-rw-r--r--examples/examples-myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/TestSaleAuthListener.java11
1 files changed, 5 insertions, 6 deletions
diff --git a/examples/examples-myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/TestSaleAuthListener.java b/examples/examples-myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/TestSaleAuthListener.java
index 3fce59c93..0169d14cb 100644
--- a/examples/examples-myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/TestSaleAuthListener.java
+++ b/examples/examples-myfirstpolicy/src/test/java/org/onap/policy/apex/examples/myfirstpolicy/TestSaleAuthListener.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,10 +23,12 @@ package org.onap.policy.apex.examples.myfirstpolicy;
import java.util.ArrayList;
import java.util.List;
+import java.util.concurrent.TimeUnit;
import org.onap.policy.apex.core.engine.engine.EnEventListener;
import org.onap.policy.apex.core.engine.event.EnEvent;
-import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities;
+
+import static org.awaitility.Awaitility.await;
/**
* The listener interface for receiving SaleAuth events. The class that is interested in processing a SaleAuth event
@@ -57,9 +60,7 @@ public class TestSaleAuthListener implements EnEventListener {
* @return the result
*/
public EnEvent getResult() {
- while (resultEvents.isEmpty()) {
- ThreadUtilities.sleep(100);
- }
+ await().atMost(200, TimeUnit.MILLISECONDS).until(() -> !resultEvents.isEmpty());
return resultEvents.remove(0);
}
@@ -68,8 +69,6 @@ public class TestSaleAuthListener implements EnEventListener {
*/
@Override
public void onEnEvent(final EnEvent saleauthEvent) {
- ThreadUtilities.sleep(100);
-
if (saleauthEvent != null) {
System.out.println("SaleAuth event from engine:" + saleauthEvent.getName());
resultEvents.add(saleauthEvent);