2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2018 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;
26 import static org.junit.Assert.assertEquals;
27 import static org.junit.Assert.assertNotNull;
29 import java.io.IOException;
30 import java.io.ObjectInputStream;
31 import java.util.ArrayList;
32 import java.util.List;
34 import org.junit.Test;
36 public class CldsDbServiceCacheTest {
39 public void testConstructor() throws IOException, ClassNotFoundException {
40 CldsServiceData cldsServiceData = new CldsServiceData();
41 cldsServiceData.setServiceUUID("testUUID");
42 cldsServiceData.setAgeOfRecord(Long.valueOf(100));
43 cldsServiceData.setServiceInvariantUUID("testInvariantUUID");
44 CldsVfData cldsVfData = new CldsVfData();
45 cldsVfData.setVfName("vf");
46 CldsVfKPIData cldsVfKpiData = new CldsVfKPIData();
47 cldsVfKpiData.setFieldPath("fieldPath");
48 cldsVfKpiData.setFieldPathValue("fieldValue");
49 List<CldsVfKPIData> cldsKpiList = new ArrayList<>();
50 cldsKpiList.add(cldsVfKpiData);
51 cldsVfData.setCldsKPIList(cldsKpiList);
52 List<CldsVfData> cldsVfs = new ArrayList<>();
53 cldsVfs.add(cldsVfData);
54 cldsServiceData.setCldsVfs(cldsVfs);
55 CldsDbServiceCache cldsDbServiceCache = new CldsDbServiceCache(cldsServiceData);
56 ObjectInputStream reader = new ObjectInputStream(cldsDbServiceCache.getCldsDataInstream());
57 CldsServiceData cldsServiceDataResult = (CldsServiceData) reader.readObject();
58 assertNotNull(cldsServiceDataResult);
59 assertNotNull(cldsServiceDataResult.getCldsVfs());
60 assertEquals(cldsServiceDataResult.getCldsVfs().size(), 1);
61 assertNotNull(cldsServiceDataResult.getCldsVfs().get(0).getCldsKPIList());
62 assertEquals(cldsServiceDataResult.getCldsVfs().get(0).getCldsKPIList().size(), 1);
63 assertEquals(cldsServiceDataResult.getServiceInvariantUUID(), "testInvariantUUID");
64 assertEquals(cldsServiceDataResult.getServiceUUID(), "testUUID");
65 assertEquals(cldsServiceDataResult.getAgeOfRecord(), Long.valueOf(100L));