@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));
}