diff --git a/dashboard/src/main/org/apache/maven/dashboard/aggregator/clover/CloverTPC.java b/dashboard/src/main/org/apache/maven/dashboard/aggregator/clover/CloverTPC.java index a5409aee..dbeec034 100644 --- a/dashboard/src/main/org/apache/maven/dashboard/aggregator/clover/CloverTPC.java +++ b/dashboard/src/main/org/apache/maven/dashboard/aggregator/clover/CloverTPC.java @@ -17,6 +17,7 @@ package org.apache.maven.dashboard.aggregator.clover; * ==================================================================== */ + import java.text.DecimalFormat; /** @@ -26,11 +27,12 @@ import java.text.DecimalFormat; */ public class CloverTPC { - public static String computeTPC(String elements, String coveredElements) + public static String computeTPC( String elements, String coveredElements ) { - double e = Double.valueOf(elements).doubleValue(); - double ce = Double.valueOf(coveredElements).doubleValue(); - DecimalFormat formatter = new DecimalFormat("##%"); - return formatter.format(ce/e); - } -} \ No newline at end of file + double e = Double.valueOf( elements ).doubleValue(); + double ce = Double.valueOf( coveredElements ).doubleValue(); + DecimalFormat formatter = new DecimalFormat( "##%" ); + + return formatter.format( ce / e ); + } +} diff --git a/dashboard/src/test/org/apache/maven/dashboard/aggregator/clover/CloverTPCTest.java b/dashboard/src/test/org/apache/maven/dashboard/aggregator/clover/CloverTPCTest.java new file mode 100644 index 00000000..9f0c6836 --- /dev/null +++ b/dashboard/src/test/org/apache/maven/dashboard/aggregator/clover/CloverTPCTest.java @@ -0,0 +1,48 @@ +package org.apache.maven.dashboard.aggregator.clover; + +/* ==================================================================== + * Copyright 2006 The Apache Software Foundation. + * + * 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. + * ==================================================================== + */ + + +import junit.framework.TestCase; + + +/** + */ +public class CloverTPCTest extends TestCase +{ + /** + * Constructor. + * @param name Name of the test. + */ + public CloverTPCTest( String name ) + { + super( name ); + } + + /** + */ + public void testcomputeTPC() throws Exception + { + String elements = "100"; + String coveredElements = "53"; + assertEquals( "Clover TPC is '53%'", + "53%", CloverTPC.computeTPC( elements, coveredElements) ); + } + +} +