@Test public void getArtifactModuleButWithNoModule() throws IOException{ final String gavc = "com.my.company:test:1233:jar"; stubFor(get(urlEqualTo("/" + ServerAPI.ARTIFACT_RESOURCE + "/" + gavc + ServerAPI.GET_MODULE)) .willReturn(aResponse().withStatus(Status.NO_CONTENT.getStatusCode()))); Exception exception = null; try{ final Module module = client.getArtifactModule(gavc); assertNull(module); }catch (Exception e) { exception = e; } assertNull(exception); }
public Module getArtifactModule(final String gavc) throws GrapesCommunicationException { final Client client = getClient(); final WebResource resource = client.resource(serverURL).path(RequestUtils.getArtifactModule(gavc)); final ClientResponse response = resource .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class); client.destroy(); if(ClientResponse.Status.NO_CONTENT.getStatusCode() == response.getStatus()){ return null; } if(ClientResponse.Status.OK.getStatusCode() != response.getStatus()){ final String message = FAILED_TO_GET_CORPORATE_FILTERS; if(LOG.isErrorEnabled()) { LOG.error(String.format(HTTP_STATUS_TEMPLATE_MSG, message, response.getStatus())); } throw new GrapesCommunicationException(message, response.getStatus()); } return response.getEntity(Module.class); }
GrapesClient { public Module getArtifactModule(final String gavc) throws GrapesCommunicationException { final Client client = getClient(); final WebResource resource = client.resource(serverURL).path(RequestUtils.getArtifactModule(gavc)); final ClientResponse response = resource .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class); client.destroy(); if(ClientResponse.Status.NO_CONTENT.getStatusCode() == response.getStatus()){ return null; } if(ClientResponse.Status.OK.getStatusCode() != response.getStatus()){ final String message = FAILED_TO_GET_CORPORATE_FILTERS; if(LOG.isErrorEnabled()) { LOG.error(String.format(HTTP_STATUS_TEMPLATE_MSG, message, response.getStatus())); } throw new GrapesCommunicationException(message, response.getStatus()); } return response.getEntity(Module.class); } }
GrapesClient { public Module getArtifactModule(final String gavc) throws GrapesCommunicationException { final Client client = getClient(); final WebResource resource = client.resource(serverURL).path(RequestUtils.getArtifactModule(gavc)); final ClientResponse response = resource .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class); client.destroy(); if(ClientResponse.Status.NO_CONTENT.getStatusCode() == response.getStatus()){ return null; } if(ClientResponse.Status.OK.getStatusCode() != response.getStatus()){ final String message = FAILED_TO_GET_CORPORATE_FILTERS; if(LOG.isErrorEnabled()) { LOG.error(String.format(HTTP_STATUS_TEMPLATE_MSG, message, response.getStatus())); } throw new GrapesCommunicationException(message, response.getStatus()); } return response.getEntity(Module.class); } GrapesClient(final String host, final String port); }
GrapesClient { public Module getArtifactModule(final String gavc) throws GrapesCommunicationException { final Client client = getClient(); final WebResource resource = client.resource(serverURL).path(RequestUtils.getArtifactModule(gavc)); final ClientResponse response = resource .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class); client.destroy(); if(ClientResponse.Status.NO_CONTENT.getStatusCode() == response.getStatus()){ return null; } if(ClientResponse.Status.OK.getStatusCode() != response.getStatus()){ final String message = FAILED_TO_GET_CORPORATE_FILTERS; if(LOG.isErrorEnabled()) { LOG.error(String.format(HTTP_STATUS_TEMPLATE_MSG, message, response.getStatus())); } throw new GrapesCommunicationException(message, response.getStatus()); } return response.getEntity(Module.class); } GrapesClient(final String host, final String port); void setTimeout(final Integer timeout); String getServerURL(); boolean isServerAvailable(); void postBuildInfo(final String moduleName, final String moduleVersion, final Map<String, String> buildInfo, final String user, final String password); Map<String, String> getBuildInfo(final String moduleName, final String moduleVersion); void postModule(final Module module, final String user, final String password); void deleteModule(final String name, final String version, final String user, final String password); Module getModule(final String name, final String version); List<Module> getModules(final Map<String, String> filters); List<String> getModuleVersions(final String name); Boolean getModulePromotionStatus(final String name, final String version); void promoteModule(final String name, final String version, final String user, final String password); Boolean moduleCanBePromoted(final String name, final String version); T getModulePromotionReportRaw(final String name,
                                             final String version,
                                             final boolean excludeSnapshotValidation,
                                             final Class<T> entityClass); PromotionEvaluationReport getModulePromotionReport(final String name, final String version); void postArtifact(final Artifact artifact, final String user, final String password); void deleteArtifact(final String gavc, final String user, final String password); Artifact getArtifact(final String gavc); List<Artifact> getArtifacts(final Boolean hasLicense); void postDoNotUseArtifact(final String gavc, final Boolean doNotUse, final String user, final String password); Boolean isMarkedAsDoNotUse(final String gavc); List<String> getArtifactVersions(final String gavc); String getArtifactLastVersion(final String gavc); Module getArtifactModule(final String gavc); void addLicense(final String gavc, final String licenseId, final String user, final String password); void postLicense(final License license, final String user, final String password); void deleteLicense(final String licenseId, final String user, final String password); License getLicense(final String licenseId); void approveLicense(final String licenseId, final Boolean approve, final String user, final String password); List<Dependency> getModuleAncestors(final String moduleName, final String moduleVersion); List<Dependency> getModuleDependencies(final String moduleName, final String moduleVersion, final Boolean fullRecursive, final Boolean corporate, final Boolean thirdParty); Organization getModuleOrganization(final String moduleName, final String moduleVersion); List<String> getProductModuleNames(final String projectId); List<String> getAllProductNames(); Delivery getProductDelivery(final String productLogicalName, final String commercialName, final String commercialVersion); List<Delivery> getProductDeliveries(final String productLogicalName); void createProductDelivery(final String productLogicalName, final Delivery delivery, final String user, final String password); }
GrapesClient { public Module getArtifactModule(final String gavc) throws GrapesCommunicationException { final Client client = getClient(); final WebResource resource = client.resource(serverURL).path(RequestUtils.getArtifactModule(gavc)); final ClientResponse response = resource .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class); client.destroy(); if(ClientResponse.Status.NO_CONTENT.getStatusCode() == response.getStatus()){ return null; } if(ClientResponse.Status.OK.getStatusCode() != response.getStatus()){ final String message = FAILED_TO_GET_CORPORATE_FILTERS; if(LOG.isErrorEnabled()) { LOG.error(String.format(HTTP_STATUS_TEMPLATE_MSG, message, response.getStatus())); } throw new GrapesCommunicationException(message, response.getStatus()); } return response.getEntity(Module.class); } GrapesClient(final String host, final String port); void setTimeout(final Integer timeout); String getServerURL(); boolean isServerAvailable(); void postBuildInfo(final String moduleName, final String moduleVersion, final Map<String, String> buildInfo, final String user, final String password); Map<String, String> getBuildInfo(final String moduleName, final String moduleVersion); void postModule(final Module module, final String user, final String password); void deleteModule(final String name, final String version, final String user, final String password); Module getModule(final String name, final String version); List<Module> getModules(final Map<String, String> filters); List<String> getModuleVersions(final String name); Boolean getModulePromotionStatus(final String name, final String version); void promoteModule(final String name, final String version, final String user, final String password); Boolean moduleCanBePromoted(final String name, final String version); T getModulePromotionReportRaw(final String name,
                                             final String version,
                                             final boolean excludeSnapshotValidation,
                                             final Class<T> entityClass); PromotionEvaluationReport getModulePromotionReport(final String name, final String version); void postArtifact(final Artifact artifact, final String user, final String password); void deleteArtifact(final String gavc, final String user, final String password); Artifact getArtifact(final String gavc); List<Artifact> getArtifacts(final Boolean hasLicense); void postDoNotUseArtifact(final String gavc, final Boolean doNotUse, final String user, final String password); Boolean isMarkedAsDoNotUse(final String gavc); List<String> getArtifactVersions(final String gavc); String getArtifactLastVersion(final String gavc); Module getArtifactModule(final String gavc); void addLicense(final String gavc, final String licenseId, final String user, final String password); void postLicense(final License license, final String user, final String password); void deleteLicense(final String licenseId, final String user, final String password); License getLicense(final String licenseId); void approveLicense(final String licenseId, final Boolean approve, final String user, final String password); List<Dependency> getModuleAncestors(final String moduleName, final String moduleVersion); List<Dependency> getModuleDependencies(final String moduleName, final String moduleVersion, final Boolean fullRecursive, final Boolean corporate, final Boolean thirdParty); Organization getModuleOrganization(final String moduleName, final String moduleVersion); List<String> getProductModuleNames(final String projectId); List<String> getAllProductNames(); Delivery getProductDelivery(final String productLogicalName, final String commercialName, final String commercialVersion); List<Delivery> getProductDeliveries(final String productLogicalName); void createProductDelivery(final String productLogicalName, final Delivery delivery, final String user, final String password); static final String FAILED_TO_GET_CORPORATE_FILTERS; static final String FAILED_TO_GET_MODULE; }