aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/test
diff options
context:
space:
mode:
authorBilal A <bilal@research.att.com>2019-08-01 13:53:39 -0400
committerBilal A <bilal@research.att.com>2019-08-01 16:19:51 -0400
commit9b4c685930a76acf43bd5cad5bf2a127a38ed656 (patch)
tree2835e24ae8ba459a3b214229c5a0e0dd83ce33fb /main/src/test
parente39f04fe2180e02c4b6628f79127a9543d4478b6 (diff)
Policy API Junit tests
Issue-ID: POLICY-1771 Signed-off-by: Bilal A <bilal@research.att.com> Change-Id: I8ee41b6df32a97cebdc4e07782e564698d10154b
Diffstat (limited to 'main/src/test')
-rw-r--r--main/src/test/java/org/onap/policy/api/main/rest/TestApiRestServer.java51
1 files changed, 51 insertions, 0 deletions
diff --git a/main/src/test/java/org/onap/policy/api/main/rest/TestApiRestServer.java b/main/src/test/java/org/onap/policy/api/main/rest/TestApiRestServer.java
index 103eb4ca..665616b5 100644
--- a/main/src/test/java/org/onap/policy/api/main/rest/TestApiRestServer.java
+++ b/main/src/test/java/org/onap/policy/api/main/rest/TestApiRestServer.java
@@ -34,6 +34,7 @@ import java.lang.reflect.Modifier;
import java.security.SecureRandom;
import java.security.cert.X509Certificate;
import java.util.Properties;
+
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
@@ -44,6 +45,7 @@ import javax.ws.rs.client.Invocation;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
+
import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.client.ClientProperties;
import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
@@ -135,6 +137,19 @@ public class TestApiRestServer {
private static final String OPS_POLICIES_VFIREWALL_VERSION = "policytypes/"
+ "onap.policies.controlloop.Guard/versions/1.0.0/policies/operational.modifyconfig/versions/1";
+ private static final String GET_DEPLOYED_VERSION_OF_POLICY =
+ "policytypes/onap.policies.monitoring.cdap.tca.hi.lo.app/versions/"
+ + "1.0.0/policies/onap.restart.tca/versions/deployed";
+ private static final String GET_LATEST_VERSION_OF_OPERATIONAL_POLICY =
+ "policytypes/onap.policies.controlloop.Operational/versions/"
+ + "1.0.0/policies/operational.scaleout/versions/latest";
+ private static final String GET_SPECIFIC_VERSION_OF_OPERATIONAL_POLICY =
+ "policytypes/onap.policies.controlloop.Operational/versions/"
+ + "1.0.0/policies/operational.scaleout/versions/3";
+ private static final String DEL_SPECIFIC_VERSION_OF_OPERATIONAL_POLICY =
+ "policytypes/onap.policies.controlloop.Operational/versions/1.0.0/"
+ + "policies/operational.scaleout/versions/1";
+
private static final String KEYSTORE = System.getProperty("user.dir") + "/src/test/resources/ssl/policy-keystore";
private static final CommonTestData COMMON_TEST_DATA = new CommonTestData();
private Main main;
@@ -619,6 +634,42 @@ public class TestApiRestServer {
}).doesNotThrowAnyException();
}
+ @Test
+ public void testGetDeployedVersionsOfPolicy() {
+ assertThatCode(() -> {
+ main = startApiService(true);
+ Response rawResponse = readResource(GET_DEPLOYED_VERSION_OF_POLICY, true);
+ assertEquals(Response.Status.NOT_FOUND.getStatusCode(), rawResponse.getStatus());
+ }).doesNotThrowAnyException();
+ }
+
+ @Test
+ public void testGetLatestVersionOfOperationalPolicy() {
+ assertThatCode(() -> {
+ main = startApiService(true);
+ Response rawResponse = readResource(GET_LATEST_VERSION_OF_OPERATIONAL_POLICY, true);
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), rawResponse.getStatus());
+ }).doesNotThrowAnyException();
+ }
+
+ @Test
+ public void testGetSpecificVersionOfOperationalPolicy() {
+ assertThatCode(() -> {
+ main = startApiService(true);
+ Response rawResponse = readResource(GET_SPECIFIC_VERSION_OF_OPERATIONAL_POLICY, true);
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), rawResponse.getStatus());
+ }).doesNotThrowAnyException();
+ }
+
+ @Test
+ public void testDeleteSpecificVersionOfOperationalPolicy() {
+ assertThatCode(() -> {
+ main = startApiService(true);
+ Response rawResponse = deleteResource(DEL_SPECIFIC_VERSION_OF_OPERATIONAL_POLICY, true);
+ assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), rawResponse.getStatus());
+ }).doesNotThrowAnyException();
+ }
+
private Response createResource(String endpoint, String resourceName, boolean http) throws Exception {
ToscaServiceTemplate rawServiceTemplate = standardCoder.decode(