use of org.jmock.Expectations in project commons-gdx by gemserk.
the class ContactsTest method whenAddingOneContactBAItIsAdded.
@Test
public void whenAddingOneContactBAItIsAdded() {
mockery.checking(new Expectations() {
{
oneOf(box2dcontact).getWorldManifold();
will(returnValue(worldManifold));
oneOf(worldManifold).getNormal();
will(returnValue(normal));
oneOf(box2dcontact).getFixtureA();
will(returnValue(fixtureA));
oneOf(box2dcontact).getFixtureB();
will(returnValue(fixtureB));
ignoring(fixtureA);
ignoring(fixtureB);
}
});
contacts.addContact(box2dcontact, false);
assertTrue(contacts.isInContact());
assertThat(1, IsEqual.equalTo(contacts.getContactCount()));
Contact contact = contacts.getContact(0);
assertThat(contact.getNormal().dst(0, -1), OrderingComparisons.lessThan(0.1f));
assertSame(fixtureA, contact.getOtherFixture());
assertSame(fixtureB, contact.getMyFixture());
}
use of org.jmock.Expectations in project RoboBinding by RoboBinding.
the class SimpleOneWayPropertyInfoTest method givenPrimitivePropertyType_thenReturnBoxedType.
@Test
public void givenPrimitivePropertyType_thenReturnBoxedType() {
final SetterElement setter = context.mock(SetterElement.class);
final WrappedPrimitiveType primitiveType = context.mock(WrappedPrimitiveType.class);
context.checking(new Expectations() {
{
oneOf(setter).parameterType();
will(returnValue(primitiveType));
oneOf(primitiveType).isPrimitive();
will(returnValue(true));
oneOf(primitiveType).boxedClassName();
will(returnValue(Integer.class.getName()));
}
});
SimpleOneWayPropertyInfo info = new SimpleOneWayPropertyInfo(setter);
assertThat(info.propertyType(), equalTo(Integer.class.getName()));
}
use of org.jmock.Expectations in project RoboBinding by RoboBinding.
the class ElementWrapperTest method whenWrapSupportedElements_thenReturnCoorespondingWrappedInstance.
@Theory
public void whenWrapSupportedElements_thenReturnCoorespondingWrappedInstance(@FromDataPoints("supportedElements") ElementToWrapped elementToWrapped) {
Mockery context = new ClassMockery();
final TypeMirrorWrapper typeWrapper = context.mock(TypeMirrorWrapper.class);
context.checking(new Expectations() {
{
allowing(typeWrapper).wrap(with(any(TypeMirror.class)));
will(returnValue(null));
}
});
ElementWrapper wrapper = new ElementWrapper(typeWrapper, null, null, null);
AbstractWrappedElement wrapped = wrapper.wrap(elementToWrapped.element);
assertThat(wrapped, isA(elementToWrapped.wrappedType));
}
use of org.jmock.Expectations in project RoboBinding by RoboBinding.
the class WrappedPrimitiveTypeTest method shouldGetCorrectBoxedClassName.
@Theory
public void shouldGetCorrectBoxedClassName(@FromDataPoints("primitiveBoxedClassNames") PrimitiveTypeToClassName typeToBoxedClassName) {
ClassMockery context = new ClassMockery();
final TypeMirrorWrapper wrapper = context.mock(TypeMirrorWrapper.class);
final WrappedDeclaredType integerDeclaredType = context.mock(WrappedDeclaredType.class);
final WrappedDeclaredType booleanDeclaredType = context.mock(WrappedDeclaredType.class);
context.checking(new Expectations() {
{
allowing(integerDeclaredType).className();
will(returnValue(Integer.class.getName()));
allowing(wrapper).wrap(declaredTypeOf(Integer.class));
will(returnValue(integerDeclaredType));
allowing(booleanDeclaredType).className();
will(returnValue(Boolean.class.getName()));
allowing(wrapper).wrap(declaredTypeOf(Boolean.class));
will(returnValue(booleanDeclaredType));
}
});
WrappedPrimitiveType type = new WrappedPrimitiveType(typeToBoxedClassName.type, compilation.getTypes(), wrapper);
assertThat(type.boxedClassName(), equalTo(typeToBoxedClassName.className));
}
use of org.jmock.Expectations in project nhin-d by DirectProject.
the class CertificateServiceTest method testListCertificates.
/**
* Test the listCertificates method.
*/
public void testListCertificates() {
final CertificateDao certificateDao = context.mock(CertificateDao.class);
final Long certificateId = 7L;
final int maxResults = 7;
final CertificateGetOptions certificateOptions = CertificateGetOptions.DEFAULT;
context.checking(new Expectations() {
{
oneOf(certificateDao).list((String) null);
will(returnValue(Collections.<Certificate>emptyList()));
}
});
CertificateServiceImpl service = new CertificateServiceImpl();
service.setDao(certificateDao);
try {
Collection<Certificate> output = service.listCertificates(certificateId, maxResults, certificateOptions);
assertNotNull("Output is null when using valid params", output);
assertEquals("Output does not match mocked return value when using valid params", Collections.<Certificate>emptyList(), output);
} catch (Exception e) {
fail("Exception thrown");
}
}
Aggregations