Search in sources :

Example 1 with Mvp4gEventPasser

use of com.mvp4g.client.Mvp4gEventPasser in project mvp4g by mvp4g.

the class PlaceServiceTest method testConverterForChildModuleNoParameter.

@Test
public void testConverterForChildModuleNoParameter() {
    String historyName = "child/historyName";
    EventBusWithLookUpStub childBus = new EventBusWithLookUpStub();
    Mvp4gModuleStub childModule = new Mvp4gModuleStub(childBus);
    ValueChangeEvent<String> event = new ValueChangeEventStub<String>(historyName);
    placeServiceDefault.addConverter(historyName, buildHistoryConverter(false));
    placeServiceDefault.onValueChange(event);
    assertEquals(historyName, module.getEventType());
    Mvp4gEventPasser passer = module.getPasser();
    passer.setEventObject(false);
    passer.pass(childModule);
    assertTrue(module.isHistoryNotFound());
    passer.setEventObject(true);
    passer.pass(childModule);
    childBus.assertEvent("historyName", new Object[] { null });
}
Also used : ValueChangeEventStub(com.mvp4g.client.test_tools.ValueChangeEventStub) EventBusWithLookUpStub(com.mvp4g.client.test_tools.EventBusWithLookUpStub) Mvp4gEventPasser(com.mvp4g.client.Mvp4gEventPasser) Mvp4gModuleStub(com.mvp4g.client.test_tools.Mvp4gModuleStub) Test(org.junit.Test)

Example 2 with Mvp4gEventPasser

use of com.mvp4g.client.Mvp4gEventPasser in project mvp4g by mvp4g.

the class PlaceServiceTest method testConverterForChildModuleNoConverter.

@Test
public void testConverterForChildModuleNoConverter() {
    String historyName = "child/historyName";
    EventBusWithLookUpStub childBus = new EventBusWithLookUpStub();
    Mvp4gModuleStub childModule = new Mvp4gModuleStub(childBus);
    ValueChangeEvent<String> event = new ValueChangeEventStub<String>(historyName);
    placeServiceDefault.onValueChange(event);
    assertEquals(historyName, module.getEventType());
    Mvp4gEventPasser passer = module.getPasser();
    passer.setEventObject(true);
    passer.pass(childModule);
    assertTrue(module.isHistoryNotFound());
}
Also used : ValueChangeEventStub(com.mvp4g.client.test_tools.ValueChangeEventStub) EventBusWithLookUpStub(com.mvp4g.client.test_tools.EventBusWithLookUpStub) Mvp4gEventPasser(com.mvp4g.client.Mvp4gEventPasser) Mvp4gModuleStub(com.mvp4g.client.test_tools.Mvp4gModuleStub) Test(org.junit.Test)

Example 3 with Mvp4gEventPasser

use of com.mvp4g.client.Mvp4gEventPasser in project mvp4g by mvp4g.

the class PlaceService method forwardToChildModuleIfNeeded.

/**
 * Check if this event is a child's module event. If it's the case, forward the token to the
 * child module and return true.
 *
 * @param eventName
 *   name of the event that was stored in the token
 * @param param
 *   parameters stored in the token
 *
 * @return true if this child module's event.
 */
protected boolean forwardToChildModuleIfNeeded(final String eventName, final String param) {
    boolean forAChild = eventName.contains(MODULE_SEPARATOR);
    if (forAChild) {
        Mvp4gEventPasser passer = new Mvp4gEventPasser(true) {

            @Override
            public void pass(Mvp4gModule module) {
                if ((Boolean) eventObjects[0]) {
                    dispatchEvent(eventName, param, module);
                } else {
                    sendNotFoundEvent(module);
                }
            }
        };
        module.dispatchHistoryEvent(eventName, passer);
    }
    return forAChild;
}
Also used : Mvp4gModule(com.mvp4g.client.Mvp4gModule) Mvp4gEventPasser(com.mvp4g.client.Mvp4gEventPasser)

Example 4 with Mvp4gEventPasser

use of com.mvp4g.client.Mvp4gEventPasser in project mvp4g by mvp4g.

the class PlaceServiceTest method testConverterForChildModuleWithParameter.

@Test
public void testConverterForChildModuleWithParameter() {
    String historyName = "child/eventType";
    String form = "form";
    EventBusWithLookUpStub childBus = new EventBusWithLookUpStub();
    Mvp4gModuleStub childModule = new Mvp4gModuleStub(childBus);
    placeServiceDefault.addConverter(historyName, buildHistoryConverter(false));
    ValueChangeEvent<String> event = new ValueChangeEventStub<String>(historyName + "?" + form);
    placeServiceDefault.onValueChange(event);
    assertEquals(historyName, module.getEventType());
    Mvp4gEventPasser passer = module.getPasser();
    passer.setEventObject(true);
    passer.pass(childModule);
    childBus.assertEvent("eventType", new Object[] { form });
}
Also used : ValueChangeEventStub(com.mvp4g.client.test_tools.ValueChangeEventStub) EventBusWithLookUpStub(com.mvp4g.client.test_tools.EventBusWithLookUpStub) Mvp4gEventPasser(com.mvp4g.client.Mvp4gEventPasser) Mvp4gModuleStub(com.mvp4g.client.test_tools.Mvp4gModuleStub) Test(org.junit.Test)

Aggregations

Mvp4gEventPasser (com.mvp4g.client.Mvp4gEventPasser)4 EventBusWithLookUpStub (com.mvp4g.client.test_tools.EventBusWithLookUpStub)3 Mvp4gModuleStub (com.mvp4g.client.test_tools.Mvp4gModuleStub)3 ValueChangeEventStub (com.mvp4g.client.test_tools.ValueChangeEventStub)3 Test (org.junit.Test)3 Mvp4gModule (com.mvp4g.client.Mvp4gModule)1