package com.rmd.personal.projecteuler;

import java.util.Date;
import java.util.Map;

import org.junit.Ignore;
import org.junit.Test;

import static org.junit.Assert.*;

public class CommonTest {

    @Test
    public void findFactorTreeReturnsCorrectlyFor2DigitNumber() {
        long startTime = new Date().getTime();
        // Arrange
        final long value = 12L;

        // Act
        Map<Long, Integer> primeFactorTree = Common.findPrimeFactorTreeForValue(value);

        // Assert
        assertEquals(2, primeFactorTree.size());
        assertEquals((Integer) 2, primeFactorTree.get(2L));
        assertEquals((Integer) 1, primeFactorTree.get(3L)); // SUPPRESS CHECKSTYLE magicNumber
        System.out.println("DONE (2Digit): took " + (new Date().getTime() - startTime) + " ms");
    }

    @Test
    public void findFactorTreeReturnsCorrectlyFor7DigitNumber() {
        long startTime = new Date().getTime();
        // Arrange
        final long value = 8004150L;

        // Act
        Map<Long, Integer> primeFactorTree = Common.findPrimeFactorTreeForValue(value);

        // Assert
        assertEquals(5, primeFactorTree.size()); // SUPPRESS CHECKSTYLE magicNumber
        assertEquals((Integer) 1, primeFactorTree.get(2L));
        assertEquals((Integer) 3, primeFactorTree.get(3L)); // SUPPRESS CHECKSTYLE magicNumber
        assertEquals((Integer) 2, primeFactorTree.get(5L)); // SUPPRESS CHECKSTYLE magicNumber
        assertEquals((Integer) 2, primeFactorTree.get(7L)); // SUPPRESS CHECKSTYLE magicNumber
        assertEquals((Integer) 2, primeFactorTree.get(11L)); // SUPPRESS CHECKSTYLE magicNumber
        System.out.println("DONE (7Digit): took " + (new Date().getTime() - startTime) + " ms");
    }

    @Test
    @Ignore
    public void findFactorTreeReturnsCorrectlyForLargePrime() {
        long startTime = new Date().getTime();
        // Arrange
        final int powerOf2 = 3;
        final int powerOf3 = 5;
        final int powerOf17 = 2;
        final int powerOf19 = 2;
        final long value = (long)
                (Math.pow(2, powerOf2) * Math.pow(3, powerOf3) * Math.pow(17, powerOf17) * Math.pow(19, powerOf19)); // SUPPRESS CHECKSTYLE magicNumber

        // Act
        Map<Long, Integer> primeFactorTree = Common.findPrimeFactorTreeForValue(value);

        // Assert
        assertEquals(4, primeFactorTree.size()); // SUPPRESS CHECKSTYLE magicNumber
        assertEquals((Integer) powerOf2, primeFactorTree.get(2L));
        assertEquals((Integer) powerOf3, primeFactorTree.get(3L)); // SUPPRESS CHECKSTYLE magicNumber
        assertEquals((Integer) powerOf17, primeFactorTree.get(17L)); // SUPPRESS CHECKSTYLE magicNumber
        assertEquals((Integer) powerOf19, primeFactorTree.get(19L)); // SUPPRESS CHECKSTYLE magicNumber
        System.out.println("DONE (largePrime): took " + (new Date().getTime() - startTime) + " ms");
    }
}

@@ -39,32 +39,8 @@
 %0D%0A%0D%0A
-import java.util.Date;%0D%0A
 impo
@@ -58,16 +58,16 @@
 l.Map;%0D%0A
+
 %0D%0Aimport
@@ -260,56 +260,8 @@
  %7B%0D%0A
-        long startTime = new Date().getTime();%0D%0A
     
@@ -648,106 +648,8 @@
 er%0D%0A
-        System.out.println(%22DONE (2Digit): took %22 + (new Date().getTime() - startTime) + %22 ms%22);%0D%0A
     
@@ -735,56 +735,8 @@
  %7B%0D%0A
-        long startTime = new Date().getTime();%0D%0A
     
@@ -1452,106 +1452,8 @@
 er%0D%0A
-        System.out.println(%22DONE (7Digit): took %22 + (new Date().getTime() - startTime) + %22 ms%22);%0D%0A
     
@@ -1550,56 +1550,8 @@
  %7B%0D%0A
-        long startTime = new Date().getTime();%0D%0A
     
@@ -2369,32 +2369,32 @@
 LE magicNumber%0D%0A
+
         assertEq
@@ -2486,110 +2486,8 @@
 er%0D%0A
-        System.out.println(%22DONE (largePrime): took %22 + (new Date().getTime() - startTime) + %22 ms%22);%0D%0A
     

Remove output from CommonTest.