S3PropertiesLocationHelper { public void validate(S3PropertiesLocation s3PropertiesLocation) { String bucketName = s3PropertiesLocation.getBucketName(); String key = s3PropertiesLocation.getKey(); Assert.hasText(bucketName, "S3 properties location bucket name must be specified."); Assert.hasText(key, "S3 properties location object key must be specified."); s3PropertiesLocation.setBucketName(bucketName.trim()); s3PropertiesLocation.setKey(key.trim()); }  void validate(S3PropertiesLocation s3PropertiesLocation);  }
@Test public void testValidateNoErrorsAndTrimmed() { S3PropertiesLocation s3PropertiesLocation = getS3PropertiesLocation(); String expectedBucketName = s3PropertiesLocation.getBucketName(); String expectedKey = s3PropertiesLocation.getKey(); s3PropertiesLocation.setBucketName(BLANK_TEXT + s3PropertiesLocation.getBucketName() + BLANK_TEXT); s3PropertiesLocation.setKey(BLANK_TEXT + s3PropertiesLocation.getKey() + BLANK_TEXT); try { s3PropertiesLocationHelper.validate(s3PropertiesLocation); Assert.assertEquals("s3PropertiesLocation bucketName", expectedBucketName, s3PropertiesLocation.getBucketName()); Assert.assertEquals("s3PropertiesLocation key", expectedKey, s3PropertiesLocation.getKey()); } catch (Exception e) { Assert.fail("unexpected exception was thrown. " + e); } }