public static SoapOperation generateSoapOperation(){ final SoapOperation soapOperation = new SoapOperation(); soapOperation.setId("SOAP OPERATION"); soapOperation.setName("Soap operation name"); soapOperation.setCurrentResponseSequenceIndex(1); soapOperation.setDefaultBody("Default body"); soapOperation.setForwardedEndpoint("Forwarded event"); soapOperation.setInvokeAddress("Invoke address"); soapOperation.setOriginalEndpoint("Original endpoint"); soapOperation.setHttpMethod(HttpMethod.POST); soapOperation.setStatus(SoapOperationStatus.MOCKED); soapOperation.setSoapVersion(SoapVersion.SOAP11); soapOperation.setIdentifyStrategy(SoapOperationIdentifyStrategy.ELEMENT_NAMESPACE); soapOperation.setMockResponses(new ArrayList<SoapMockResponse>()); return soapOperation; } }
@Test public void testServiceFunctionalityUpdateEndpoint() throws Exception { final String projectId = "projectId"; final String portId = "portId"; final String[] soapOperationIds = {"Operation1", "Operation2"}; final SoapOperation soapOperation1 = new SoapOperation(); soapOperation1.setId("SoapOperation1"); final SoapOperation soapOperation2 = new SoapOperation(); soapOperation2.setId("SoapOperation2"); Mockito.when(serviceProcessor.process(Mockito.any(ReadSoapOperationInput.class))) .thenReturn(ReadSoapOperationOutput.builder().operation(soapOperation1).build()) .thenReturn(ReadSoapOperationOutput.builder().operation(soapOperation2).build()); final List<SoapOperation> operations = Arrays.asList(soapOperation1, soapOperation2); final SoapOperationModifierCommand command = new SoapOperationModifierCommand(); command.setSoapOperationIds(soapOperationIds); command.setSoapOperationStatus("ENABLED"); final MockHttpServletRequestBuilder message = MockMvcRequestBuilders.post(SERVICE_URL + PROJECT + SLASH + projectId + SLASH + PORT + SLASH + portId) .param("action", "update-endpoint").flashAttr("command", command); mockMvc.perform(message) .andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.model().size(4 + GLOBAL_VIEW_MODEL_COUNT)) .andExpect(MockMvcResultMatchers.forwardedUrl(INDEX)) .andExpect(MockMvcResultMatchers.model().attribute(PARTIAL, UPDATE_SOAP_OPERATIONS_ENDPOINT_PAGE)) .andExpect(MockMvcResultMatchers.model().attribute(SOAP_PROJECT_ID, projectId)) .andExpect(MockMvcResultMatchers.model().attribute(SOAP_PORT_ID, portId)) .andExpect(MockMvcResultMatchers.model().attribute(SOAP_OPERATIONS, operations)) .andExpect(MockMvcResultMatchers.model().attributeExists(UPDATE_SOAP_OPERATIONS_ENDPOINT_COMMAND)); Mockito.verify(serviceProcessor, Mockito.times(2)).process(Mockito.isA(ReadSoapOperationInput.class)); }
soapOperation.setForwardedEndpoint(FORWARD_ENDPOINT); soapOperation.setHttpMethod(HttpMethod.GET); soapOperation.setId(SOAP_OPERATION_ID); soapOperation.setInvokeAddress("http://localhost:8080" + CONTEXT + SLASH + MOCK + SLASH + SOAP + SLASH + PROJECT + SLASH + PROJECT_ID + SLASH + SOAP_PORT_ID);
operation.setId(operationV1.getId()); operation.setName(operationV1.getName()); operation.setResponseStrategy(operationV1.getResponseStrategy());