public static RestResource generateRestResource(){ final RestResource restResource = new RestResource(); restResource.setId("REST Resource"); restResource.setName("Rest resource name"); restResource.setMethods(new ArrayList<RestMethod>()); restResource.setUri("URI"); return restResource; }
final String resourceName = resourceElement.getAttribute("path"); final RestResource restResource = new RestResource(); restResource.setName(resourceName); restResource.setUri(baseUri.orElse("") + resourceName); restApplication.getResources().add(restResource);
if(!methods.isEmpty()){ RestResource restResource = new RestResource(); restResource.setName(uri); restResource.setUri(uri); result.add(restResource);
if(!methods.isEmpty()){ RestResource restResource = new RestResource(); restResource.setName(resource.displayName().value()); restResource.setUri(uri); result.add(restResource);
final RestResource restResource = new RestResource(); restResource.setName(resourceName); restResource.setUri(resourceName);
/** * 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<UpdateRestResourceOutput> process(final ServiceTask<UpdateRestResourceInput> serviceTask) { final UpdateRestResourceInput input = serviceTask.getInput(); final RestResource existing = this.resourceRepository.findOne(input.getRestResourceId()); final RestResource updatedRestResource = input.getRestResource(); existing.setName(updatedRestResource.getName()); existing.setUri(updatedRestResource.getUri()); this.resourceRepository.update(input.getRestResourceId(), existing); return createServiceResult(UpdateRestResourceOutput.builder() .updatedRestResource(updatedRestResource) .build()); } }
@Test public void projectFunctionalityDelete() throws Exception { final String projectId = "projectId"; final String applicationId = "applicationId"; final String[] restResourceIds = {"restApplication1", "restApplication2"}; final RestResource restResource1 = new RestResource(); restResource1.setName("restResource1"); final RestResource restResource2 = new RestResource(); restResource2.setName("restResource2"); final List<RestResource> restResources = Arrays.asList(restResource1, restResource2); Mockito.when(serviceProcessor.process(Mockito.any(ReadRestResourceInput.class))) .thenReturn(ReadRestResourceOutput.builder().restResource(restResource1).build()) .thenReturn(ReadRestResourceOutput.builder().restResource(restResource2).build()); final RestResourceModifierCommand command = new RestResourceModifierCommand(); command.setRestResourceIds(restResourceIds); final MockHttpServletRequestBuilder message = MockMvcRequestBuilders.post(SERVICE_URL + PROJECT + SLASH + projectId + SLASH + APPLICATION + SLASH + applicationId) .param("action", "delete").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, DELETE_REST_RESOURCES_PAGE)) .andExpect(MockMvcResultMatchers.model().attribute(REST_PROJECT_ID, projectId)) .andExpect(MockMvcResultMatchers.model().attribute(REST_APPLICATION_ID, applicationId)) .andExpect(MockMvcResultMatchers.model().attribute(REST_RESOURCES, restResources)) .andExpect(MockMvcResultMatchers.model().attributeExists(DELETE_REST_RESOURCES_COMMAND)); Mockito.verify(serviceProcessor, Mockito.times(2)).process(Mockito.any(ReadRestResourceInput.class)); }
RestResource resource = new RestResource(); resource.setUri(restResourceV1.getUri()); resource.setName(restResourceV1.getName()); resource.setId(restResourceV1.getId()); resource.setApplicationId(application.getId());