Refine search
@Test public void testFileManagerInit() throws Exception { FilterFileManagerConfig config = new FilterFileManagerConfig(new String[]{"test", "test1"}, new String[]{"com.netflix.blah.SomeFilter"}, 1); FilterFileManager manager = new FilterFileManager(config, filterLoader); manager = spy(manager); doNothing().when(manager).manageFiles(); manager.init(); verify(manager, atLeast(1)).manageFiles(); verify(manager, times(1)).startPoller(); assertNotNull(manager.poller); } }
@Test public void shouldClearWorkingDirectoryBeforeCheckingOut() throws Exception { File workingDirectory = mock(File.class); when(workingDirectory.exists()).thenReturn(true); TfsSDKCommand spy = spy(tfsCommand); doNothing().when(spy).initializeWorkspace(workingDirectory); doNothing().when(spy).retrieveFiles(workingDirectory, null); spy.checkout(workingDirectory, null); verify(workingDirectory).exists(); }
private OutputCommitter setupOutputCommitter(boolean needsTaskCommit) throws IOException { OutputCommitter outputCommitter = Mockito.mock(OutputCommitter.class); when(outputCommitter.needsTaskCommit(nullable(TaskAttemptContext.class))).thenReturn(needsTaskCommit); doNothing().when(outputCommitter).commitTask(any(TaskAttemptContext.class)); return outputCommitter; }
@Test public void shouldCheckoutAllFilesWhenWorkingDirectoryIsDeleted() throws Exception { File workingDirectory = mock(File.class); when(workingDirectory.exists()).thenReturn(false); when(workingDirectory.getCanonicalPath()).thenReturn("canonical_path"); when(workingDirectory.listFiles()).thenReturn(null); TfsSDKCommand spy = spy(tfsCommand); doNothing().when(spy).initializeWorkspace(workingDirectory); GoTfsWorkspace workspace = mock(GoTfsWorkspace.class); when(client.queryWorkspace(TFS_WORKSPACE, USERNAME)).thenReturn(workspace); doNothing().when(workspace).get(any(GetRequest.class), eq(GetOptions.GET_ALL)); spy.checkout(workingDirectory, null); verify(workingDirectory).getCanonicalPath(); verify(workingDirectory).listFiles(); verify(workspace).get(any(GetRequest.class), eq(GetOptions.GET_ALL)); }
@Test public void should_GetLatestRevisions_WhenCheckingOutToLaterRevision() throws Exception { File workingDirectory = mock(File.class); when(workingDirectory.exists()).thenReturn(false); when(workingDirectory.getCanonicalPath()).thenReturn("canonical_path"); File[] checkedOutFiles = {mock(File.class)}; when(workingDirectory.listFiles()).thenReturn(checkedOutFiles); TfsSDKCommand spy = spy(tfsCommand); doNothing().when(spy).initializeWorkspace(workingDirectory); GoTfsWorkspace workspace = mock(GoTfsWorkspace.class); when(client.queryWorkspace(TFS_WORKSPACE, USERNAME)).thenReturn(workspace); doNothing().when(workspace).get(any(GetRequest.class), eq(GetOptions.NONE)); spy.checkout(workingDirectory, null); verify(workingDirectory).getCanonicalPath(); verify(workingDirectory).listFiles(); verify(workspace).get(any(GetRequest.class), eq(GetOptions.NONE)); }
@Test public void shouldMarkPluginAsInvalidWhenServiceReportsAnError() throws Exception { String pluginId = "plugin-id"; String message = "plugin is broken beyond repair"; List<String> reasons = Arrays.asList(message); doNothing().when(pluginRegistry).markPluginInvalid(pluginId, reasons); serviceDefault.reportErrorAndInvalidate(pluginId, reasons); verify(pluginRegistry).markPluginInvalid(pluginId, reasons); }
@Before public void setUpPluginRegistry() throws Exception { // Intercept access to registry registry = LifecycleSupport.registry = KettleLifecycleSupport.registry = mock( PluginRegistry.class ); registeredPlugins = new ArrayList<PluginInterface>(); when( registry.getPlugins( KettleLifecyclePluginType.class ) ).thenReturn( registeredPlugins ); typeListenerRegistration = ArgumentCaptor.forClass( PluginTypeListener.class ); doNothing().when( registry ).addPluginListener( eq( KettleLifecyclePluginType.class ), typeListenerRegistration.capture() ); }
@Before public void setUp() { initMocks(this); sharedPreferenceListenerCaptor = ArgumentCaptor.forClass(OnSharedPreferenceChangeListener.class); doNothing().when(sharedPreferences).registerOnSharedPreferenceChangeListener( sharedPreferenceListenerCaptor.capture()); updatable = mockUpdatable(); secondUpdatable = mockUpdatable(); }
@Test public void testCommit() throws Exception { Mockito.when(mockTuple.getSourceStreamId()).thenReturn("default"); executor.execute(mockTuple); Mockito.when(mockCheckpointTuple.getSourceStreamId()).thenReturn(CheckpointSpout.CHECKPOINT_STREAM_ID); Mockito.when(mockCheckpointTuple.getValueByField(CHECKPOINT_FIELD_ACTION)).thenReturn(COMMIT); Mockito.when(mockCheckpointTuple.getLongByField(CHECKPOINT_FIELD_TXID)).thenReturn(new Long(0)); Mockito.doNothing().when(mockOutputCollector).ack(mockCheckpointTuple); executor.execute(mockCheckpointTuple); Mockito.verify(mockBolt, Mockito.times(1)).preCommit(new Long(0)); Mockito.verify(mockState, Mockito.times(1)).commit(new Long(0)); }
@Test public void testRollback() throws Exception { Mockito.when(mockTuple.getSourceStreamId()).thenReturn("default"); executor.execute(mockTuple); Mockito.when(mockCheckpointTuple.getSourceStreamId()).thenReturn(CheckpointSpout.CHECKPOINT_STREAM_ID); Mockito.when(mockCheckpointTuple.getValueByField(CHECKPOINT_FIELD_ACTION)).thenReturn(ROLLBACK); Mockito.when(mockCheckpointTuple.getLongByField(CHECKPOINT_FIELD_TXID)).thenReturn(new Long(0)); Mockito.doNothing().when(mockOutputCollector).ack(mockCheckpointTuple); executor.execute(mockCheckpointTuple); Mockito.verify(mockState, Mockito.times(1)).rollback(); }
private LocalFsBlobStore initLocalFs() { LocalFsBlobStore store = new LocalFsBlobStore(); // Spy object that tries to mock the real object store LocalFsBlobStore spy = spy(store); Mockito.doNothing().when(spy).checkForBlobUpdate("test"); Mockito.doNothing().when(spy).checkForBlobUpdate("other"); Mockito.doNothing().when(spy).checkForBlobUpdate("test-empty-subject-WE"); Mockito.doNothing().when(spy).checkForBlobUpdate("test-empty-subject-DEF"); Mockito.doNothing().when(spy).checkForBlobUpdate("test-empty-acls"); Map<String, Object> conf = Utils.readStormConfig(); conf.put(Config.STORM_ZOOKEEPER_PORT, zk.getPort()); conf.put(Config.STORM_LOCAL_DIR, baseFile.getAbsolutePath()); conf.put(Config.STORM_PRINCIPAL_TO_LOCAL_PLUGIN,"org.apache.storm.security.auth.DefaultPrincipalToLocal"); NimbusInfo nimbusInfo = new NimbusInfo("localhost", 0, false); spy.prepare(conf, null, nimbusInfo, null); return spy; }