diff options
author | jhh <jorge.hernandez-herrero@att.com> | 2019-04-24 07:21:05 -0500 |
---|---|---|
committer | jhh <jorge.hernandez-herrero@att.com> | 2019-04-24 09:12:32 -0500 |
commit | 8c05a8d5c676a8db8692f0c494e8edf1fc26aaa2 (patch) | |
tree | 365e866eaa9dbc0e4b0280cdf4314f859c94e21e /feature-lifecycle/src/test/java/org/onap | |
parent | a2e7d569974b018235e821d7bc0bb7a43d75aa2c (diff) |
Add telemetry API interface for Lifecycle
Some cleanup consolidating code in cire telemetry apis.
Issue-ID: POLICY-1687
Signed-off-by: jhh <jorge.hernandez-herrero@att.com>
Change-Id: Ic5241d45eba06796192cca1e82cba5ae53dc5aaf
Signed-off-by: jhh <jorge.hernandez-herrero@att.com>
Diffstat (limited to 'feature-lifecycle/src/test/java/org/onap')
2 files changed, 90 insertions, 2 deletions
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 b96779aa..181b11cf 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 @@ -66,8 +66,6 @@ public class LifecycleStatePassiveTest extends LifecycleStateRunningTest { fsm = new LifecycleFsm(); fsm.setStatusTimerSeconds(15L); simpleStart(); - - assertEquals(0, fsm.client.getSink().getRecentEvents().length); } @Test diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/server/restful/RestLifecycleManagerTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/server/restful/RestLifecycleManagerTest.java new file mode 100644 index 00000000..a11bc020 --- /dev/null +++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/server/restful/RestLifecycleManagerTest.java @@ -0,0 +1,90 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.drools.server.restful; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams; +import org.onap.policy.common.endpoints.http.client.HttpClient; +import org.onap.policy.common.endpoints.http.server.HttpServletServer; +import org.onap.policy.common.utils.network.NetworkUtil; +import org.onap.policy.drools.persistence.SystemPersistence; +import org.onap.policy.models.pdp.enums.PdpState; + +/** + * REST Lifecycle Manager Test. + */ +public class RestLifecycleManagerTest { + + /** + * Set up. + */ + @Before + public void setUp() throws Exception { + HttpServletServer.factory.destroy(); + HttpClient.factory.destroy(); + + SystemPersistence.manager.setConfigurationDir("target/test-classes"); + + HttpClient.factory.build( + BusTopicParams.builder() + .clientName("lifecycle") + .hostname("localhost") + .port(8765) + .basePath("policy/pdp/engine/lifecycle") + .managed(true) + .build()); + + HttpServletServer server = + HttpServletServer.factory.build("lifecycle", "localhost", 8765, "/", true, true); + server.addServletClass("/*", RestLifecycleManager.class.getName()); + server.setSerializationProvider("org.onap.policy.common.gson.JacksonHandler"); + server.waitedStart(5000L); + + Assert.assertTrue(NetworkUtil.isTcpPortOpen("localhost", 8765, 5, 10000L)); + + } + + /** + * Tear down. + */ + @After + public void tearDown() { + HttpServletServer.factory.destroy(); + HttpClient.factory.destroy(); + } + + @Test + public void fsm() { + Response response = HttpClient.factory.get("lifecycle").get("fsm"); + assertNotNull(HttpClient.getBody(response, String.class)); + assertEquals(Status.OK.getStatusCode(), response.getStatus()); + + response = HttpClient.factory.get("lifecycle").get("fsm/state"); + assertEquals(PdpState.TERMINATED, HttpClient.getBody(response, PdpState.class)); + assertEquals(Status.OK.getStatusCode(), response.getStatus()); + } +}
\ No newline at end of file |