diff options
author | Taka Cho <takamune.cho@att.com> | 2020-07-06 12:02:45 -0400 |
---|---|---|
committer | Taka Cho <takamune.cho@att.com> | 2020-07-06 12:03:58 -0400 |
commit | ae5a28031340a46f2a99e2dbaea0fc00b25cd39e (patch) | |
tree | c527566f75f067947a5dbb2b7b18c93b1ae467c2 | |
parent | 38f2ed14fdd23d4e696e3f4bf9e145b62e4e36ca (diff) |
fix complete the assertion
add isInstanceOf for assertThatThrownBy.
Issue-ID: POLICY-2616
Change-Id: If49255aec6004870d7d2acfeabe258def872c1fa
Signed-off-by: Taka Cho <takamune.cho@att.com>
2 files changed, 19 insertions, 9 deletions
diff --git a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager2Test.java b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager2Test.java index d09c2c88b..86381ebec 100644 --- a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager2Test.java +++ b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager2Test.java @@ -47,6 +47,7 @@ import java.util.function.Consumer; import org.drools.core.WorkingMemory; import org.junit.Before; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.kie.api.runtime.rule.FactHandle; import org.mockito.ArgumentCaptor; import org.mockito.Mock; @@ -199,7 +200,8 @@ public class ControlLoopEventManager2Test { // invalid event.setTarget("unknown-target"); - assertThatThrownBy(() -> new ControlLoopEventManager2(params, event, workMem)); + assertThatThrownBy(() -> new ControlLoopEventManager2(params, event, workMem)) + .isInstanceOf(ControlLoopException.class); } /** @@ -602,13 +604,16 @@ public class ControlLoopEventManager2Test { Map<String, String> orig = event.getAai(); event.setAai(addAai(orig, ControlLoopEventManager2.VSERVER_IS_CLOSED_LOOP_DISABLED, "true")); - assertThatThrownBy(() -> new ControlLoopEventManager2(params, event, workMem)); + assertThatThrownBy(() -> new ControlLoopEventManager2(params, event, workMem)) + .isInstanceOf(IllegalStateException.class); event.setAai(addAai(orig, ControlLoopEventManager2.GENERIC_VNF_IS_CLOSED_LOOP_DISABLED, "true")); - assertThatThrownBy(() -> new ControlLoopEventManager2(params, event, workMem)); + assertThatThrownBy(() -> new ControlLoopEventManager2(params, event, workMem)) + .isInstanceOf(IllegalStateException.class); event.setAai(addAai(orig, ControlLoopEventManager2.PNF_IS_IN_MAINT, "true")); - assertThatThrownBy(() -> new ControlLoopEventManager2(params, event, workMem)); + assertThatThrownBy(() -> new ControlLoopEventManager2(params, event, workMem)) + .isInstanceOf(IllegalStateException.class); } private Map<String, String> addAai(Map<String, String> original, String key, String value) { @@ -625,13 +630,15 @@ public class ControlLoopEventManager2Test { assertThatCode(() -> new ControlLoopEventManager2(params, event, workMem)).doesNotThrowAnyException(); event.setAai(addAai(orig, ControlLoopEventManager2.VSERVER_PROV_STATUS, "inactive")); - assertThatThrownBy(() -> new ControlLoopEventManager2(params, event, workMem)); + assertThatThrownBy(() -> new ControlLoopEventManager2(params, event, workMem)) + .isInstanceOf(IllegalStateException.class); event.setAai(addAai(orig, ControlLoopEventManager2.GENERIC_VNF_PROV_STATUS, "ACTIVE")); assertThatCode(() -> new ControlLoopEventManager2(params, event, workMem)).doesNotThrowAnyException(); - + event.setAai(addAai(orig, ControlLoopEventManager2.GENERIC_VNF_PROV_STATUS, "inactive")); - assertThatThrownBy(() -> new ControlLoopEventManager2(params, event, workMem)); + assertThatThrownBy(() -> new ControlLoopEventManager2(params, event, workMem)) + .isInstanceOf(IllegalStateException.class); } @Test @@ -640,7 +647,8 @@ public class ControlLoopEventManager2Test { for (String value : Arrays.asList("yes", "y", "true", "t", "yEs", "trUe")) { event.setAai(addAai(orig, ControlLoopEventManager2.VSERVER_IS_CLOSED_LOOP_DISABLED, value)); - assertThatThrownBy(() -> new ControlLoopEventManager2(params, event, workMem)); + assertThatThrownBy(() -> new ControlLoopEventManager2(params, event, workMem)) + .isInstanceOf(IllegalStateException.class); } event.setAai(addAai(orig, ControlLoopEventManager2.VSERVER_IS_CLOSED_LOOP_DISABLED, "false")); diff --git a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/EventManagerServicesTest.java b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/EventManagerServicesTest.java index ea3fff311..13ad56259 100644 --- a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/EventManagerServicesTest.java +++ b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/EventManagerServicesTest.java @@ -33,6 +33,7 @@ import org.junit.After; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance; import org.onap.policy.controlloop.actorserviceprovider.ActorService; import org.onap.policy.controlloop.ophistory.OperationHistoryDataManagerImpl; @@ -109,7 +110,8 @@ public class EventManagerServicesTest { @Test public void testMakeDataManager() { - assertThatThrownBy(() -> new EventManagerServices(FILEPFX + "event-svc-invalid-db")); + assertThatThrownBy(() -> new EventManagerServices(FILEPFX + "event-svc-invalid-db")) + .isInstanceOf(IllegalArgumentException.class); } |