47252e92adab168eaa876a2809d05772761846c0
[so.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.openecomp.mso.camunda.tests;
22
23
24 import static org.junit.Assert.assertEquals;
25
26 import java.io.IOException;
27
28 import org.codehaus.jackson.JsonGenerationException;
29 import org.codehaus.jackson.map.JsonMappingException;
30 import org.codehaus.jackson.map.ObjectMapper;
31 import org.codehaus.jackson.map.SerializationConfig;
32 import org.junit.Test;
33
34 import org.openecomp.mso.apihandler.camundabeans.CamundaInput;
35 import org.openecomp.mso.apihandler.camundabeans.CamundaRequest;
36 import org.openecomp.mso.apihandler.common.CommonConstants;
37
38 /**
39  * This class implements test methods of Camunda Beans.
40  */
41 public class CamundaRequestTest {
42
43     @Test
44     public final void testSerialization() throws JsonGenerationException,
45             JsonMappingException, IOException {
46         CamundaRequest camundaRequest = new CamundaRequest();
47         CamundaInput camundaInput = new CamundaInput();
48         CamundaInput host = new CamundaInput();
49         CamundaInput schema = new CamundaInput();
50         CamundaInput reqid = new CamundaInput();
51         CamundaInput svcid = new CamundaInput();
52         CamundaInput timeout = new CamundaInput();
53         camundaInput
54                 .setValue("<aetgt:CreateTenantRequest xmlns:aetgt=\"http://org.openecomp/mso/workflow/schema/v1\" xmlns:sdncadapterworkflow=\"http://org.openecomp/mso/workflow/schema/v1\" xmlns:ns5=\"http://org.openecomp/mso/request/types/v1\"> <msoservtypes:request-information xmlns:msoservtypes=\"http://org.openecomp/mso/request/types/v1\"><msoservtypes:request-id>155415ab-b4a7-4382-b4c6-d17d950604</msoservtypes:request-id><msoservtypes:request-action>Layer3ServiceActivateRequest</msoservtypes:request-action><msoservtypes:source>OMX</msoservtypes:source><msoservtypes:notification-url>https://localhost:22443/Services/com/cingular/csi/sdn/SendManagedNetworkStatusNotification.jws</msoservtypes:notification-url><msoservtypes:order-number>5051563</msoservtypes:order-number><msoservtypes:order-version>1</msoservtypes:order-version> </msoservtypes:request-information> <msoservtypes:service-information xmlns:msoservtypes=\"http://org.openecomp/mso/request/types/v1\"><msoservtypes:service-type>SDN-ETHERNET-INTERNET</msoservtypes:service-type><msoservtypes:service-instance-id>HI/VLXM/950604//SW_INTERNET</msoservtypes:service-instance-id><msoservtypes:subscriber-name>SubName01</msoservtypes:subscriber-name> </msoservtypes:service-information> <sdncadapterworkflow:cloudId>MTSNJA4LCP1</sdncadapterworkflow:cloudId> </aetgt:CreateTenantRequest>");
55         camundaRequest.setServiceInput(camundaInput);
56         host.setValue("localhost");
57         camundaRequest.setHost(host);
58         schema.setValue("v1");
59         camundaRequest.setSchema(schema);
60         reqid.setValue("reqid123");
61         camundaRequest.setReqid(reqid);
62         svcid.setValue("svcid123");
63         camundaRequest.setSvcid(svcid);
64         timeout.setValue("");
65         camundaRequest.setTimeout(timeout);
66         ObjectMapper mapper = new ObjectMapper();
67         mapper.configure(SerializationConfig.Feature.WRAP_ROOT_VALUE, true);
68
69         String json = mapper.writeValueAsString(camundaRequest);
70         System.out.println(json);
71         assertEquals(
72                 "{\"variables\":{\"" + CommonConstants.CAMUNDA_SERVICE_INPUT + "\":{\"value\":\"<aetgt:CreateTenantRequest xmlns:aetgt=\\\"http://org.openecomp/mso/workflow/schema/v1\\\" xmlns:sdncadapterworkflow=\\\"http://org.openecomp/mso/workflow/schema/v1\\\" xmlns:ns5=\\\"http://org.openecomp/mso/request/types/v1\\\"> <msoservtypes:request-information xmlns:msoservtypes=\\\"http://org.openecomp/mso/request/types/v1\\\"><msoservtypes:request-id>155415ab-b4a7-4382-b4c6-d17d950604</msoservtypes:request-id><msoservtypes:request-action>Layer3ServiceActivateRequest</msoservtypes:request-action><msoservtypes:source>OMX</msoservtypes:source><msoservtypes:notification-url>https://localhost:22443/Services/com/cingular/csi/sdn/SendManagedNetworkStatusNotification.jws</msoservtypes:notification-url><msoservtypes:order-number>5051563</msoservtypes:order-number><msoservtypes:order-version>1</msoservtypes:order-version> </msoservtypes:request-information> <msoservtypes:service-information xmlns:msoservtypes=\\\"http://org.openecomp/mso/request/types/v1\\\"><msoservtypes:service-type>SDN-ETHERNET-INTERNET</msoservtypes:service-type><msoservtypes:service-instance-id>HI/VLXM/950604//SW_INTERNET</msoservtypes:service-instance-id><msoservtypes:subscriber-name>SubName01</msoservtypes:subscriber-name> </msoservtypes:service-information> <sdncadapterworkflow:cloudId>MTSNJA4LCP1</sdncadapterworkflow:cloudId> </aetgt:CreateTenantRequest>\",\"type\":\"String\"}" +
73                         ",\"host\":{\"value\":\"localhost\",\"type\":\"String\"},\"mso-schema-version\":{\"value\":\"v1\",\"type\":\"String\"},\"mso-request-id\":{\"value\":\"reqid123\",\"type\":\"String\"},\"mso-service-instance-id\":{\"value\":\"svcid123\",\"type\":\"String\"},\"mso-service-request-timeout\":{\"value\":\"\",\"type\":\"String\"}}}",
74                 json);
75
76     }
77
78 }