-
-
Save tomjadams/7169 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.googlecode.furnace.analyse.blast; | |
import static com.googlecode.instinct.expect.Expect.expect; | |
import com.googlecode.instinct.integrate.junit4.InstinctRunner; | |
import com.googlecode.instinct.internal.util.instance.ObjectFactory; | |
import com.googlecode.instinct.marker.annotate.BeforeSpecification; | |
import com.googlecode.instinct.marker.annotate.Dummy; | |
import com.googlecode.instinct.marker.annotate.Mock; | |
import com.googlecode.instinct.marker.annotate.Specification; | |
import com.googlecode.instinct.marker.annotate.Subject; | |
import java.util.ArrayList; | |
import java.util.List; | |
import org.jmock.Expectations; | |
import org.junit.runner.RunWith; | |
@RunWith(InstinctRunner.class) | |
public final class AnObjectFactory { | |
@Subject ListUserAdaptor listUserAdaptor; | |
@Mock ObjectFactory factory; | |
@Mock ListUser mockListUser; | |
@Dummy private List<?> list; | |
@BeforeSpecification | |
public void before() { | |
listUserAdaptor = new ListUserAdaptor(factory, mockListUser); | |
} | |
@Specification | |
public void shouldUseArrayListsOnListUser() { | |
expect.that(new Expectations() {{ | |
one(factory).create(ArrayList.class); will(returnValue(list)); | |
one(mockListUser).useAList(list); | |
}}); | |
listUserAdaptor.useAList(); | |
} | |
private class ListUserAdaptor { | |
private final ObjectFactory factory; | |
private final ListUser listUser; | |
public ListUserAdaptor(ObjectFactory factory, AnObjectFactory.ListUser listUser) { | |
this.factory = factory; | |
this.listUser = listUser; | |
} | |
public void useAList() { | |
final List<?> list = factory.create(ArrayList.class); | |
listUser.useAList(list); | |
} | |
} | |
private class ListUser { | |
public void useAList(List list) { | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment