Search in sources :

Example 1 with PushDownType

use of org.pentaho.di.trans.dataservice.optimization.PushDownType in project pdi-dataservice-server-plugin by pentaho.

the class DataServiceModelTest method testGetDataService.

@Test
public void testGetDataService() throws Exception {
    model.setServiceName("service");
    model.setServiceStep("step");
    PushDownOptimizationMeta optimizationMeta = mock(PushDownOptimizationMeta.class);
    model.setPushDownOptimizations(Lists.newArrayList(optimizationMeta));
    PushDownType pushDownType = mock(PushDownType.class);
    when(optimizationMeta.getType()).thenReturn(pushDownType);
    DataServiceMeta dataService = model.getDataService();
    assertThat(dataService, allOf(hasProperty("name", equalTo("service")), hasProperty("stepname", equalTo("step")), hasProperty("pushDownOptimizationMeta", contains(optimizationMeta))));
    verify(pushDownType).init(transMeta, dataService, optimizationMeta);
}
Also used : DataServiceMeta(org.pentaho.di.trans.dataservice.DataServiceMeta) PushDownOptimizationMeta(org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationMeta) PushDownType(org.pentaho.di.trans.dataservice.optimization.PushDownType) Test(org.junit.Test)

Example 2 with PushDownType

use of org.pentaho.di.trans.dataservice.optimization.PushDownType in project pdi-dataservice-server-plugin by pentaho.

the class DataServiceModelTest method testPushDownOptimizations.

@Test
public void testPushDownOptimizations() throws Exception {
    List<PushDownOptimizationMeta> emptyList = Collections.emptyList();
    List<PushDownOptimizationMeta> optimizations = Lists.newArrayList(mock(PushDownOptimizationMeta.class));
    model.setPushDownOptimizations(optimizations);
    verify(propertyChangeSupport).firePropertyChange("pushDownOptimizations", emptyList, optimizations);
    ImmutableList<PushDownOptimizationMeta> init = ImmutableList.copyOf(optimizations);
    PushDownOptimizationMeta optimizationMeta = mock(PushDownOptimizationMeta.class);
    optimizations.add(optimizationMeta);
    assertTrue(model.add(optimizationMeta));
    verify(propertyChangeSupport).firePropertyChange("pushDownOptimizations", init, optimizations);
    PushDownType pushDownType = mock(PushDownType.class);
    when(optimizationMeta.getType()).thenReturn(pushDownType);
    assertThat(model.getPushDownOptimizations(pushDownType.getClass()), contains(optimizationMeta));
    assertThat(model.getPushDownOptimizations(), equalTo(optimizations));
    assertTrue(model.remove(optimizationMeta));
    verify(propertyChangeSupport).firePropertyChange("pushDownOptimizations", optimizations, init);
    assertFalse(model.remove(optimizationMeta));
    verifyNoMoreInteractions(propertyChangeSupport);
    assertTrue(model.removeAll(optimizations));
    verify(propertyChangeSupport).firePropertyChange("pushDownOptimizations", init, emptyList);
    assertFalse(model.removeAll(optimizations));
    verifyNoMoreInteractions(propertyChangeSupport);
}
Also used : PushDownOptimizationMeta(org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationMeta) PushDownType(org.pentaho.di.trans.dataservice.optimization.PushDownType) Test(org.junit.Test)

Example 3 with PushDownType

use of org.pentaho.di.trans.dataservice.optimization.PushDownType in project pdi-dataservice-server-plugin by pentaho.

the class ServiceCacheControllerTest method testLocateServiceCacheMeta.

@Test
public void testLocateServiceCacheMeta() throws Exception {
    controller = new ServiceCacheController(factory);
    when(factory.getType()).thenReturn(ServiceCache.class);
    when(model.getPushDownOptimizations(ServiceCache.class)).thenReturn(ImmutableList.<PushDownOptimizationMeta>of());
    when(factory.createPushDown()).thenReturn(serviceCache = mock(ServiceCache.class));
    meta = controller.locateServiceCacheMeta(model);
    assertThat(meta.isEnabled(), is(true));
    assertThat(meta.getType(), is((PushDownType) serviceCache));
    PushDownOptimizationMeta meta2 = mock(PushDownOptimizationMeta.class);
    when(model.getPushDownOptimizations(ServiceCache.class)).thenReturn(ImmutableList.of(meta, meta2));
    assertThat(controller.locateServiceCacheMeta(model), is(meta));
    verify(model).add(meta);
    verify(model).removeAll(ImmutableList.of(meta2));
}
Also used : PushDownOptimizationMeta(org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationMeta) PushDownType(org.pentaho.di.trans.dataservice.optimization.PushDownType) Test(org.junit.Test)

Example 4 with PushDownType

use of org.pentaho.di.trans.dataservice.optimization.PushDownType in project pdi-dataservice-server-plugin by pentaho.

the class DataServiceMetaStoreUtilTest method setUp.

@Before
public void setUp() throws Exception {
    when(repository.getRepositoryMeta().getRepositoryCapabilities().supportsReferences()).thenReturn(true);
    when(repository.loadTransformation(any(ObjectId.class), isNull(String.class))).then(new Answer<TransMeta>() {

        @Override
        public TransMeta answer(InvocationOnMock invocation) throws Throwable {
            if (invocation.getArguments()[0].equals(transMeta.getObjectId())) {
                return transMeta;
            } else {
                throw notFoundException;
            }
        }
    });
    metaStore.setName(DataServiceMetaStoreUtilTest.class.getName());
    when(repository.getMetaStore()).thenReturn(metaStore);
    PushDownFactory optimizationFactory = mock(PushDownFactory.class);
    when((Class) optimizationFactory.getType()).thenReturn(TestOptimization.class);
    when(optimizationFactory.createPushDown()).then(new Answer<PushDownType>() {

        @Override
        public PushDownType answer(InvocationOnMock invocation) throws Throwable {
            return new TestOptimization();
        }
    });
    pushDownFactories.add(optimizationFactory);
    metaStoreUtil = DataServiceMetaStoreUtil.create(context);
}
Also used : ObjectId(org.pentaho.di.repository.ObjectId) TransMeta(org.pentaho.di.trans.TransMeta) PushDownType(org.pentaho.di.trans.dataservice.optimization.PushDownType) PushDownFactory(org.pentaho.di.trans.dataservice.optimization.PushDownFactory) InvocationOnMock(org.mockito.invocation.InvocationOnMock) Before(org.junit.Before)

Aggregations

PushDownType (org.pentaho.di.trans.dataservice.optimization.PushDownType)4 Test (org.junit.Test)3 PushDownOptimizationMeta (org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationMeta)3 Before (org.junit.Before)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1 ObjectId (org.pentaho.di.repository.ObjectId)1 TransMeta (org.pentaho.di.trans.TransMeta)1 DataServiceMeta (org.pentaho.di.trans.dataservice.DataServiceMeta)1 PushDownFactory (org.pentaho.di.trans.dataservice.optimization.PushDownFactory)1