Search in sources :

Example 1 with MutableJobCatalog

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

the class MockedKafkaJobMonitor method createMockCatalog.

private static MutableJobCatalog createMockCatalog(final Map<URI, JobSpec> jobSpecs) {
    MutableJobCatalog jobCatalog = Mockito.mock(MutableJobCatalog.class);
    Mockito.doAnswer(new Answer<Void>() {

        @Override
        public Void answer(InvocationOnMock invocation) throws Throwable {
            JobSpec jobSpec = (JobSpec) invocation.getArguments()[0];
            jobSpecs.put(jobSpec.getUri(), jobSpec);
            return null;
        }
    }).when(jobCatalog).put(Mockito.any(JobSpec.class));
    Mockito.doAnswer(new Answer<Void>() {

        @Override
        public Void answer(InvocationOnMock invocation) throws Throwable {
            URI uri = (URI) invocation.getArguments()[0];
            jobSpecs.remove(uri);
            return null;
        }
    }).when(jobCatalog).remove(Mockito.any(URI.class));
    return jobCatalog;
}
Also used : InvocationOnMock(org.mockito.invocation.InvocationOnMock) JobSpec(org.apache.gobblin.runtime.api.JobSpec) MutableJobCatalog(org.apache.gobblin.runtime.api.MutableJobCatalog) URI(java.net.URI)

Aggregations

URI (java.net.URI)1 JobSpec (org.apache.gobblin.runtime.api.JobSpec)1 MutableJobCatalog (org.apache.gobblin.runtime.api.MutableJobCatalog)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1