This file contains hidden or 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 searls.dougu.examples; | |
public class BoxOfGlassPops { | |
@Autowired GlassFlavorResolver glassFlavorResolver; | |
public int numberOfPops; | |
... | |
} |
This file contains hidden or 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 searls.dougu.examples; | |
public class ShardsOGlassSalesman { | |
private BoxOfGlassPops boxOfGlassPops; | |
public void setBoxOfGlassPops(BoxOfGlassPops boxOfGlassPops) { | |
this.boxOfGlassPops = boxOfGlassPops; | |
} | |
private Wallet wallet; | |
public void setWallet(Wallet wallet) { |
This file contains hidden or 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
@Test | |
public void insertingThreeDollarsYieldsThreeDollars() { | |
int expected = 3; | |
sut.insertDollars(expected); | |
assertEquals(sut.getDollarCount(),expected); | |
} |
This file contains hidden or 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
assertEquals(expected,sut.getDollarCount()); |
This file contains hidden or 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
assertThat(sut.getDollarCount(),is(expected)); |
This file contains hidden or 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
@Test | |
public void returnsSoldGlassPop() { | |
ShardsOGlassPop expected = mock(ShardsOGlassPop.class); | |
when(boxOfGlassPops.retrieve()).thenReturn(expected); | |
ShardsOGlassPop result = sut.sellGlassPop(); | |
assertThat(result,is(expected)); | |
} |
This file contains hidden or 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
@Test | |
public void addsMessageOnUpdate() { | |
String expected = "update.success"; | |
target.update(); | |
assertThat(target.getActionMessages(),hasItem(expected)); | |
} |
This file contains hidden or 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
public static <T extends ActionSupport> Matcher<T> hasActionMessage(final String messageText) { | |
return new TypeSafeMatcher<T>() { | |
public boolean matchesSafely(T action) { | |
return action.getActionMessages().contains(messageText); | |
} | |
public void describeTo(Description description) { | |
description.appendText("contains action message text '"+messageText+"'"); | |
} |
This file contains hidden or 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
@Test | |
public void addsMessageOnUpdate() { | |
String expected = "update.success"; | |
target.update(); | |
assertThat(target,hasActionMessage(expected)); | |
} |
This file contains hidden or 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
String string = new String(); |