public static RestApplication generateRestApplication(){ final RestApplication restApplication = new RestApplication(); restApplication.setId("REST APPLICATION"); restApplication.setName("Rest application name"); restApplication.setResources(new ArrayList<RestResource>()); return restApplication; }
final Optional<String> baseUri = getResourceBase(applicationElement); final RestApplication restApplication = new RestApplication(); restApplication.setName(applicationName); applications.add(restApplication);
/** * The convert method provides the functionality to convert the provided {@link File} into * a list of {@link RestApplication}. * @param ramlModelResult The RAML model result * @param generateResponse Will generate a default response if true. No response will be generated if false. * @return A list of {@link RestApplication} based on the provided file. * @throws IllegalStateException In case the {@link RamlModelResult} is not parsable. */ private List<RestApplication> convert(final RamlModelResult ramlModelResult, final boolean generateResponse){ if(!ramlModelResult.getValidationResults().isEmpty()){ throw new IllegalStateException("Unable to parse the RAML file"); } String title = null; List<RestResource> restResources = new ArrayList<>(); if(ramlModelResult.getApiV08() != null){ org.raml.v2.api.model.v08.api.Api api = ramlModelResult.getApiV08(); title = api.title(); new RAML08Parser().getResources(api.resources(), restResources, "", generateResponse); } else if(ramlModelResult.getApiV10() != null){ org.raml.v2.api.model.v10.api.Api api = ramlModelResult.getApiV10(); title = api.title().value(); new RAML10Parser().getResources(api.resources(), restResources, "", generateResponse); } RestApplication restApplication = new RestApplication(); restApplication.setName(title); restApplication.setResources(restResources); return Arrays.asList(restApplication); }
restApplication.setName(this.getApplicationName(swagger));
/** * 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<UpdateRestApplicationOutput> process(final ServiceTask<UpdateRestApplicationInput> serviceTask) { final UpdateRestApplicationInput input = serviceTask.getInput(); final RestApplication updated = input.getRestApplication(); final RestApplication existing = this.applicationRepository.findOne(input.getRestApplicationId()); existing.setName(updated.getName()); final RestApplication updatedRestApplication = this.applicationRepository.update(input.getRestApplicationId(), existing); return createServiceResult(UpdateRestApplicationOutput.builder() .updatedRestApplication(updatedRestApplication) .build()); } }
@Test public void projectFunctionalityDelete() throws Exception { final String projectId = "projectId"; final String[] restApplicationIds = {"restApplication1", "restApplication2"}; final RestApplication restApplication1 = new RestApplication(); restApplication1.setName("restApplication1"); final RestApplication restApplication2 = new RestApplication(); restApplication1.setName("restApplication2"); final List<RestApplication> restApplications = Arrays.asList(restApplication1, restApplication2); Mockito.when(serviceProcessor.process(Mockito.any(ReadRestApplicationInput.class))) .thenReturn(ReadRestApplicationOutput.builder().restApplication(restApplication1).build()) .thenReturn(ReadRestApplicationOutput.builder().restApplication(restApplication2).build()); final RestApplicationModifierCommand command = new RestApplicationModifierCommand(); command.setRestApplicationIds(restApplicationIds); final MockHttpServletRequestBuilder message = MockMvcRequestBuilders.post(SERVICE_URL + PROJECT + SLASH + projectId + SLASH) .param("action", "delete").flashAttr("command", command); mockMvc.perform(message) .andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.model().size(3 + GLOBAL_VIEW_MODEL_COUNT)) .andExpect(MockMvcResultMatchers.forwardedUrl(INDEX)) .andExpect(MockMvcResultMatchers.model().attribute(PARTIAL, DELETE_REST_APPLICATIONS_PAGE)) .andExpect(MockMvcResultMatchers.model().attribute(REST_PROJECT_ID, projectId)) .andExpect(MockMvcResultMatchers.model().attribute(REST_APPLICATIONS, restApplications)) .andExpect(MockMvcResultMatchers.model().attributeExists(DELETE_REST_APPLICATIONS_COMMAND)); Mockito.verify(serviceProcessor, Mockito.times(2)).process(Mockito.any(ReadRestApplicationInput.class)); }
RestApplication application = new RestApplication(); application.setId(applicationV1.getId()); application.setName(applicationV1.getName()); application.setProjectId(project.getId()); project.getApplications().add(application);