@PreAuthorize("hasAuthority('MODIFIER') or hasAuthority('ADMIN')") @RequestMapping(value = "/{projectId}/create/application", method = RequestMethod.GET) public ModelAndView defaultPage(@PathVariable final String projectId) { final ModelAndView model = createPartialModelAndView(PAGE); model.addObject(REST_PROJECT_ID, projectId); model.addObject(REST_APPLICATION, new RestApplication()); return model; }
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 String applicationName = file.getName().replace(".wadl", ""); 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); }
final RestApplication restApplication = new RestApplication(); restApplication.setName(this.getApplicationName(swagger));
@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)); }
final RestApplication restApplication1 = new RestApplication(); restApplication1.setName("restApplication1"); final RestApplication restApplication2 = new RestApplication(); restApplication1.setName("restApplication2");
RestApplication application = new RestApplication(); application.setId(applicationV1.getId()); application.setName(applicationV1.getName());