Initial OpenECOMP MSO commit
[so.git] / mso-api-handlers / mso-api-handler-common / src / test / java / org / openecomp / mso / camunda / tests / CamundaRequestTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * OPENECOMP - MSO
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
25 import static org.junit.Assert.assertEquals;
26
27 import java.io.IOException;
28
29 import org.codehaus.jackson.JsonGenerationException;
30 import org.codehaus.jackson.map.JsonMappingException;
31 import org.codehaus.jackson.map.ObjectMapper;
32 import org.codehaus.jackson.map.SerializationConfig;
33 import org.junit.Test;
34
35 import org.openecomp.mso.apihandler.camundabeans.CamundaInput;
36 import org.openecomp.mso.apihandler.camundabeans.CamundaRequest;
37 import org.openecomp.mso.apihandler.common.CommonConstants;
38
39 /**
40  * This class implements test methods of Camunda Beans.
41  * 
42  *
43  */
44 public class CamundaRequestTest {
45
46         @Test
47         public final void testSerialization() throws JsonGenerationException,
48                         JsonMappingException, IOException {
49                 CamundaRequest camundaRequest = new CamundaRequest();
50                 CamundaInput camundaInput = new CamundaInput();
51                 CamundaInput host = new CamundaInput();
52                 CamundaInput schema = new CamundaInput();
53                 CamundaInput reqid = new CamundaInput();
54                 CamundaInput svcid = new CamundaInput();
55                 CamundaInput timeout = new CamundaInput();
56                 camundaInput
57                                 .setValue("<aetgt:CreateTenantRequest xmlns:aetgt=\"http://ecomp.att.com/mso/workflow/schema/v1\" xmlns:sdncadapterworkflow=\"http://ecomp.att.com/mso/workflow/schema/v1\" xmlns:ns5=\"http://ecomp.att.com/mso/request/types/v1\"> <msoservtypes:request-information xmlns:msoservtypes=\"http://ecomp.att.com/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://csi-tst-q22.it.att.com: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://ecomp.att.com/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>");
58                 camundaRequest.setServiceInput(camundaInput);
59                 host.setValue("localhost");
60                 camundaRequest.setHost(host);
61                 schema.setValue("v1");
62                 camundaRequest.setSchema(schema);
63                 reqid.setValue("reqid123");
64                 camundaRequest.setReqid(reqid);
65                 svcid.setValue("svcid123");
66                 camundaRequest.setSvcid(svcid);
67                 timeout.setValue("");
68                 camundaRequest.setTimeout(timeout);
69                 ObjectMapper mapper = new ObjectMapper();
70                 mapper.configure(SerializationConfig.Feature.WRAP_ROOT_VALUE, true);
71
72                 String json = mapper.writeValueAsString(camundaRequest);
73                 System.out.println(json);
74                 assertEquals(
75                                 "{\"variables\":{\""+CommonConstants.CAMUNDA_SERVICE_INPUT+"\":{\"value\":\"<aetgt:CreateTenantRequest xmlns:aetgt=\\\"http://ecomp.att.com/mso/workflow/schema/v1\\\" xmlns:sdncadapterworkflow=\\\"http://ecomp.att.com/mso/workflow/schema/v1\\\" xmlns:ns5=\\\"http://ecomp.att.com/mso/request/types/v1\\\"> <msoservtypes:request-information xmlns:msoservtypes=\\\"http://ecomp.att.com/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://csi-tst-q22.it.att.com: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://ecomp.att.com/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\"}" +
76                                 ",\"host\":{\"value\":\"localhost\",\"type\":\"String\"},\"att-mso-schema-version\":{\"value\":\"v1\",\"type\":\"String\"},\"att-mso-request-id\":{\"value\":\"reqid123\",\"type\":\"String\"},\"att-mso-service-instance-id\":{\"value\":\"svcid123\",\"type\":\"String\"},\"att-mso-service-request-timeout\":{\"value\":\"\",\"type\":\"String\"}}}",
77                                 json);
78
79         }
80
81 }