aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsebdet <sebastien.determe@intl.att.com>2019-12-09 12:58:20 +0100
committersebdet <sebastien.determe@intl.att.com>2019-12-09 14:18:15 +0100
commit47767ece79658f9c2f20fe77af6cee0ca6c027df (patch)
tree77208aa41f79cce505dd1687d8be85a8eac340fa
parent1ebfe6b467e5a6a42c756f225397da76f9e3dfc2 (diff)
Add dcae structure
Add the DCAE structure to handle the sorting of the loops defined in the DCAE inventory. Issue-ID: CLAMP-575 Change-Id: I52cffd1d1812f5d3e5802e46d6c5147dafb4a7f5 Signed-off-by: sebdet <sebastien.determe@intl.att.com>
-rw-r--r--src/main/java/org/onap/clamp/clds/model/dcae/DcaeInventoryCache.java57
-rw-r--r--src/main/java/org/onap/clamp/clds/model/dcae/DcaeInventoryResponse.java62
-rw-r--r--src/main/resources/boot-message.txt29
-rw-r--r--src/test/java/org/onap/clamp/clds/model/dcae/DcaeInventoryResponseCacheTest.java78
-rw-r--r--src/test/java/org/onap/clamp/clds/model/dcae/DcaeInventoryResponseTest.java60
5 files changed, 270 insertions, 16 deletions
diff --git a/src/main/java/org/onap/clamp/clds/model/dcae/DcaeInventoryCache.java b/src/main/java/org/onap/clamp/clds/model/dcae/DcaeInventoryCache.java
new file mode 100644
index 000000000..b383c18bf
--- /dev/null
+++ b/src/main/java/org/onap/clamp/clds/model/dcae/DcaeInventoryCache.java
@@ -0,0 +1,57 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * 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.clamp.clds.model.dcae;
+
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * This class stores the multiple DcaeInventoryResponse coming back from DCAE.
+ * The structure is a map of list indexed by asdcServiceId. The list is sorted
+ * by asdcResourceId. Therefore it's possible to retrieve all the loops defined
+ * in the DCAE inventory and created by DCAE Mod.
+ */
+public class DcaeInventoryCache {
+
+ private Map<String, Set<DcaeInventoryResponse>> blueprintsMap = new ConcurrentHashMap<>();
+
+ public void addDcaeInventoryResponse(DcaeInventoryResponse inventoryResponse) {
+ Set<DcaeInventoryResponse> responsesSet = blueprintsMap.get(inventoryResponse.getAsdcServiceId());
+ if (responsesSet == null) {
+ responsesSet = new TreeSet<DcaeInventoryResponse>();
+ blueprintsMap.put(inventoryResponse.getAsdcServiceId(), responsesSet);
+ }
+ responsesSet.add(inventoryResponse);
+ }
+
+ public Set<String> getAllLoopIds() {
+ return this.blueprintsMap.keySet();
+ }
+
+ public Set<DcaeInventoryResponse> getAllBlueprintsPerLoopId(String loopId) {
+ return blueprintsMap.getOrDefault(loopId, new TreeSet<>());
+ }
+}
diff --git a/src/main/java/org/onap/clamp/clds/model/dcae/DcaeInventoryResponse.java b/src/main/java/org/onap/clamp/clds/model/dcae/DcaeInventoryResponse.java
index 972450665..bdf6e70f5 100644
--- a/src/main/java/org/onap/clamp/clds/model/dcae/DcaeInventoryResponse.java
+++ b/src/main/java/org/onap/clamp/clds/model/dcae/DcaeInventoryResponse.java
@@ -3,7 +3,7 @@
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -29,7 +29,7 @@ import com.google.gson.annotations.Expose;
/**
* This class maps the DCAE inventory answer to a nice pojo.
*/
-public class DcaeInventoryResponse {
+public class DcaeInventoryResponse implements Comparable<DcaeInventoryResponse> {
@Expose
private String typeName;
@@ -37,6 +37,25 @@ public class DcaeInventoryResponse {
@Expose
private String typeId;
+ @Expose
+ private String blueprintTemplate;
+
+ /**
+ * This field will be used to know all blueprints associated a loop.
+ */
+ @Expose
+ private String asdcServiceId;
+
+ /**
+ * This field will be used to know to order of each blueprint microservice in a
+ * loop.
+ */
+ @Expose
+ private String asdcResourceId;
+
+ @Expose
+ private String selfLink;
+
public String getTypeName() {
return typeName;
}
@@ -52,4 +71,43 @@ public class DcaeInventoryResponse {
public void setTypeId(String typeId) {
this.typeId = typeId;
}
+
+ public String getBlueprintTemplate() {
+ return blueprintTemplate;
+ }
+
+ public void setBlueprintTemplate(String blueprintTemplate) {
+ this.blueprintTemplate = blueprintTemplate;
+ }
+
+ public String getAsdcServiceId() {
+ return asdcServiceId;
+ }
+
+ public void setAsdcServiceId(String asdcServiceId) {
+ this.asdcServiceId = asdcServiceId;
+ }
+
+ public String getAsdcResourceId() {
+ return asdcResourceId;
+ }
+
+ public void setAsdcResourceId(String asdcResourceId) {
+ this.asdcResourceId = asdcResourceId;
+ }
+
+ public String getSelfLink() {
+ return selfLink;
+ }
+
+ public void setSelfLink(String selfLink) {
+ this.selfLink = selfLink;
+ }
+
+ @Override
+ public int compareTo(DcaeInventoryResponse otherResponse) {
+ int thisResourceId = Integer.parseInt(this.asdcResourceId);
+ int otherResourceId = Integer.parseInt(otherResponse.getAsdcResourceId());
+ return (thisResourceId < otherResourceId ? -1 : (thisResourceId > otherResourceId ? 1 : 0));
+ }
}
diff --git a/src/main/resources/boot-message.txt b/src/main/resources/boot-message.txt
index 46b0a6faa..a1c646f53 100644
--- a/src/main/resources/boot-message.txt
+++ b/src/main/resources/boot-message.txt
@@ -1,15 +1,16 @@
-
-
- ▐ ▄ ▄▄▄· ▄▄▄· ▄▄▄ .▄▄▌ ▄▄▄· ▄▄▌ ▄▄▄▄▄
-▪ •█▌▐█▐█ ▀█ ▐█ ▄█ ▀▄.▀·██• ▐█ ▀█ ██• •██ ▪
- ▄█▀▄ ▐█▐▐▌▄█▀▀█ ██▀· ▐▀▀▪▄██▪ ▄█▀▀█ ██▪ ▐█.▪ ▄█▀▄
-▐█▌.▐▌██▐█▌▐█ ▪▐▌▐█▪·• ▐█▄▄▌▐█▌▐▌ ▐█ ▪▐▌▐█▌▐▌▐█▌·▐█▌.▐▌
- ▀█▄▀▪▀▀ █▪ ▀ ▀ .▀ ▀▀▀ .▀▀▀ ▀ ▀ .▀▀▀ ▀▀▀ ▀█▄▀▪
- ▄▄· ▄▄▌ ▄▄▄· • ▌ ▄ ·. ▄▄▄·
- ▐█ ▌▪██• ▐█ ▀█ ·██ ▐███▪▐█ ▄█
- ██ ▄▄██▪ ▄█▀▀█ ▐█ ▌▐▌▐█· ██▀·
- ▐███▌▐█▌▐▌▐█ ▪▐▌██ ██▌▐█▌▐█▪·•
- ·▀▀▀ .▀▀▀ ▀ ▀ ▀▀ █▪▀▀▀.▀
-
- :: Starting :: \ No newline at end of file
+ ___ ____ ____ ____ _____ ____ ____ ____ __ _ _____ __ __ ____ ______
+ / \ | \ / T| \ | || \ / T| \ | l/ ]| || T T| \| T
+Y Y| _ YY o || o ) | __j| D )Y o || _ Y| ' / | __j| | || D ) |
+| O || | || || _/ | l_ | / | || | || \ | l_ | | || /l_j l_j
+| || | || _ || | | _] | \ | _ || | || Y| _] | : || \ | |
+l !| | || | || | | T | . Y| | || | || . || T l || . Y | |
+ \___/ l__j__jl__j__jl__j l__j l__j\_jl__j__jl__j__jl__j\_jl__j \__,_jl__j\_j l__j
+ __ _ ____ ___ ___ ____
+ / ]| T / T| T T| \
+ / / | | Y o || _ _ || o )
+ / / | l___ | || \_/ || _/
+ / \_ | T| _ || | || |
+ \ || || | || | || |
+ \____jl_____jl__j__jl___j___jl__j
+ :: Starting :: \ No newline at end of file
diff --git a/src/test/java/org/onap/clamp/clds/model/dcae/DcaeInventoryResponseCacheTest.java b/src/test/java/org/onap/clamp/clds/model/dcae/DcaeInventoryResponseCacheTest.java
new file mode 100644
index 000000000..70d1b4ac2
--- /dev/null
+++ b/src/test/java/org/onap/clamp/clds/model/dcae/DcaeInventoryResponseCacheTest.java
@@ -0,0 +1,78 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * 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.clamp.clds.model.dcae;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class DcaeInventoryResponseCacheTest {
+
+ public static DcaeInventoryCache inventoryCache = new DcaeInventoryCache();
+
+ @BeforeClass
+ public static void createExample() {
+ DcaeInventoryResponse response1 = new DcaeInventoryResponse();
+ response1.setAsdcServiceId("id1");
+ response1.setAsdcResourceId("0");
+ DcaeInventoryResponse response2 = new DcaeInventoryResponse();
+ response2.setAsdcServiceId("id1");
+ response2.setAsdcResourceId("1");
+ DcaeInventoryResponse response3 = new DcaeInventoryResponse();
+ response3.setAsdcServiceId("id1");
+ response3.setAsdcResourceId("2");
+ DcaeInventoryResponse response4 = new DcaeInventoryResponse();
+ response4.setAsdcServiceId("id2");
+ response4.setAsdcResourceId("0");
+ DcaeInventoryResponse response5 = new DcaeInventoryResponse();
+ response5.setAsdcServiceId("id2");
+ response5.setAsdcResourceId("1");
+
+ inventoryCache.addDcaeInventoryResponse(response1);
+ inventoryCache.addDcaeInventoryResponse(response3);
+ inventoryCache.addDcaeInventoryResponse(response2);
+ inventoryCache.addDcaeInventoryResponse(response4);
+ inventoryCache.addDcaeInventoryResponse(response5);
+ }
+
+ @Test
+ public void testGetAllLoopIds() {
+ assertThat(inventoryCache.getAllLoopIds().size()).isEqualTo(2);
+ }
+
+ @Test
+ public void testGetAllBlueprintsPerLoopId() {
+ int value = 0;
+ for (DcaeInventoryResponse inventoryResponse : inventoryCache.getAllBlueprintsPerLoopId("id1")) {
+ assertThat(Integer.valueOf(inventoryResponse.getAsdcResourceId())).isEqualTo(value++);
+ }
+
+ value = 0;
+ for (DcaeInventoryResponse inventoryResponse : inventoryCache.getAllBlueprintsPerLoopId("id2")) {
+ assertThat(Integer.valueOf(inventoryResponse.getAsdcResourceId())).isEqualTo(value++);
+ }
+ }
+
+}
diff --git a/src/test/java/org/onap/clamp/clds/model/dcae/DcaeInventoryResponseTest.java b/src/test/java/org/onap/clamp/clds/model/dcae/DcaeInventoryResponseTest.java
new file mode 100644
index 000000000..fc4872c3b
--- /dev/null
+++ b/src/test/java/org/onap/clamp/clds/model/dcae/DcaeInventoryResponseTest.java
@@ -0,0 +1,60 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * 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.clamp.clds.model.dcae;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.util.TreeSet;
+
+import org.junit.Test;
+
+public class DcaeInventoryResponseTest {
+
+ @Test
+ public void testComparator() {
+ DcaeInventoryResponse response1 = new DcaeInventoryResponse();
+ response1.setAsdcServiceId("id1");
+ response1.setAsdcResourceId("0");
+ DcaeInventoryResponse response2 = new DcaeInventoryResponse();
+ response2.setAsdcServiceId("id2");
+ response2.setAsdcResourceId("1");
+ DcaeInventoryResponse response3 = new DcaeInventoryResponse();
+ response3.setAsdcServiceId("id3");
+ response3.setAsdcResourceId("2");
+ DcaeInventoryResponse response4 = new DcaeInventoryResponse();
+ response4.setAsdcServiceId("id4");
+ response4.setAsdcResourceId("3");
+
+ TreeSet<DcaeInventoryResponse> responseSet = new TreeSet<>();
+ responseSet.add(response4);
+ responseSet.add(response3);
+ responseSet.add(response1);
+ responseSet.add(response2);
+
+ int value = 0;
+ for (DcaeInventoryResponse inventoryResponse : responseSet) {
+ assertThat(Integer.valueOf(inventoryResponse.getAsdcResourceId()) == value++).isTrue();
+ }
+ }
+}