diff options
Diffstat (limited to 'mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/camunda')
5 files changed, 0 insertions, 565 deletions
diff --git a/mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/camunda/tests/BPELRestClientTest.java b/mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/camunda/tests/BPELRestClientTest.java deleted file mode 100644 index 6cc6c562e5..0000000000 --- a/mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/camunda/tests/BPELRestClientTest.java +++ /dev/null @@ -1,125 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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.apache.http.HttpResponse; -import org.apache.http.HttpStatus; -import org.apache.http.ProtocolVersion; -import org.apache.http.client.HttpClient; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.entity.StringEntity; -import org.apache.http.message.BasicHttpResponse; -import org.apache.http.message.BasicStatusLine; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.MockitoAnnotations; -import org.openecomp.mso.apihandler.common.CommonConstants; -import org.openecomp.mso.apihandler.common.RequestClient; -import org.openecomp.mso.apihandler.common.RequestClientFactory; -import org.openecomp.mso.properties.MsoJavaProperties; - -import com.fasterxml.jackson.core.JsonGenerationException; -import com.fasterxml.jackson.databind.JsonMappingException; - - -/** - * This class implements test methods of Camunda Beans. - * - * - */ -public class BPELRestClientTest { - - - - @Mock - private HttpClient mockHttpClient; - - @Before - public void setUp() { - MockitoAnnotations.initMocks(this); - } - - @Test - public void tesBPELPost() throws JsonGenerationException, - JsonMappingException, IOException { - - - String responseBody ="<layer3activate:service-response xmlns:layer3activate=\"http://org.openecomp/mso/request/layer3serviceactivate/schema/v1\"" - + "xmlns:reqtype=\"http://org.openecomp/mso/request/types/v1\"" - + "xmlns:aetgt=\"http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd\"" - + "xmlns:types=\"http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd\">" - + "<reqtype:request-id>req5</reqtype:request-id>" - + "<reqtype:request-action>Layer3ServiceActivateRequest</reqtype:request-action>" - + "<reqtype:source>OMX</reqtype:source>" - + "<reqtype:ack-final-indicator>n</reqtype:ack-final-indicator>" - + "</layer3activate:service-response>"; - - HttpResponse mockResponse = createResponse(200, responseBody); - mockHttpClient = Mockito.mock(HttpClient.class); - Mockito.when(mockHttpClient.execute(Mockito.any(HttpPost.class))) - .thenReturn(mockResponse); - - String reqXML = "<xml>test</xml>"; - String orchestrationURI = "/active-bpel/services/REST/MsoLayer3ServiceActivate"; - - MsoJavaProperties props = new MsoJavaProperties(); - props.setProperty(CommonConstants.BPEL_URL, "http://localhost:8089"); - props.setProperty("bpelAuth", "786864AA53D0DCD881AED1154230C0C3058D58B9339D2EFB6193A0F0D82530E1"); - - RequestClient requestClient = RequestClientFactory.getRequestClient(orchestrationURI, props); - requestClient.setClient(mockHttpClient); - HttpResponse response = requestClient.post(reqXML, "reqId", "timeout", "version", null, null); - - - int statusCode = response.getStatusLine().getStatusCode(); - assertEquals(requestClient.getType(), CommonConstants.BPEL); - assertEquals(statusCode, HttpStatus.SC_OK); - - - } - - private HttpResponse createResponse(int respStatus, - String respBody) { - HttpResponse response = new BasicHttpResponse( - new BasicStatusLine( - new ProtocolVersion("HTTP", 1, 1), respStatus, "")); - response.setStatusCode(respStatus); - try { - response.setEntity(new StringEntity(respBody)); - response.setHeader("Content-Type", "text/xml"); - } catch (Exception e) { - e.printStackTrace(); - } - return response; - } - - - - - -} diff --git a/mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/camunda/tests/CamundaClientTest.java b/mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/camunda/tests/CamundaClientTest.java deleted file mode 100644 index 69927e2126..0000000000 --- a/mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/camunda/tests/CamundaClientTest.java +++ /dev/null @@ -1,144 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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.apache.http.HttpResponse; -import org.apache.http.HttpStatus; -import org.apache.http.ProtocolVersion; -import org.apache.http.client.HttpClient; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.entity.StringEntity; -import org.apache.http.message.BasicHttpResponse; -import org.apache.http.message.BasicStatusLine; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.MockitoAnnotations; -import org.openecomp.mso.apihandler.common.CommonConstants; -import org.openecomp.mso.apihandler.common.RequestClient; -import org.openecomp.mso.apihandler.common.RequestClientFactory; -import org.openecomp.mso.apihandler.common.RequestClientParamater; -import org.openecomp.mso.properties.MsoJavaProperties; - -/** - * This class implements test methods of Camunda Beans. - * - * - */ -public class CamundaClientTest { - - - - @Mock - private HttpClient mockHttpClient; - - @Before - public void setUp() { - MockitoAnnotations.initMocks(this); - } - - @Test - public void tesCamundaPost() throws IOException { - String responseBody ="{\"links\":[{\"method\":\"GET\",\"href\":\"http://localhost:9080/engine-rest/process-instance/2047c658-37ae-11e5-9505-7a1020524153\",\"rel\":\"self\"}],\"id\":\"2047c658-37ae-11e5-9505-7a1020524153\",\"definitionId\":\"dummy:10:73298961-37ad-11e5-9505-7a1020524153\",\"businessKey\":null,\"caseInstanceId\":null,\"ended\":true,\"suspended\":false}"; - - HttpResponse mockResponse = createResponse(200, responseBody); - mockHttpClient = Mockito.mock(HttpClient.class); - Mockito.when(mockHttpClient.execute(Mockito.any(HttpPost.class))) - .thenReturn(mockResponse); - - String reqXML = "<xml>test</xml>"; - String orchestrationURI = "/engine-rest/process-definition/key/dummy/start"; - - MsoJavaProperties props = new MsoJavaProperties(); - props.setProperty(CommonConstants.CAMUNDA_URL, "http://localhost:8089"); - - RequestClient requestClient = RequestClientFactory.getRequestClient(orchestrationURI, props); - requestClient.setClient(mockHttpClient); - HttpResponse response = requestClient.post(reqXML, "reqId", "timeout", "version", null, null); - - - int statusCode = response.getStatusLine().getStatusCode(); - assertEquals(requestClient.getType(), CommonConstants.CAMUNDA); - assertEquals(statusCode, HttpStatus.SC_OK); - - props.setProperty (CommonConstants.CAMUNDA_AUTH, "ABCD1234"); - requestClient = RequestClientFactory.getRequestClient(orchestrationURI, props); - requestClient.setClient(mockHttpClient); - response = requestClient.post(null, "reqId", null, null, null, null); - assertEquals(requestClient.getType(), CommonConstants.CAMUNDA); - assertEquals(statusCode, HttpStatus.SC_OK); - } - - @Test - public void testCamundaPostJson() throws IOException { - String responseBody ="{\"links\":[{\"method\":\"GET\",\"href\":\"http://localhost:9080/engine-rest/process-instance/2047c658-37ae-11e5-9505-7a1020524153\",\"rel\":\"self\"}],\"id\":\"2047c658-37ae-11e5-9505-7a1020524153\",\"definitionId\":\"dummy:10:73298961-37ad-11e5-9505-7a1020524153\",\"businessKey\":null,\"caseInstanceId\":null,\"ended\":true,\"suspended\":false}"; - - HttpResponse mockResponse = createResponse(200, responseBody); - mockHttpClient = Mockito.mock(HttpClient.class); - Mockito.when(mockHttpClient.execute(Mockito.any(HttpPost.class))) - .thenReturn(mockResponse); - String orchestrationURI = "/engine-rest/process-definition/key/dummy/start"; - - MsoJavaProperties props = new MsoJavaProperties(); - props.setProperty(CommonConstants.CAMUNDA_URL, "http://localhost:8089"); - - RequestClient requestClient = RequestClientFactory.getRequestClient(orchestrationURI, props); - requestClient.setClient(mockHttpClient); - HttpResponse response = requestClient.post(createParams()); - assertEquals(requestClient.getType(), CommonConstants.CAMUNDA); - assertEquals(response.getStatusLine().getStatusCode(), HttpStatus.SC_OK); - } - - private HttpResponse createResponse(int respStatus, - String respBody) { - HttpResponse response = new BasicHttpResponse( - new BasicStatusLine( - new ProtocolVersion("HTTP", 1, 1), respStatus, "")); - response.setStatusCode(respStatus); - try { - response.setEntity(new StringEntity(respBody)); - response.setHeader("Content-Type", "application/json"); - } catch (Exception e) { - e.printStackTrace(); - } - return response; - } - - private RequestClientParamater createParams(){ - return new RequestClientParamater.Builder().setRequestId("mso-req-id").setBaseVfModule(false). - setRecipeTimeout(180).setRequestAction("createInstance").setServiceInstanceId("svc-inst-id"). - setVnfId("vnf-id").setVfModuleId("vf-module-id").setVolumeGroupId("vg-id").setNetworkId("nw-id"). - setConfigurationId("conf-id").setServiceType("svc-type").setVnfType("vnf-type"). - setVfModuleType("vf-module-type").setNetworkType("nw-type").setRequestDetails(""). - setRecipeParamXsd("").build(); - } - - - - - -} diff --git a/mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/camunda/tests/CamundaRequestTest.java b/mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/camunda/tests/CamundaRequestTest.java deleted file mode 100644 index 622bb1e242..0000000000 --- a/mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/camunda/tests/CamundaRequestTest.java +++ /dev/null @@ -1,81 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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.junit.Test; -import org.openecomp.mso.apihandler.camundabeans.CamundaInput; -import org.openecomp.mso.apihandler.camundabeans.CamundaRequest; -import org.openecomp.mso.apihandler.common.CommonConstants; - -import com.fasterxml.jackson.core.JsonGenerationException; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; - -/** - * 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("<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>"); - 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(SerializationFeature.WRAP_ROOT_VALUE, true); - - String json = mapper.writeValueAsString(camundaRequest); - System.out.println(json); - assertEquals( - "{\"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\"}" + - ",\"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\"}}}", - json); - - } - -} diff --git a/mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/camunda/tests/CamundaResponseTest.java b/mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/camunda/tests/CamundaResponseTest.java deleted file mode 100644 index 7fc2815b4b..0000000000 --- a/mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/camunda/tests/CamundaResponseTest.java +++ /dev/null @@ -1,78 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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 org.junit.Test; -import org.openecomp.mso.apihandler.camundabeans.CamundaResponse; -import org.openecomp.mso.utils.RootIgnoringObjectMapper; - -import com.fasterxml.jackson.databind.ObjectMapper; - -/** - * This class implements test methods of Camunda Beans. - * - * - */ -public class CamundaResponseTest { - - @Test - public final void testDeserializationWithoutRootElement() throws Exception { - - ObjectMapper mapper = new RootIgnoringObjectMapper<CamundaResponse>(CamundaResponse.class); - - String content = "{" - + "\"messageCode\":202" - + ",\"message\":\"Successfully started the process\"" - + ",\"content\":\"<xml>xml</xml>\"" - + ",\"processInstanceId\":\"4d3b3201a7ce\"" - + ",\"variables\":null" - + "}"; - - CamundaResponse response = mapper.readValue(content, CamundaResponse.class); - - assertEquals( - "CamundaResponse[processInstanceId=4d3b3201a7ce,messageCode=202,message=Successfully started the process,variables=null,content=<xml>xml</xml>]", - response.toString()); - } - - @Test - public final void testDeserializationWithRootElement() throws Exception { - - ObjectMapper mapper = new RootIgnoringObjectMapper<CamundaResponse>(CamundaResponse.class); - - String content = "{\"WorkflowResponse\":{" - + "\"messageCode\":202" - + ",\"message\":\"Successfully started the process\"" - + ",\"content\":\"<xml>xml</xml>\"" - + ",\"processInstanceId\":\"4d3b3201a7ce\"" - + ",\"variables\":null" - + "}}"; - - CamundaResponse response = mapper.readValue(content, CamundaResponse.class); - - assertEquals( - "CamundaResponse[processInstanceId=4d3b3201a7ce,messageCode=202,message=Successfully started the process,variables=null,content=<xml>xml</xml>]", - response.toString()); - } -}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/camunda/tests/ResponseHandlerTest.java b/mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/camunda/tests/ResponseHandlerTest.java deleted file mode 100644 index e04aba0ede..0000000000 --- a/mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/camunda/tests/ResponseHandlerTest.java +++ /dev/null @@ -1,137 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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 static org.junit.Assert.assertTrue; - -import java.io.IOException; - -import org.apache.http.HttpResponse; -import org.apache.http.HttpStatus; -import org.apache.http.ProtocolVersion; -import org.apache.http.entity.StringEntity; -import org.apache.http.message.BasicHttpResponse; -import org.apache.http.message.BasicStatusLine; -import org.junit.Test; -import org.openecomp.mso.apihandler.common.ResponseHandler; - -import com.fasterxml.jackson.core.JsonGenerationException; -import com.fasterxml.jackson.databind.JsonMappingException; - -/** - * This class implements test methods of CamundaResoponseHandler. - * - * - */ -public class ResponseHandlerTest { - - @Test - public void tesParseCamundaResponse () throws JsonGenerationException, JsonMappingException, IOException { - - String content = "{\"WorkflowResponse\":{" - + "\"messageCode\":202" - + ",\"message\":\"Successfully started the process\"" - + ",\"content\":\"<xml>xml</xml>\"" - + ",\"processInstanceId\":\"4d3b3201a7ce\"" - + "}}"; - - HttpResponse response = createResponse (200, content, "application/json"); - - ResponseHandler respHandler = new ResponseHandler (response, 1); - - int status = respHandler.getStatus (); - assertEquals (status, HttpStatus.SC_ACCEPTED); - assertEquals (respHandler.getResponse ().getMessage (), "Successfully started the process"); - - } - - @Test - public void tesParseBpelResponse () throws JsonGenerationException, JsonMappingException, IOException { - String body = "<layer3activate:service-response xmlns:layer3activate=\"http://org.openecomp/mso/request/layer3serviceactivate/schema/v1\"" - + "xmlns:reqtype=\"http://org.openecomp/mso/request/types/v1\"" - + "xmlns:aetgt=\"http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd\"" - + "xmlns:types=\"http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd\">" - + "<reqtype:request-id>req5</reqtype:request-id>" - + "<reqtype:request-action>Layer3ServiceActivateRequest</reqtype:request-action>" - + "<reqtype:source>OMX</reqtype:source>" - + "<reqtype:ack-final-indicator>n</reqtype:ack-final-indicator>" - + "</layer3activate:service-response>"; - - HttpResponse response = createResponse (200, body, "text/xml"); - - ResponseHandler respHandler = new ResponseHandler (response, 0); - - int status = respHandler.getStatus (); - assertEquals (status, HttpStatus.SC_ACCEPTED); - assertTrue (respHandler.getContent() != null); - } - - @Test - public void tes404ErrorResponse () throws JsonGenerationException, JsonMappingException, IOException { - - - HttpResponse response = createResponse (HttpStatus.SC_NOT_FOUND, "<html>error</html>", "text/html"); - ResponseHandler respHandler = new ResponseHandler (response, 1); - - int status = respHandler.getStatus (); - - assertEquals (HttpStatus.SC_NOT_IMPLEMENTED, status); - - } - - @Test - public void tesGenricErrorResponse () throws JsonGenerationException, JsonMappingException, IOException { - - String content = "{\"WorkflowResponse\":{" - + "\"messageCode\":500" - + ",\"message\":\"Something went wrong\"" - + ",\"content\":\"<xml>xml</xml>\"" - + ",\"processInstanceId\":\"4d3b3201a7ce\"" - + "}}"; - - HttpResponse response = createResponse (500, content, "application/json"); - - ResponseHandler respHandler = new ResponseHandler (response, 1); - - int status = respHandler.getStatus (); - assertEquals (HttpStatus.SC_BAD_GATEWAY, status); - assertEquals (respHandler.getResponse ().getMessage (), "Something went wrong"); - System.out.println (respHandler.getContent()); - - } - - private HttpResponse createResponse (int respStatus, String respBody, String contentType) { - HttpResponse response = new BasicHttpResponse (new BasicStatusLine (new ProtocolVersion ("HTTP", 1, 1), - respStatus, - "")); - response.setStatusCode (respStatus); - try { - response.setEntity (new StringEntity (respBody)); - response.setHeader ("Content-Type", contentType); - } catch (Exception e) { - e.printStackTrace (); - } - return response; - } - -} |