use of org.pentaho.di.partition.PartitionSchema in project pentaho-kettle by pentaho.
the class PartitionSettingsTest method defaultSelectedSchemaIndexWhenSchemaNameIsNotDefined.
@Test
public void defaultSelectedSchemaIndexWhenSchemaNameIsNotDefined() throws Exception {
PartitionSchema schema = new PartitionSchema();
StepPartitioningMeta meta = mock(StepPartitioningMeta.class);
when(meta.getPartitionSchema()).thenReturn(schema);
when(stepMeta.getStepPartitioningMeta()).thenReturn(meta);
List<String> schemas = Arrays.asList("test");
when(partitionSchemasProvider.getPartitionSchemasNames(any(TransMeta.class))).thenReturn(schemas);
assertEquals(0, settings.getDefaultSelectedSchemaIndex());
}
use of org.pentaho.di.partition.PartitionSchema in project pentaho-kettle by pentaho.
the class SharedObjectSyncUtilTest method synchronizePartitionSchemasDeleteFromRepository.
@Test
public void synchronizePartitionSchemasDeleteFromRepository() throws Exception {
try {
spoon.rep = repository;
when(spoon.getRepository()).thenReturn(repository);
final String objectId = "object-id";
final String partitionName = "partsch";
TransMeta trans1 = createTransMeta();
trans1.setRepository(repository);
trans1.setSharedObjects(createSharedObjects(SHARED_OBJECTS_FILE));
PartitionSchema part1 = createPartitionSchema(partitionName, false);
part1.setObjectId(new StringObjectId(objectId));
trans1.addOrReplacePartitionSchema(part1);
spoon.delegates.trans.addTransformation(trans1);
TransMeta trans2 = createTransMeta();
trans2.setRepository(repository);
trans2.setSharedObjects(createSharedObjects(SHARED_OBJECTS_FILE));
PartitionSchema part2 = createPartitionSchema(partitionName, false);
part2.setObjectId(new StringObjectId(objectId));
trans2.addOrReplacePartitionSchema(part2);
spoon.delegates.trans.addTransformation(trans2);
assertFalse(trans1.getPartitionSchemas().isEmpty());
spoon.delegates.partitions.delPartitionSchema(trans2, part2);
verify(repository).deletePartitionSchema(part2.getObjectId());
assertTrue(trans1.getPartitionSchemas().isEmpty());
} finally {
spoon.rep = null;
when(spoon.getRepository()).thenReturn(null);
}
}
use of org.pentaho.di.partition.PartitionSchema in project pentaho-kettle by pentaho.
the class SharedObjectSyncUtilTest method createPartitionSchema.
private static PartitionSchema createPartitionSchema(String name, boolean shared) {
PartitionSchema partitionSchema = new PartitionSchema();
partitionSchema.setName(name);
partitionSchema.setNumberOfPartitionsPerSlave(BEFORE_SYNC_VALUE);
partitionSchema.setShared(shared);
return partitionSchema;
}
use of org.pentaho.di.partition.PartitionSchema in project pentaho-kettle by pentaho.
the class SharedObjectSyncUtilTest method synchronizePartitionSchemas_use_case_sensitive_name.
@Test
public void synchronizePartitionSchemas_use_case_sensitive_name() throws Exception {
TransMeta transformarion1 = createTransMeta();
PartitionSchema partitionSchema1 = createPartitionSchema("PartitionSchema", true);
transformarion1.setPartitionSchemas(Collections.singletonList(partitionSchema1));
spoonDelegates.trans.addTransformation(transformarion1);
TransMeta transformarion2 = createTransMeta();
PartitionSchema partitionSchema2 = createPartitionSchema("Partitionschema", true);
transformarion2.setPartitionSchemas(Collections.singletonList(partitionSchema2));
spoonDelegates.trans.addTransformation(transformarion2);
partitionSchema2.setNumberOfPartitionsPerSlave(AFTER_SYNC_VALUE);
sharedUtil.synchronizePartitionSchemas(partitionSchema2);
assertThat(partitionSchema1.getNumberOfPartitionsPerSlave(), equalTo(BEFORE_SYNC_VALUE));
}
Aggregations