sft.report.HtmlResources Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of SimpleFunctionalTest Show documentation
Show all versions of SimpleFunctionalTest Show documentation
A JUnit extension to easily adopt functional testing and acceptance testing
/*******************************************************************************
* Copyright (c) 2013 Sylvain Lézier.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sylvain Lézier - initial implementation
*******************************************************************************/
package sft.report;
import sft.environment.FileSystem;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class HtmlResources {
public static final String HTML_DEPENDENCIES_FOLDER = "sft-html-default";
private FileSystem fileSystem = new FileSystem();
private static List filesUsed;
public HtmlResources ensureIsCreated() throws IOException {
// if (filesUsed == null) {
filesUsed = fileSystem.targetFolder.copyFromResources(HTML_DEPENDENCIES_FOLDER);
// }
return this;
}
public String convertIssue(Issue issue) {
return issue.toString().toLowerCase();
}
public String getIncludeCssDirectives(Class> useCaseClass) {
RelativeHtmlPathResolver pathResolver = new RelativeHtmlPathResolver();
String callerPath = pathResolver.getPathOf(useCaseClass, ".html");
String includeCssDirectives = "";
for (String cssToInclude : getCssToInclude()) {
includeCssDirectives += "\n";
}
return includeCssDirectives;
}
public String getIncludeJsDirectives(Class> useCaseClass) {
RelativeHtmlPathResolver pathResolver = new RelativeHtmlPathResolver();
String callerPath = pathResolver.getPathOf(useCaseClass, ".html");
String includeJsDirectives = "";
for (String jsToInclude : getJsToInclude()) {
includeJsDirectives += "\n";
}
return includeJsDirectives;
}
private List getCssToInclude() {
ArrayList cssFiles = new ArrayList();
for (String file : filesUsed) {
if( file.endsWith(".css")){
cssFiles.add(file);
}
}
return cssFiles;
}
private List getJsToInclude() {
ArrayList jsFiles = new ArrayList();
for (String file : filesUsed) {
if( file.endsWith(".js")){
jsFiles.add(file);
}
}
return jsFiles;
}
}