1 /*******************************************************************************
2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2022 CTC, Inc.
6 * ==============================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
20 *******************************************************************************/
22 package org.onap.slice.analysis.ms.models.aai;
24 import org.apache.commons.lang3.StringUtils;
25 import org.junit.Test;
26 import org.junit.runner.RunWith;
27 import org.powermock.core.classloader.annotations.PowerMockIgnore;
28 import org.powermock.modules.junit4.PowerMockRunner;
29 import org.powermock.modules.junit4.PowerMockRunnerDelegate;
30 import org.springframework.boot.test.context.SpringBootTest;
31 import org.springframework.test.context.junit4.SpringRunner;
33 import java.util.ArrayList;
34 import java.util.List;
36 import static org.junit.jupiter.api.Assertions.assertEquals;
37 import static org.junit.jupiter.api.Assertions.assertTrue;
39 @RunWith(PowerMockRunner.class)
40 @PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*", "javax.management.*"})
41 @PowerMockRunnerDelegate(SpringRunner.class)
42 @SpringBootTest(classes = ServiceInstanceTest.class)
43 public class ServiceInstanceTest {
46 public void ServiceInstanceTest() {
48 ServiceInstance serviceInstance = new ServiceInstance();
49 serviceInstance.setServiceInstanceId("service-instance-id");
50 serviceInstance.setServiceInstanceName("service-instance-name");
51 serviceInstance.setServiceType("service-type");
52 serviceInstance.setServiceRole("service-role");
53 serviceInstance.setEnvironmentContext("environment-context");
54 serviceInstance.setWorkloadContext("workload-context");
55 serviceInstance.setOrchestrationStatus("orchestration-status");
56 List<Relationship> relationships = new ArrayList<>();
57 RelationshipList relationshipList = new RelationshipList();
58 relationshipList.setRelationship(relationships);
59 serviceInstance.setRelationshipList(relationshipList);
62 assertEquals("service-instance-id", serviceInstance.getServiceInstanceId());
63 assertEquals("service-instance-name", serviceInstance.getServiceInstanceName());
64 assertEquals("service-type", serviceInstance.getServiceType());
65 assertEquals("service-role", serviceInstance.getServiceRole());
66 assertEquals("environment-context", serviceInstance.getEnvironmentContext());
67 assertEquals("workload-context", serviceInstance.getWorkloadContext());
68 assertEquals("orchestration-status", serviceInstance.getOrchestrationStatus());
69 assertEquals(0, serviceInstance.getRelationshipList().getRelationship().size());
73 public void ServiceInstanceEqualsTest() {
75 ServiceInstance serviceInstance = new ServiceInstance();
76 serviceInstance.setServiceInstanceId("service-instance-id");
77 serviceInstance.setServiceInstanceName("service-instance-name");
78 serviceInstance.setServiceType("service-type");
79 serviceInstance.setServiceRole("service-role");
80 serviceInstance.setEnvironmentContext("environment-context");
81 serviceInstance.setWorkloadContext("workload-context");
82 serviceInstance.setOrchestrationStatus("orchestration-status");
83 List<Relationship> relationships = new ArrayList<>();
84 RelationshipList relationshipList = new RelationshipList();
85 relationshipList.setRelationship(relationships);
86 serviceInstance.setRelationshipList(relationshipList);
88 ServiceInstance serviceInstance1 = new ServiceInstance();
89 serviceInstance1.setServiceInstanceId("service-instance-id");
90 serviceInstance1.setServiceInstanceName("service-instance-name");
91 serviceInstance1.setServiceType("service-type");
92 serviceInstance1.setServiceRole("service-role");
93 serviceInstance1.setEnvironmentContext("environment-context");
94 serviceInstance1.setWorkloadContext("workload-context");
95 serviceInstance1.setOrchestrationStatus("orchestration-status");
96 List<Relationship> relationships1 = new ArrayList<>();
97 RelationshipList relationshipList1 = new RelationshipList();
98 relationshipList1.setRelationship(relationships1);
99 serviceInstance1.setRelationshipList(relationshipList1);
101 assertTrue(serviceInstance1.equals(serviceInstance));
102 assertTrue(StringUtils.isNotBlank(serviceInstance.toString()));