Skip to content

Commit

Permalink
#38 Testing Framework - ignorableFileAnalyser simple test.
Browse files Browse the repository at this point in the history
  • Loading branch information
spuliaiev-sfdc committed Aug 5, 2018
1 parent 0faf6d0 commit 2bd5ac8
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
5 changes: 5 additions & 0 deletions core/libs/image-importer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<!-- Embedded mongo -->
<!-- dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package gallerymine.backend.analyzer;

import com.google.common.collect.Sets;
import org.apache.commons.io.FilenameUtils;
import org.springframework.stereotype.Component;

import java.util.Set;
Expand All @@ -9,11 +10,13 @@
public class IgnorableFileAnayser {

public static final Set<String> skippableFiles = Sets.newHashSet(
".DS_Store"
".DS_Store",
"read.me",
"README.md"
);

public static final Set<String> skippableExtensions = Sets.newHashSet(
".DS_Store"
"txt"
);

public boolean accepts(String fileName) {
Expand All @@ -26,7 +29,7 @@ public boolean accepts(String fileName) {
return true;
}

String fileExt = fileName.substring(fileName.lastIndexOf(".") + 1);
String fileExt = FilenameUtils.getExtension(fileName);

if (skippableExtensions.contains(fileExt)) {
return true;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package gallerymine.backend.analyzer;

import static org.junit.Assert.*;

public class IgnorableFileAnayserTest {

IgnorableFileAnayser analyser = new IgnorableFileAnayser();

@org.junit.Test
public void accepts() {
assertTrue("System file was not ignored", analyser.accepts(".git"));
assertTrue("Mac thumb file was not ignored", analyser.accepts(".DS_Store"));
assertTrue("Text read.me file was not ignored", analyser.accepts("read.me"));
assertTrue("Git readme.md file was not ignored", analyser.accepts("README.md"));
assertTrue("Text file was not ignored", analyser.accepts("sample.txt"));
assertFalse("JPEG file was ignored", analyser.accepts("sample.jpg"));
}
}

0 comments on commit 2bd5ac8

Please sign in to comment.