2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 AT&T Intellectual Property. All rights
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END============================================
20 * ===================================================================
24 package org.onap.clamp.clds.model.dcae;
26 import static org.assertj.core.api.Assertions.assertThat;
28 import org.junit.BeforeClass;
29 import org.junit.Test;
31 public class DcaeInventoryResponseCacheTest {
33 public static DcaeInventoryCache inventoryCache = new DcaeInventoryCache();
36 * Initialize the responses.
39 public static void createExample() {
40 DcaeInventoryResponse response1 = new DcaeInventoryResponse();
41 response1.setAsdcServiceId("id1");
42 response1.setAsdcResourceId("0");
43 DcaeInventoryResponse response2 = new DcaeInventoryResponse();
44 response2.setAsdcServiceId("id1");
45 response2.setAsdcResourceId("1");
46 DcaeInventoryResponse response3 = new DcaeInventoryResponse();
47 response3.setAsdcServiceId("id1");
48 response3.setAsdcResourceId("2");
49 DcaeInventoryResponse response4 = new DcaeInventoryResponse();
50 response4.setAsdcServiceId("id2");
51 response4.setAsdcResourceId("0");
52 DcaeInventoryResponse response5 = new DcaeInventoryResponse();
53 response5.setAsdcServiceId("id2");
54 response5.setAsdcResourceId("1");
56 inventoryCache.addDcaeInventoryResponse(response1);
57 inventoryCache.addDcaeInventoryResponse(response3);
58 inventoryCache.addDcaeInventoryResponse(response2);
59 inventoryCache.addDcaeInventoryResponse(response4);
60 inventoryCache.addDcaeInventoryResponse(response5);
64 public void testGetAllLoopIds() {
65 assertThat(inventoryCache.getAllLoopIds().size()).isEqualTo(2);
69 public void testGetAllBlueprintsPerLoopId() {
71 for (DcaeInventoryResponse inventoryResponse : inventoryCache.getAllBlueprintsPerLoopId("id1")) {
72 assertThat(Integer.valueOf(inventoryResponse.getAsdcResourceId())).isEqualTo(value++);
76 for (DcaeInventoryResponse inventoryResponse : inventoryCache.getAllBlueprintsPerLoopId("id2")) {
77 assertThat(Integer.valueOf(inventoryResponse.getAsdcResourceId())).isEqualTo(value++);