aboutsummaryrefslogtreecommitdiffstats
path: root/common/src/test/java/org/openecomp/mso/client/grm
diff options
context:
space:
mode:
Diffstat (limited to 'common/src/test/java/org/openecomp/mso/client/grm')
-rw-r--r--common/src/test/java/org/openecomp/mso/client/grm/GRMBeansTest.java62
-rw-r--r--common/src/test/java/org/openecomp/mso/client/grm/GRMClientTest.java185
-rw-r--r--common/src/test/java/org/openecomp/mso/client/grm/ServiceEndPointListTest.java75
-rw-r--r--common/src/test/java/org/openecomp/mso/client/grm/ServiceEndPointRequestTest.java90
4 files changed, 0 insertions, 412 deletions
diff --git a/common/src/test/java/org/openecomp/mso/client/grm/GRMBeansTest.java b/common/src/test/java/org/openecomp/mso/client/grm/GRMBeansTest.java
deleted file mode 100644
index e22dc7b754..0000000000
--- a/common/src/test/java/org/openecomp/mso/client/grm/GRMBeansTest.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 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.openecomp.mso.client.grm;
-
-import java.util.List;
-
-import org.junit.Test;
-
-import com.openpojo.reflection.PojoClass;
-import com.openpojo.reflection.PojoClassFilter;
-import com.openpojo.reflection.filters.FilterEnum;
-import com.openpojo.reflection.filters.FilterPackageInfo;
-import com.openpojo.reflection.impl.PojoClassFactory;
-import com.openpojo.validation.Validator;
-import com.openpojo.validation.ValidatorBuilder;
-import com.openpojo.validation.affirm.Affirm;
-import com.openpojo.validation.rule.impl.GetterMustExistRule;
-import com.openpojo.validation.rule.impl.SetterMustExistRule;
-import com.openpojo.validation.test.impl.GetterTester;
-import com.openpojo.validation.test.impl.SetterTester;
-
-public class GRMBeansTest {
- private static final String POJO_PACKAGE = "org.openecomp.mso.client.grm.beans";
- private PojoClassFilter filterTestClasses = new FilterTestClasses();
-
- @Test
- public void testPojoStructureAndBehavior() {
- Validator validator = ValidatorBuilder.create()
- .with(new GetterMustExistRule())
- .with(new SetterMustExistRule())
- .with(new SetterTester())
- .with(new GetterTester())
- .build();
-
- validator.validate(POJO_PACKAGE, new FilterPackageInfo(), new FilterEnum(), filterTestClasses);
- }
-
- private static class FilterTestClasses implements PojoClassFilter {
- public boolean include(PojoClass pojoClass) {
- return !pojoClass.getSourcePath().contains("/test-classes/");
- }
- }
-
-}
diff --git a/common/src/test/java/org/openecomp/mso/client/grm/GRMClientTest.java b/common/src/test/java/org/openecomp/mso/client/grm/GRMClientTest.java
deleted file mode 100644
index 6865bbd773..0000000000
--- a/common/src/test/java/org/openecomp/mso/client/grm/GRMClientTest.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 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.openecomp.mso.client.grm;
-
-import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
-import static org.junit.Assert.*;
-
-import java.io.File;
-import java.nio.file.Files;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.ws.rs.core.MediaType;
-
-import org.junit.Ignore;
-import org.junit.Rule;
-import org.junit.Test;
-import org.openecomp.mso.client.grm.exceptions.GRMClientCallFailed;
-import org.openecomp.mso.client.grm.GRMClient;
-import org.openecomp.mso.client.grm.beans.ServiceEndPointRequest;
-import org.openecomp.mso.client.grm.beans.OperationalInfo;
-import org.openecomp.mso.client.grm.beans.Property;
-import org.openecomp.mso.client.grm.beans.ServiceEndPoint;
-import org.openecomp.mso.client.grm.beans.ServiceEndPointList;
-import org.openecomp.mso.client.grm.beans.ServiceEndPointLookupRequest;
-import org.openecomp.mso.client.grm.beans.Version;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.github.tomakehurst.wiremock.junit.WireMockRule;
-import static com.github.tomakehurst.wiremock.client.WireMock.post;
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
-
-public class GRMClientTest {
-
- @Rule
- public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().port(28090));
-
- private ObjectMapper mapper = new ObjectMapper();
-
- @Test
- public void testFind() throws Exception {
- String endpoints = getFileContentsAsString("__files/grm/endpoints.json");
- wireMockRule.stubFor(post(urlPathEqualTo("/GRMLWPService/v1/serviceEndPoint/findRunning"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", MediaType.APPLICATION_JSON)
- .withBody(endpoints)));
-
-
- GRMClient client = new GRMClient();
- ServiceEndPointList sel = client.findRunningServices("TEST.ECOMP_PSL.*", 1, "TEST");
- List<ServiceEndPoint> list = sel.getServiceEndPointList();
- assertEquals(3, list.size());
- }
-
- @Test(expected = GRMClientCallFailed.class)
- public void testFindFail() throws Exception {
-
- wireMockRule.stubFor(post(urlPathEqualTo("/GRMLWPService/v1/serviceEndPoint/findRunning"))
- .willReturn(aResponse()
- .withStatus(400)
- .withHeader("Content-Type", MediaType.APPLICATION_JSON)
- .withBody("")));
-
- GRMClient client = new GRMClient();
- client.findRunningServices("TEST.ECOMP_PSL.*", 1, "TEST");
- }
-
- @Ignore
- @Test
- public void testAdd() throws Exception {
-
- wireMockRule.stubFor(post(urlPathEqualTo("/GRMLWPService/v1/serviceEndPoint/add"))
- .willReturn(aResponse()
- .withStatus(202)
- .withHeader("Content-Type", MediaType.APPLICATION_JSON)
- .withBody("test")));
- wireMockRule.addMockServiceRequestListener((request, response) -> {
- System.out.println("URL Requested => " + request.getAbsoluteUrl());
- System.out.println("Request Body => " + request.getBodyAsString());
- System.out.println("Request Headers => " + request.getHeaders().toString());
- System.out.println("Response Status => " + response.getStatus());
- System.out.println("Response Body => " + response.getBodyAsString());
- });
-
- Version ver = new Version();
- ver.setMajor(1);
- ver.setMinor(0);
- ver.setPatch("0");
-
- ServiceEndPoint sep = new ServiceEndPoint();
- sep.setName("TEST.ECOMP_PSL.Inventory");
- sep.setVersion(ver);
- sep.setHostAddress("127.0.0.1");
- sep.setListenPort("8080");
- sep.setLatitude("37.7022");
- sep.setLongitude("121.9358");
- sep.setContextPath("/");
- sep.setRouteOffer("TEST");
-
- OperationalInfo operInfo = new OperationalInfo();
- operInfo.setCreatedBy("edge");
- operInfo.setUpdatedBy("edge");
-
- sep.setOperationalInfo(operInfo);
-
- Property prop1 = new Property();
- prop1.setName("Environment");
- prop1.setValue("TEST");
-
- Property prop2 = new Property();
- prop2.setName("cpfrun_cluster_name");
- prop2.setValue("testcase_cluster_no_cluster");
-
- List<Property> props = new ArrayList<Property>();
- props.add(prop1);
- props.add(prop2);
-
- sep.setProperties(props);
-
- ServiceEndPointRequest request = new ServiceEndPointRequest();
- request.setEnv("DEV");
- request.setServiceEndPoint(sep);
-
- System.out.println("Request in JSON: " + mapper.writeValueAsString(request));
-
- GRMClient client = new GRMClient();
- client.addServiceEndPoint(request);
- }
-
- @Test(expected = GRMClientCallFailed.class)
- public void testAddFail() throws Exception {
- wireMockRule.stubFor(post(urlPathEqualTo("/GRMLWPService/v1/serviceEndPoint/add"))
- .willReturn(aResponse()
- .withStatus(404)
- .withHeader("Content-Type", MediaType.APPLICATION_JSON)
- .withBody("test")));
- ServiceEndPointRequest request = new ServiceEndPointRequest();
- GRMClient client = new GRMClient();
- client.addServiceEndPoint(request);
- }
-
- @Test
- public void testBuildServiceEndPointLookupRequest() {
- GRMClient client = new GRMClient();
- ServiceEndPointLookupRequest request = client.buildServiceEndPointlookupRequest("TEST.ECOMP_PSL.Inventory", 1, "DEV");
- assertEquals("TEST.ECOMP_PSL.Inventory", request.getServiceEndPoint().getName());
- assertEquals(Integer.valueOf(1), Integer.valueOf(request.getServiceEndPoint().getVersion().getMajor()));
- assertEquals("DEV", request.getEnv());
-
- }
-
- protected String getFileContentsAsString(String fileName) {
- String content = "";
- try {
- ClassLoader classLoader = this.getClass().getClassLoader();
- File file = new File(classLoader.getResource(fileName).getFile());
- content = new String(Files.readAllBytes(file.toPath()));
- }
- catch(Exception e) {
- e.printStackTrace();
- System.out.println("Exception encountered reading " + fileName + ". Error: " + e.getMessage());
- }
- return content;
- }
-}
diff --git a/common/src/test/java/org/openecomp/mso/client/grm/ServiceEndPointListTest.java b/common/src/test/java/org/openecomp/mso/client/grm/ServiceEndPointListTest.java
deleted file mode 100644
index 111fec46eb..0000000000
--- a/common/src/test/java/org/openecomp/mso/client/grm/ServiceEndPointListTest.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 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.openecomp.mso.client.grm;
-
-import java.io.File;
-import java.nio.file.Files;
-import java.util.List;
-import static org.junit.Assert.*;
-import org.junit.Test;
-import org.openecomp.mso.client.grm.beans.ServiceEndPoint;
-import org.openecomp.mso.client.grm.beans.ServiceEndPointList;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-public class ServiceEndPointListTest {
-
- private ObjectMapper mapper = new ObjectMapper();
-
- @Test
- public void testUnmarshall() throws Exception {
- String endpointsJson = getFileContentsAsString("__files/grm/endpoints.json");
- ServiceEndPointList sel = mapper.readValue(endpointsJson, ServiceEndPointList.class);
-
- List<ServiceEndPoint> list = sel.getServiceEndPointList();
- ServiceEndPoint se = list.get(0);
-
- assertEquals(3, list.size());
- assertEquals("dummy.pod.ns.dummy-pod3", se.getName());
- assertEquals(Integer.valueOf(1), Integer.valueOf(se.getVersion().getMajor()));
- assertEquals(Integer.valueOf(0), Integer.valueOf(se.getVersion().getMinor()));
- assertEquals(Integer.valueOf(0), Integer.valueOf(se.getVersion().getPatch()));
- assertEquals("135.144.120.218", se.getHostAddress());
- assertEquals("32004", se.getListenPort());
- assertEquals("37.7022", se.getLatitude());
- assertEquals("121.9358", se.getLongitude());
- assertEquals("/", se.getContextPath());
- assertEquals("edge", se.getOperationalInfo().getCreatedBy());
- assertEquals("edge", se.getOperationalInfo().getUpdatedBy());
- assertEquals("Environment", se.getProperties().get(0).getName());
- assertEquals("DEV", se.getProperties().get(0).getValue());
- }
-
- protected String getFileContentsAsString(String fileName) {
-
- String content = "";
- try {
- ClassLoader classLoader = this.getClass().getClassLoader();
- File file = new File(classLoader.getResource(fileName).getFile());
- content = new String(Files.readAllBytes(file.toPath()));
- }
- catch(Exception e) {
- e.printStackTrace();
- System.out.println("Exception encountered reading " + fileName + ". Error: " + e.getMessage());
- }
- return content;
- }
-}
diff --git a/common/src/test/java/org/openecomp/mso/client/grm/ServiceEndPointRequestTest.java b/common/src/test/java/org/openecomp/mso/client/grm/ServiceEndPointRequestTest.java
deleted file mode 100644
index 230b58bd84..0000000000
--- a/common/src/test/java/org/openecomp/mso/client/grm/ServiceEndPointRequestTest.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 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.openecomp.mso.client.grm;
-
-import static org.junit.Assert.assertEquals;
-import java.util.ArrayList;
-import java.util.List;
-import org.junit.Test;
-import org.openecomp.mso.client.grm.beans.OperationalInfo;
-import org.openecomp.mso.client.grm.beans.Property;
-import org.openecomp.mso.client.grm.beans.ServiceEndPoint;
-import org.openecomp.mso.client.grm.beans.ServiceEndPointRequest;
-import org.openecomp.mso.client.grm.beans.Version;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-public class ServiceEndPointRequestTest {
-
- private ObjectMapper mapper = new ObjectMapper();
-
- @Test
- public void testMarshall() throws Exception {
-
- String expected =
- "{\"serviceEndPoint\":{\"name\":\"TEST.ECOMP_PSL.Inventory\",\"version\":{\"major\":1,\"minor\":0,\"patch\":\"0\"}," +
- "\"hostAddress\":\"127.0.0.1\",\"listenPort\":\"8080\",\"latitude\":\"37.7022\",\"longitude\":\"121.9358\"," +
- "\"contextPath\":\"/\",\"routeOffer\":\"TEST\",\"operationalInfo\":{\"createdBy\":\"edge\",\"updatedBy\":\"edge\"}," +
- "\"properties\":[{\"name\":\"Environment\",\"value\":\"TEST\"},{\"name\":\"cpfrun_cluster_name\"," +
- "\"value\":\"testcase_cluster_no_cluster\"}]},\"env\":\"DEV\"}";
-
- Version ver = new Version();
- ver.setMajor(1);
- ver.setMinor(0);
- ver.setPatch("0");
-
- ServiceEndPoint sep = new ServiceEndPoint();
- sep.setName("TEST.ECOMP_PSL.Inventory");
- sep.setVersion(ver);
- sep.setHostAddress("127.0.0.1");
- sep.setListenPort("8080");
- sep.setLatitude("37.7022");
- sep.setLongitude("121.9358");
- sep.setContextPath("/");
- sep.setRouteOffer("TEST");
-
- OperationalInfo operInfo = new OperationalInfo();
- operInfo.setCreatedBy("edge");
- operInfo.setUpdatedBy("edge");
-
- sep.setOperationalInfo(operInfo);
-
- Property prop1 = new Property();
- prop1.setName("Environment");
- prop1.setValue("TEST");
-
- Property prop2 = new Property();
- prop2.setName("cpfrun_cluster_name");
- prop2.setValue("testcase_cluster_no_cluster");
-
- List<Property> props = new ArrayList<Property>();
- props.add(prop1);
- props.add(prop2);
-
- sep.setProperties(props);
-
- ServiceEndPointRequest request = new ServiceEndPointRequest();
- request.setEnv("DEV");
- request.setServiceEndPoint(sep);
-
- assertEquals(expected, mapper.writeValueAsString(request));
- }
-}