Update based on comments
[clamp.git] / src / test / java / org / onap / clamp / clds / model / dcae / DcaeInventoryResponseCacheTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP CLAMP
4  * ================================================================================
5  * Copyright (C) 2019 AT&T Intellectual Property. All rights
6  *                             reserved.
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
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
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  * ===================================================================
21  *
22  */
23
24 package org.onap.clamp.clds.model.dcae;
25
26 import static org.assertj.core.api.Assertions.assertThat;
27
28 import org.junit.BeforeClass;
29 import org.junit.Test;
30
31 public class DcaeInventoryResponseCacheTest {
32
33     public static DcaeInventoryCache inventoryCache = new DcaeInventoryCache();
34
35     /**
36      * Initialize the responses.
37      */
38     @BeforeClass
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");
55
56         inventoryCache.addDcaeInventoryResponse(response1);
57         inventoryCache.addDcaeInventoryResponse(response3);
58         inventoryCache.addDcaeInventoryResponse(response2);
59         inventoryCache.addDcaeInventoryResponse(response4);
60         inventoryCache.addDcaeInventoryResponse(response5);
61     }
62
63     @Test
64     public void testGetAllLoopIds() {
65         assertThat(inventoryCache.getAllLoopIds().size()).isEqualTo(2);
66     }
67
68     @Test
69     public void testGetAllBlueprintsPerLoopId() {
70         int value = 0;
71         for (DcaeInventoryResponse inventoryResponse : inventoryCache.getAllBlueprintsPerLoopId("id1")) {
72             assertThat(Integer.valueOf(inventoryResponse.getAsdcResourceId())).isEqualTo(value++);
73         }
74
75         value = 0;
76         for (DcaeInventoryResponse inventoryResponse : inventoryCache.getAllBlueprintsPerLoopId("id2")) {
77             assertThat(Integer.valueOf(inventoryResponse.getAsdcResourceId())).isEqualTo(value++);
78         }
79     }
80
81 }