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 * Modifications copyright (c) 2018 Nokia
21 * ===================================================================
25 package org.onap.clamp.clds.model;
27 import static org.assertj.core.api.Assertions.assertThat;
28 import static org.junit.Assert.assertEquals;
29 import static org.junit.Assert.assertNotNull;
31 import java.io.IOException;
32 import java.io.ObjectInputStream;
33 import java.util.ArrayList;
34 import java.util.List;
35 import org.junit.Test;
37 public class CldsDbServiceCacheTest {
40 public void testConstructor() throws IOException, ClassNotFoundException {
42 CldsServiceData cldsServiceData = new CldsServiceData();
43 cldsServiceData.setServiceUUID("testUUID");
44 cldsServiceData.setAgeOfRecord(100L);
45 cldsServiceData.setServiceInvariantUUID("testInvariantUUID");
47 CldsVfData cldsVfData = new CldsVfData();
48 cldsVfData.setVfName("vf");
50 CldsVfKPIData cldsVfKpiData = new CldsVfKPIData();
51 cldsVfKpiData.setFieldPath("fieldPath");
52 cldsVfKpiData.setFieldPathValue("fieldValue");
54 List<CldsVfKPIData> cldsKpiList = new ArrayList<>();
55 cldsKpiList.add(cldsVfKpiData);
56 cldsVfData.setCldsKPIList(cldsKpiList);
58 List<CldsVfData> cldsVfs = new ArrayList<>();
59 cldsVfs.add(cldsVfData);
60 cldsServiceData.setCldsVfs(cldsVfs);
62 CldsDbServiceCache cldsDbServiceCache = new CldsDbServiceCache(cldsServiceData);
65 ObjectInputStream reader = new ObjectInputStream(cldsDbServiceCache.getCldsDataInstream());
66 CldsServiceData cldsServiceDataResult = (CldsServiceData) reader.readObject();
69 assertThat(cldsServiceDataResult).isNotNull();
70 assertThat(cldsServiceDataResult.getCldsVfs()).hasSize(1);
71 assertThat(cldsServiceDataResult.getCldsVfs().get(0).getCldsKPIList()).hasSize(1);
73 assertThat(cldsServiceDataResult.getServiceInvariantUUID()).isEqualTo("testInvariantUUID");
74 assertThat(cldsServiceDataResult.getServiceUUID()).isEqualTo("testUUID");
75 assertThat(cldsServiceDataResult.getAgeOfRecord()).isEqualTo(100L);