Search in sources :

Example 26 with InOrder

use of org.mockito.InOrder in project hadoop by apache.

the class TestFind method processArgumentsNoDescend.

// check expressions are called in the correct order
@Test
public void processArgumentsNoDescend() throws IOException {
    LinkedList<PathData> items = createDirectories();
    Find find = new Find();
    find.setConf(conf);
    PrintStream out = mock(PrintStream.class);
    find.getOptions().setOut(out);
    PrintStream err = mock(PrintStream.class);
    find.getOptions().setErr(err);
    Expression expr = mock(Expression.class);
    when(expr.apply((PathData) any(), anyInt())).thenReturn(Result.PASS);
    when(expr.apply(eq(item1a), anyInt())).thenReturn(Result.STOP);
    FileStatusChecker fsCheck = mock(FileStatusChecker.class);
    Expression test = new TestExpression(expr, fsCheck);
    find.setRootExpression(test);
    find.processArguments(items);
    InOrder inOrder = inOrder(expr);
    inOrder.verify(expr).setOptions(find.getOptions());
    inOrder.verify(expr).prepare();
    inOrder.verify(expr).apply(item1, 0);
    inOrder.verify(expr).apply(item1a, 1);
    inOrder.verify(expr).apply(item1b, 1);
    inOrder.verify(expr).apply(item2, 0);
    inOrder.verify(expr).apply(item3, 0);
    inOrder.verify(expr).apply(item4, 0);
    inOrder.verify(expr).apply(item5, 0);
    inOrder.verify(expr).apply(item5a, 1);
    inOrder.verify(expr).apply(item5b, 1);
    inOrder.verify(expr).apply(item5c, 1);
    inOrder.verify(expr).apply(item5ca, 2);
    inOrder.verify(expr).apply(item5d, 1);
    inOrder.verify(expr).apply(item5e, 1);
    inOrder.verify(expr).finish();
    verifyNoMoreInteractions(expr);
    InOrder inOrderFsCheck = inOrder(fsCheck);
    inOrderFsCheck.verify(fsCheck).check(item1.stat);
    inOrderFsCheck.verify(fsCheck).check(item1a.stat);
    inOrderFsCheck.verify(fsCheck).check(item1b.stat);
    inOrderFsCheck.verify(fsCheck).check(item2.stat);
    inOrderFsCheck.verify(fsCheck).check(item3.stat);
    inOrderFsCheck.verify(fsCheck).check(item4.stat);
    inOrderFsCheck.verify(fsCheck).check(item5.stat);
    inOrderFsCheck.verify(fsCheck).check(item5a.stat);
    inOrderFsCheck.verify(fsCheck).check(item5b.stat);
    inOrderFsCheck.verify(fsCheck).check(item5c.stat);
    inOrderFsCheck.verify(fsCheck).check(item5ca.stat);
    inOrderFsCheck.verify(fsCheck).check(item5d.stat);
    inOrderFsCheck.verify(fsCheck).check(item5e.stat);
    verifyNoMoreInteractions(fsCheck);
    verifyNoMoreInteractions(out);
    verifyNoMoreInteractions(err);
}
Also used : PrintStream(java.io.PrintStream) InOrder(org.mockito.InOrder) BaseExpression(org.apache.hadoop.fs.shell.find.BaseExpression) Expression(org.apache.hadoop.fs.shell.find.Expression) Find(org.apache.hadoop.fs.shell.find.Find) PathData(org.apache.hadoop.fs.shell.PathData) Test(org.junit.Test)

Example 27 with InOrder

use of org.mockito.InOrder in project Store by NYTimes.

the class FilePersisterTest method writeThenRead.

@Test
public void writeThenRead() throws IOException {
    when(fileSystem.read(resolvedPath)).thenReturn(bufferedSource);
    when(fileSystem.exists(resolvedPath)).thenReturn(true);
    fileSystemPersister.write(simple, bufferedSource).toBlocking().single();
    BufferedSource source = fileSystemPersister.read(simple).toBlocking().first();
    InOrder inOrder = inOrder(fileSystem);
    inOrder.verify(fileSystem).write(resolvedPath, bufferedSource);
    inOrder.verify(fileSystem).exists(resolvedPath);
    inOrder.verify(fileSystem).read(resolvedPath);
    assertThat(source).isEqualTo(bufferedSource);
}
Also used : InOrder(org.mockito.InOrder) BufferedSource(okio.BufferedSource) Test(org.junit.Test)

Example 28 with InOrder

use of org.mockito.InOrder in project Store by NYTimes.

the class FileSystemRecordPersisterTest method writeThenRead.

@Test
public void writeThenRead() throws IOException {
    when(fileSystem.read(resolvedPath)).thenReturn(bufferedSource);
    when(fileSystem.exists(resolvedPath)).thenReturn(true);
    fileSystemPersister.write(simple, bufferedSource).toBlocking().single();
    BufferedSource source = fileSystemPersister.read(simple).toBlocking().first();
    InOrder inOrder = inOrder(fileSystem);
    inOrder.verify(fileSystem).write(resolvedPath, bufferedSource);
    inOrder.verify(fileSystem).exists(resolvedPath);
    inOrder.verify(fileSystem).read(resolvedPath);
    assertThat(source).isEqualTo(bufferedSource);
}
Also used : InOrder(org.mockito.InOrder) BufferedSource(okio.BufferedSource) Test(org.junit.Test)

Example 29 with InOrder

use of org.mockito.InOrder in project sonarqube by SonarSource.

the class UserSessionFilterTest method doFilter_loads_and_unloads_settings.

@Test
public void doFilter_loads_and_unloads_settings() throws Exception {
    mockNoUserSessionInitializer();
    underTest.doFilter(request, response, chain);
    InOrder inOrder = inOrder(settings);
    inOrder.verify(settings).load();
    inOrder.verify(settings).unload();
    inOrder.verifyNoMoreInteractions();
}
Also used : InOrder(org.mockito.InOrder) Test(org.junit.Test)

Example 30 with InOrder

use of org.mockito.InOrder in project RxJava by ReactiveX.

the class FlowableTests method testJustWithScheduler.

@Test
public void testJustWithScheduler() {
    TestScheduler scheduler = new TestScheduler();
    Flowable<Integer> observable = Flowable.fromArray(1, 2).subscribeOn(scheduler);
    Subscriber<Integer> observer = TestHelper.mockSubscriber();
    observable.subscribe(observer);
    scheduler.advanceTimeBy(1, TimeUnit.MILLISECONDS);
    InOrder inOrder = inOrder(observer);
    inOrder.verify(observer, times(1)).onNext(1);
    inOrder.verify(observer, times(1)).onNext(2);
    inOrder.verify(observer, times(1)).onComplete();
    inOrder.verifyNoMoreInteractions();
}
Also used : InOrder(org.mockito.InOrder)

Aggregations

InOrder (org.mockito.InOrder)3292 Test (org.junit.Test)2308 Test (org.junit.jupiter.api.Test)377 AbstractRestServiceTest (org.camunda.bpm.engine.rest.AbstractRestServiceTest)108 HashMap (java.util.HashMap)104 ArrayList (java.util.ArrayList)98 Response (com.jayway.restassured.response.Response)79 Matchers.containsString (org.hamcrest.Matchers.containsString)69 IOException (java.io.IOException)64 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)63 SmallTest (org.mule.tck.size.SmallTest)62 List (java.util.List)57 CompletableFuture (java.util.concurrent.CompletableFuture)52 Cleanup (lombok.Cleanup)46 InvocationOnMock (org.mockito.invocation.InvocationOnMock)46 WireCommands (io.pravega.shared.protocol.netty.WireCommands)45 ProcessorInterceptor (org.mule.runtime.api.interception.ProcessorInterceptor)44 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)44 Metadata (io.grpc.Metadata)43 ComponentLocation (org.mule.runtime.api.component.location.ComponentLocation)41