package cucumber.runtime.java.guice;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertThat;

import org.junit.Before;
import org.junit.Test;

import cucumber.runtime.java.ObjectFactory;

import java.io.IOException;
import java.util.Properties;

public class GuiceFactoryTest {
    @Test
    public void shouldGiveUsNewInstancesForEachScenario() throws IOException {
        ObjectFactory factory = new GuiceFactory();
        factory.addClass(Mappings.class);

        // Scenario 1
        factory.createInstances();
        Mappings o1 = factory.getInstance(Mappings.class);
        factory.disposeInstances();

        // Scenario 2
        factory.createInstances();
        Mappings o2 = factory.getInstance(Mappings.class);
        factory.disposeInstances();

        assertNotNull(o1);
        assertNotSame(o1, o2);
    }

    @Test
    public void copeWithMissingGuiceModuleProperty() throws Exception {
        ObjectFactory factory = new GuiceFactory(new Properties());
        factory.createInstances();
        Mappings mappings = factory.getInstance(Mappings.class);
        assertThat(mappings, is(notNullValue()));
    }
}
@@ -35,291 +35,8 @@
 e;%0A%0A
-import static org.hamcrest.CoreMatchers.is;%0Aimport static org.hamcrest.CoreMatchers.notNullValue;%0Aimport static org.junit.Assert.assertNotNull;%0Aimport static org.junit.Assert.assertNotSame;%0Aimport static org.junit.Assert.assertThat;%0A%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0A%0A
 impo
@@ -74,16 +74,39 @@
 Factory;
+%0Aimport org.junit.Test;
 %0A%0Aimport
@@ -157,16 +157,51 @@
 rties;%0A%0A
+import static org.junit.Assert.*;%0A%0A
 public c
@@ -779,16 +779,71 @@
 %0A    %7D%0A%0A
+    // TODO: verify that this is what the author meant%0A
     @Tes
@@ -864,42 +864,63 @@
 oid 
-copeWithM
+m
 issing
-G
+_g
 uice
-M
+_m
 odule
-P
+_p
 roperty
+_causes_mapping_to_be_null
 () t
@@ -1123,12 +1123,12 @@
 sert
-That
+Null
 (map
@@ -1136,28 +1136,8 @@
 ings
-, is(notNullValue())
 );%0A 

Clarify intent of test