Search in sources :

Example 1 with ClassMockery

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));
}
Also used : Expectations(org.jmock.Expectations) TypeMirror(javax.lang.model.type.TypeMirror) TypeMirrorWrapper(org.robobinding.codegen.apt.type.TypeMirrorWrapper) ClassMockery(org.robobinding.codegen.ClassMockery) ClassMockery(org.robobinding.codegen.ClassMockery) Mockery(org.jmock.Mockery) Theory(org.junit.experimental.theories.Theory)

Example 2 with ClassMockery

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));
}
Also used : Expectations(org.jmock.Expectations) ClassMockery(org.robobinding.codegen.ClassMockery) Theory(org.junit.experimental.theories.Theory)

Aggregations

Expectations (org.jmock.Expectations)2 Theory (org.junit.experimental.theories.Theory)2 ClassMockery (org.robobinding.codegen.ClassMockery)2 TypeMirror (javax.lang.model.type.TypeMirror)1 Mockery (org.jmock.Mockery)1 TypeMirrorWrapper (org.robobinding.codegen.apt.type.TypeMirrorWrapper)1