aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/java/org
diff options
context:
space:
mode:
authorXue Gao <xg353y@intl.att.com>2020-01-29 13:58:14 +0000
committerGerrit Code Review <gerrit@onap.org>2020-01-29 13:58:14 +0000
commitb8587538b6d4495977ebde95c21ba659136f43da (patch)
treeab0448f2e74c6aff9f25e88aa9dea115eab074ed /src/test/java/org
parent05db0f21630449ddaaa2f29f8c26685b94c261da (diff)
parent4593656e1f168c067e2a37389aeaa67889c1c173 (diff)
Merge "Create a camel route that would retrieve all the DCAE blueprints"
Diffstat (limited to 'src/test/java/org')
-rw-r--r--src/test/java/org/onap/clamp/clds/model/dcae/DcaeInventoryResponseCacheTestItCase.java (renamed from src/test/java/org/onap/clamp/clds/model/dcae/DcaeInventoryResponseCacheTest.java)47
-rw-r--r--src/test/java/org/onap/clamp/loop/DcaeComponentTest.java89
2 files changed, 135 insertions, 1 deletions
diff --git a/src/test/java/org/onap/clamp/clds/model/dcae/DcaeInventoryResponseCacheTest.java b/src/test/java/org/onap/clamp/clds/model/dcae/DcaeInventoryResponseCacheTestItCase.java
index 26cc831ec..50da40049 100644
--- a/src/test/java/org/onap/clamp/clds/model/dcae/DcaeInventoryResponseCacheTest.java
+++ b/src/test/java/org/onap/clamp/clds/model/dcae/DcaeInventoryResponseCacheTestItCase.java
@@ -24,14 +24,31 @@
package org.onap.clamp.clds.model.dcae;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertEquals;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.ExchangeBuilder;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.clamp.clds.Application;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
-public class DcaeInventoryResponseCacheTest {
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = Application.class)
+public class DcaeInventoryResponseCacheTestItCase {
public static DcaeInventoryCache inventoryCache = new DcaeInventoryCache();
+ @Autowired
+ CamelContext camelContext;
+
/**
* Initialize the responses.
*/
@@ -78,4 +95,32 @@ public class DcaeInventoryResponseCacheTest {
}
}
+ @Test
+ public void testDcaeInventoryResponse() {
+ Exchange exchange = ExchangeBuilder.anExchange(camelContext).build();
+ Exchange exchangeResponse = camelContext.createProducerTemplate()
+ .send("direct:get-all-dcae-blueprint-inventory", exchange);
+ assertThat(exchangeResponse.getIn().getHeader("CamelHttpResponseCode")).isEqualTo(200);
+ Set<DcaeInventoryResponse> blueprint = inventoryCache.getAllBlueprintsPerLoopId("testAsdcServiceId");
+ assertThat(blueprint.size()).isEqualTo(2);
+
+ DcaeInventoryResponse response1 = new DcaeInventoryResponse();
+ response1.setAsdcResourceId("0");
+ response1.setTypeName("testTypeName");
+ response1.setAsdcServiceId("testAsdcServiceId");
+ response1.setBlueprintTemplate("testBlueprintTemplate");
+ response1.setTypeId("testtypeId");
+ DcaeInventoryResponse response2 = new DcaeInventoryResponse();
+ response2.setAsdcResourceId("1");
+ response2.setTypeName("testTypeName2");
+ response2.setAsdcServiceId("testAsdcServiceId");
+ response2.setBlueprintTemplate("testBlueprintTemplate2");
+ response2.setTypeId("testtypeId2");
+
+ Set<DcaeInventoryResponse> expectedBlueprint = new HashSet<>();
+ expectedBlueprint.add(response1);
+ expectedBlueprint.add(response2);
+
+ assertEquals(blueprint, expectedBlueprint);
+ }
}
diff --git a/src/test/java/org/onap/clamp/loop/DcaeComponentTest.java b/src/test/java/org/onap/clamp/loop/DcaeComponentTest.java
index 969215144..0a7c424d0 100644
--- a/src/test/java/org/onap/clamp/loop/DcaeComponentTest.java
+++ b/src/test/java/org/onap/clamp/loop/DcaeComponentTest.java
@@ -30,11 +30,15 @@ import com.google.gson.JsonObject;
import java.io.IOException;
import java.util.HashSet;
+import java.util.List;
import org.apache.camel.Exchange;
import org.apache.camel.Message;
+import org.json.simple.parser.ParseException;
+import org.junit.Ignore;
import org.junit.Test;
import org.mockito.Mockito;
+import org.onap.clamp.clds.model.dcae.DcaeInventoryResponse;
import org.onap.clamp.clds.model.dcae.DcaeOperationStatusResponse;
import org.onap.clamp.loop.components.external.DcaeComponent;
import org.onap.clamp.loop.components.external.ExternalComponentState;
@@ -151,4 +155,89 @@ public class DcaeComponentTest {
ExternalComponentState state9 = dcae.computeState(exchange);
assertThat(state9.getStateName()).isEqualTo("IN_ERROR");
}
+
+ @Test
+ public void convertToDcaeInventoryResponseTest() throws IOException, ParseException {
+ String dcaeFakeResponse = "{\n"
+ + " \"links\": {\n"
+ + " \"previousLink\": {\n"
+ + " \"title\": \"string\",\n"
+ + " \"rel\": \"string\",\n"
+ + " \"uri\": \"string\",\n"
+ + " \"uriBuilder\": {},\n"
+ + " \"rels\": [\n"
+ + " \"string\"\n"
+ + " ],\n"
+ + " \"params\": {\n"
+ + " \"additionalProp1\": \"string\",\n"
+ + " \"additionalProp2\": \"string\",\n"
+ + " \"additionalProp3\": \"string\"\n"
+ + " },\n"
+ + " \"type\": \"string\"\n"
+ + " },\n"
+ + " \"nextLink\": {\n"
+ + " \"title\": \"string\",\n"
+ + " \"rel\": \"string\",\n"
+ + " \"uri\": \"string\",\n"
+ + " \"uriBuilder\": {},\n"
+ + " \"rels\": [\n"
+ + " \"string\"\n"
+ + " ],\n"
+ + " \"params\": {\n"
+ + " \"additionalProp1\": \"string\",\n"
+ + " \"additionalProp2\": \"string\",\n"
+ + " \"additionalProp3\": \"string\"\n"
+ + " },\n"
+ + " \"type\": \"string\"\n"
+ + " }\n"
+ + " },\n"
+ + " \"totalCount\": 0,\n"
+ + " \"items\": [\n"
+ + " {\n"
+ + " \"owner\": \"testOwner\",\n"
+ + " \"application\": \"testApplication\",\n"
+ + " \"component\": \"testComponent\",\n"
+ + " \"typeName\": \"testTypeName\",\n"
+ + " \"typeVersion\": 0,\n"
+ + " \"blueprintTemplate\": \"testBlueprintTemplate\",\n"
+ + " \"serviceIds\": [\n"
+ + " \"serviceId1\", \"serviceId2\"\n"
+ + " ],\n"
+ + " \"vnfTypes\": [\n"
+ + " \"vnfType1\", \"vnfType2\"\n"
+ + " ],\n"
+ + " \"serviceLocations\": [\n"
+ + " \"serviceLocation1\", \"serviceLocation2\"\n"
+ + " ],\n"
+ + " \"asdcServiceId\": \"testAsdcServiceId\",\n"
+ + " \"asdcResourceId\": \"testAsdcResourceId\",\n"
+ + " \"asdcServiceURL\": \"testAsdcServiceURL\",\n"
+ + " \"typeId\": \"testTypeId\",\n"
+ + " \"selfLink\": {\n"
+ + " \"title\": \"selfLinkTitle\",\n"
+ + " \"rel\": \"selfLinkRel\",\n"
+ + " \"uri\": \"selfLinkUri\",\n"
+ + " \"uriBuilder\": {},\n"
+ + " \"rels\": [\n"
+ + " \"string\"\n"
+ + " ],\n"
+ + " \"params\": {\n"
+ + " \"additionalProp1\": \"string\",\n"
+ + " \"additionalProp2\": \"string\",\n"
+ + " \"additionalProp3\": \"string\"\n"
+ + " },\n"
+ + " \"type\": \"string\"\n"
+ + " },\n"
+ + " \"created\": \"2020-01-22T09:38:15.436Z\",\n"
+ + " \"deactivated\": \"2020-01-22T09:38:15.437Z\"\n"
+ + " }\n"
+ + " ]\n"
+ + "}";
+ List<DcaeInventoryResponse> responseObject = DcaeComponent.convertToDcaeInventoryResponse(dcaeFakeResponse);
+ assertThat(responseObject.get(0).getAsdcResourceId()).isEqualTo("testAsdcResourceId");
+ assertThat(responseObject.get(0).getAsdcServiceId()).isEqualTo("testAsdcServiceId");
+ assertThat(responseObject.get(0).getTypeName()).isEqualTo("testTypeName");
+ assertThat(responseObject.get(0).getTypeId()).isEqualTo("testTypeId");
+ assertThat(responseObject.get(0).getBlueprintTemplate()).isEqualTo("testBlueprintTemplate");
+ }
}