LifecycleController { @RequestMapping(value = "/applications/{name}/versions", method = GET) @ApiOperation(value = "Shows a list of all rules", response = LifecylceDTO.class, responseContainer = "List", authorizations = {@Authorization(value = "oauth", scopes = {@AuthorizationScope(scope = "uid", description = "")})}) @ApiImplicitParams({ @ApiImplicitParam(name = "page", dataType = "integer", paramType = "query", value = "Results page you want to retrieve (0..N)"), @ApiImplicitParam(name = "size", dataType = "integer", paramType = "query", value = "Number of records per page."), @ApiImplicitParam(name = "sort", allowMultiple = true, dataType = "string", paramType = "query", value = "Sorting criteria in the format: \"property,[asc|desc]\". " + "Default sort order is ascending. " + "Multiple sort criteria are supported.") }) @ApiResponses(@ApiResponse(code = 200, message = "the list of violations grouped by version, instance, created; Ordered by date")) public Page<LifecylceDTO> findByApplicationName(@PathVariable("name") final String name, @ApiIgnore @PageableDefault(page = 0, size = 10, sort = "created", direction = ASC) final Pageable pageable) { final Page<LifecycleEntity> lifecycleEntities = applicationLifecycleService.findByApplicationNameAndVersion(name, null, pageable); return mapToDto(lifecycleEntities); } @Autowired  LifecycleController(final ApplicationLifecycleService applicationLifecycleService); @RequestMapping(value = "/applications/{name}/versions", method = GET) @ApiOperation(value = "Shows a list of all rules", response = LifecylceDTO.class, responseContainer = "List", authorizations = {@Authorization(value = "oauth", scopes = {@AuthorizationScope(scope = "uid", description = "")})}) @ApiImplicitParams({ @ApiImplicitParam(name = "page", dataType = "integer", paramType = "query", value = "Results page you want to retrieve (0..N)"), @ApiImplicitParam(name = "size", dataType = "integer", paramType = "query", value = "Number of records per page."), @ApiImplicitParam(name = "sort", allowMultiple = true, dataType = "string", paramType = "query", value = "Sorting criteria in the format: \"property,[asc|desc]\". " + "Default sort order is ascending. " + "Multiple sort criteria are supported.") }) @ApiResponses(@ApiResponse(code = 200, message = "the list of violations grouped by version, instance, created; Ordered by date")) Page<LifecylceDTO> findByApplicationName(@PathVariable("name")
                                                    final String name,
                                                    @ApiIgnore
                                                    @PageableDefault(page = 0, size = 10, sort = "created", direction = ASC) final Pageable pageable); @RequestMapping(value = "/applications/{name}/versions/{version}", method = GET) @ApiOperation(value = "Shows a list of all rules", response = LifecylceDTO.class, responseContainer = "List", authorizations = {@Authorization(value = "oauth", scopes = {@AuthorizationScope(scope = "uid", description = "")})}) @ApiImplicitParams({ @ApiImplicitParam(name = "page", dataType = "integer", paramType = "query", value = "Results page you want to retrieve (0..N)"), @ApiImplicitParam(name = "size", dataType = "integer", paramType = "query", value = "Number of records per page."), @ApiImplicitParam(name = "sort", allowMultiple = true, dataType = "string", paramType = "query", value = "Sorting criteria in the format: \"property,[asc|desc]\". " + "Default sort order is ascending. " + "Multiple sort criteria are supported.") }) @ApiResponses(@ApiResponse(code = 200, message = "the list of violations grouped by version, instance, created; Ordered by date")) Page<LifecylceDTO> findByApplicationName(@PathVariable("name")
                                                    final String name,
                                                    @PathVariable("version")
                                                    final String version,
                                                    @ApiIgnore
                                                    @PageableDefault(page = 0, size = 10, sort = "created", direction = ASC) final Pageable pageable);  }
@Test public void testFindByApplicationName() throws Exception { lifecycleEntity1 = new LifecycleEntity(); lifecycleEntity1.setAccountId("1234"); lifecycleEntity1.setApplicationEntity(new ApplicationEntity("test")); lifecycleEntity1.setVersionEntity(new VersionEntity("1.0-SNAP")); lifecycleEntity1.setCreated(DateTime.now()); lifecycleEntity2 = new LifecycleEntity(); lifecycleEntity2.setAccountId("456"); lifecycleEntity2.setApplicationEntity(new ApplicationEntity("test")); lifecycleEntity2.setVersionEntity(new VersionEntity("2.0-SNAP")); lifecycleEntity2.setCreated(DateTime.now()); final List<LifecycleEntity> lifecycleEntityList = Lists.newArrayList(lifecycleEntity1, lifecycleEntity2); when(applicationLifecycleServiceMock.findByApplicationNameAndVersion(any(), any(), any())).thenReturn( new PageImpl<>( lifecycleEntityList, new PageRequest(0, 20, ASC, "created"), 50)); final ResultActions resultActions = mockMvc.perform(get("/api/lifecycles/applications/test/versions")).andExpect(status().isOk()); resultActions.andExpect(jsonPath("$.content", hasSize(2))); resultActions.andExpect(jsonPath("$.content[0].application").value("test")); resultActions.andExpect(jsonPath("$.content[1].version").value("2.0-SNAP")); verify(applicationLifecycleServiceMock).findByApplicationNameAndVersion(any(), any(), any()); }