/** * Count the operation statuses * @param soapOperations The list of operations, which status will be counted * @return The result of the status count */ private Map<SoapOperationStatus, Integer> getSoapOperationStatusCount(final List<SoapOperation> soapOperations){ Preconditions.checkNotNull(soapOperations, "The operation list cannot be null"); final Map<SoapOperationStatus, Integer> statuses = new HashMap<SoapOperationStatus, Integer>(); for(SoapOperationStatus soapOperationStatus : SoapOperationStatus.values()){ statuses.put(soapOperationStatus, 0); } for(SoapOperation soapOperation : soapOperations){ SoapOperationStatus soapOperationStatus = soapOperation.getStatus(); statuses.put(soapOperationStatus, statuses.get(soapOperationStatus)+1); } return statuses; } }
/** * The method retrieves a specific port and returns a view that displays the retrieved operation. * @param soapProjectId The id of the project that the port belongs to * @param soapPortId The id of the port that will be retrieved * @return A view that displays the retrieved port */ @PreAuthorize("hasAuthority('MODIFIER') or hasAuthority('ADMIN')") @RequestMapping(value = "/{soapProjectId}/port/{soapPortId}/update", method = RequestMethod.GET) public ModelAndView defaultPage(@PathVariable final String soapProjectId, @PathVariable final String soapPortId) { final ReadSoapPortOutput output = serviceProcessor.process(ReadSoapPortInput.builder() .projectId(soapProjectId) .portId(soapPortId) .build()); final ModelAndView model = createPartialModelAndView(PAGE); model.addObject(SOAP_PORT, output.getPort()); model.addObject(SOAP_PROJECT_ID, soapProjectId); model.addObject(SOAP_PORT_ID, soapPortId); model.addObject(SOAP_MOCK_RESPONSE_STRATEGIES, SoapResponseStrategy.values()); model.addObject(SOAP_OPERATION_STATUSES, SoapOperationStatus.values()); return model; }
@Test public void updateSoapOperationGet() throws Exception { final SoapProject soapProject = SoapProjectGenerator.generateSoapProject(); final SoapPort soapPort = SoapPortGenerator.generateSoapPort(); final SoapOperation soapOperation = SoapOperationGenerator.generateSoapOperation(); final List<SoapOperationStatus> soapOperationStatuses = Arrays.asList(SoapOperationStatus.values()); when(serviceProcessor.process(any(Input.class))).thenReturn(ReadSoapOperationOutput.builder() .operation(soapOperation) .build()); final MockHttpServletRequestBuilder message = MockMvcRequestBuilders.get(SERVICE_URL + PROJECT + SLASH + soapProject.getId() + SLASH + PORT + SLASH + soapPort.getId() + SLASH + OPERATION + SLASH + soapOperation.getId() + SLASH + UPDATE + SLASH); mockMvc.perform(message) .andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.model().size(7 + GLOBAL_VIEW_MODEL_COUNT)) .andExpect(MockMvcResultMatchers.forwardedUrl(INDEX)) .andExpect(MockMvcResultMatchers.model().attribute(PARTIAL, PAGE)) .andExpect(MockMvcResultMatchers.model().attribute(SOAP_PROJECT_ID, soapProject.getId())) .andExpect(MockMvcResultMatchers.model().attribute(SOAP_PORT_ID, soapPort.getId())) .andExpect(MockMvcResultMatchers.model().attribute(SOAP_OPERATION_ID, soapOperation.getId())) .andExpect(MockMvcResultMatchers.model().attribute(COMMAND, soapOperation)) .andExpect(MockMvcResultMatchers.model().attribute(SOAP_OPERATION_STATUSES, soapOperationStatuses)) .andExpect(MockMvcResultMatchers.model().attribute(SOAP_OPERATION_IDENTIFY_STRATEGIES, SoapOperationIdentifyStrategy.values())) .andExpect(MockMvcResultMatchers.model().attribute(SOAP_MOCK_RESPONSE_STRATEGIES, SoapResponseStrategy.values())); }