use of org.apache.samza.coordinator.ClusterMembership in project samza by apache.
the class TestLocalApplicationRunner method prepareTestForRunId.
private void prepareTestForRunId() throws Exception {
coordinationUtils = mock(CoordinationUtils.class);
DistributedLock lock = mock(DistributedLock.class);
when(lock.lock(anyObject())).thenReturn(true);
when(coordinationUtils.getLock(anyString())).thenReturn(lock);
clusterMembership = mock(ClusterMembership.class);
when(clusterMembership.getNumberOfProcessors()).thenReturn(1);
when(coordinationUtils.getClusterMembership()).thenReturn(clusterMembership);
metadataStore = mock(ZkMetadataStore.class);
when(metadataStore.get(any())).thenReturn(null);
PowerMockito.whenNew(ZkMetadataStore.class).withAnyArguments().thenReturn(metadataStore);
ApplicationDescriptorImpl<? extends ApplicationDescriptor> appDesc = ApplicationDescriptorUtil.getAppDescriptor(mockApp, config);
runner = spy(new LocalApplicationRunner(mockApp, config, coordinationUtils));
localPlanner = spy(new LocalJobPlanner(appDesc, coordinationUtils, "FAKE_UID", "FAKE_RUNID"));
doReturn(localPlanner).when(runner).getPlanner();
StreamProcessor sp = mock(StreamProcessor.class);
CoordinatorStreamStore coordinatorStreamStore = mock(CoordinatorStreamStore.class);
doReturn(sp).when(runner).createStreamProcessor(anyObject(), anyObject(), anyObject(), anyObject(), any(CoordinatorStreamStore.class));
doReturn(coordinatorStreamStore).when(runner).createCoordinatorStreamStore(any(Config.class));
}
Aggregations