2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
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=========================================================
21 package org.onap.so.client.sdnc.mapper;
23 import static com.shazam.shazamcrest.MatcherAssert.assertThat;
24 import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
26 import java.nio.file.Files;
27 import java.nio.file.Paths;
28 import java.util.HashMap;
30 import org.junit.Test;
31 import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
32 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
33 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription;
34 import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
35 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance;
36 import org.onap.so.client.sdnc.beans.SDNCSvcAction;
37 import org.onap.so.client.sdnc.beans.SDNCSvcOperation;
39 import org.onap.sdnc.apps.client.model.GenericResourceApiOnapmodelinformationOnapModelInformation;
40 import org.onap.sdnc.apps.client.model.GenericResourceApiRequestActionEnumeration;
41 import org.onap.sdnc.apps.client.model.GenericResourceApiServiceOperationInformation;
42 import com.fasterxml.jackson.databind.ObjectMapper;
44 public class ServiceTopologyOperationMapperTest {
47 public void reqMapperTest() throws Exception {
48 // prepare and set service instance
49 ServiceInstance serviceInstance = new ServiceInstance();
50 ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
51 modelInfoServiceInstance.setModelInvariantUuid("modelInvariantUuid");
52 modelInfoServiceInstance.setModelName("modelName");
53 modelInfoServiceInstance.setModelUuid("modelUuid");
54 modelInfoServiceInstance.setModelVersion("modelVersion");
55 serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
57 // prepare Customer object
58 Customer customer = new Customer();
59 customer.setGlobalCustomerId("globalCustomerId");
61 customer.setServiceSubscription(new ServiceSubscription());
62 // set Customer on service instance
63 customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
65 //prepare RequestContext
66 RequestContext requestContext = new RequestContext();
67 HashMap<String, String> userParams = new HashMap<String, String>();
68 userParams.put("key1", "value1");
69 requestContext.setUserParams(userParams);
70 requestContext.setProductFamilyId("productFamilyId");
72 ServiceTopologyOperationMapper mapper = new ServiceTopologyOperationMapper();
73 GenericResourceApiServiceOperationInformation serviceOpInformation = mapper.reqMapper(
74 SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE, serviceInstance, customer,
77 String jsonToCompare = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/BuildingBlocks/genericResourceApiEcompModelInformation.json")));
79 ObjectMapper omapper = new ObjectMapper();
80 GenericResourceApiOnapmodelinformationOnapModelInformation reqMapper1 = omapper.readValue(jsonToCompare,
81 GenericResourceApiOnapmodelinformationOnapModelInformation.class);
83 assertThat(reqMapper1, sameBeanAs(serviceOpInformation.getServiceInformation().getOnapModelInformation()));