use of org.robobinding.codegen.ClassMockery 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.robobinding.codegen.ClassMockery 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));
}
Aggregations