2 * ============LICENSE_START======================================================= ONAP : SO
3 * ================================================================================ Copyright (C) 2018 TechMahindra
4 * ================================================================================ Licensed under the Apache License,
5 * Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
11 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
12 * specific language governing permissions and limitations under the License.
13 * ============LICENSE_END=========================================================
15 package org.onap.so.bpmn.core.domain;
17 import static org.junit.Assert.*;
18 import java.io.IOException;
20 import com.fasterxml.jackson.databind.ObjectMapper;
21 import org.junit.Test;
23 public class ServiceInstanceTest {
25 private ServiceInstance si = new ServiceInstance();
27 Configuration config = new Configuration();
28 ModelInfo model = new ModelInfo();
31 public void testServiceInstance() {
32 si.setServiceType("serviceType");
33 si.setServiceId("serviceId");
34 si.setServiceParams(serviceParams);
35 si.setInstanceId("instanceId");
36 si.setInstanceName("instanceName");
37 si.setOrchestrationStatus("orchestrationStatus");
38 si.setConfiguration(config);
39 si.setModelInfo(model);
40 si.setEnvironmentContext("environmentContext");
41 si.setWorkloadContext("workloadContext");
42 assertEquals(si.getServiceType(), "serviceType");
43 assertEquals(si.getServiceId(), "serviceId");
44 assertEquals(si.getServiceParams(), serviceParams);
45 assertEquals(si.getInstanceId(), "instanceId");
46 assertEquals(si.getInstanceName(), "instanceName");
47 assertEquals(si.getOrchestrationStatus(), "orchestrationStatus");
48 assertEquals(si.getConfiguration(), config);
49 assertEquals(si.getModelInfo(), model);
50 assertEquals(si.getEnvironmentContext(), "environmentContext");
51 assertEquals(si.getWorkloadContext(), "workloadContext");
57 public void serviceInstanceMapperTest() throws IOException {
58 String jsonStr = "{\"workloadContext\": \"code123\", \"resourceOrder\": \"sample\"}";
59 ObjectMapper objectMapper = new ObjectMapper();
60 ServiceInstance serviceInstance = objectMapper.readValue(jsonStr, ServiceInstance.class);
61 assertTrue(serviceInstance != null);