Search in sources :

Example 1 with JobCatalogListenersContainer

use of org.apache.gobblin.runtime.api.JobCatalogListenersContainer in project incubator-gobblin by apache.

the class TestJobLifecycleListenersList method testHappyPath.

@Test
public void testHappyPath() {
    Logger log = LoggerFactory.getLogger("testHappyPath");
    JobCatalogListenersContainer jobCatalog = mock(JobCatalogListenersContainer.class);
    JobSpecSchedulerListenersContainer jobScheduler = mock(JobSpecSchedulerListenersContainer.class);
    JobExecutionDriver mockDriver = mock(JobExecutionDriver.class);
    JobExecutionState mockState = mock(JobExecutionState.class);
    JobLifecycleListener listener1 = mock(JobLifecycleListener.class);
    JobLifecycleListener listener2 = mock(JobLifecycleListener.class);
    JobLifecycleListenersList disp = new JobLifecycleListenersList(jobCatalog, jobScheduler, log);
    disp.registerJobLifecycleListener(listener1);
    disp.onJobLaunch(mockDriver);
    disp.registerWeakJobLifecycleListener(listener2);
    disp.onMetadataChange(mockState, "key", "oldValue", "newValue");
    verify(jobCatalog).addListener(eq(listener1));
    verify(jobScheduler).registerJobSpecSchedulerListener(eq(listener1));
    verify(listener1).onJobLaunch(eq(mockDriver));
    verify(listener2, never()).onJobLaunch(eq(mockDriver));
    verify(jobCatalog).registerWeakJobCatalogListener(eq(listener2));
    verify(jobScheduler).registerWeakJobSpecSchedulerListener(eq(listener2));
    verify(listener1).onMetadataChange(eq(mockState), eq("key"), eq("oldValue"), eq("newValue"));
    verify(listener2).onMetadataChange(eq(mockState), eq("key"), eq("oldValue"), eq("newValue"));
}
Also used : JobCatalogListenersContainer(org.apache.gobblin.runtime.api.JobCatalogListenersContainer) JobExecutionState(org.apache.gobblin.runtime.api.JobExecutionState) JobLifecycleListener(org.apache.gobblin.runtime.api.JobLifecycleListener) JobExecutionDriver(org.apache.gobblin.runtime.api.JobExecutionDriver) Logger(org.slf4j.Logger) JobSpecSchedulerListenersContainer(org.apache.gobblin.runtime.api.JobSpecSchedulerListenersContainer) Test(org.testng.annotations.Test)

Aggregations

JobCatalogListenersContainer (org.apache.gobblin.runtime.api.JobCatalogListenersContainer)1 JobExecutionDriver (org.apache.gobblin.runtime.api.JobExecutionDriver)1 JobExecutionState (org.apache.gobblin.runtime.api.JobExecutionState)1 JobLifecycleListener (org.apache.gobblin.runtime.api.JobLifecycleListener)1 JobSpecSchedulerListenersContainer (org.apache.gobblin.runtime.api.JobSpecSchedulerListenersContainer)1 Logger (org.slf4j.Logger)1 Test (org.testng.annotations.Test)1