package com.jasonlam604.stocktechnicals.util;

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
	public void testPrivateConstructor()  {
		final Constructor<?>[] constructors = NumberFormatter.class.getDeclaredConstructors();
        for (Constructor<?> constructor : constructors) {
            Assert.assertTrue(Modifier.isPrivate(constructor.getModifiers()));
        }
	}
}

@@ -40,16 +40,54 @@
 .util;%0A%0A
+import static org.junit.Assert.fail;%0A%0A
 import j
@@ -1120,32 +1120,71 @@
  0);%0A%09%7D%0A%09%0A%09@Test
+(expected=IllegalAccessException.class)
 %0A%09public void te
@@ -1185,23 +1185,16 @@
 oid test
-Private
 Construc
@@ -1200,249 +1200,132 @@
 ctor
-()  %7B%0A%09%09final Constructor%3C?%3E%5B%5D constructors = NumberFormatter.class.getDeclaredConstructors
+Private() throws Exception %7B%0A%09%09NumberFormatter.class.newInstance
 ();%0A
- 
+%09
     
-   for (Constructor%3C?%3E constructor : constructors) %7B%0A            Assert.assertTrue(Modifier.isPrivate(constructor.getModifiers()));%0A        %7D
+Assert.fail(%22class constructor should be private%22);
 %0A%09%7D%0A

Update private constructor test