javarequirementstracer.ReporterUtils Maven / Gradle / Ivy
/*
* Copyright 2008-2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package javarequirementstracer;
import java.io.IOException;
import java.text.DecimalFormatSymbols;
import java.util.Date;
import java.util.Properties;
/**
* @author Ronald Koster
*/
@SuppressTraceabilityWarnings
public final class ReporterUtils {
static final String CODE_COVERAGE_DEF = "= traceableTypeCount/allTypesCount = ";
static final String REQUIREMENTS_COVERAGE_DEF = "= (foundLabelCount - unknownLabelCount)/requiredLabelCount = ";
private ReporterUtils() {
// Util class.
}
static void appendReporterInfo(XhtmlBuilder bldr) {
bldr.append("Generated with ").spanStart(AttributeId.REPORTER_INFO);
bldr.append("JavaRequirementsTracer ").append(getVersion());
bldr.spanEnd().append(".");
}
static void appendTimestampBuildNumber(XhtmlBuilder bldr, String buildNr) {
bldr.parStart();
bldr.append("Timestamp: ").append(AttributeId.TIMESTAMP, new Date());
bldr.br().append("\nBuild Number: ").append(AttributeId.BUILD_NUMBER, buildNr == null ? "???" : buildNr);
bldr.parEnd();
}
static void appendProgressIndicatorEstimate(XhtmlBuilder bldr, boolean total) {
String prefix = total ? "Total" : "";
bldr.parStart().append("").append(prefix).append(" Completeness estimates:").parEnd();
bldr.append("\n");
bldr.append("\n- Best choice: ")
.append(prefix).append("Completeness").nbsp().append("=").nbsp()
.append(prefix).append("SytemTestCodeRequirementsCoverage").nbsp().append("*").nbsp()
.append(prefix).append("PercentageSuccessfulSystemTests
");
bldr.append("\n- Next best choice (no System Test code): ")
.append(prefix).append("Completeness").nbsp().append("=").nbsp()
.append(prefix).append("MainCodeRequirementsCoverage").nbsp().append("*").nbsp()
.append(prefix).append("PercentageSuccessfulManualSystemTests
");
bldr.append("\n
");
}
private static String getVersion() {
Properties props = new Properties();
try {
props.load(ReporterUtils.class.getResourceAsStream("/jrt-reporter.properties"));
} catch (IOException ioex) {
throw new UncheckedException(ioex);
}
return props.getProperty("version");
}
public static String formatPercentage(double d) {
return String.format("%.2f", 100D * d) + "%";
}
public static String formatPercentage(String integerPart, String fraction) {
return integerPart + getDecimalSeparator() + fraction + "%";
}
public static char getDecimalSeparator() {
return DecimalFormatSymbols.getInstance().getDecimalSeparator();
}
static String getPercentageGraph(double coverage) {
return getPercentageGraph(coverage, 1D, 100D);
}
static String getPercentageGraph(double coverage, double weigth, double width) {
return ""
+ "";
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy