Created
May 15, 2014 20:13
-
-
Save cgruber/cb3b053f4a2a0f9d9c6f 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
class Foo { | |
@AutoFactory | |
Foo(@Provider bar, String aString) {...} | |
} | |
@Generated(...AutoFactoryProcessor.class) | |
final class FooFactory { | |
... | |
public Foo create(String s) { ... } | |
} | |
class MyService { | |
@Inject MyService(FooFactory factoryOfFoos) { ... } | |
@Inject ActionLogger log; | |
Whoop extractWhoop() { | |
Foo = factoryOfFoos().create(getSomeBlahString()); | |
... // do stuff with Foo to get a Whoop for 10 lines or so | |
Whoop result = ... // the final Whoop creation. | |
return result; | |
} | |
} | |
class MyServiceTest { | |
@Test testDoStuffLogsProperly() { | |
Foo testFoo = new Foo(new Bar(blah), "this is a test."); | |
FooFactory factory = mock(FooFactory); | |
when(factory.create(any(String.class))).return(testFoo); // faked for the test | |
Whoop expectedWhoop = new Whoop(... whatever); | |
ASSERT.that(objectUnderTest.extractWhoop()).isEqualTo(expectedWhoop); | |
ASSERT.that(objectUnderTest.extractWhoop().whatever()).contains("this is a test."); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment