Search in sources :

Example 1 with Mockery

use of org.jmock.Mockery 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 Mockery

use of org.jmock.Mockery in project geode by apache.

the class SerializableObjectHttpMessageConverterJUnitTest method setUp.

@Before
public void setUp() {
    mockContext = new Mockery();
    mockContext.setImposteriser(ClassImposteriser.INSTANCE);
    mockContext.setThreadingPolicy(new Synchroniser());
}
Also used : Synchroniser(org.jmock.lib.concurrent.Synchroniser) Mockery(org.jmock.Mockery) Before(org.junit.Before)

Example 3 with Mockery

use of org.jmock.Mockery in project geode by apache.

the class InitializerJUnitTest method setUp.

@Before
public void setUp() {
    mockContext = new Mockery();
    mockContext.setImposteriser(ClassImposteriser.INSTANCE);
    mockContext.setThreadingPolicy(new Synchroniser());
}
Also used : Synchroniser(org.jmock.lib.concurrent.Synchroniser) Mockery(org.jmock.Mockery) Before(org.junit.Before)

Example 4 with Mockery

use of org.jmock.Mockery in project sling by apache.

the class MockFactory method mockSlingSettingsService.

public static SlingSettingsService mockSlingSettingsService(final String slingId) {
    Mockery context = new JUnit4Mockery();
    final SlingSettingsService settingsService = context.mock(SlingSettingsService.class);
    context.checking(new Expectations() {

        {
            allowing(settingsService).getSlingId();
            will(returnValue(slingId));
            allowing(settingsService).getSlingHomePath();
            will(returnValue("/n/a"));
        }
    });
    return settingsService;
}
Also used : Expectations(org.jmock.Expectations) JUnit4Mockery(org.jmock.integration.junit4.JUnit4Mockery) JUnit4Mockery(org.jmock.integration.junit4.JUnit4Mockery) Mockery(org.jmock.Mockery) SlingSettingsService(org.apache.sling.settings.SlingSettingsService)

Example 5 with Mockery

use of org.jmock.Mockery in project sling by apache.

the class MockFactory method mockComponentContext.

public static ComponentContext mockComponentContext() {
    Mockery context = new JUnit4Mockery();
    final BundleContext bc = context.mock(BundleContext.class);
    context.checking(new Expectations() {

        {
            allowing(bc).registerService(with(any(String.class)), with(any(Object.class)), with(any(Dictionary.class)));
            will(VoidAction.INSTANCE);
            allowing(bc).getProperty(with(any(String.class)));
            will(new ReturnValueAction("foo"));
        }
    });
    final ComponentContext cc = context.mock(ComponentContext.class);
    context.checking(new Expectations() {

        {
            allowing(cc).getProperties();
            will(returnValue(new Properties()));
            allowing(cc).getBundleContext();
            will(returnValue(bc));
        }
    });
    return cc;
}
Also used : Expectations(org.jmock.Expectations) Dictionary(java.util.Dictionary) ReturnValueAction(org.jmock.lib.action.ReturnValueAction) JUnit4Mockery(org.jmock.integration.junit4.JUnit4Mockery) ComponentContext(org.osgi.service.component.ComponentContext) Properties(java.util.Properties) JUnit4Mockery(org.jmock.integration.junit4.JUnit4Mockery) Mockery(org.jmock.Mockery) BundleContext(org.osgi.framework.BundleContext)

Aggregations

Mockery (org.jmock.Mockery)149 Expectations (org.jmock.Expectations)118 Test (org.junit.Test)77 Before (org.junit.Before)29 ArrayList (java.util.ArrayList)25 Date (java.util.Date)21 JUnit4Mockery (org.jmock.integration.junit4.JUnit4Mockery)17 File (java.io.File)15 BeforeMethod (org.testng.annotations.BeforeMethod)15 Synchroniser (org.jmock.lib.concurrent.Synchroniser)14 List (java.util.List)11 ActorDTO (com.management.dto.ActorDTO)7 FanZoneDTO (com.management.dto.FanZoneDTO)6 PropsDTO (com.management.dto.PropsDTO)6 ActorPerformancesRepository (com.management.repositories.ActorPerformancesRepository)6 ActorRepository (com.management.repositories.ActorRepository)6 CinemaTheatreRepository (com.management.repositories.CinemaTheatreRepository)6 EventRepository (com.management.repositories.EventRepository)6 FriendsListRepository (com.management.repositories.FriendsListRepository)6 PerformanceRepository (com.management.repositories.PerformanceRepository)6