Search in sources :

Example 1 with Splitters

use of com.mvp4g.rebind.test_tools.Splitters in project mvp4g by mvp4g.

the class Mvp4gConfigurationTest method testSplitterLoaders.

@Test
public void testSplitterLoaders() throws InvalidMvp4gConfigurationException {
    setEventBus();
    oracle.addClass(Loaders.Loader1.class);
    oracle.addClass(Loaders.Loader2.class);
    oracle.addClass(Splitters.SplitterWithLoader.class);
    oracle.addClass(Splitters.SplitterWithSameLoader1.class);
    oracle.addClass(Splitters.SplitterWithSameLoader2.class);
    PresenterElement presenter1 = newPresenter(SimplePresenter01.class, "presenter1");
    presenter1.setAsync(Splitters.SplitterWithLoader.class.getCanonicalName());
    presenters.add(presenter1);
    PresenterElement presenter2 = newPresenter(SimplePresenter02.class, "presenter2");
    presenter2.setAsync(Splitters.SplitterWithSameLoader1.class.getCanonicalName());
    presenters.add(presenter2);
    PresenterElement presenter3 = newPresenter(SimplePresenter03.class, "presenter3");
    presenter3.setAsync(Splitters.SplitterWithSameLoader2.class.getCanonicalName());
    presenters.add(presenter3);
    EventElement event = new EventElement();
    event.setHandlers(new String[] { "presenter1", "presenter2", "presenter3" });
    configuration.getEvents().add(event);
    configuration.validateSplitters();
    assertEquals(3, configuration.getSplitters().size());
    String loader1Name = "loader" + Loaders.Loader1.class.getCanonicalName().replace(".", "_");
    String loader2Name = "loader" + Loaders.Loader2.class.getCanonicalName().replace(".", "_");
    String splitter1Name = Splitters.SplitterWithLoader.class.getCanonicalName().replace(".", "_");
    String splitter2Name = Splitters.SplitterWithSameLoader1.class.getCanonicalName().replace(".", "_");
    String splitter3Name = Splitters.SplitterWithSameLoader2.class.getCanonicalName().replace(".", "_");
    Set<SplitterElement> splitters = configuration.getSplitters();
    Iterator<SplitterElement> itSplitter = splitters.iterator();
    SplitterElement splitter;
    String splitterName;
    while (itSplitter.hasNext()) {
        splitter = itSplitter.next();
        splitterName = splitter.getName();
        if (splitter1Name.equals(splitterName)) {
            assertEquals(splitter.getLoader(), loader1Name);
        } else if (splitter2Name.equals(splitterName)) {
            assertEquals(splitter.getLoader(), loader2Name);
        } else if (splitter3Name.equals(splitterName)) {
            assertEquals(splitter.getLoader(), loader2Name);
        } else {
            fail("Unknown splitter " + splitterName);
        }
    }
    Set<LoaderElement> loaders = configuration.getLoaders();
    assertEquals(2, loaders.size());
    Iterator<LoaderElement> it = loaders.iterator();
    LoaderElement next;
    String name;
    while (it.hasNext()) {
        next = it.next();
        name = next.getName();
        if (name.equals(loader1Name)) {
            assertEquals(Loaders.Loader1.class.getCanonicalName(), next.getClassName());
        } else if (name.equals(loader2Name)) {
            assertEquals(Loaders.Loader2.class.getCanonicalName(), next.getClassName());
        } else {
            fail("Unknown loader " + next.getName());
        }
    }
}
Also used : Loaders(com.mvp4g.rebind.test_tools.Loaders) SplitterElement(com.mvp4g.rebind.config.element.SplitterElement) LoaderElement(com.mvp4g.rebind.config.element.LoaderElement) EventElement(com.mvp4g.rebind.config.element.EventElement) Splitters(com.mvp4g.rebind.test_tools.Splitters) PresenterElement(com.mvp4g.rebind.config.element.PresenterElement) Test(org.junit.Test)

Aggregations

EventElement (com.mvp4g.rebind.config.element.EventElement)1 LoaderElement (com.mvp4g.rebind.config.element.LoaderElement)1 PresenterElement (com.mvp4g.rebind.config.element.PresenterElement)1 SplitterElement (com.mvp4g.rebind.config.element.SplitterElement)1 Loaders (com.mvp4g.rebind.test_tools.Loaders)1 Splitters (com.mvp4g.rebind.test_tools.Splitters)1 Test (org.junit.Test)1