ModuleResource extends AbstractResource { @GET @Produces(MediaType.APPLICATION_JSON) @Path("/{name}/{version}" + ServerAPI.PROMOTION + ServerAPI.GET_FEASIBLE) public Response canBePromoted(@PathParam("name") final String name, @PathParam("version") final String version) { if (LOG.isInfoEnabled()) { LOG.info(String.format("Got a is the module promotable request [%s, %s]", name, version)); } final String moduleId = DbModule.generateID(name, version); final PromotionReportView promotionReportView = getModuleHandler().getPromotionReport(moduleId); final PromotionEvaluationReport report = PromotionReportTranslator.toReport(promotionReportView); return Response.ok(report.isPromotable()).build(); } ModuleResource(final RepositoryHandler repoHandler, final GrapesServerConfig dmConfig); @POST @Produces(MediaType.TEXT_HTML) Response postModule(@Auth final DbCredential credential, final Module module); @GET @Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON}) @Path(ServerAPI.GET_NAMES) Response getNames(@Context final UriInfo uriInfo); @GET @Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON}) @Path("/{name}") Response getVersionsRedirection(@PathParam("name") final String name, @Context final UriInfo uriInfo); @GET @Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON}) @Path("/{name}" + ServerAPI.GET_VERSIONS) Response getVersions(@PathParam("name") final String name, @Context final UriInfo uriInfo); @GET @Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON}) @Path("/{name}/{version}") Response get(@PathParam("name") final String name, @PathParam("version") final String version); @DELETE @Path("/{name}/{version}") Response delete(@Auth final DbCredential credential, @PathParam("name") final String name, @PathParam("version") final String version); @GET @Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON}) @Path("/{name}/{version}" + ServerAPI.GET_ORGANIZATION) Response getOrganization(@PathParam("name") final String name, @PathParam("version") final String version); @GET @Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON}) @Path("/{name}/{version}" + ServerAPI.GET_ANCESTORS) Response getAncestors(@PathParam("name") final String name,
                                 @PathParam("version") final String version,
                                 @Context final UriInfo uriInfo); @GET @Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON}) @Path("/{name}/{version}" + ServerAPI.GET_DEPENDENCIES) Response getDependencies(@PathParam("name") final String name,
                                    @PathParam("version") final String version,
                                    @Context final UriInfo uriInfo); @GET @Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON}) @Path("/{name}/{version}" + ServerAPI.GET_DEPENDENCIES + ServerAPI.GET_REPORT) Response getDependencyReport(@PathParam("name") final String name,
                                        @PathParam("version") final String version,
                                        @Context final UriInfo uriInfo); @GET @Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON}) @Path("/{name}/{version}" + ServerAPI.GET_LICENSES) Response getLicenses(@PathParam("name") final String name, @PathParam("version") final String version); @POST @Path("/{name}/{version}" + ServerAPI.PROMOTION) Response promote(@Auth final DbCredential credential, @PathParam("name") final String name, @PathParam("version") final String version); @GET @Produces(MediaType.APPLICATION_JSON) @Path("/{name}/{version}" + ServerAPI.PROMOTION + ServerAPI.GET_FEASIBLE) Response canBePromoted(@PathParam("name") final String name, @PathParam("version") final String version); @GET @Produces({MediaType.APPLICATION_JSON}) @Path("/{name}/{version}" + ServerAPI.PROMOTION + ServerAPI.GET_REPORT) Response getPromotionStatusReport(@PathParam("name") final String name,
                                             @PathParam("version") final String version,
                                             @QueryParam(ServerAPI.EXCLUDE_SNAPSHOT_PARAM) boolean excludeSnapshot); @GET @Produces(MediaType.APPLICATION_JSON) @Path("/{name}/{version}" + ServerAPI.PROMOTION) Response isPromoted(@PathParam("name") final String name, @PathParam("version") final String version); @GET @Produces(MediaType.APPLICATION_JSON) @Path("/{name}/{version}" + ServerAPI.GET_BUILD_INFO) Response getBuildInfo(@PathParam("name") final String name, @PathParam("version") final String version); @POST @Path("/{name}/{version}" + ServerAPI.GET_BUILD_INFO) Response updateBuildInfo(@PathParam("name") final String name, @PathParam("version") final String version, final Map<String, String> buildInfo); @GET @Produces(MediaType.APPLICATION_JSON) @Path(ServerAPI.GET_ALL) Response getAllModules(@Context final UriInfo uriInfo);  }
@Test public void canBePromoted() throws UnknownHostException { final DbModule dbModule = new DbModule(); dbModule.setName("moduleTest"); dbModule.setVersion("1.0.0"); when(repositoryHandler.getModule(dbModule.getId())).thenReturn(dbModule); withErrors(PromotionValidation.VERSION_IS_SNAPSHOT); final WebResource resource = client().resource("/" + ServerAPI.MODULE_RESOURCE + "/" + dbModule.getName() + "/" + dbModule.getVersion() + ServerAPI.PROMOTION + ServerAPI.GET_FEASIBLE); ClientResponse response = resource.accept(MediaType.APPLICATION_JSON).get(ClientResponse.class); assertNotNull(response); assertEquals(HttpStatus.OK_200, response.getStatus()); Boolean results = response.getEntity(Boolean.class); assertNotNull(results); assertTrue(results); }