10 miliardi di farmaci!
1 day ago
...or how to be heavyweight and agile at the same time
@RunWith(JMock.class)
private Mockery context = new JUnit4Mockery();
@Test
public void testGetTable() {
System.out.println("getTable");
context.setImposteriser(ClassImposteriser.INSTANCE);
final LookupTableRepository repository = context.mock(LookupTableRepository.class);
final LookupTable table = context.mock(LookupTable.class);
final LookupTableFacadeResultFactory factory = context.mock(LookupTableFacadeResultFactory.class);
final LookupTableFacadeResult expResult = context.mock(LookupTableFacadeResult.class);
context.checking(new Expectations() {{
oneOf(repository).getTable(with(equal(tableName)));
will(returnValue(table));
oneOf(factory).make(with(equal(table)));
will(returnValue(expResult));
}});
LookupTableFacade instance = new LookupTableFacadeImpl(repository, factory);
LookupTableFacadeResult result = instance.getTable(tableName);
assertSame(expResult, result);
}
context.checking(new Expectations() {{
Matcher<LookupTable> tableNameMatcher = Matchers.hasProperty("tableName", equal(tableName));
oneOf(repository).save(with(tableNameMatcher));
will(returnValue(table));
oneOf(factory).make(with(equal(table)));
will(returnValue(expResult));
}});
Matcher<LookupTableItem> codeMatcher = Matchers.hasProperty("code", equal(code));
Matcher<LookupTableItem> descriptionMatcher = Matchers.hasProperty("description", equal(description));
oneOf(repository).save(with(allOf(codeMatcher, descriptionMatcher)));
will(returnValue(table));