Package org.mockito.internal.stubbing.answers

Examples of org.mockito.internal.stubbing.answers.ReturnsArgumentAt


     * @return Answer that will return the second argument of the invocation.
     *
     * @since 1.9.5
     */
    public static <T> Answer<T> returnsArgAt(int position) {
        return (Answer<T>) new ReturnsArgumentAt(position);
    }
View Full Code Here


     * @return Answer that will return the argument from the given position in the argument's list
     *
     * @since 1.9.5
     */
    public static <T> Answer<T> returnsArgAt(int position) {
        return (Answer<T>) new ReturnsArgumentAt(position);
    }
View Full Code Here

  }
 
  @Test
  public void testFactory() {
   
    Mockito.when(mockModule.configure(Mockito.any(Graph.class), Mockito.any(FramedGraphConfiguration.class))).then(new ReturnsArgumentAt(0));
    FramedGraphFactory graphFactory = new FramedGraphFactory(mockModule);
   
    FramedGraph<Graph> framed = graphFactory.create(base);
    Assert.assertEquals(base, framed.getBaseGraph());
   
View Full Code Here

  }
 
  @Test
  public void testSubclassing() {
    MyFramedGraphFactory myFramedGraphFactory = new MyFramedGraphFactory(mockModule);
    Mockito.when(mockModule.configure(Mockito.any(Graph.class), Mockito.any(FramedGraphConfiguration.class))).then(new ReturnsArgumentAt(0));
    MyFramedGraph<Graph> create = myFramedGraphFactory.create(base);
    Assert.assertEquals(base, create.getBaseGraph());
  }
View Full Code Here

import static org.junit.Assert.fail;

public class ReturnsArgumentAtTest {
  @Test
  public void should_be_able_to_return_the_first_parameter() throws Throwable {
    assertThat(new ReturnsArgumentAt(0).answer(invocationWith("A", "B"))).isEqualTo("A");
  }
View Full Code Here

  }

  @Test
  public void should_be_able_to_return_the_second_parameter()
      throws Throwable {
    assertThat(new ReturnsArgumentAt(1).answer(invocationWith("A", "B", "C"))).isEqualTo("B");
  }
View Full Code Here

    assertThat(new ReturnsArgumentAt(1).answer(invocationWith("A", "B", "C"))).isEqualTo("B");
  }

  @Test
  public void should_be_able_to_return_the_last_parameter() throws Throwable {
    assertThat(new ReturnsArgumentAt(-1).answer(invocationWith("A"))).isEqualTo("A");
    assertThat(new ReturnsArgumentAt(-1).answer(invocationWith("A", "B"))).isEqualTo("B");
  }
View Full Code Here

    assertThat(new ReturnsArgumentAt(-1).answer(invocationWith("A", "B"))).isEqualTo("B");
  }

  @Test
  public void should_be_able_to_return_the_specified_parameter() throws Throwable {
    assertThat(new ReturnsArgumentAt(0).answer(invocationWith("A", "B", "C"))).isEqualTo("A");
    assertThat(new ReturnsArgumentAt(1).answer(invocationWith("A", "B", "C"))).isEqualTo("B");
    assertThat(new ReturnsArgumentAt(2).answer(invocationWith("A", "B", "C"))).isEqualTo("C");
  }
View Full Code Here

  }

  @Test
  public void should_raise_an_exception_if_index_is_not_in_allowed_range_at_creation_time() throws Throwable {
        try {
            new ReturnsArgumentAt(-30);
            fail();
        } catch (Exception e) {
            assertThat(e.getMessage())
                    .containsIgnoringCase("argument index")
                    .containsIgnoringCase("positive number")
View Full Code Here

TOP

Related Classes of org.mockito.internal.stubbing.answers.ReturnsArgumentAt

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.