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 class AccountTest { | |
Mockery mockery; | |
Strategy mockStrategy; | |
Account account; | |
@Before | |
public void before() { | |
mockery = new Mockery(); | |
mockery.setImposteriser(ClassImposteriser.INSTANCE); | |
mockStrategy = mockery.mock(Strategy.class); |
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 class StrategyTest { | |
@Test | |
public void testHighRiskLowFraction_okayForRisky() { | |
assertTrue(Strategy.AGGRESIVE.isRiskAcceptable(0.1, 0.75)); | |
assertTrue(Strategy.AGGRESIVE.isRiskAcceptable(0.2, 0.75)); | |
assertTrue(Strategy.AGGRESIVE.isRiskAcceptable(0.2, 0.5)); | |
} | |
} |
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
enum Strategy { | |
AGGRESIVE { | |
@Override | |
boolean isRiskAcceptable(double percentOfAssets, double riskiness) { | |
return percentOfAssets * riskiness < 0.25; | |
} | |
}, | |
CONSERVATIVE { | |
@Override | |
boolean isRiskAcceptable(double percentOfAssets, double riskiness) { |
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
switch (account.getStrategy()) { | |
case AGGRESIVE: | |
return "aggressive high risk"; | |
case CONSERVATIVE: | |
return "conservative low risk"; | |
default: | |
return "unknown strategy"; | |
} |
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
At 8:55am on 2013-06-17, while riding west at about 12-15mph | |
over the Willow Rd. Hwy 101 overcrossing in the right hand lane, | |
a dumbarton express bus #DB1 passed unsafely, with 12-18" of | |
space between the bus and my handlebar before taking the 101S onramp. | |
AC Transit feedback #10300 |
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
class WithLambda { | |
public static void main(String[] args) { | |
Runnable r = () -> System.out.println("and it works..."); | |
r.run(); | |
} | |
} |
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 testNeedToUpdateHolidaysBeforeNextYear() throws Exception { | |
DateTime now = new DateTime(ET); | |
DateTime warningDate = new DateTime(2012, 12, 15, 0, 0, 0, 0, ET); | |
LocalDate newYearsDate = new LocalDate(warningDate.getYear()+1, 1, 1); | |
/** | |
* Once you update the holidays in Market.java, increment the year in this test | |
* so it passes until next year. | |
*/ |
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
@Singleton | |
public class Market { | |
final static Set<LocalDate> HOLIDAYS = ImmutableSet.of( | |
// ... | |
new LocalDate(2012, 1, 2), // New Years | |
new LocalDate(2012, 1, 16), // MLK | |
new LocalDate(2012, 2, 20), // Washington's Birthday | |
new LocalDate(2012, 4, 6), // Good Friday | |
new LocalDate(2012, 5, 28), // Memorial Day |
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 class Nullery { | |
private static MockObjectNamingScheme namingScheme = new CamelCaseNamingScheme(); | |
private static Imposteriser imposteriser = ClassImposteriser.INSTANCE; | |
public static <T> T nulled(Class<T> typeToNull) { | |
return nulled(typeToNull, namingScheme.defaultNameFor(typeToNull)); | |
} | |
public static <T> T nulled(Class<T> typeToMock, final String name) { |
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
require 'formula' | |
class Emacs < Formula | |
url 'http://ftp.gnu.org/pub/gnu/emacs/emacs-23.3a.tar.bz2' | |
md5 'f2cf8dc6f28f8ae59bc695b4ddda339c' | |
homepage 'http://www.gnu.org/software/emacs/' | |
if ARGV.include? "--use-git-head" | |
head 'git://repo.or.cz/emacs.git' | |
else |