@Test public void artifactWithArtifactIdNullIsNotValid(){ final Artifact artifact = DataModelFactory.createArtifact("groupId", null, "version", null, null, null); WebApplicationException exception = null; try{ DataValidator.validate(artifact); } catch (WebApplicationException e){ exception = e; } assertNotNull(exception); }
public static void validate(final Artifact artifact) { if((artifact.getOrigin()== null || "maven".equals(artifact.getOrigin())) && (artifact.getGroupId() == null || artifact.getGroupId().isEmpty())){ throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity("Artifact groupId should not be null or empty") .build()); } if(artifact.getArtifactId() == null || artifact.getArtifactId().isEmpty()){ throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity("Artifact artifactId should not be null or empty") .build()); } if(artifact.getVersion() == null || artifact.getVersion().isEmpty()){ throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity("Artifact version should not be null or empty") .build()); } }
DataValidator { public static void validate(final Artifact artifact) { if((artifact.getOrigin()== null || "maven".equals(artifact.getOrigin())) && (artifact.getGroupId() == null || artifact.getGroupId().isEmpty())){ throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity("Artifact groupId should not be null or empty") .build()); } if(artifact.getArtifactId() == null || artifact.getArtifactId().isEmpty()){ throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity("Artifact artifactId should not be null or empty") .build()); } if(artifact.getVersion() == null || artifact.getVersion().isEmpty()){ throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity("Artifact version should not be null or empty") .build()); } } }
DataValidator { public static void validate(final Artifact artifact) { if((artifact.getOrigin()== null || "maven".equals(artifact.getOrigin())) && (artifact.getGroupId() == null || artifact.getGroupId().isEmpty())){ throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity("Artifact groupId should not be null or empty") .build()); } if(artifact.getArtifactId() == null || artifact.getArtifactId().isEmpty()){ throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity("Artifact artifactId should not be null or empty") .build()); } if(artifact.getVersion() == null || artifact.getVersion().isEmpty()){ throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity("Artifact version should not be null or empty") .build()); } } private  DataValidator(); }
DataValidator { public static void validate(final Artifact artifact) { if((artifact.getOrigin()== null || "maven".equals(artifact.getOrigin())) && (artifact.getGroupId() == null || artifact.getGroupId().isEmpty())){ throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity("Artifact groupId should not be null or empty") .build()); } if(artifact.getArtifactId() == null || artifact.getArtifactId().isEmpty()){ throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity("Artifact artifactId should not be null or empty") .build()); } if(artifact.getVersion() == null || artifact.getVersion().isEmpty()){ throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity("Artifact version should not be null or empty") .build()); } } private  DataValidator(); static void validate(final Artifact artifact); static void validatePostArtifact(final Artifact artifact); static void validate(final License license); static void validate(final Module module); static void validate(final Organization organization); static void validate(final ArtifactQuery artifactQuery); }
DataValidator { public static void validate(final Artifact artifact) { if((artifact.getOrigin()== null || "maven".equals(artifact.getOrigin())) && (artifact.getGroupId() == null || artifact.getGroupId().isEmpty())){ throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity("Artifact groupId should not be null or empty") .build()); } if(artifact.getArtifactId() == null || artifact.getArtifactId().isEmpty()){ throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity("Artifact artifactId should not be null or empty") .build()); } if(artifact.getVersion() == null || artifact.getVersion().isEmpty()){ throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity("Artifact version should not be null or empty") .build()); } } private  DataValidator(); static void validate(final Artifact artifact); static void validatePostArtifact(final Artifact artifact); static void validate(final License license); static void validate(final Module module); static void validate(final Organization organization); static void validate(final ArtifactQuery artifactQuery);  }