package com.yammer.dropwizard.jersey.tests;

import static org.junit.Assert.assertEquals;

import java.util.Iterator;

import javax.ws.rs.GET;
import javax.ws.rs.Path;

import org.junit.Test;

import com.sun.jersey.core.spi.scanning.PackageNamesScanner;
import com.yammer.dropwizard.jersey.DropwizardResourceConfig;
import com.yammer.dropwizard.jersey.tests.dummy.DummyResource;

public class DropwizardResourceConfigTest {

    @Test
    public void findsResourceClassInPackage() {
        final DropwizardResourceConfig rc = new DropwizardResourceConfig(true);
        rc.init(new PackageNamesScanner(new String[] { DummyResource.class.getPackage().getName() }));
        assertEquals("Resource classes found", 1, rc.getRootResourceClasses().size());
        assertEquals(
                "Unexpected resource class found",
                DummyResource.class,
                rc.getRootResourceClasses().iterator().next());
    }

    @Test
    public void findsResourceClassesInPackageAndSubpackage() {
        final DropwizardResourceConfig rc = new DropwizardResourceConfig(true);
        rc.init(new PackageNamesScanner(new String[] { getClass().getPackage().getName() }));
        assertEquals("Resource classes found", 2, rc.getRootResourceClasses().size());
        final Iterator<Class<?>> resources = rc.getRootResourceClasses().iterator();
        assertEquals(
                "Unexpected resource class found",
                TestResource.class,
                resources.next());
        assertEquals(
                "Unexpected resource class found",
                DummyResource.class,
                resources.next());
    }

    @Path("/dummy")
    public static class TestResource {
        @GET
        public String foo() {
            return "bar";
        }
    }
}

@@ -49,149 +49,48 @@
 ort 
-static org.junit.Assert.assertEquals;%0A%0Aimport java.util.Iterator;%0A%0Aimport javax.ws.rs.GET;%0Aimport javax.ws.rs.Path;%0A%0Aimport org.junit.Tes
+com.google.common.collect.ImmutableSe
 t;%0A
-%0A
 impo
@@ -270,16 +270,195 @@
 esource;
+%0Aimport org.junit.Test;%0A%0Aimport javax.ws.rs.GET;%0Aimport javax.ws.rs.Path;%0Aimport java.util.Set;%0A%0Aimport static org.hamcrest.Matchers.is;%0Aimport static org.junit.Assert.assertThat;
 %0A%0Apublic
@@ -729,32 +729,33 @@
 .getName() %7D));%0A
+%0A
         assertEq
@@ -756,154 +756,118 @@
 sert
-Equals(%22Resource classes found%22, 1, rc.getRootResourceClasses().size());%0A        assertEquals(%0A                %22Unexpected resource class found%22,%0A
+That(rc.getRootResourceClasses(),%0A                   is((Set%3CClass%3C?%3E%3E) ImmutableSet.%3CClass%3C?%3E%3Eof(%0A           
     
@@ -889,33 +889,32 @@
 myResource.class
-,
 %0A               
@@ -918,52 +918,12 @@
     
-rc.getRootResourceClasses().iterator().next(
+   )
 ));%0A
@@ -1172,24 +1172,25 @@
 Name() %7D));%0A
+%0A
         asse
@@ -1195,382 +1195,173 @@
 sert
-Equals(%22Resource classes found%22, 2, rc.getRootResourceClasses().size());%0A        final Iterator%3CClass%3C?%3E%3E resources = rc.getRootResourceClasses().iterator();%0A        assertEquals(%0A                %22Unexpected resource class found%22,%0A                TestResource.class,%0A                resources.next());%0A        assertEquals(%0A                %22Unexpected r
+That(rc.getRootResourceClasses(),%0A                   is((Set%3CClass%3C?%3E%3E) ImmutableSet.%3CClass%3C?%3E%3Eof(%0A                           DummyResource.class, TestR
 esource
- 
+.
 class
- found%22,
 %0A   
@@ -1377,60 +1377,12 @@
     
-DummyResource.class,%0A                resources.next(
+   )
 ));%0A

Fix DropwizardResourceConfigTest.