package com.jasonlam604.stocktechnicals.util;

import static org.junit.Assert.fail;

import java.lang.reflect.Constructor;
import java.lang.reflect.Modifier;

import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

public class NumberFormatterTest {

	@Rule
	public ExpectedException thrown = ExpectedException.none();
	
	@Test
	public void roundingTwoDecimals() {
		Assert.assertEquals(10, NumberFormatter.round(10), 0);
		Assert.assertEquals(1, NumberFormatter.round(1), 0);
		Assert.assertEquals(1.1, NumberFormatter.round(1.1), 0);
		Assert.assertEquals(1.14, NumberFormatter.round(1.144), 0);
		Assert.assertEquals(1.15, NumberFormatter.round(1.145), 0);
		Assert.assertEquals(1.20, NumberFormatter.round(1.19555555), 0);
	}

	@Test
	public void roundingWithIndicateDecimalPoints() {
		Assert.assertEquals(1, NumberFormatter.round(1.19555555, 0), 0);
		Assert.assertEquals(1.2, NumberFormatter.round(1.19555555, 1), 0);
		Assert.assertEquals(1.20, NumberFormatter.round(1.19555555, 2), 0);
		Assert.assertEquals(1.196, NumberFormatter.round(1.19555555, 3), 0);
	}
	
	@Test(expected=IllegalAccessException.class)
	public void testConstructorPrivate() throws Exception {
		NumberFormatter.class.newInstance();
	    Assert.fail("class constructor should be private");
	}
}

@@ -116,16 +116,68 @@
 ructor;%0A
+import java.lang.reflect.InvocationTargetException;%0A
 import j
@@ -203,16 +203,16 @@
 difier;%0A
-
 %0Aimport 
@@ -422,18 +422,17 @@
 none();%0A
-%09
 %0A
+
 %09@Test%0A%09
@@ -1175,55 +1175,15 @@
 %0A%09%7D%0A
-%09
 %0A%09@Test
-(expected=IllegalAccessException.class)
 %0A%09pu
@@ -1242,101 +1242,989 @@
 %7B%0A%09%09
-NumberFormatter.class.newInstance();%0A%09    Assert.fail(%22class constructor should be private%22);
+Constructor%5B%5D ctors = NumberFormatter.class.getDeclaredConstructors();%0A%09%09Assert.assertEquals(%22Utility class should only have one constructor%22, 1, ctors.length);%0A%09%09Constructor ctor = ctors%5B0%5D;%0A%09%09Assert.assertFalse(%22Utility class constructor should be inaccessible%22, ctor.isAccessible());%0A%09%09ctor.setAccessible(true); // obviously we'd never do this in production%0A%09%09Assert.assertEquals(%22You'd expect the construct to return the expected type%22, NumberFormatter.class,%0A%09%09%09%09ctor.newInstance().getClass());%0A%09%7D%0A%0A%09@Test%0A%09public void callPrivateConstructorsForCodeCoverage() throws SecurityException, NoSuchMethodException,%0A%09%09%09IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException %7B%0A%09%09Class%3C?%3E%5B%5D classesToConstruct = %7B NumberFormatter.class %7D;%0A%09%09for (Class%3C?%3E clazz : classesToConstruct) %7B%0A%09%09%09Constructor%3C?%3E constructor = clazz.getDeclaredConstructor();%0A%09%09%09constructor.setAccessible(true);%0A%09%09%09Assert.assertNotNull(constructor.newInstance());%0A%09%09%7D
 %0A%09%7D%0A

Add another private constructor test to improve code coverage