/*- * ============LICENSE_START======================================================= * OPENECOMP - MSO * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END========================================================= */ package org.openecomp.mso.camunda.tests; import static org.junit.Assert.assertEquals; import java.io.IOException; import org.codehaus.jackson.JsonGenerationException; import org.codehaus.jackson.map.JsonMappingException; import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.map.SerializationConfig; import org.junit.Test; import org.openecomp.mso.apihandler.camundabeans.CamundaInput; import org.openecomp.mso.apihandler.camundabeans.CamundaRequest; import org.openecomp.mso.apihandler.common.CommonConstants; /** * This class implements test methods of Camunda Beans. * * */ public class CamundaRequestTest { @Test public final void testSerialization() throws JsonGenerationException, JsonMappingException, IOException { CamundaRequest camundaRequest = new CamundaRequest(); CamundaInput camundaInput = new CamundaInput(); CamundaInput host = new CamundaInput(); CamundaInput schema = new CamundaInput(); CamundaInput reqid = new CamundaInput(); CamundaInput svcid = new CamundaInput(); CamundaInput timeout = new CamundaInput(); camundaInput .setValue(" 155415ab-b4a7-4382-b4c6-d17d950604Layer3ServiceActivateRequestOMXhttps://csi-tst-q22.it.att.com:22443/Services/com/cingular/csi/sdn/SendManagedNetworkStatusNotification.jws50515631 SDN-ETHERNET-INTERNETHI/VLXM/950604//SW_INTERNETSubName01 MTSNJA4LCP1 "); camundaRequest.setServiceInput(camundaInput); host.setValue("localhost"); camundaRequest.setHost(host); schema.setValue("v1"); camundaRequest.setSchema(schema); reqid.setValue("reqid123"); camundaRequest.setReqid(reqid); svcid.setValue("svcid123"); camundaRequest.setSvcid(svcid); timeout.setValue(""); camundaRequest.setTimeout(timeout); ObjectMapper mapper = new ObjectMapper(); mapper.configure(SerializationConfig.Feature.WRAP_ROOT_VALUE, true); String json = mapper.writeValueAsString(camundaRequest); System.out.println(json); assertEquals( "{\"variables\":{\""+CommonConstants.CAMUNDA_SERVICE_INPUT+"\":{\"value\":\" 155415ab-b4a7-4382-b4c6-d17d950604Layer3ServiceActivateRequestOMXhttps://csi-tst-q22.it.att.com:22443/Services/com/cingular/csi/sdn/SendManagedNetworkStatusNotification.jws50515631 SDN-ETHERNET-INTERNETHI/VLXM/950604//SW_INTERNETSubName01 MTSNJA4LCP1 \",\"type\":\"String\"}" + ",\"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\"}}}", json); } }