com.github.searls.jasmine.io.scripts.ResolvesLocationOfPreloadSources Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jasmine-maven-plugin Show documentation
Show all versions of jasmine-maven-plugin Show documentation
A JavaScript unit test plugin that processes JavaScript sources and Jasmine specs, prepares test runner HTML files, executes Jasmine specs headlessly with HtmlUnit, and produces JUnit XML reports
package com.github.searls.jasmine.io.scripts;
import com.github.searls.jasmine.collections.CollectionHelper;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
public class ResolvesLocationOfPreloadSources {
private CollectionHelper collectionHelper = new CollectionHelper();
private ConvertsFileToUriString convertsFileToUriString = new ConvertsFileToUriString();
public List resolve(List preloadSources, File sourceDir, File specDir) {
List sources = new ArrayList();
for (String source : collectionHelper.list(preloadSources)) {
if (fileCouldNotBeAdded(new File(sourceDir, source), sources)
&& fileCouldNotBeAdded(new File(specDir, source), sources)
&& fileCouldNotBeAdded(new File(source), sources)) {
sources.add(source);
}
}
return sources;
}
private boolean fileCouldNotBeAdded(File file, List sourcePaths) {
boolean canAdd = file.exists();
if (canAdd) {
sourcePaths.add(convertsFileToUriString.convert(file));
}
return !canAdd;
}
}