FileExtension { public String appendExtension(String filePath) { Preconditions.checkArgument(StringUtils.isNotBlank(filePath), "filePath cannot be null or blank"); return filePath + asFileSuffix(); } @VisibleForTesting  FileExtension(String extension); static FileExtension of(String extension); String appendExtension(String filePath); String asFileSuffix(); String getExtension(); @Override final boolean equals(Object o); @Override final int hashCode(); static final FileExtension ZIP; }
@Test void appendExtensionShouldThrowWhenPassingNullValue() { FileExtension fileExtension = new FileExtension(ZIP_EXTENSION_STRING); assertThatThrownBy(() -> fileExtension.appendExtension(null)) .isInstanceOf(IllegalArgumentException.class); }
@Test void appendExtensionShouldThrowWhenPassingEmptyStringValue() { FileExtension fileExtension = new FileExtension(ZIP_EXTENSION_STRING); assertThatThrownBy(() -> fileExtension.appendExtension("")) .isInstanceOf(IllegalArgumentException.class); }
@Test void appendExtensionShouldReturnValueEndsWithExtension() { FileExtension fileExtension = new FileExtension("tar.gz"); assertThat(fileExtension.appendExtension("/local/james")) .endsWith(".tar.gz"); }