@Test public void artifactWithExtensionNullIsNotValid(){ final Artifact artifact = DataModelFactory.createArtifact("groupId", "artifactId", "version", "classifier" , null , null); WebApplicationException exception = null; try{ DataValidator.validatePostArtifact(artifact); } catch (WebApplicationException e){ exception = e; } assertNotNull(exception); }
public static void validatePostArtifact(final Artifact artifact) { validate(artifact); if(artifact.getExtension() == null || artifact.getExtension().isEmpty()){ throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity("Artifact extension should not be null or empty") .build()); } if(artifact.getSha256() == null || artifact.getSha256().isEmpty()){ throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity("Artifact SHA256 checksum should not be null or empty") .build()); } if(artifact.getSha256().length() != 64){ throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity("Artifact SHA256 checksum length should be 64") .build()); } }
DataValidator { public static void validatePostArtifact(final Artifact artifact) { validate(artifact); if(artifact.getExtension() == null || artifact.getExtension().isEmpty()){ throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity("Artifact extension should not be null or empty") .build()); } if(artifact.getSha256() == null || artifact.getSha256().isEmpty()){ throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity("Artifact SHA256 checksum should not be null or empty") .build()); } if(artifact.getSha256().length() != 64){ throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity("Artifact SHA256 checksum length should be 64") .build()); } } }
DataValidator { public static void validatePostArtifact(final Artifact artifact) { validate(artifact); if(artifact.getExtension() == null || artifact.getExtension().isEmpty()){ throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity("Artifact extension should not be null or empty") .build()); } if(artifact.getSha256() == null || artifact.getSha256().isEmpty()){ throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity("Artifact SHA256 checksum should not be null or empty") .build()); } if(artifact.getSha256().length() != 64){ throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity("Artifact SHA256 checksum length should be 64") .build()); } } private  DataValidator(); }
DataValidator { public static void validatePostArtifact(final Artifact artifact) { validate(artifact); if(artifact.getExtension() == null || artifact.getExtension().isEmpty()){ throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity("Artifact extension should not be null or empty") .build()); } if(artifact.getSha256() == null || artifact.getSha256().isEmpty()){ throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity("Artifact SHA256 checksum should not be null or empty") .build()); } if(artifact.getSha256().length() != 64){ throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity("Artifact SHA256 checksum length should be 64") .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 validatePostArtifact(final Artifact artifact) { validate(artifact); if(artifact.getExtension() == null || artifact.getExtension().isEmpty()){ throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity("Artifact extension should not be null or empty") .build()); } if(artifact.getSha256() == null || artifact.getSha256().isEmpty()){ throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity("Artifact SHA256 checksum should not be null or empty") .build()); } if(artifact.getSha256().length() != 64){ throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity("Artifact SHA256 checksum length should be 64") .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);  }