Search in sources :

Example 91 with Expectations

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());
}
Also used : Expectations(org.jmock.Expectations) Contact(com.gemserk.commons.gdx.box2d.Contacts.Contact) Test(org.junit.Test)

Example 92 with Expectations

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()));
}
Also used : Expectations(org.jmock.Expectations) SetterElement(org.robobinding.codegen.apt.element.SetterElement) WrappedPrimitiveType(org.robobinding.codegen.apt.type.WrappedPrimitiveType) Test(org.junit.Test)

Example 93 with Expectations

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));
}
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 94 with Expectations

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

Example 95 with Expectations

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");
    }
}
Also used : Expectations(org.jmock.Expectations) CertificateGetOptions(org.nhindirect.config.service.impl.CertificateGetOptions) CertificateDao(org.nhindirect.config.store.dao.CertificateDao) CertificateServiceImpl(org.nhindirect.config.service.impl.CertificateServiceImpl) Certificate(org.nhindirect.config.store.Certificate)

Aggregations

Expectations (org.jmock.Expectations)651 Test (org.junit.Test)443 UnitTest (org.apache.geode.test.junit.categories.UnitTest)109 File (java.io.File)41 ConfigurationServiceImpl (org.nhindirect.config.service.impl.ConfigurationServiceImpl)41 InternalCache (org.apache.geode.internal.cache.InternalCache)35 SlingHttpServletRequest (org.apache.sling.api.SlingHttpServletRequest)33 SlingHttpServletResponse (org.apache.sling.api.SlingHttpServletResponse)32 Resource (org.apache.sling.api.resource.Resource)31 RewriterResponse (org.apache.sling.security.impl.ContentDispositionFilter.RewriterResponse)31 ArrayList (java.util.ArrayList)27 DiskStore (org.apache.geode.cache.DiskStore)23 ValueMap (org.apache.sling.api.resource.ValueMap)21 Before (org.junit.Before)20 CertificateGetOptions (org.nhindirect.config.service.impl.CertificateGetOptions)20 Sequence (org.jmock.Sequence)19 Cache (org.apache.geode.cache.Cache)18 Region (org.apache.geode.cache.Region)18 DistributedMember (org.apache.geode.distributed.DistributedMember)18 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)17