aboutsummaryrefslogtreecommitdiffstats
path: root/feature-lifecycle/src/test/java/org
diff options
context:
space:
mode:
authorjhh <jorge.hernandez-herrero@att.com>2020-01-07 12:09:47 -0600
committerjhh <jorge.hernandez-herrero@att.com>2020-01-07 15:22:50 -0600
commit38919c45aafa99d950eddf879b2bc25e95529378 (patch)
treef83af51e2c90cefeae5358e3cadc6171430a16e7 /feature-lifecycle/src/test/java/org
parent4112fecf3d65f1d5dd1eb99334061b2b17c6ad43 (diff)
Remove supported policy types from status message
Issue-ID: POLICY-2233 Signed-off-by: jhh <jorge.hernandez-herrero@att.com> Change-Id: I2168b9616d35ee3b9aa491aaa5d363b8609adb84 Signed-off-by: jhh <jorge.hernandez-herrero@att.com>
Diffstat (limited to 'feature-lifecycle/src/test/java/org')
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActiveTest.java23
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStatePassiveTest.java42
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateRunningTest.java27
3 files changed, 46 insertions, 46 deletions
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActiveTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActiveTest.java
index bb8e4940..2a258305 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActiveTest.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActiveTest.java
@@ -1,6 +1,6 @@
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,7 +34,6 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
-import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;
import org.junit.Before;
import org.junit.Test;
@@ -44,7 +43,6 @@ import org.onap.policy.common.utils.network.NetworkUtil;
import org.onap.policy.models.pdp.concepts.PdpStateChange;
import org.onap.policy.models.pdp.concepts.PdpStatus;
import org.onap.policy.models.pdp.concepts.PdpUpdate;
-import org.onap.policy.models.pdp.enums.PdpMessageType;
import org.onap.policy.models.pdp.enums.PdpState;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
@@ -127,28 +125,19 @@ public class LifecycleStateActiveTest extends LifecycleStateRunningTest {
assertTrue(fsm.statusTask.isDone());
}
- private Callable<Boolean> isStatus(PdpState state) {
- return () -> {
- if (fsm.client.getSink().getRecentEvents().length == 0) {
- return false;
- }
-
- List<String> events = Arrays.asList(fsm.client.getSink().getRecentEvents());
- PdpStatus status =
- new StandardCoder().decode(events.get(events.size() - 1), PdpStatus.class);
-
- return status.getMessageName() == PdpMessageType.PDP_STATUS && state == status.getState();
- };
- }
-
@Test
public void status() {
waitUntil(fsm.getStatusTimerSeconds() + 1, TimeUnit.SECONDS, isStatus(PdpState.ACTIVE));
int preCount = fsm.client.getSink().getRecentEvents().length;
assertTrue(fsm.status());
+ assertEquals(preCount, fsm.client.getSink().getRecentEvents().length);
+
+ fsm.start(controllerSupport.getController());
+ assertTrue(fsm.status());
assertEquals(preCount + 1, fsm.client.getSink().getRecentEvents().length);
+ fsm.stop(controllerSupport.getController());
fsm.shutdown();
}
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStatePassiveTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStatePassiveTest.java
index 341d9857..f242e4c6 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStatePassiveTest.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStatePassiveTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,7 +33,6 @@ import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Collections;
-import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;
import org.junit.Before;
import org.junit.Test;
@@ -94,23 +93,6 @@ public class LifecycleStatePassiveTest extends LifecycleStateRunningTest {
fsm.shutdown();
}
- private Callable<Boolean> isStatus(PdpState state, int count) {
- return () -> {
- if (!fsm.client.getSink().isAlive()) {
- return false;
- }
-
- if (fsm.client.getSink().getRecentEvents().length != count) {
- return false;
- }
-
- String[] events = fsm.client.getSink().getRecentEvents();
- PdpStatus status = new StandardCoder().decode(events[events.length - 1], PdpStatus.class);
-
- return status.getMessageName() == PdpMessageType.PDP_STATUS && state == status.getState();
- };
- }
-
@Test
public void stop() {
simpleStop();
@@ -137,19 +119,23 @@ public class LifecycleStatePassiveTest extends LifecycleStateRunningTest {
@Test
public void status() {
- status(PdpState.PASSIVE);
- fsm.shutdown();
- }
-
- private void status(PdpState state) {
- waitUntil(5, TimeUnit.SECONDS, isStatus(state, 1));
+ assertTrue(fsm.client.getSink().isAlive());
+ assertTrue(fsm.status());
+ assertSame(0, fsm.client.getSink().getRecentEvents().length);
- waitUntil(fsm.statusTimerSeconds + 2, TimeUnit.SECONDS, isStatus(state, 2));
- waitUntil(fsm.statusTimerSeconds + 2, TimeUnit.SECONDS, isStatus(state, 3));
+ fsm.start(controllerSupport.getController());
+ status(PdpState.PASSIVE, 1);
+ fsm.stop(controllerSupport.getController());
+ fsm.shutdown();
+ }
+ private void status(PdpState state, int initial) {
+ waitUntil(5, TimeUnit.SECONDS, isStatus(state, initial));
+ waitUntil(fsm.statusTimerSeconds + 2, TimeUnit.SECONDS, isStatus(state, initial + 1));
+ waitUntil(fsm.statusTimerSeconds + 2, TimeUnit.SECONDS, isStatus(state, initial + 2));
assertTrue(fsm.status());
- waitUntil(200, TimeUnit.MILLISECONDS, isStatus(state, 4));
+ waitUntil(200, TimeUnit.MILLISECONDS, isStatus(state, initial + 3));
}
@Test
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateRunningTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateRunningTest.java
index b5b59767..fe3566db 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateRunningTest.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateRunningTest.java
@@ -1,6 +1,6 @@
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,10 +28,14 @@ import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import org.junit.AfterClass;
import org.junit.BeforeClass;
+import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.common.utils.time.PseudoScheduledExecutorService;
import org.onap.policy.common.utils.time.TestTimeMulti;
import org.onap.policy.drools.persistence.SystemPersistenceConstants;
import org.onap.policy.drools.utils.logging.LoggerUtil;
+import org.onap.policy.models.pdp.concepts.PdpStatus;
+import org.onap.policy.models.pdp.enums.PdpMessageType;
+import org.onap.policy.models.pdp.enums.PdpState;
public abstract class LifecycleStateRunningTest {
@@ -84,4 +88,25 @@ public abstract class LifecycleStateRunningTest {
public void waitUntil(long twait, TimeUnit units, Callable<Boolean> condition) {
time.waitUntil(twait, units, condition);
}
+
+ protected Callable<Boolean> isStatus(PdpState state, int count) {
+ return () -> {
+ if (fsm.client.getSink().getRecentEvents().length != count) {
+ return false;
+ }
+
+ String[] events = fsm.client.getSink().getRecentEvents();
+ PdpStatus status = new StandardCoder().decode(events[events.length - 1], PdpStatus.class);
+
+ if (status.getSupportedPolicyTypes() != null) {
+ return false;
+ }
+
+ return status.getMessageName() == PdpMessageType.PDP_STATUS && state == status.getState();
+ };
+ }
+
+ protected Callable<Boolean> isStatus(PdpState state) {
+ return isStatus(state, fsm.client.getSink().getRecentEvents().length);
+ }
}