Search in sources :

Example 1 with XulTabbox

use of org.pentaho.ui.xul.containers.XulTabbox in project pdi-dataservice-server-plugin by pentaho.

the class DataServiceDialogTest method testInitOptimizations.

@Test
public void testInitOptimizations() throws Exception {
    PushDownFactory pushDownFactory;
    ArrayList<PushDownFactory> factories = Lists.newArrayList();
    XulTabbox tabBox = mock(XulTabbox.class, RETURNS_DEEP_STUBS);
    when(controller.getElementById("optimizationTabs")).thenReturn(tabBox);
    when(tabBox.getTabs().getTabCount()).thenReturn(2);
    // Create first overlay, low priority
    pushDownFactory = mock(PushDownFactory.class);
    DataServiceDialog.OptimizationOverlay overlay1 = mock(DataServiceDialog.OptimizationOverlay.class);
    when(pushDownFactory.createOverlay()).thenReturn(overlay1);
    when(overlay1.getPriority()).thenReturn(100.0);
    factories.add(pushDownFactory);
    // Create another overlay, higher priority
    pushDownFactory = mock(PushDownFactory.class);
    DataServiceDialog.OptimizationOverlay overlay0 = mock(DataServiceDialog.OptimizationOverlay.class);
    when(pushDownFactory.createOverlay()).thenReturn(overlay0);
    when(overlay0.getPriority()).thenReturn(0.0);
    factories.add(pushDownFactory);
    // Create push down factory without overlay
    pushDownFactory = mock(PushDownFactory.class);
    when(pushDownFactory.createOverlay()).thenReturn(null);
    factories.add(pushDownFactory);
    dialog.initOptimizations(factories);
    InOrder inOrder = inOrder(overlay0, overlay1);
    inOrder.verify(overlay0).apply(dialog);
    inOrder.verify(overlay1).apply(dialog);
    inOrder.verifyNoMoreInteractions();
    verify(tabBox).setSelectedIndex(0);
    reset(tabBox);
    when(tabBox.getTabs().getTabCount()).thenReturn(0);
    dialog.initOptimizations(factories);
    verify(tabBox, times(0)).setSelectedIndex(0);
}
Also used : InOrder(org.mockito.InOrder) XulTabbox(org.pentaho.ui.xul.containers.XulTabbox) PushDownFactory(org.pentaho.di.trans.dataservice.optimization.PushDownFactory) Test(org.junit.Test)

Example 2 with XulTabbox

use of org.pentaho.ui.xul.containers.XulTabbox in project pdi-dataservice-server-plugin by pentaho.

the class DataServiceDialog method initStreaming.

protected DataServiceDialog initStreaming(StreamingOverlay streamingOverlay) throws KettleException {
    streamingOverlay.apply(this);
    XulTabbox optimizationTabs = controller.getElementById("optimizationTabs");
    if (optimizationTabs.getTabs().getTabCount() > 0) {
        optimizationTabs.setSelectedIndex(0);
    }
    return this;
}
Also used : XulTabbox(org.pentaho.ui.xul.containers.XulTabbox)

Example 3 with XulTabbox

use of org.pentaho.ui.xul.containers.XulTabbox in project pdi-dataservice-server-plugin by pentaho.

the class DataServiceDialog method initOptimizations.

protected DataServiceDialog initOptimizations(List<PushDownFactory> pushDownFactories) throws KettleException {
    ImmutableList<OptimizationOverlay> overlays = FluentIterable.from(pushDownFactories).transform(new Function<PushDownFactory, OptimizationOverlay>() {

        @Override
        public OptimizationOverlay apply(PushDownFactory input) {
            return input.createOverlay();
        }
    }).filter(Predicates.notNull()).toSortedList(Ordering.natural().onResultOf(new Function<OptimizationOverlay, Comparable>() {

        @Override
        public Comparable apply(OptimizationOverlay input) {
            return input.getPriority();
        }
    }));
    for (OptimizationOverlay overlay : overlays) {
        overlay.apply(this);
    }
    XulTabbox optimizationTabs = controller.getElementById("optimizationTabs");
    if (optimizationTabs.getTabs().getTabCount() > 0) {
        optimizationTabs.setSelectedIndex(0);
    }
    return this;
}
Also used : Function(com.google.common.base.Function) XulTabbox(org.pentaho.ui.xul.containers.XulTabbox) PushDownFactory(org.pentaho.di.trans.dataservice.optimization.PushDownFactory)

Example 4 with XulTabbox

use of org.pentaho.ui.xul.containers.XulTabbox in project pdi-dataservice-server-plugin by pentaho.

the class DataServiceDialogTest method testInitStreaming.

@Test
public void testInitStreaming() throws Exception {
    XulTabbox tabBox = mock(XulTabbox.class, RETURNS_DEEP_STUBS);
    when(controller.getElementById("optimizationTabs")).thenReturn(tabBox);
    when(tabBox.getTabs().getTabCount()).thenReturn(2);
    // Create first overlay, low priority
    dialog.initStreaming(streamingOverlay);
    verify(streamingOverlay).apply(dialog);
    verify(tabBox).setSelectedIndex(0);
    reset(tabBox);
    when(tabBox.getTabs().getTabCount()).thenReturn(0);
    dialog.initStreaming(streamingOverlay);
    verify(tabBox, times(0)).setSelectedIndex(0);
}
Also used : XulTabbox(org.pentaho.ui.xul.containers.XulTabbox) Test(org.junit.Test)

Aggregations

XulTabbox (org.pentaho.ui.xul.containers.XulTabbox)4 Test (org.junit.Test)2 PushDownFactory (org.pentaho.di.trans.dataservice.optimization.PushDownFactory)2 Function (com.google.common.base.Function)1 InOrder (org.mockito.InOrder)1