use of org.pentaho.di.job.JobMeta in project pentaho-kettle by pentaho.
the class SharedObjectSyncUtilTest method synchronizeConnectionsRename.
@Test
public void synchronizeConnectionsRename() throws Exception {
final String databaseName = BEFORE_SYNC_VALUE;
DatabaseMeta sharedDB0 = createDatabaseMeta(databaseName, true);
saveSharedObjects(SHARED_OBJECTS_FILE, sharedDB0);
JobMeta job1 = createJobMeta();
spoonDelegates.jobs.addJob(job1);
JobMeta job2 = createJobMeta();
spoonDelegates.jobs.addJob(job2);
DatabaseMeta sharedDB2 = job2.getDatabase(0);
assertEquals(databaseName, sharedDB2.getName());
DatabaseMeta sharedDB1 = job1.getDatabase(0);
assertEquals(databaseName, sharedDB1.getName());
assertTrue(sharedDB1 != sharedDB2);
assertThat(sharedDB1.getName(), equalTo(BEFORE_SYNC_VALUE));
sharedDB2.setName(AFTER_SYNC_VALUE);
sharedUtil.synchronizeConnections(sharedDB2, BEFORE_SYNC_VALUE);
assertThat(sharedDB1.getName(), equalTo(AFTER_SYNC_VALUE));
}
use of org.pentaho.di.job.JobMeta in project pentaho-kettle by pentaho.
the class SharedObjectSyncUtilTest method synchronizeSlaveServers_sync_shared_only.
@Test
public void synchronizeSlaveServers_sync_shared_only() throws Exception {
final String slaveServerName = "SlaveServer";
JobMeta job1 = createJobMeta();
SlaveServer slaveServer1 = createSlaveServer(slaveServerName, true);
job1.setSlaveServers(Collections.singletonList(slaveServer1));
spoonDelegates.jobs.addJob(job1);
JobMeta job2 = createJobMeta();
SlaveServer unsharedSlaveServer2 = createSlaveServer(slaveServerName, false);
job2.setSlaveServers(Collections.singletonList(unsharedSlaveServer2));
spoonDelegates.jobs.addJob(job2);
JobMeta job3 = createJobMeta();
SlaveServer slaveServer3 = createSlaveServer(slaveServerName, true);
job3.setSlaveServers(Collections.singletonList(slaveServer3));
spoonDelegates.jobs.addJob(job3);
slaveServer3.setHostname(AFTER_SYNC_VALUE);
sharedUtil.synchronizeSlaveServers(slaveServer3);
assertThat(slaveServer1.getHostname(), equalTo(AFTER_SYNC_VALUE));
assertThat(unsharedSlaveServer2.getHostname(), equalTo(BEFORE_SYNC_VALUE));
}
use of org.pentaho.di.job.JobMeta in project pentaho-kettle by pentaho.
the class SharedObjectSyncUtilTest method synchronizeConnectionsOpenNew.
@Test
public void synchronizeConnectionsOpenNew() throws Exception {
final String databaseName = "SharedDB";
DatabaseMeta sharedDB0 = createDatabaseMeta(databaseName, true);
saveSharedObjects(SHARED_OBJECTS_FILE, sharedDB0);
JobMeta job1 = createJobMeta();
spoonDelegates.jobs.addJob(job1);
DatabaseMeta sharedDB1 = job1.getDatabase(0);
JobMeta job2 = createJobMeta();
spoonDelegates.jobs.addJob(job2);
DatabaseMeta sharedDB2 = job2.getDatabase(0);
assertThat(sharedDB1.getHostname(), equalTo(BEFORE_SYNC_VALUE));
sharedDB2.setHostname(AFTER_SYNC_VALUE);
sharedUtil.synchronizeConnections(sharedDB2, sharedDB2.getName());
assertThat(sharedDB1.getHostname(), equalTo(AFTER_SYNC_VALUE));
JobMeta job3 = createJobMeta();
spoonDelegates.jobs.addJob(job3);
DatabaseMeta sharedDB3 = job3.getDatabase(0);
assertThat(sharedDB3.getHostname(), equalTo(AFTER_SYNC_VALUE));
}
use of org.pentaho.di.job.JobMeta in project pentaho-kettle by pentaho.
the class SharedObjectSyncUtilTest method synchronizeConnections.
@Test
public void synchronizeConnections() throws Exception {
final String databaseName = "SharedDB";
DatabaseMeta sharedDB0 = createDatabaseMeta(databaseName, true);
saveSharedObjects(SHARED_OBJECTS_FILE, sharedDB0);
JobMeta job1 = createJobMeta();
spoonDelegates.jobs.addJob(job1);
JobMeta job2 = createJobMeta();
spoonDelegates.jobs.addJob(job2);
DatabaseMeta sharedDB2 = job2.getDatabase(0);
assertEquals(databaseName, sharedDB2.getName());
DatabaseMeta sharedDB1 = job1.getDatabase(0);
assertEquals(databaseName, sharedDB1.getName());
assertTrue(sharedDB1 != sharedDB2);
assertThat(sharedDB1.getHostname(), equalTo(BEFORE_SYNC_VALUE));
sharedDB2.setHostname(AFTER_SYNC_VALUE);
sharedUtil.synchronizeConnections(sharedDB2, sharedDB2.getName());
assertThat(sharedDB1.getHostname(), equalTo(AFTER_SYNC_VALUE));
}
use of org.pentaho.di.job.JobMeta in project pentaho-kettle by pentaho.
the class SharedObjectSyncUtilTest method synchronizeSlaveServerRenameBackAndForth.
@Test
public void synchronizeSlaveServerRenameBackAndForth() throws Exception {
final String serverName = "SharedServer";
SlaveServer server0 = createSlaveServer(serverName, true);
saveSharedObjects(SHARED_OBJECTS_FILE, server0);
JobMeta j1 = createJobMeta();
spoonDelegates.jobs.addJob(j1);
JobMeta j2 = createJobMeta();
spoonDelegates.jobs.addJob(j2);
final String name2 = "NAME 2";
when(spoon.getActiveMeta()).thenReturn(j1);
SlaveServer server1 = j1.getSlaveServers().get(0);
server1.setName(name2);
sharedUtil.synchronizeSlaveServers(server1, serverName);
SlaveServer server2 = j2.getSlaveServers().get(0);
assertTrue(server2.getName().equals(name2));
when(spoon.getActiveMeta()).thenReturn(j2);
server2.setName("name3");
sharedUtil.synchronizeSlaveServers(server2, name2);
assertTrue(server1.getName().equals(server2.getName()));
}
Aggregations