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);
}
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);
}
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));
}
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);
}
Aggregations