diff --git a/s3auth-hosts/src/main/java/com/s3auth/hosts/BucketMocker.java b/s3auth-hosts/src/main/java/com/s3auth/hosts/BucketMocker.java index 847ad2b1..efee845d 100644 --- a/s3auth-hosts/src/main/java/com/s3auth/hosts/BucketMocker.java +++ b/s3auth-hosts/src/main/java/com/s3auth/hosts/BucketMocker.java @@ -135,26 +135,32 @@ private static class MkBucket implements Bucket { * The Bucket Name. */ private final transient String name; + /** * The Bucket key. */ private final transient String key; + /** * The Bucket secret. */ private final transient String secret; + /** * The Bucket bucket. */ private final transient String bucket; + /** * The Bucket region. */ private final transient String region; + /** * The Bucket syslog. */ private final transient String syslog; + /** * The Bucket client. */ diff --git a/s3auth-hosts/src/main/java/com/s3auth/hosts/DefaultDomain.java b/s3auth-hosts/src/main/java/com/s3auth/hosts/DefaultDomain.java index 8b897951..1c9da5d0 100644 --- a/s3auth-hosts/src/main/java/com/s3auth/hosts/DefaultDomain.java +++ b/s3auth-hosts/src/main/java/com/s3auth/hosts/DefaultDomain.java @@ -70,26 +70,32 @@ final class DefaultDomain implements Domain { public String toString() { return String.format("%s/%s", name, region); } + @Override public String name() { return name; } + @Override public String key() { return key; } + @Override public String secret() { return secret; } + @Override public String bucket() { return bucket; } + @Override public String region() { return region; } + @Override public String syslog() { return syslog; diff --git a/s3auth-hosts/src/main/java/com/s3auth/hosts/DefaultDynamo.java b/s3auth-hosts/src/main/java/com/s3auth/hosts/DefaultDynamo.java index e314bc2c..c5a64d6e 100644 --- a/s3auth-hosts/src/main/java/com/s3auth/hosts/DefaultDynamo.java +++ b/s3auth-hosts/src/main/java/com/s3auth/hosts/DefaultDynamo.java @@ -112,6 +112,7 @@ final class DefaultDynamo implements Dynamo { /** * Public ctor. */ + @SuppressWarnings("PMD.ConstructorOnlyInitializesOrCallOtherConstructors") DefaultDynamo() { Credentials creds = new Credentials.Simple( Manifests.read("S3Auth-AwsDynamoKey"), diff --git a/s3auth-hosts/src/main/java/com/s3auth/hosts/DefaultHost.java b/s3auth-hosts/src/main/java/com/s3auth/hosts/DefaultHost.java index 1fc46fcb..f4ba8b93 100644 --- a/s3auth-hosts/src/main/java/com/s3auth/hosts/DefaultHost.java +++ b/s3auth-hosts/src/main/java/com/s3auth/hosts/DefaultHost.java @@ -288,6 +288,7 @@ private final class NameWithSuffix implements DefaultHost.ObjectName { * Original name. */ private final transient String origin; + /** * Public ctor. * @param name The original name @@ -295,6 +296,7 @@ private final class NameWithSuffix implements DefaultHost.ObjectName { NameWithSuffix(final String name) { this.origin = name; } + @Override public String get() { String suffix = null; @@ -328,6 +330,8 @@ public String toString() { /** * Object name. + * + * @since 0.0.1 */ @EqualsAndHashCode(of = "name") private static final class Simple implements DefaultHost.ObjectName { @@ -335,6 +339,7 @@ private static final class Simple implements DefaultHost.ObjectName { * Original name. */ private final transient String name; + /** * Public ctor. * @param nme The name @@ -342,10 +347,12 @@ private static final class Simple implements DefaultHost.ObjectName { Simple(final String nme) { this.name = nme; } + @Override public String get() { return this.name; } + @Override public String toString() { return this.name; @@ -354,6 +361,8 @@ public String toString() { /** * Stats for this domain. + * + * @since 0.0.1 */ @Loggable(Loggable.DEBUG) @EqualsAndHashCode(of = "bucket") @@ -362,6 +371,7 @@ private final class HostStats implements Stats { * The S3 bucket. */ private final transient String bucket; + /** * Public ctor. * @param bckt The name of the bucket @@ -369,6 +379,7 @@ private final class HostStats implements Stats { public HostStats(final String bckt) { this.bucket = bckt; } + @Override @Cacheable(lifetime = 30, unit = TimeUnit.MINUTES) public long bytesTransferred() { @@ -399,6 +410,8 @@ public long bytesTransferred() { /** * Name of an S3 Object, context dependent. + * + * @since 0.0.1 */ private interface ObjectName { /** diff --git a/s3auth-hosts/src/main/java/com/s3auth/hosts/Domain.java b/s3auth-hosts/src/main/java/com/s3auth/hosts/Domain.java index a483b62b..e087a73e 100644 --- a/s3auth-hosts/src/main/java/com/s3auth/hosts/Domain.java +++ b/s3auth-hosts/src/main/java/com/s3auth/hosts/Domain.java @@ -78,7 +78,7 @@ public interface Domain { /** * Region of S3 bucket. - * @return Region name/endpoint, e.g. "us-east-1" + * @return Region name/endpoint, e.g. "s3-us-east-1" * @see S3 Regions */ String region(); @@ -110,6 +110,8 @@ public interface Domain { /** * Validator of Domain. + * + * @since 0.0.1 */ @SuppressWarnings("PMD.NPathComplexity") class Validator implements ConstraintValidator { @@ -125,12 +127,12 @@ public boolean isValid(final Domain domain, boolean isValid = true; if (domain.name() == null) { ctx.buildConstraintViolationWithTemplate( - "domain name is mandatory and can't be NULL" + "Domain name is mandatory and can't be NULL" ).addConstraintViolation(); isValid = false; - } else if (!domain.name().matches("\\s*[a-zA-Z0-9\\-\\.]+\\s*")) { + } else if (!domain.name().matches("\\s*[a-zA-Z0-9\\-.]+\\s*")) { ctx.buildConstraintViolationWithTemplate( - String.format("invalid domain name '%s'", domain.name()) + String.format("Invalid domain name '%s'", domain.name()) ).addPropertyNode("name").addConstraintViolation(); isValid = false; } @@ -141,7 +143,7 @@ public boolean isValid(final Domain domain, isValid = false; } else if (!domain.key().matches("\\s*[A-Z0-9]{20}\\s*")) { ctx.buildConstraintViolationWithTemplate( - String.format("invalid AWS key '%s'", domain.key()) + String.format("Invalid AWS key '%s'", domain.key()) ).addPropertyNode("key").addConstraintViolation(); isValid = false; } @@ -150,9 +152,9 @@ public boolean isValid(final Domain domain, "AWS S3 region is mandatory and can't be NULL" ).addConstraintViolation(); isValid = false; - } else if (!domain.region().matches("s3[a-z0-9\\-]*")) { + } else if (!domain.region().matches("[a-z0-9\\-]*")) { ctx.buildConstraintViolationWithTemplate( - String.format("invalid AWS S3 region '%s'", domain.region()) + String.format("Invalid AWS S3 region '%s'", domain.region()) ).addPropertyNode("region").addConstraintViolation(); isValid = false; } @@ -164,7 +166,7 @@ public boolean isValid(final Domain domain, } else if (!domain.secret() .matches("\\s*[a-zA-Z0-9\\+/]{40}\\s*")) { ctx.buildConstraintViolationWithTemplate( - String.format("invalid AWS secret '%s'", domain.secret()) + String.format("Invalid AWS secret '%s'", domain.secret()) ).addPropertyNode("secret").addConstraintViolation(); isValid = false; } @@ -173,7 +175,7 @@ public boolean isValid(final Domain domain, .matches("\\s*[a-zA-Z0-9\\-\\.]+(:\\d+)?\\s*") ) { ctx.buildConstraintViolationWithTemplate( - String.format("invalid syslog host '%s'", domain.syslog()) + String.format("Invalid syslog host '%s'", domain.syslog()) ).addPropertyNode("syslog").addConstraintViolation(); isValid = false; } diff --git a/s3auth-hosts/src/main/java/com/s3auth/hosts/DynamoHosts.java b/s3auth-hosts/src/main/java/com/s3auth/hosts/DynamoHosts.java index 23e67952..12a1ffc3 100644 --- a/s3auth-hosts/src/main/java/com/s3auth/hosts/DynamoHosts.java +++ b/s3auth-hosts/src/main/java/com/s3auth/hosts/DynamoHosts.java @@ -198,6 +198,8 @@ private Domain byName(final String name) throws IOException { /** * Wrap of domains. + * + * @since 0.0.1 */ @Loggable(Loggable.DEBUG) private final class Wrap extends AbstractSet { @@ -205,10 +207,12 @@ private final class Wrap extends AbstractSet { * User. */ private final transient User user; + /** * Domains. */ private final transient Domains domains; + /** * Public ctor. * @param usr User @@ -219,22 +223,27 @@ private final class Wrap extends AbstractSet { this.user = usr; this.domains = dmns; } + @Override public int size() { return this.domains.size(); } + @Override public Iterator iterator() { return this.domains.iterator(); } + @Override public boolean contains(final Object obj) { return this.domains.contains(obj); } + @Override public boolean add(@NotNull @Valid final Domain domain) { return DynamoHosts.this.add(this.user.identity(), domain); } + @Override public boolean remove(final Object obj) { return DynamoHosts.this.remove( diff --git a/s3auth-hosts/src/main/java/com/s3auth/hosts/DynamoMocker.java b/s3auth-hosts/src/main/java/com/s3auth/hosts/DynamoMocker.java index 770c2195..38700c11 100644 --- a/s3auth-hosts/src/main/java/com/s3auth/hosts/DynamoMocker.java +++ b/s3auth-hosts/src/main/java/com/s3auth/hosts/DynamoMocker.java @@ -30,7 +30,6 @@ package com.s3auth.hosts; import com.jcabi.urn.URN; -import java.io.IOException; import java.util.Collections; import java.util.Map; import java.util.Set; @@ -61,6 +60,7 @@ public Dynamo mock() { public Map load() { return Collections.unmodifiableMap(DynamoMocker.this.users); } + @Override public boolean add(final URN user, final Domain domain) { DynamoMocker.this.users.putIfAbsent(user, new Domains()); @@ -68,6 +68,7 @@ public boolean add(final URN user, final Domain domain) { .add(new DefaultDomain(domain)); return true; } + @Override public boolean remove(final Domain domain) { for (final Set domains @@ -77,6 +78,7 @@ public boolean remove(final Domain domain) { } return true; } + @Override public void close() { assert this != null; diff --git a/s3auth-hosts/src/main/java/com/s3auth/hosts/H2DomainStatsData.java b/s3auth-hosts/src/main/java/com/s3auth/hosts/H2DomainStatsData.java index c2129ea1..80eefb98 100644 --- a/s3auth-hosts/src/main/java/com/s3auth/hosts/H2DomainStatsData.java +++ b/s3auth-hosts/src/main/java/com/s3auth/hosts/H2DomainStatsData.java @@ -110,7 +110,7 @@ final class H2DomainStatsData implements DomainStatsData { H2DomainStatsData(final File file) throws IOException { this.jdbc = String.format("jdbc:h2:file:%s", file.getAbsolutePath()); try { - this.session().sql(CREATE).execute().commit(); + this.session().sql(H2DomainStatsData.CREATE).execute().commit(); } catch (final SQLException ex) { throw new IOException(ex); } @@ -120,7 +120,7 @@ final class H2DomainStatsData implements DomainStatsData { public void put(final String domain, final Stats stats) throws IOException { try { this.session() - .sql(INSERT) + .sql(H2DomainStatsData.INSERT) .set(domain) .set(stats.bytesTransferred()) .execute() @@ -138,7 +138,7 @@ public Stats get(final String domain) throws IOException { final Stats result = session .sql("SELECT SUM(BYTES) FROM DOMAIN_STATS WHERE DOMAIN = ?") .set(domain) - .select(STATS); + .select(H2DomainStatsData.STATS); session.sql("DELETE FROM DOMAIN_STATS WHERE DOMAIN = ?") .set(domain) .execute() @@ -157,7 +157,7 @@ public Map all() throws IOException { // @checkstyle LineLength (2 lines) final Map result = session .sql("SELECT DOMAIN, SUM(BYTES) FROM DOMAIN_STATS GROUP BY DOMAIN") - .select(STATS_ALL); + .select(H2DomainStatsData.STATS_ALL); session.sql("DELETE FROM DOMAIN_STATS").execute().commit(); return result; } catch (final SQLException ex) { diff --git a/s3auth-hosts/src/main/java/com/s3auth/hosts/HostMocker.java b/s3auth-hosts/src/main/java/com/s3auth/hosts/HostMocker.java index 9b13439d..91597fac 100644 --- a/s3auth-hosts/src/main/java/com/s3auth/hosts/HostMocker.java +++ b/s3auth-hosts/src/main/java/com/s3auth/hosts/HostMocker.java @@ -29,7 +29,6 @@ */ package com.s3auth.hosts; -import java.io.IOException; import java.net.URI; import lombok.Builder; @@ -84,6 +83,11 @@ public Host mock() { return this.host.build(); } + /** + * Mock. + * + * @since 0.0.1 + */ @Builder @SuppressWarnings({ "PMD.TooManyMethods", "PMD.AvoidFieldNameMatchingMethodName" }) @@ -92,18 +96,22 @@ private static class MkHost implements Host { * The host resource. */ private final transient Resource resource; + /** * Whether the host authorized. */ private final transient boolean authorized; + /** * Whether the host is hidden. */ private final transient boolean hidden; + /** * The host syslog. */ private final transient String syslog; + /** * The host stats. */ diff --git a/s3auth-hosts/src/main/java/com/s3auth/hosts/HostsMocker.java b/s3auth-hosts/src/main/java/com/s3auth/hosts/HostsMocker.java index d761c76a..6e265293 100644 --- a/s3auth-hosts/src/main/java/com/s3auth/hosts/HostsMocker.java +++ b/s3auth-hosts/src/main/java/com/s3auth/hosts/HostsMocker.java @@ -29,7 +29,6 @@ */ package com.s3auth.hosts; -import java.io.IOException; import java.util.Collections; import java.util.Set; @@ -53,6 +52,11 @@ public Hosts mock() { return this.hosts; } + /** + * Mock. + * + * @since 0.0.1 + */ private static class MkHosts implements Hosts { @Override public void close() { diff --git a/s3auth-hosts/src/main/java/com/s3auth/hosts/Htpasswd.java b/s3auth-hosts/src/main/java/com/s3auth/hosts/Htpasswd.java index 621d95b4..406b73ea 100644 --- a/s3auth-hosts/src/main/java/com/s3auth/hosts/Htpasswd.java +++ b/s3auth-hosts/src/main/java/com/s3auth/hosts/Htpasswd.java @@ -166,10 +166,8 @@ private String content() { * @param hash The hash to match * @param password Password * @return TRUE if they match - * @throws IOException If some error inside */ - private static boolean matches(final String hash, final String password) - throws IOException { + private static boolean matches(final String hash, final String password) { boolean matches = false; for (final Htpasswd.Algorithm algo : Htpasswd.ALGORITHMS) { if (algo.matches(hash, password)) { diff --git a/s3auth-hosts/src/main/java/com/s3auth/hosts/MkAmazonS3.java b/s3auth-hosts/src/main/java/com/s3auth/hosts/MkAmazonS3.java index 8217efc8..594a41c5 100644 --- a/s3auth-hosts/src/main/java/com/s3auth/hosts/MkAmazonS3.java +++ b/s3auth-hosts/src/main/java/com/s3auth/hosts/MkAmazonS3.java @@ -224,17 +224,19 @@ /** * AmazonS3 Mock (without Mockito). * - * @checkstyle ThrowsCount (1000 lines) - * @checkstyle RedundantThrows (1000 lines) - * @checkstyle ParameterName (1000 lines) - * @checkstyle DesignForExtension (1000 lines) - * @checkstyle FinalParameters (1000 lines) - * @checkstyle MethodName (1000 lines) - * @checkstyle ParameterNumber (1000 lines) - * @checkstyle BracketsStructure (1000 lines) - * @checkstyle LineLength (1000 lines) - * @checkstyle ClassFanOutComplexity (1000 lines) - * @checkstyle MethodCountCheck (1000 lines) + * @since 0.0.1 + * @checkstyle ThrowsCount (10000 lines) + * @checkstyle RedundantThrows (10000 lines) + * @checkstyle ParameterName (10000 lines) + * @checkstyle DesignForExtension (10000 lines) + * @checkstyle FinalParameters (10000 lines) + * @checkstyle MethodName (10000 lines) + * @checkstyle ParameterNumber (10000 lines) + * @checkstyle BracketsStructure (10000 lines) + * @checkstyle LineLength (10000 lines) + * @checkstyle ClassFanOutComplexity (10000 lines) + * @checkstyle MethodCountCheck (10000 lines) + * @checkstyle FileLengthCheck (10000 lines) */ @SuppressWarnings({"PMD", "deprecation", "serial"}) public class MkAmazonS3 implements AmazonS3, Serializable { @@ -279,8 +281,7 @@ public Bucket createBucket(CreateBucketRequest arg0) } @Override - public Bucket createBucket(String arg0) throws AmazonClientException, - AmazonServiceException { + public Bucket createBucket(String arg0) throws AmazonClientException { return null; } @@ -302,8 +303,7 @@ public void deleteBucket(DeleteBucketRequest arg0) } @Override - public void deleteBucket(String arg0) throws AmazonClientException, - AmazonServiceException { + public void deleteBucket(String arg0) throws AmazonClientException { } @Override @@ -325,8 +325,7 @@ public void deleteBucketLifecycleConfiguration( } @Override - public void deleteBucketPolicy(String arg0) throws AmazonClientException, - AmazonServiceException { + public void deleteBucketPolicy(String arg0) throws AmazonClientException { } @Override @@ -448,8 +447,7 @@ public BucketLifecycleConfiguration getBucketLifecycleConfiguration(GetBucketLif } @Override - public String getBucketLocation(String arg0) throws AmazonClientException, - AmazonServiceException { + public String getBucketLocation(String arg0) throws AmazonClientException { return null; } @@ -552,7 +550,7 @@ public ObjectMetadata getObject(GetObjectRequest arg0, File arg1) } @Override - public String getObjectAsString(String s, String s1) throws AmazonServiceException, SdkClientException { + public String getObjectAsString(String s, String s1) throws SdkClientException { return null; } @@ -601,8 +599,7 @@ public ObjectMetadata getObjectMetadata(String arg0, String arg1) } @Override - public Owner getS3AccountOwner() throws AmazonClientException, - AmazonServiceException { + public Owner getS3AccountOwner() throws AmazonClientException { return null; } @@ -613,14 +610,12 @@ public Owner getS3AccountOwner(GetS3AccountOwnerRequest getS3AccountOwnerRequest @Override public InitiateMultipartUploadResult initiateMultipartUpload( - InitiateMultipartUploadRequest arg0) throws AmazonClientException, - AmazonServiceException { + InitiateMultipartUploadRequest arg0) throws AmazonClientException { return null; } @Override - public List listBuckets() throws AmazonClientException, - AmazonServiceException { + public List listBuckets() throws AmazonClientException { return null; } @@ -632,8 +627,7 @@ public List listBuckets(ListBucketsRequest arg0) @Override public MultipartUploadListing listMultipartUploads( - ListMultipartUploadsRequest arg0) throws AmazonClientException, - AmazonServiceException { + ListMultipartUploadsRequest arg0) throws AmazonClientException { return null; } @@ -660,8 +654,7 @@ public VersionListing listNextBatchOfVersions(ListNextBatchOfVersionsRequest lis } @Override - public ObjectListing listObjects(String arg0) throws AmazonClientException, - AmazonServiceException { + public ObjectListing listObjects(String arg0) throws AmazonClientException { return null; } @@ -712,8 +705,7 @@ public VersionListing listVersions(String arg0, String arg1) @Override public VersionListing listVersions(String arg0, String arg1, String arg2, - String arg3, String arg4, Integer arg5) throws AmazonClientException, - AmazonServiceException { + String arg3, String arg4, Integer arg5) throws AmazonClientException { return null; } @@ -774,246 +766,239 @@ public boolean isRequesterPaysEnabled(final String bucket) @Override public void setRequestPaymentConfiguration(SetRequestPaymentConfigurationRequest setRequestPaymentConfigurationRequest) { - } @Override - public void setBucketReplicationConfiguration(String s, BucketReplicationConfiguration bucketReplicationConfiguration) throws AmazonServiceException, SdkClientException { - + public void setBucketReplicationConfiguration(String s, BucketReplicationConfiguration bucketReplicationConfiguration) throws SdkClientException { } @Override - public void setBucketReplicationConfiguration(SetBucketReplicationConfigurationRequest setBucketReplicationConfigurationRequest) throws AmazonServiceException, SdkClientException { - + public void setBucketReplicationConfiguration(SetBucketReplicationConfigurationRequest setBucketReplicationConfigurationRequest) throws SdkClientException { } @Override - public BucketReplicationConfiguration getBucketReplicationConfiguration(String s) throws AmazonServiceException, SdkClientException { + public BucketReplicationConfiguration getBucketReplicationConfiguration(String s) throws SdkClientException { return null; } @Override - public BucketReplicationConfiguration getBucketReplicationConfiguration(GetBucketReplicationConfigurationRequest getBucketReplicationConfigurationRequest) throws AmazonServiceException, SdkClientException { + public BucketReplicationConfiguration getBucketReplicationConfiguration(GetBucketReplicationConfigurationRequest getBucketReplicationConfigurationRequest) throws SdkClientException { return null; } @Override - public void deleteBucketReplicationConfiguration(String s) throws AmazonServiceException, SdkClientException { - + public void deleteBucketReplicationConfiguration(String s) throws SdkClientException { } @Override - public void deleteBucketReplicationConfiguration(DeleteBucketReplicationConfigurationRequest deleteBucketReplicationConfigurationRequest) throws AmazonServiceException, SdkClientException { - + public void deleteBucketReplicationConfiguration(DeleteBucketReplicationConfigurationRequest deleteBucketReplicationConfigurationRequest) throws SdkClientException { } @Override - public boolean doesObjectExist(String s, String s1) throws AmazonServiceException, SdkClientException { + public boolean doesObjectExist(String s, String s1) throws SdkClientException { return false; } @Override - public BucketAccelerateConfiguration getBucketAccelerateConfiguration(String s) throws AmazonServiceException, SdkClientException { + public BucketAccelerateConfiguration getBucketAccelerateConfiguration(String s) throws SdkClientException { return null; } @Override - public BucketAccelerateConfiguration getBucketAccelerateConfiguration(GetBucketAccelerateConfigurationRequest getBucketAccelerateConfigurationRequest) throws AmazonServiceException, SdkClientException { + public BucketAccelerateConfiguration getBucketAccelerateConfiguration(GetBucketAccelerateConfigurationRequest getBucketAccelerateConfigurationRequest) throws SdkClientException { return null; } @Override - public void setBucketAccelerateConfiguration(String s, BucketAccelerateConfiguration bucketAccelerateConfiguration) throws AmazonServiceException, SdkClientException { - + public void setBucketAccelerateConfiguration(String s, BucketAccelerateConfiguration bucketAccelerateConfiguration) throws SdkClientException { } @Override - public void setBucketAccelerateConfiguration(SetBucketAccelerateConfigurationRequest setBucketAccelerateConfigurationRequest) throws AmazonServiceException, SdkClientException { - + public void setBucketAccelerateConfiguration(SetBucketAccelerateConfigurationRequest setBucketAccelerateConfigurationRequest) throws SdkClientException { } @Override - public DeleteBucketMetricsConfigurationResult deleteBucketMetricsConfiguration(String s, String s1) throws AmazonServiceException, SdkClientException { + public DeleteBucketMetricsConfigurationResult deleteBucketMetricsConfiguration(String s, String s1) throws SdkClientException { return null; } @Override - public DeleteBucketMetricsConfigurationResult deleteBucketMetricsConfiguration(DeleteBucketMetricsConfigurationRequest deleteBucketMetricsConfigurationRequest) throws AmazonServiceException, SdkClientException { + public DeleteBucketMetricsConfigurationResult deleteBucketMetricsConfiguration(DeleteBucketMetricsConfigurationRequest deleteBucketMetricsConfigurationRequest) throws SdkClientException { return null; } @Override - public GetBucketMetricsConfigurationResult getBucketMetricsConfiguration(String s, String s1) throws AmazonServiceException, SdkClientException { + public GetBucketMetricsConfigurationResult getBucketMetricsConfiguration(String s, String s1) throws SdkClientException { return null; } @Override - public GetBucketMetricsConfigurationResult getBucketMetricsConfiguration(GetBucketMetricsConfigurationRequest getBucketMetricsConfigurationRequest) throws AmazonServiceException, SdkClientException { + public GetBucketMetricsConfigurationResult getBucketMetricsConfiguration(GetBucketMetricsConfigurationRequest getBucketMetricsConfigurationRequest) throws SdkClientException { return null; } @Override - public SetBucketMetricsConfigurationResult setBucketMetricsConfiguration(String s, MetricsConfiguration metricsConfiguration) throws AmazonServiceException, SdkClientException { + public SetBucketMetricsConfigurationResult setBucketMetricsConfiguration(String s, MetricsConfiguration metricsConfiguration) throws SdkClientException { return null; } @Override - public SetBucketMetricsConfigurationResult setBucketMetricsConfiguration(SetBucketMetricsConfigurationRequest setBucketMetricsConfigurationRequest) throws AmazonServiceException, SdkClientException { + public SetBucketMetricsConfigurationResult setBucketMetricsConfiguration(SetBucketMetricsConfigurationRequest setBucketMetricsConfigurationRequest) throws SdkClientException { return null; } @Override - public ListBucketMetricsConfigurationsResult listBucketMetricsConfigurations(ListBucketMetricsConfigurationsRequest listBucketMetricsConfigurationsRequest) throws AmazonServiceException, SdkClientException { + public ListBucketMetricsConfigurationsResult listBucketMetricsConfigurations(ListBucketMetricsConfigurationsRequest listBucketMetricsConfigurationsRequest) throws SdkClientException { return null; } @Override - public DeleteBucketOwnershipControlsResult deleteBucketOwnershipControls(DeleteBucketOwnershipControlsRequest deleteBucketOwnershipControlsRequest) throws AmazonServiceException, SdkClientException { + public DeleteBucketOwnershipControlsResult deleteBucketOwnershipControls(DeleteBucketOwnershipControlsRequest deleteBucketOwnershipControlsRequest) throws SdkClientException { return null; } @Override - public GetBucketOwnershipControlsResult getBucketOwnershipControls(GetBucketOwnershipControlsRequest getBucketOwnershipControlsRequest) throws AmazonServiceException, SdkClientException { + public GetBucketOwnershipControlsResult getBucketOwnershipControls(GetBucketOwnershipControlsRequest getBucketOwnershipControlsRequest) throws SdkClientException { return null; } @Override - public SetBucketOwnershipControlsResult setBucketOwnershipControls(String s, OwnershipControls ownershipControls) throws AmazonServiceException, SdkClientException { + public SetBucketOwnershipControlsResult setBucketOwnershipControls(String s, OwnershipControls ownershipControls) throws SdkClientException { return null; } @Override - public SetBucketOwnershipControlsResult setBucketOwnershipControls(SetBucketOwnershipControlsRequest setBucketOwnershipControlsRequest) throws AmazonServiceException, SdkClientException { + public SetBucketOwnershipControlsResult setBucketOwnershipControls(SetBucketOwnershipControlsRequest setBucketOwnershipControlsRequest) throws SdkClientException { return null; } @Override - public DeleteBucketAnalyticsConfigurationResult deleteBucketAnalyticsConfiguration(String s, String s1) throws AmazonServiceException, SdkClientException { + public DeleteBucketAnalyticsConfigurationResult deleteBucketAnalyticsConfiguration(String s, String s1) throws SdkClientException { return null; } @Override - public DeleteBucketAnalyticsConfigurationResult deleteBucketAnalyticsConfiguration(DeleteBucketAnalyticsConfigurationRequest deleteBucketAnalyticsConfigurationRequest) throws AmazonServiceException, SdkClientException { + public DeleteBucketAnalyticsConfigurationResult deleteBucketAnalyticsConfiguration(DeleteBucketAnalyticsConfigurationRequest deleteBucketAnalyticsConfigurationRequest) throws SdkClientException { return null; } @Override - public GetBucketAnalyticsConfigurationResult getBucketAnalyticsConfiguration(String s, String s1) throws AmazonServiceException, SdkClientException { + public GetBucketAnalyticsConfigurationResult getBucketAnalyticsConfiguration(String s, String s1) throws SdkClientException { return null; } @Override - public GetBucketAnalyticsConfigurationResult getBucketAnalyticsConfiguration(GetBucketAnalyticsConfigurationRequest getBucketAnalyticsConfigurationRequest) throws AmazonServiceException, SdkClientException { + public GetBucketAnalyticsConfigurationResult getBucketAnalyticsConfiguration(GetBucketAnalyticsConfigurationRequest getBucketAnalyticsConfigurationRequest) throws SdkClientException { return null; } @Override - public SetBucketAnalyticsConfigurationResult setBucketAnalyticsConfiguration(String s, AnalyticsConfiguration analyticsConfiguration) throws AmazonServiceException, SdkClientException { + public SetBucketAnalyticsConfigurationResult setBucketAnalyticsConfiguration(String s, AnalyticsConfiguration analyticsConfiguration) throws SdkClientException { return null; } @Override - public SetBucketAnalyticsConfigurationResult setBucketAnalyticsConfiguration(SetBucketAnalyticsConfigurationRequest setBucketAnalyticsConfigurationRequest) throws AmazonServiceException, SdkClientException { + public SetBucketAnalyticsConfigurationResult setBucketAnalyticsConfiguration(SetBucketAnalyticsConfigurationRequest setBucketAnalyticsConfigurationRequest) throws SdkClientException { return null; } @Override - public ListBucketAnalyticsConfigurationsResult listBucketAnalyticsConfigurations(ListBucketAnalyticsConfigurationsRequest listBucketAnalyticsConfigurationsRequest) throws AmazonServiceException, SdkClientException { + public ListBucketAnalyticsConfigurationsResult listBucketAnalyticsConfigurations(ListBucketAnalyticsConfigurationsRequest listBucketAnalyticsConfigurationsRequest) throws SdkClientException { return null; } @Override - public DeleteBucketIntelligentTieringConfigurationResult deleteBucketIntelligentTieringConfiguration(String s, String s1) throws AmazonServiceException, SdkClientException { + public DeleteBucketIntelligentTieringConfigurationResult deleteBucketIntelligentTieringConfiguration(String s, String s1) throws SdkClientException { return null; } @Override - public DeleteBucketIntelligentTieringConfigurationResult deleteBucketIntelligentTieringConfiguration(DeleteBucketIntelligentTieringConfigurationRequest deleteBucketIntelligentTieringConfigurationRequest) throws AmazonServiceException, SdkClientException { + public DeleteBucketIntelligentTieringConfigurationResult deleteBucketIntelligentTieringConfiguration(DeleteBucketIntelligentTieringConfigurationRequest deleteBucketIntelligentTieringConfigurationRequest) throws SdkClientException { return null; } @Override - public GetBucketIntelligentTieringConfigurationResult getBucketIntelligentTieringConfiguration(String s, String s1) throws AmazonServiceException, SdkClientException { + public GetBucketIntelligentTieringConfigurationResult getBucketIntelligentTieringConfiguration(String s, String s1) throws SdkClientException { return null; } @Override - public GetBucketIntelligentTieringConfigurationResult getBucketIntelligentTieringConfiguration(GetBucketIntelligentTieringConfigurationRequest getBucketIntelligentTieringConfigurationRequest) throws AmazonServiceException, SdkClientException { + public GetBucketIntelligentTieringConfigurationResult getBucketIntelligentTieringConfiguration(GetBucketIntelligentTieringConfigurationRequest getBucketIntelligentTieringConfigurationRequest) throws SdkClientException { return null; } @Override - public SetBucketIntelligentTieringConfigurationResult setBucketIntelligentTieringConfiguration(String s, IntelligentTieringConfiguration intelligentTieringConfiguration) throws AmazonServiceException, SdkClientException { + public SetBucketIntelligentTieringConfigurationResult setBucketIntelligentTieringConfiguration(String s, IntelligentTieringConfiguration intelligentTieringConfiguration) throws SdkClientException { return null; } @Override - public SetBucketIntelligentTieringConfigurationResult setBucketIntelligentTieringConfiguration(SetBucketIntelligentTieringConfigurationRequest setBucketIntelligentTieringConfigurationRequest) throws AmazonServiceException, SdkClientException { + public SetBucketIntelligentTieringConfigurationResult setBucketIntelligentTieringConfiguration(SetBucketIntelligentTieringConfigurationRequest setBucketIntelligentTieringConfigurationRequest) throws SdkClientException { return null; } @Override - public ListBucketIntelligentTieringConfigurationsResult listBucketIntelligentTieringConfigurations(ListBucketIntelligentTieringConfigurationsRequest listBucketIntelligentTieringConfigurationsRequest) throws AmazonServiceException, SdkClientException { + public ListBucketIntelligentTieringConfigurationsResult listBucketIntelligentTieringConfigurations(ListBucketIntelligentTieringConfigurationsRequest listBucketIntelligentTieringConfigurationsRequest) throws SdkClientException { return null; } @Override - public DeleteBucketInventoryConfigurationResult deleteBucketInventoryConfiguration(String s, String s1) throws AmazonServiceException, SdkClientException { + public DeleteBucketInventoryConfigurationResult deleteBucketInventoryConfiguration(String s, String s1) throws SdkClientException { return null; } @Override - public DeleteBucketInventoryConfigurationResult deleteBucketInventoryConfiguration(DeleteBucketInventoryConfigurationRequest deleteBucketInventoryConfigurationRequest) throws AmazonServiceException, SdkClientException { + public DeleteBucketInventoryConfigurationResult deleteBucketInventoryConfiguration(DeleteBucketInventoryConfigurationRequest deleteBucketInventoryConfigurationRequest) throws SdkClientException { return null; } @Override - public GetBucketInventoryConfigurationResult getBucketInventoryConfiguration(String s, String s1) throws AmazonServiceException, SdkClientException { + public GetBucketInventoryConfigurationResult getBucketInventoryConfiguration(String s, String s1) throws SdkClientException { return null; } @Override - public GetBucketInventoryConfigurationResult getBucketInventoryConfiguration(GetBucketInventoryConfigurationRequest getBucketInventoryConfigurationRequest) throws AmazonServiceException, SdkClientException { + public GetBucketInventoryConfigurationResult getBucketInventoryConfiguration(GetBucketInventoryConfigurationRequest getBucketInventoryConfigurationRequest) throws SdkClientException { return null; } @Override - public SetBucketInventoryConfigurationResult setBucketInventoryConfiguration(String s, InventoryConfiguration inventoryConfiguration) throws AmazonServiceException, SdkClientException { + public SetBucketInventoryConfigurationResult setBucketInventoryConfiguration(String s, InventoryConfiguration inventoryConfiguration) throws SdkClientException { return null; } @Override - public SetBucketInventoryConfigurationResult setBucketInventoryConfiguration(SetBucketInventoryConfigurationRequest setBucketInventoryConfigurationRequest) throws AmazonServiceException, SdkClientException { + public SetBucketInventoryConfigurationResult setBucketInventoryConfiguration(SetBucketInventoryConfigurationRequest setBucketInventoryConfigurationRequest) throws SdkClientException { return null; } @Override - public ListBucketInventoryConfigurationsResult listBucketInventoryConfigurations(ListBucketInventoryConfigurationsRequest listBucketInventoryConfigurationsRequest) throws AmazonServiceException, SdkClientException { + public ListBucketInventoryConfigurationsResult listBucketInventoryConfigurations(ListBucketInventoryConfigurationsRequest listBucketInventoryConfigurationsRequest) throws SdkClientException { return null; } @Override - public DeleteBucketEncryptionResult deleteBucketEncryption(String s) throws AmazonServiceException, SdkClientException { + public DeleteBucketEncryptionResult deleteBucketEncryption(String s) throws SdkClientException { return null; } @Override - public DeleteBucketEncryptionResult deleteBucketEncryption(DeleteBucketEncryptionRequest deleteBucketEncryptionRequest) throws AmazonServiceException, SdkClientException { + public DeleteBucketEncryptionResult deleteBucketEncryption(DeleteBucketEncryptionRequest deleteBucketEncryptionRequest) throws SdkClientException { return null; } @Override - public GetBucketEncryptionResult getBucketEncryption(String s) throws AmazonServiceException, SdkClientException { + public GetBucketEncryptionResult getBucketEncryption(String s) throws SdkClientException { return null; } @Override - public GetBucketEncryptionResult getBucketEncryption(GetBucketEncryptionRequest getBucketEncryptionRequest) throws AmazonServiceException, SdkClientException { + public GetBucketEncryptionResult getBucketEncryption(GetBucketEncryptionRequest getBucketEncryptionRequest) throws SdkClientException { return null; } @Override - public SetBucketEncryptionResult setBucketEncryption(SetBucketEncryptionRequest setBucketEncryptionRequest) throws AmazonServiceException, SdkClientException { + public SetBucketEncryptionResult setBucketEncryption(SetBucketEncryptionRequest setBucketEncryptionRequest) throws SdkClientException { return null; } @@ -1038,7 +1023,7 @@ public GetBucketPolicyStatusResult getBucketPolicyStatus(GetBucketPolicyStatusRe } @Override - public SelectObjectContentResult selectObjectContent(SelectObjectContentRequest selectObjectContentRequest) throws AmazonServiceException, SdkClientException { + public SelectObjectContentResult selectObjectContent(SelectObjectContentRequest selectObjectContentRequest) throws SdkClientException { return null; } @@ -1084,7 +1069,6 @@ public PresignedUrlDownloadResult download(PresignedUrlDownloadRequest presigned @Override public void download(PresignedUrlDownloadRequest presignedUrlDownloadRequest, File file) { - } @Override @@ -1094,7 +1078,6 @@ public PresignedUrlUploadResult upload(PresignedUrlUploadRequest presignedUrlUpl @Override public void shutdown() { - } @Override @@ -1166,8 +1149,7 @@ public void setBucketNotificationConfiguration( @Override public void setBucketNotificationConfiguration(String arg0, - BucketNotificationConfiguration arg1) throws AmazonClientException, - AmazonServiceException { + BucketNotificationConfiguration arg1) throws AmazonClientException { } @Override @@ -1204,8 +1186,7 @@ public void setBucketWebsiteConfiguration( @Override public void setBucketWebsiteConfiguration(String arg0, - BucketWebsiteConfiguration arg1) throws AmazonClientException, - AmazonServiceException { + BucketWebsiteConfiguration arg1) throws AmazonClientException { } @Override @@ -1219,25 +1200,21 @@ public void setObjectAcl(String arg0, String arg1, AccessControlList arg2) @Override public void setObjectAcl(String arg0, String arg1, - CannedAccessControlList arg2) throws AmazonClientException, - AmazonServiceException { + CannedAccessControlList arg2) throws AmazonClientException { } @Override public void setObjectAcl(String arg0, String arg1, String arg2, - AccessControlList arg3) throws AmazonClientException, - AmazonServiceException { + AccessControlList arg3) throws AmazonClientException { } @Override public void setObjectAcl(String arg0, String arg1, String arg2, - CannedAccessControlList arg3) throws AmazonClientException, - AmazonServiceException { + CannedAccessControlList arg3) throws AmazonClientException { } @Override public void setObjectAcl(SetObjectAclRequest setObjectAclRequest) throws SdkClientException { - } @Override diff --git a/s3auth-hosts/src/main/java/com/s3auth/hosts/ObjectVersionListing.java b/s3auth-hosts/src/main/java/com/s3auth/hosts/ObjectVersionListing.java index 99bf5483..85d4d8bc 100644 --- a/s3auth-hosts/src/main/java/com/s3auth/hosts/ObjectVersionListing.java +++ b/s3auth-hosts/src/main/java/com/s3auth/hosts/ObjectVersionListing.java @@ -83,6 +83,7 @@ final class ObjectVersionListing implements Resource { * @param bucket Bucket name * @param key The S3 object key */ + @SuppressWarnings("PMD.ConstructorOnlyInitializesOrCallOtherConstructors") ObjectVersionListing(@NotNull final AmazonS3 client, @NotNull final String bucket, @NotNull final String key) { VersionListing listing = client.listVersions( diff --git a/s3auth-hosts/src/main/java/com/s3auth/hosts/Range.java b/s3auth-hosts/src/main/java/com/s3auth/hosts/Range.java index 353c7a4f..d454532b 100644 --- a/s3auth-hosts/src/main/java/com/s3auth/hosts/Range.java +++ b/s3auth-hosts/src/main/java/com/s3auth/hosts/Range.java @@ -44,16 +44,20 @@ public interface Range { /** * All inclusive range. + * + * @since 0.0.1 */ Range ENTIRE = new Range() { @Override public String toString() { return "ENTIRE"; } + @Override public long first() { return 0; } + @Override public long last() { return Long.MAX_VALUE; @@ -74,6 +78,7 @@ public long last() { /** * Simple implementation. + * @since 0.0.1 */ @Loggable(Loggable.DEBUG) @ToString @@ -83,10 +88,12 @@ final class Simple implements Range { * First byte. */ private final transient long frst; + /** * Last byte. */ private final transient long lst; + /** * Public ctor. * @param first First byte @@ -96,10 +103,12 @@ public Simple(final long first, final long last) { this.frst = first; this.lst = last; } + @Override public long first() { return this.frst; } + @Override public long last() { return this.lst; diff --git a/s3auth-hosts/src/main/java/com/s3auth/hosts/Resource.java b/s3auth-hosts/src/main/java/com/s3auth/hosts/Resource.java index df3d26a4..ea02519e 100644 --- a/s3auth-hosts/src/main/java/com/s3auth/hosts/Resource.java +++ b/s3auth-hosts/src/main/java/com/s3auth/hosts/Resource.java @@ -97,6 +97,7 @@ public interface Resource extends Closeable { /** * Simple resource made out of plain text. + * @since 0.0.1 */ @Immutable @ToString @@ -108,14 +109,17 @@ final class PlainText implements Resource { */ @Immutable.Array private final transient byte[] text; + /** * Last modified date to return. Equal to the time of object creation. */ private final transient long modified = System.currentTimeMillis(); + /** * Headers associated with this resource. */ private final Array hdrs; + /** * Public ctor. * @param txt The text to show @@ -135,33 +139,40 @@ public PlainText(@NotNull final String txt) { ) ); } + @Override public int status() { return HttpURLConnection.HTTP_OK; } + @Override public long writeTo(@NotNull final OutputStream stream) throws IOException { IOUtils.write(this.text, stream); return this.text.length; } + @Override public String etag() { return DigestUtils.md5Hex(this.text); } + @Override public Date lastModified() { return new Date(this.modified); } + @Override public String contentType() { return "text/plain"; } + @Override @NotNull public Collection headers() { return this.hdrs; } + @Override public void close() { // nothing to do diff --git a/s3auth-hosts/src/main/java/com/s3auth/hosts/ResourceMocker.java b/s3auth-hosts/src/main/java/com/s3auth/hosts/ResourceMocker.java index 3ea11027..63486f9c 100644 --- a/s3auth-hosts/src/main/java/com/s3auth/hosts/ResourceMocker.java +++ b/s3auth-hosts/src/main/java/com/s3auth/hosts/ResourceMocker.java @@ -89,6 +89,7 @@ public ResourceMocker withHeaders(final String... headers) { * @return Its text * @throws IOException If fails */ + @SuppressWarnings("PMD.ProhibitPublicStaticMethods") public static String toString(final Resource res) throws IOException { return new String(ResourceMocker.toByteArray(res), StandardCharsets.UTF_8); } @@ -99,6 +100,7 @@ public static String toString(final Resource res) throws IOException { * @return Its text * @throws IOException If fails */ + @SuppressWarnings("PMD.ProhibitPublicStaticMethods") public static byte[] toByteArray(final Resource res) throws IOException { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); res.writeTo(baos); @@ -113,6 +115,11 @@ public Resource mock() { return this.resource.build(); } + /** + * Mock. + * + * @since 0.0.1 + */ @Builder @SuppressWarnings({ "PMD.TooManyMethods", "PMD.AvoidFieldNameMatchingMethodName" }) @@ -121,23 +128,28 @@ private static class MkResource implements Resource { * The resource content. */ private final transient char[] content; + /** * The resource status. */ private final transient int status; + /** * The resource headers. */ private final transient Collection headers; + /** * The resource etag. */ private final transient String etag; + /** * The resource lastModified. * @checkstyle MemberName (3 lines) */ private final transient Date lastModified; + /** * The resource contentType. * @checkstyle MemberName (3 lines) diff --git a/s3auth-hosts/src/main/java/com/s3auth/hosts/SyslogHosts.java b/s3auth-hosts/src/main/java/com/s3auth/hosts/SyslogHosts.java index 09a8b9d8..eb3c5201 100644 --- a/s3auth-hosts/src/main/java/com/s3auth/hosts/SyslogHosts.java +++ b/s3auth-hosts/src/main/java/com/s3auth/hosts/SyslogHosts.java @@ -98,10 +98,12 @@ private static final class SyslogHost implements Host { private static final Pattern PATTERN = Pattern.compile( "(\\w+)(:(\\d+))?" ); + /** * The underlying Host instance. */ private final transient Host host; + /** * Constructor. * @param hst Host @@ -109,10 +111,12 @@ private static final class SyslogHost implements Host { SyslogHost(final Host hst) { this.host = hst; } + @Override public void close() throws IOException { this.host.close(); } + @Override public Resource fetch(final URI uri, final Range range, final Version version) throws IOException { @@ -134,19 +138,23 @@ public Resource fetch(final URI uri, final Range range, } return res; } + @Override public boolean isHidden(final URI uri) throws IOException { return this.host.isHidden(uri); } + @Override public boolean authorized(final String user, final String password) throws IOException { return this.host.authorized(user, password); } + @Override public String syslog() { return this.host.syslog(); } + @Override public Stats stats() { return this.host.stats(); @@ -161,14 +169,17 @@ private static final class SyslogResource implements Resource { * The underlying resource. */ private final transient Resource resource; + /** * URI of the resource. */ private final transient URI location; + /** * The syslog client. */ private final transient SyslogIF syslog; + /** * Constructor. * @param res The underlying resource @@ -184,13 +195,15 @@ private static final class SyslogResource implements Resource { this.syslog = new UDPNetSyslog(); this.syslog.initialize("udp", new UDPNetSyslogConfig(syslg, port)); } + @Override public int status() { return this.resource.status(); } + @Override public long writeTo(final OutputStream stream) throws IOException { - long bytes = 0L; + long bytes; try { bytes = this.resource.writeTo(stream); this.syslog.info( @@ -210,22 +223,27 @@ public long writeTo(final OutputStream stream) throws IOException { } return bytes; } + @Override public Collection headers() throws IOException { return this.resource.headers(); } + @Override public String etag() { return this.resource.etag(); } + @Override public Date lastModified() { return this.resource.lastModified(); } + @Override public String contentType() { return this.resource.contentType(); } + @Override public void close() throws IOException { this.resource.close(); diff --git a/s3auth-hosts/src/main/java/com/s3auth/hosts/User.java b/s3auth-hosts/src/main/java/com/s3auth/hosts/User.java index ac705d4d..85f136f4 100644 --- a/s3auth-hosts/src/main/java/com/s3auth/hosts/User.java +++ b/s3auth-hosts/src/main/java/com/s3auth/hosts/User.java @@ -61,10 +61,12 @@ public interface User { public URN identity() { return URN.create("urn:anonymous:0"); } + @Override public String name() { return "Mr. Anonymous"; } + @Override public URI photo() { return URI.create("http://img.s3auth.com/unknown.png"); @@ -89,19 +91,26 @@ public URI photo() { */ URI photo(); + /** + * Valid User. + * + * @since 0.0.1 + */ @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @Constraint(validatedBy = User.Validator.class) @Documented - public @interface Valid { + @interface Valid { /** * Message of the validation error. */ String message() default "invalid user"; + /** * Groups. */ Class[] groups() default { }; + /** * Payload. */ @@ -114,12 +123,13 @@ public URI photo() { class Validator implements ConstraintValidator { @Override public void initialize(final User.Valid annotation) { - //nothing to do + // nothing to do } + @Override public boolean isValid(final User user, final ConstraintValidatorContext ctx) { - boolean isValid = true; + boolean valid = true; final String nid = user.identity().nid(); if (!"facebook".equals(nid) && !"google".equals(nid) @@ -128,15 +138,15 @@ public boolean isValid(final User user, ctx.buildConstraintViolationWithTemplate( String.format("invalid NID of URN: %s", user.identity()) ).addPropertyNode("identity").addConstraintViolation(); - isValid = false; + valid = false; } if (!user.identity().nss().matches("\\d+")) { ctx.buildConstraintViolationWithTemplate( String.format("invalid NSS of URN: %s", user.identity()) ).addPropertyNode("identity").addConstraintViolation(); - isValid = false; + valid = false; } - return isValid; + return valid; } } diff --git a/s3auth-hosts/src/main/java/com/s3auth/hosts/Version.java b/s3auth-hosts/src/main/java/com/s3auth/hosts/Version.java index 53e7336f..96ea9c33 100644 --- a/s3auth-hosts/src/main/java/com/s3auth/hosts/Version.java +++ b/s3auth-hosts/src/main/java/com/s3auth/hosts/Version.java @@ -44,35 +44,42 @@ public interface Version { /** * Specify that the latest version be fetched. + * + * @since 0.0.1 */ Version LATEST = new Version() { @Override public boolean latest() { return true; } + @Override public boolean list() { return false; } + @Override public String version() { - // @checkstyle MultipleStringLiterals (1 line) throw new UnsupportedOperationException("Version is unspecified."); } }; /** * Specify that the object's versions be listed. + * + * @since 0.0.1 */ Version LIST = new Version() { @Override public boolean latest() { return false; } + @Override public boolean list() { return true; } + @Override public String version() { throw new UnsupportedOperationException("Version is unspecified."); @@ -100,6 +107,8 @@ public String version() { /** * Simple implementation. + * + * @since 0.0.1 */ @Immutable @Loggable(Loggable.DEBUG) @@ -110,6 +119,7 @@ final class Simple implements Version { * The version ID. */ private final String ver; + /** * Public ctor. * @param version Version ID string @@ -117,14 +127,17 @@ final class Simple implements Version { public Simple(final String version) { this.ver = version; } + @Override public boolean latest() { return false; } + @Override public boolean list() { return false; } + @Override public String version() { return this.ver; diff --git a/s3auth-hosts/src/test/java/com/s3auth/hosts/DefaultBucketTest.java b/s3auth-hosts/src/test/java/com/s3auth/hosts/DefaultBucketTest.java index f9813ce6..f5e8fbf5 100644 --- a/s3auth-hosts/src/test/java/com/s3auth/hosts/DefaultBucketTest.java +++ b/s3auth-hosts/src/test/java/com/s3auth/hosts/DefaultBucketTest.java @@ -35,6 +35,8 @@ /** * Test case for {@link DefaultBucket}. + * + * @since 0.0.1 */ final class DefaultBucketTest { diff --git a/s3auth-hosts/src/test/java/com/s3auth/hosts/DefaultDomainTest.java b/s3auth-hosts/src/test/java/com/s3auth/hosts/DefaultDomainTest.java index ffd152fe..7c51f8a4 100644 --- a/s3auth-hosts/src/test/java/com/s3auth/hosts/DefaultDomainTest.java +++ b/s3auth-hosts/src/test/java/com/s3auth/hosts/DefaultDomainTest.java @@ -35,6 +35,7 @@ /** * Test case for {@link DefaultDomain}. + * @since 0.0.1 */ final class DefaultDomainTest { diff --git a/s3auth-hosts/src/test/java/com/s3auth/hosts/DefaultDynamoTest.java b/s3auth-hosts/src/test/java/com/s3auth/hosts/DefaultDynamoTest.java index aecf542e..4ab4fa3d 100644 --- a/s3auth-hosts/src/test/java/com/s3auth/hosts/DefaultDynamoTest.java +++ b/s3auth-hosts/src/test/java/com/s3auth/hosts/DefaultDynamoTest.java @@ -52,7 +52,7 @@ final class DefaultDynamoTest { @Test - public void loadsDynamoConfiguration() throws Exception { + void loadsDynamoConfiguration() throws Exception { final String table = "table"; final Dynamo dynamo = new DefaultDynamo( this.mockRegion(table), diff --git a/s3auth-hosts/src/test/java/com/s3auth/hosts/DefaultHostITCase.java b/s3auth-hosts/src/test/java/com/s3auth/hosts/DefaultHostITCase.java index 6e53d956..8e415d0c 100644 --- a/s3auth-hosts/src/test/java/com/s3auth/hosts/DefaultHostITCase.java +++ b/s3auth-hosts/src/test/java/com/s3auth/hosts/DefaultHostITCase.java @@ -42,15 +42,16 @@ /** * Integration test case for {@link DefaultHost}. + * @since 0.0.1 */ -public final class DefaultHostITCase { +final class DefaultHostITCase { /** * DefaultHost can fetch a real object from S3 bucket. * @throws Exception If there is some problem inside */ @Test - public void fetchesRealObjectFromAmazonBucket() throws Exception { + void fetchesRealObjectFromAmazonBucket() throws Exception { final String key = System.getProperty("failsafe.aws.key"); final String secret = System.getProperty("failsafe.aws.secret"); Assume.assumeThat(key, Matchers.notNullValue()); @@ -81,10 +82,9 @@ public void fetchesRealObjectFromAmazonBucket() throws Exception { /** * DefaultHost can throw IOException for absent object. - * @throws Exception If there is some problem inside */ @Test - public void throwsWhenAbsentResource() throws Exception { + void throwsWhenAbsentResource() { final Host host = new DefaultHost( new DefaultBucket( new DomainMocker() diff --git a/s3auth-hosts/src/test/java/com/s3auth/hosts/DefaultHostTest.java b/s3auth-hosts/src/test/java/com/s3auth/hosts/DefaultHostTest.java index 5d8437e4..35738eec 100644 --- a/s3auth-hosts/src/test/java/com/s3auth/hosts/DefaultHostTest.java +++ b/s3auth-hosts/src/test/java/com/s3auth/hosts/DefaultHostTest.java @@ -323,10 +323,10 @@ void loadsErrorDocument() throws Exception { invocation.getArguments()[0] ).getKey(); if (key.endsWith(suffix)) { - final AmazonServiceException ex = + final AmazonServiceException exp = new AmazonServiceException("Object not found"); - ex.setStatusCode(HttpStatus.SC_NOT_FOUND); - throw ex; + exp.setStatusCode(HttpStatus.SC_NOT_FOUND); + throw exp; } MatcherAssert.assertThat(key, Matchers.is(error)); final S3Object object = new S3Object(); @@ -352,13 +352,12 @@ void loadsErrorDocument() throws Exception { } @Test - public void throwsExceptionIfNoBucketWebsiteConfiguration() - throws Exception { + void throwsExceptionIfNoBucketWebsiteConfiguration() { final AmazonS3 aws = Mockito.mock(AmazonS3.class); - final AmazonServiceException ex = + final AmazonServiceException exp = new AmazonServiceException("The object is not found"); - ex.setStatusCode(HttpStatus.SC_NOT_FOUND); - Mockito.doThrow(ex).when(aws) + exp.setStatusCode(HttpStatus.SC_NOT_FOUND); + Mockito.doThrow(exp).when(aws) .getObject(Mockito.any(GetObjectRequest.class)); Assertions.assertThrows( IOException.class, @@ -374,11 +373,9 @@ public void throwsExceptionIfNoBucketWebsiteConfiguration() */ private CloudWatch cloudWatch() { return new Host.CloudWatch() { - /** - * Mock Cloudwatch client. - */ private final transient AmazonCloudWatchClient cwatch = Mockito.mock(AmazonCloudWatchClient.class); + @Override public AmazonCloudWatchClient get() { return this.cwatch; diff --git a/s3auth-hosts/src/test/java/com/s3auth/hosts/DefaultResourceTest.java b/s3auth-hosts/src/test/java/com/s3auth/hosts/DefaultResourceTest.java index 2f728242..28af27c5 100644 --- a/s3auth-hosts/src/test/java/com/s3auth/hosts/DefaultResourceTest.java +++ b/s3auth-hosts/src/test/java/com/s3auth/hosts/DefaultResourceTest.java @@ -43,6 +43,7 @@ import org.apache.http.client.methods.HttpGet; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.mockito.stubbing.Answer; @@ -138,7 +139,7 @@ void writesInputToOutputStream() throws Exception { * @throws Exception If there is some problem inside */ @Test - public void throwsWhenFailedToRead() throws Exception { + void throwsWhenFailedToRead() throws Exception { final S3ObjectInputStream stream = Mockito.mock(S3ObjectInputStream.class); Mockito.doThrow(new IOException("oops")) @@ -148,14 +149,14 @@ public void throwsWhenFailedToRead() throws Exception { Mockito.doReturn(object).when(client) .getObject(Mockito.any(GetObjectRequest.class)); Mockito.doReturn(stream).when(object).getObjectContent(); - MatcherAssert.assertThat( - ResourceMocker.toString( + Assertions.assertThrows( + IOException.class, + () -> ResourceMocker.toString( new DefaultResource( client, "d", "", Range.ENTIRE, Version.LATEST, Mockito.mock(DomainStatsData.class) ) - ), - Matchers.equalTo("") + ) ); } diff --git a/s3auth-hosts/src/test/java/com/s3auth/hosts/DomainTest.java b/s3auth-hosts/src/test/java/com/s3auth/hosts/DomainTest.java index 5b33ce57..26185c0a 100644 --- a/s3auth-hosts/src/test/java/com/s3auth/hosts/DomainTest.java +++ b/s3auth-hosts/src/test/java/com/s3auth/hosts/DomainTest.java @@ -43,25 +43,24 @@ */ final class DomainTest { - /** - * Domain.Validator accepts valid syslog entry. - */ @Test void acceptsValidSyslog() { final ConstraintValidatorContext ctx = Mockito.mock(ConstraintValidatorContext.class); + final ConstraintViolationBuilder builder = + Mockito.mock(ConstraintViolationBuilder.class); + Mockito.doReturn(builder).when(ctx) + .buildConstraintViolationWithTemplate(Mockito.anyString()); + Mockito.doReturn(Mockito.mock(NodeBuilderCustomizableContext.class)) + .when(builder).addPropertyNode(Mockito.anyString()); final Domain domain = new DomainMocker() .withSyslog("sys-log.s3auth.com:514").mock(); MatcherAssert.assertThat( - new Domain.Validator().isValid(domain, ctx), Matchers.is(true) + new Domain.Validator().isValid(domain, ctx), + Matchers.is(true) ); - Mockito.verify(ctx, Mockito.never()) - .buildConstraintViolationWithTemplate(Mockito.anyString()); } - /** - * Domain.Validator rejects invalid syslog entry. - */ @Test void rejectsInvalidSyslog() { final ConstraintValidatorContext ctx = diff --git a/s3auth-hosts/src/test/java/com/s3auth/hosts/DomainsTest.java b/s3auth-hosts/src/test/java/com/s3auth/hosts/DomainsTest.java index a60aada4..4105e178 100644 --- a/s3auth-hosts/src/test/java/com/s3auth/hosts/DomainsTest.java +++ b/s3auth-hosts/src/test/java/com/s3auth/hosts/DomainsTest.java @@ -35,6 +35,7 @@ /** * Test case for {@link Domains}. + * @since 0.0.1 */ final class DomainsTest { diff --git a/s3auth-hosts/src/test/java/com/s3auth/hosts/H2DomainStatsDataTest.java b/s3auth-hosts/src/test/java/com/s3auth/hosts/H2DomainStatsDataTest.java index 6afc2896..eaf7c47e 100644 --- a/s3auth-hosts/src/test/java/com/s3auth/hosts/H2DomainStatsDataTest.java +++ b/s3auth-hosts/src/test/java/com/s3auth/hosts/H2DomainStatsDataTest.java @@ -41,10 +41,6 @@ */ final class H2DomainStatsDataTest { - /** - * H2DomainStatsData can put and get data for a single domain. - * @throws Exception If something goes wrong. - */ @Test void putsAndGetsDataPerDomain() throws Exception { final H2DomainStatsData data = new H2DomainStatsData( @@ -66,13 +62,9 @@ void putsAndGetsDataPerDomain() throws Exception { ); } - /** - * H2DomainStatsData can put and get data for all domains. - * @throws Exception If something goes wrong. - */ @Test @SuppressWarnings("PMD.UseConcurrentHashMap") - public void getsDataForAllDomains() throws Exception { + void getsDataForAllDomains() throws Exception { final H2DomainStatsData data = new H2DomainStatsData( File.createTempFile("testAll", "tempAll") ); @@ -96,7 +88,7 @@ public void getsDataForAllDomains() throws Exception { ); MatcherAssert.assertThat( stats.get(first).bytesTransferred(), - Matchers.is((long) (150)) + Matchers.is((long) 150) ); MatcherAssert.assertThat( stats.get(second).bytesTransferred(), diff --git a/s3auth-hosts/src/test/java/com/s3auth/hosts/HtpasswdTest.java b/s3auth-hosts/src/test/java/com/s3auth/hosts/HtpasswdTest.java index bcf5e08d..5c73df49 100644 --- a/s3auth-hosts/src/test/java/com/s3auth/hosts/HtpasswdTest.java +++ b/s3auth-hosts/src/test/java/com/s3auth/hosts/HtpasswdTest.java @@ -42,13 +42,10 @@ /** * Test case for {@link Htpasswd}. + * @since 0.0.1 */ final class HtpasswdTest { - /** - * Htpasswd can show some stats in {@code #toString()}. - * @throws Exception If there is some problem inside - */ @Test void showsStatsInToString() throws Exception { MatcherAssert.assertThat( @@ -57,11 +54,8 @@ void showsStatsInToString() throws Exception { ); } - /** - * Htpasswd can show some stats in {@code #toString()} with IO exception. - */ @Test - void showsStatsInToStringWithIOException() { + void showsStatsInToStringWithIoException() { final AmazonS3 aws = Mockito.mock(AmazonS3.class); Mockito.doThrow(new AmazonClientException("")).when(aws) .getObject(Mockito.any(GetObjectRequest.class)); @@ -91,10 +85,6 @@ void understandsApacheNativeHashValues() throws Exception { ); } - /** - * Htpasswd can manage apache hashes, with SHA1 algorithm. - * @throws Exception If there is some problem inside - */ @Test void understandsShaHashValues() throws Exception { MatcherAssert.assertThat( diff --git a/s3auth-hosts/src/test/java/com/s3auth/hosts/RejectingHostTest.java b/s3auth-hosts/src/test/java/com/s3auth/hosts/RejectingHostTest.java index 5923e16c..f5df82c1 100644 --- a/s3auth-hosts/src/test/java/com/s3auth/hosts/RejectingHostTest.java +++ b/s3auth-hosts/src/test/java/com/s3auth/hosts/RejectingHostTest.java @@ -36,6 +36,7 @@ /** * Test case for {@link RejectingHost}. + * @since 0.0.1 */ final class RejectingHostTest { diff --git a/s3auth-hosts/src/test/java/com/s3auth/hosts/ResourceTest.java b/s3auth-hosts/src/test/java/com/s3auth/hosts/ResourceTest.java index 64307774..f3baf726 100644 --- a/s3auth-hosts/src/test/java/com/s3auth/hosts/ResourceTest.java +++ b/s3auth-hosts/src/test/java/com/s3auth/hosts/ResourceTest.java @@ -38,6 +38,7 @@ /** * Test case for {@link Resource}. + * @since 0.0.1 */ final class ResourceTest { diff --git a/s3auth-hosts/src/test/java/com/s3auth/hosts/ScheduledCloudWatchTest.java b/s3auth-hosts/src/test/java/com/s3auth/hosts/ScheduledCloudWatchTest.java index c8969f33..9d307cec 100644 --- a/s3auth-hosts/src/test/java/com/s3auth/hosts/ScheduledCloudWatchTest.java +++ b/s3auth-hosts/src/test/java/com/s3auth/hosts/ScheduledCloudWatchTest.java @@ -40,6 +40,7 @@ /** * Test case for {@link ScheduledCloudWatch}. + * @since 0.0.1 */ final class ScheduledCloudWatchTest { diff --git a/s3auth-hosts/src/test/java/com/s3auth/hosts/SmartHostTest.java b/s3auth-hosts/src/test/java/com/s3auth/hosts/SmartHostTest.java index 7fb7557a..5e26cc25 100644 --- a/s3auth-hosts/src/test/java/com/s3auth/hosts/SmartHostTest.java +++ b/s3auth-hosts/src/test/java/com/s3auth/hosts/SmartHostTest.java @@ -36,6 +36,7 @@ /** * Test case for {@link SmartHost}. + * @since 0.0.1 */ final class SmartHostTest { diff --git a/s3auth-hosts/src/test/java/com/s3auth/hosts/SyslogHostsTest.java b/s3auth-hosts/src/test/java/com/s3auth/hosts/SyslogHostsTest.java index ea527fae..cb2baad1 100644 --- a/s3auth-hosts/src/test/java/com/s3auth/hosts/SyslogHostsTest.java +++ b/s3auth-hosts/src/test/java/com/s3auth/hosts/SyslogHostsTest.java @@ -55,17 +55,12 @@ */ final class SyslogHostsTest { - /** - * SyslogHosts can return the domains of its underlying Hosts. - * @throws Exception If something goes wrong - */ @Test void returnsUnderlyingDomains() throws Exception { final Hosts hosts = Mockito.mock(Hosts.class); final Domain first = new DomainMocker().mock(); final Domain second = new DomainMocker().mock(); - final Set domains = new HashSet<>(); - domains.addAll(Arrays.asList(new Domain[]{first, second})); + final Set domains = new HashSet<>(Arrays.asList(first, second)); final User user = new UserMocker().mock(); Mockito.doReturn(domains).when(hosts).domains(user); @SuppressWarnings("resource") @@ -76,10 +71,6 @@ void returnsUnderlyingDomains() throws Exception { ); } - /** - * SyslogHosts can close its underlying Hosts. - * @throws Exception If something goes wrong - */ @Test void closesUnderlyingHosts() throws Exception { final Hosts hosts = Mockito.mock(Hosts.class); @@ -88,10 +79,6 @@ void closesUnderlyingHosts() throws Exception { Mockito.verify(hosts, Mockito.only()).close(); } - /** - * SyslogHosts can send messages to the syslog server. - * @throws Exception If something goes wrong - */ @Test void sendsMessagesToServer() throws Exception { final SyslogServerIF server = SyslogServer.getInstance("udp"); @@ -101,9 +88,6 @@ void sendsMessagesToServer() throws Exception { new LinkedBlockingQueue<>(); server.getConfig().addEventHandler( new SyslogServerEventHandlerIF() { - /** - * Serial Version UID. - */ private static final long serialVersionUID = -7043255643054178133L; @Override @@ -143,7 +127,7 @@ public void event(final SyslogServerIF syslg, * @return The port number */ private static int port() { - int port; + final int port; try { final DatagramSocket socket = new DatagramSocket(0); try { diff --git a/s3auth-relay/src/test/java/com/s3auth/relay/FtpFacadeTest.java b/s3auth-relay/src/test/java/com/s3auth/relay/FtpFacadeTest.java index 80251af9..3c9f28f2 100644 --- a/s3auth-relay/src/test/java/com/s3auth/relay/FtpFacadeTest.java +++ b/s3auth-relay/src/test/java/com/s3auth/relay/FtpFacadeTest.java @@ -42,10 +42,9 @@ import org.apache.commons.net.ftp.FTPReply; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; -import org.junit.Ignore; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.mockito.Mockito; -import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; /** @@ -58,7 +57,7 @@ final class FtpFacadeTest { * @throws IOException If it fails inside */ @Test - @Ignore + @Disabled public void connectDisconnect() throws IOException { final FtpFacade facade = FtpFacadeTest.mockFacade(); final FTPClient ftp = new FTPClient(); diff --git a/s3auth-relay/src/test/java/com/s3auth/relay/FtpResponseTest.java b/s3auth-relay/src/test/java/com/s3auth/relay/FtpResponseTest.java index ed51335d..d2a716c3 100644 --- a/s3auth-relay/src/test/java/com/s3auth/relay/FtpResponseTest.java +++ b/s3auth-relay/src/test/java/com/s3auth/relay/FtpResponseTest.java @@ -32,7 +32,7 @@ import org.apache.commons.net.ftp.FTPReply; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; -import org.junit.Ignore; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; /** @@ -44,7 +44,7 @@ final class FtpResponseTest { * FtpResponse can construct correct FTP response. */ @Test - @Ignore + @Disabled public void constructsCorrectly() { MatcherAssert.assertThat( new FtpResponse() diff --git a/s3auth-relay/src/test/java/com/s3auth/relay/HttpFacadeTest.java b/s3auth-relay/src/test/java/com/s3auth/relay/HttpFacadeTest.java index fdeb11e2..5949b8cd 100644 --- a/s3auth-relay/src/test/java/com/s3auth/relay/HttpFacadeTest.java +++ b/s3auth-relay/src/test/java/com/s3auth/relay/HttpFacadeTest.java @@ -58,10 +58,9 @@ import org.apache.http.client.utils.DateUtils; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; -import org.junit.Ignore; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.mockito.Mockito; -import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; /** @@ -492,7 +491,7 @@ void getsCompressedContent() throws Exception { * Let's fix it and unignore the test. */ @Test - @Ignore + @Disabled public void getsContentOverSSL() throws Exception { MatcherAssert.assertThat( System.getProperty("javax.net.ssl.keyStore"),