restMethod.setName(methodName); restMethod.setHttpMethod(HttpMethod.valueOf(methodType)); restMethod.setStatus(RestMethodStatus.MOCKED);
public static RestMethod generateRestMethod(){ final RestMethod restMethod = new RestMethod(); restMethod.setId("REST METHOD"); restMethod.setName("REST method name"); restMethod.setForwardedEndpoint("Forward endpoint"); restMethod.setDefaultBody("Default body"); restMethod.setCurrentResponseSequenceIndex(1); restMethod.setStatus(RestMethodStatus.MOCKED); restMethod.setHttpMethod(HttpMethod.GET); restMethod.setMockResponses(new ArrayList<RestMockResponse>()); restMethod.setResponseStrategy(RestResponseStrategy.RANDOM); return restMethod; } }
restMethod.setName(httpMethod.name()); restMethod.setStatus(RestMethodStatus.MOCKED); restMethod.setResponseStrategy(RestResponseStrategy.RANDOM);
restMethod.setName(method.displayName().value()); restMethod.setStatus(RestMethodStatus.MOCKED); restMethod.setResponseStrategy(RestResponseStrategy.RANDOM);
restMethod.setName(methodName); restMethod.setStatus(RestMethodStatus.MOCKED); restMethod.setResponseStrategy(RestResponseStrategy.SEQUENCE);
@Test public void projectFunctionalityUpdate() throws Exception { final String projectId = "projectId"; final String applicationId = "applicationId"; final String resourceId = "resourceId"; final String[] restMethodIds = {"restMethod1", "restMethod2"}; final RestMethodModifierCommand command = new RestMethodModifierCommand(); command.setRestMethodIds(restMethodIds); command.setRestMethodStatus("MOCKED"); final RestMethod restMethod1 = new RestMethod(); restMethod1.setId("restMethod1"); restMethod1.setName("restMethod1"); final RestMethod restMethod2 = new RestMethod(); restMethod2.setId("restMethod2"); restMethod2.setName("restMethod2"); Mockito.when(serviceProcessor.process(Mockito.any(ReadRestMethodInput.class))) .thenReturn(ReadRestMethodOutput.builder().restMethod(restMethod1).build()) .thenReturn(ReadRestMethodOutput.builder().restMethod(restMethod2).build()); final MockHttpServletRequestBuilder message = MockMvcRequestBuilders.post(SERVICE_URL + PROJECT + SLASH + projectId + SLASH + APPLICATION + SLASH + applicationId + SLASH + RESOURCE + SLASH + resourceId) .param("action", "update") .flashAttr("command", command); mockMvc.perform(message) .andExpect(MockMvcResultMatchers.status().is3xxRedirection()) .andExpect(MockMvcResultMatchers.model().size(1)) .andExpect(MockMvcResultMatchers.redirectedUrl("/web/rest/project/" + projectId + "/application/" + applicationId + "/resource/" + resourceId)); Mockito.verify(serviceProcessor, Mockito.times(2)).process(Mockito.isA(ReadRestMethodInput.class)); Mockito.verify(serviceProcessor, Mockito.times(2)).process(Mockito.isA(UpdateRestMethodInput.class)); }
restMethod.setInvokeAddress("http://localhost:8080" + CONTEXT + SLASH + MOCK + SLASH + REST + SLASH + PROJECT + SLASH + PROJECT_ID + SLASH + APPLICATION + SLASH + APPLICATION_ID + "/method/test"); restMethod.setName("Method name"); restMethod.setNetworkDelay(0); restMethod.setResponseStrategy(RestResponseStrategy.SEQUENCE);
/** * The process message is responsible for processing an incoming serviceTask and generate * a response based on the incoming serviceTask input * @param serviceTask The serviceTask that will be processed by the service * @return A result based on the processed incoming serviceTask * @see ServiceTask * @see ServiceResult */ @Override public ServiceResult<UpdateRestMethodOutput> process(final ServiceTask<UpdateRestMethodInput> serviceTask) { final UpdateRestMethodInput input = serviceTask.getInput(); final RestMethod updatedRestMethod = input.getRestMethod(); final RestMethod existing = this.methodRepository.findOne(input.getRestMethodId()); existing.setName(updatedRestMethod.getName()); existing.setHttpMethod(updatedRestMethod.getHttpMethod()); existing.setResponseStrategy(updatedRestMethod.getResponseStrategy()); existing.setStatus(updatedRestMethod.getStatus()); existing.setForwardedEndpoint(updatedRestMethod.getForwardedEndpoint()); existing.setNetworkDelay(updatedRestMethod.getNetworkDelay()); existing.setSimulateNetworkDelay(updatedRestMethod.getSimulateNetworkDelay()); existing.setDefaultMockResponseId(updatedRestMethod.getDefaultMockResponseId()); this.methodRepository.update(input.getRestMethodId(), existing); return createServiceResult(UpdateRestMethodOutput.builder() .restMethod(updatedRestMethod) .build()); } }
restMethod.setNetworkDelay(methodV1.getNetworkDelay()); restMethod.setResponseStrategy(methodV1.getResponseStrategy()); restMethod.setName(methodV1.getName()); restMethod.setId(methodV1.getId()); restMethod.setHttpMethod(methodV1.getHttpMethod());
restMethod.setInvokeAddress("http://localhost:8080" + CONTEXT + SLASH + MOCK + SLASH + REST + SLASH + PROJECT + SLASH + PROJECT_ID + SLASH + APPLICATION + SLASH + APPLICATION_ID + "/method/{variable}"); restMethod.setName("Method name"); restMethod.setNetworkDelay(0); restMethod.setResponseStrategy(RestResponseStrategy.SEQUENCE);