use of org.pentaho.di.repository.StringObjectId 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.repository.StringObjectId in project pentaho-kettle by pentaho.
the class SharedObjectSyncUtilTest method synchronizeSlaveServerRenameRepository.
@Test
public void synchronizeSlaveServerRenameRepository() throws Exception {
try {
spoon.rep = repository;
final String objectId = "object-id";
final String serverName = "SharedServer";
JobMeta job1 = createJobMeta();
job1.setRepository(repository);
job1.setSharedObjects(createSharedObjects(SHARED_OBJECTS_FILE));
SlaveServer server1 = createSlaveServer(serverName, false);
server1.setObjectId(new StringObjectId(objectId));
job1.addOrReplaceSlaveServer(server1);
spoonDelegates.jobs.addJob(job1);
JobMeta job2 = createJobMeta();
job2.setRepository(repository);
job2.setSharedObjects(createSharedObjects(SHARED_OBJECTS_FILE));
SlaveServer server2 = createSlaveServer(serverName, false);
server2.setObjectId(new StringObjectId(objectId));
spoonDelegates.jobs.addJob(job2);
server2.setName(AFTER_SYNC_VALUE);
sharedUtil.synchronizeSlaveServers(server2);
job2.addOrReplaceSlaveServer(server2);
assertEquals(AFTER_SYNC_VALUE, job1.getSlaveServers().get(0).getName());
} finally {
spoon.rep = null;
}
}
use of org.pentaho.di.repository.StringObjectId in project pentaho-kettle by pentaho.
the class SharedObjectSyncUtilTest method synchronizeSlaveServerDeleteFromRepository.
@Test
public void synchronizeSlaveServerDeleteFromRepository() throws Exception {
try {
spoon.rep = repository;
when(spoon.getRepository()).thenReturn(repository);
final String objectId = "object-id";
final String serverName = "SharedServer";
TransMeta trans = createTransMeta();
trans.setRepository(repository);
trans.setSharedObjects(createSharedObjects(SHARED_OBJECTS_FILE));
SlaveServer server1 = createSlaveServer(serverName, false);
server1.setObjectId(new StringObjectId(objectId));
trans.addOrReplaceSlaveServer(server1);
spoon.delegates.trans.addTransformation(trans);
JobMeta job = createJobMeta();
job.setRepository(repository);
job.setSharedObjects(createSharedObjects(SHARED_OBJECTS_FILE));
SlaveServer server3 = createSlaveServer(serverName, false);
server3.setObjectId(new StringObjectId(objectId));
job.addOrReplaceSlaveServer(server3);
spoon.delegates.jobs.addJob(job);
TransMeta trans2 = createTransMeta();
trans2.setRepository(repository);
trans2.setSharedObjects(createSharedObjects(SHARED_OBJECTS_FILE));
SlaveServer server2 = createSlaveServer(serverName, false);
server2.setObjectId(new StringObjectId(objectId));
trans2.addOrReplaceSlaveServer(server2);
spoon.delegates.trans.addTransformation(trans2);
assertFalse(trans.getSlaveServers().isEmpty());
assertFalse(job.getSlaveServers().isEmpty());
spoon.delegates.slaves.delSlaveServer(trans2, server2);
verify(repository).deleteSlave(server2.getObjectId());
assertTrue(trans.getSlaveServers().isEmpty());
assertTrue(job.getSlaveServers().isEmpty());
} finally {
spoon.rep = null;
when(spoon.getRepository()).thenReturn(null);
}
}
use of org.pentaho.di.repository.StringObjectId in project pentaho-kettle by pentaho.
the class StarDomainMetaStoreUtil method saveStarDomain.
public static void saveStarDomain(IMetaStore metaStore, StarDomain starDomain) throws MetaStoreException {
IMetaStoreElementType elementType = getStarDomainElementType(metaStore);
IMetaStoreElement element = null;
if (starDomain.getObjectId() != null) {
// verify the ID!
//
element = metaStore.getElement(namespace, elementType, starDomain.getObjectId().toString());
}
if (element == null) {
// Create a new element
//
element = metaStore.newElement();
populateElementWithStarDomain(metaStore, starDomain, element, elementType);
metaStore.createElement(namespace, elementType, element);
} else {
// Update an existing element
//
populateElementWithStarDomain(metaStore, starDomain, element, elementType);
metaStore.updateElement(namespace, elementType, starDomain.getObjectId().toString(), element);
}
starDomain.setObjectId(new StringObjectId(element.getId().toString()));
}
use of org.pentaho.di.repository.StringObjectId in project pentaho-kettle by pentaho.
the class MQTTConsumerMetaTest method testReadsFromRepository.
@Test
public void testReadsFromRepository() throws Exception {
StringObjectId stepId = new StringObjectId("stepId");
MQTTConsumerMeta testMeta = getTestMeta();
String xml = testMeta.getXML();
when(rep.getStepAttributeString(stepId, "step-xml")).thenReturn(xml);
meta.readRep(rep, metastore, stepId, emptyList());
metaMatchesTestMetaFields(meta);
}
Aggregations