package com.phsshp;

import com.phsshp.testutils.matchers.MetricsMatcher;
import org.junit.Test;

import java.io.File;
import java.util.Arrays;
import java.util.List;

import static com.phsshp.testutils.matchers.MetricsMatcher.metricsMatching;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;

public class MetricsReporterTest {

    @Test
    public void reportMetricsForJavaFiles() throws Exception {
        // TODO: crappy test for now
        List<File> files = Arrays.asList(
                new File("src/test/resources/test-project/SomeFile.java"),
                new File("src/test/resources/test-project/pkg1/AnotherInPackage1.java"));

        List<Metrics> metrics = new MetricsReporter().report(files);

        assertThat(metrics.size(), is(2));
        assertThat(metrics.get(0).getFile().getName(), equalTo("SomeFile.java"));
        assertThat(metrics.get(0).getValue(), equalTo(1));
        assertThat(metrics.get(1).getFile().getName(), equalTo("AnotherInPackage1.java"));
        assertThat(metrics.get(1).getValue(), equalTo(3));
        assertThat(metrics.get(0), metricsMatching("SomeFile.java", 1));
    }

}
@@ -18,61 +18,8 @@
 p;%0A%0A
-import com.phsshp.testutils.matchers.MetricsMatcher;%0A
 impo
@@ -33,24 +33,24 @@
 junit.Test;%0A
+
 %0Aimport java
@@ -277,54 +277,15 @@
 ers.
-equalTo;%0Aimport static org.hamcrest.Matchers.i
+contain
 s;%0A%0A
@@ -397,45 +397,8 @@
 n %7B%0A
-        // TODO: crappy test for now%0A
     
@@ -701,87 +701,51 @@
 rics
-.size(), is(2));%0A        assertThat(metrics.get(0).getFile().getName(), equalTo
+, contains(%0A                metricsMatching
 (%22So
@@ -752,27 +752,29 @@
 meFile.java%22
-));
+, 1),
 %0A        ass
@@ -774,278 +774,60 @@
     
-assertThat(metrics.get(0).getValue(), equalTo(1));%0A        assertThat(metrics.get(1).getFile().getName(), equalTo(%22AnotherInPackage1.java%22));%0A        assertThat(metrics.get(1).getValue(), equalTo(3));%0A        assertThat(metrics.get(0), metricsMatching(%22SomeFile.java%22, 1
+        metricsMatching(%22AnotherInPackage1.java%22, 3)
 ));%0A

Refactor test to use matchers