Package samples.finalmocking

Examples of samples.finalmocking.FinalDemo


  @Test
  public void assertMockFinalWithNoExpectationsWorks() throws Exception {
        final String argument = "hello";

    FinalDemo tested = mock(FinalDemo.class);

    assertNull(tested.say(argument));

    verify(tested).say(argument);
  }
View Full Code Here


  @Test
  public void assertMockFinalWithExpectationsWorks() throws Exception {
    final String argument = "hello";
    final String expected = "Hello altered World";

    FinalDemo tested = mock(FinalDemo.class);

    when(tested.say(argument)).thenReturn(expected);

    final String actual = tested.say(argument);

    verify(tested).say(argument);

    assertEquals("Expected and actual did not match", expected, actual);
  }
View Full Code Here

  @Test
  public void assertFinalNativeWithExpectationsWorks() throws Exception {
    final String expected = "Hello altered World";
    final String argument = "hello";

    FinalDemo tested = mock(FinalDemo.class);

    when(tested.sayFinalNative(argument)).thenReturn("Hello altered World");

    String actual = tested.sayFinalNative(argument);

    verify(tested).sayFinalNative(argument);
    assertEquals("Expected and actual did not match", expected, actual);
  }
View Full Code Here

    assertEquals("Expected and actual did not match", expected, actual);
  }

  @Test
  public void assertSpyingOnFinalInstanceMethodWorks() throws Exception {
    FinalDemo tested = new FinalDemo();
    FinalDemo spy = spy(tested);

    final String argument = "PowerMock";
    final String expected = "something";

    assertEquals("Hello " + argument, spy.say(argument));
    when(spy.say(argument)).thenReturn(expected);
    assertEquals(expected, spy.say(argument));
  }
View Full Code Here

    assertEquals(expected, spy.say(argument));
  }

  @Test(expected = ArrayStoreException.class)
  public void assertSpyingOnFinalVoidInstanceMethodWorks() throws Exception {
    FinalDemo tested = new FinalDemo();
    FinalDemo spy = spy(tested);

    doThrow(new ArrayStoreException()).when(spy).finalVoidCallee();

    spy.finalVoidCaller();
  }
View Full Code Here

  @Test
  public void assertMockFinalWithNoExpectationsWorks() throws Exception {
        final String argument = "hello";

    FinalDemo tested = mock(FinalDemo.class);

    assertNull(tested.say(argument));

    verify(tested).say(argument);
  }
View Full Code Here

  @Test
  public void assertMockFinalWithExpectationsWorks() throws Exception {
    final String argument = "hello";
    final String expected = "Hello altered World";

    FinalDemo tested = mock(FinalDemo.class);

    when(tested.say(argument)).thenReturn(expected);

    final String actual = tested.say(argument);

    verify(tested).say(argument);

    assertEquals("Expected and actual did not match", expected, actual);
  }
View Full Code Here

  @Test
  public void assertFinalNativeWithExpectationsWorks() throws Exception {
    final String expected = "Hello altered World";
    final String argument = "hello";

    FinalDemo tested = mock(FinalDemo.class);

    when(tested.sayFinalNative(argument)).thenReturn("Hello altered World");

    String actual = tested.sayFinalNative(argument);

    verify(tested).sayFinalNative(argument);
    assertEquals("Expected and actual did not match", expected, actual);
  }
View Full Code Here

    assertEquals("Expected and actual did not match", expected, actual);
  }

  @Test
  public void assertSpyingOnFinalInstanceMethodWorks() throws Exception {
    FinalDemo tested = new FinalDemo();
    FinalDemo spy = spy(tested);

    final String argument = "PowerMock";
    final String expected = "something";

    assertEquals("Hello " + argument, spy.say(argument));
    when(spy.say(argument)).thenReturn(expected);
    assertEquals(expected, spy.say(argument));
  }
View Full Code Here

  @Test
  public void assertMockFinalWithNoExpectationsWorks() throws Exception {
        final String argument = "hello";

    FinalDemo tested = mock(FinalDemo.class);

    assertNull(tested.say(argument));

    verify(tested).say(argument);
  }
View Full Code Here

TOP

Related Classes of samples.finalmocking.FinalDemo

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.