Package samples.privateandfinal

Examples of samples.privateandfinal.PrivateFinal.say()


  @Test
  public void assertSpyingOnPrivateFinalInstanceMethodWorks() throws Exception {
    PrivateFinal spy = spy(new PrivateFinal());

    final String expected = "test";
    assertEquals("Hello " + expected, spy.say(expected));

    when(spy, "sayIt", isA(String.class)).thenReturn(expected);

    assertEquals(expected, spy.say(expected));
View Full Code Here


    final String expected = "test";
    assertEquals("Hello " + expected, spy.say(expected));

    when(spy, "sayIt", isA(String.class)).thenReturn(expected);

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

    verifyPrivate(spy, times(2)).invoke("sayIt", expected);
  }

  @Test
View Full Code Here

  @Test
  public void assertSpyingOnPrivateFinalInstanceMethodWorksWhenUsingJavaLangReflectMethod() throws Exception {
    PrivateFinal spy = spy(new PrivateFinal());

    final String expected = "test";
    assertEquals("Hello " + expected, spy.say(expected));
   
    final Method methodToExpect = method(PrivateFinal.class, "sayIt");
    when(spy, methodToExpect).withArguments(isA(String.class)).thenReturn(expected);

    assertEquals(expected, spy.say(expected));
View Full Code Here

    assertEquals("Hello " + expected, spy.say(expected));
   
    final Method methodToExpect = method(PrivateFinal.class, "sayIt");
    when(spy, methodToExpect).withArguments(isA(String.class)).thenReturn(expected);

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

    verifyPrivate(spy, times(2)).invoke(methodToExpect).withArguments(expected);
  }
}
View Full Code Here

    @Test
    public void captorAnnotationWorksOnPrivateMethods() throws Exception {
        final String expected = "testing";
        PrivateFinal demo = spy(new PrivateFinal());
        demo.say(expected);

        verifyPrivate(demo).invoke("sayIt", captor.capture());
        assertEquals(expected, captor.getValue());
    }
View Full Code Here

    @Test
    public void spyingOnPrivateFinalMethodsWorksWhenClassIsNotFinal() throws Exception {
        PrivateFinal tested = spy(new PrivateFinal());

        final String name = "test";
        tested.say(name);
        assertEquals("Hello " + name, tested.say(name));

        when(tested, "sayIt", name).thenReturn("First", "Second");

        assertEquals("First", tested.say(name));
View Full Code Here

    public void spyingOnPrivateFinalMethodsWorksWhenClassIsNotFinal() throws Exception {
        PrivateFinal tested = spy(new PrivateFinal());

        final String name = "test";
        tested.say(name);
        assertEquals("Hello " + name, tested.say(name));

        when(tested, "sayIt", name).thenReturn("First", "Second");

        assertEquals("First", tested.say(name));
        assertEquals("Second", tested.say(name));
View Full Code Here

        tested.say(name);
        assertEquals("Hello " + name, tested.say(name));

        when(tested, "sayIt", name).thenReturn("First", "Second");

        assertEquals("First", tested.say(name));
        assertEquals("Second", tested.say(name));
    }
}
View Full Code Here

        assertEquals("Hello " + name, tested.say(name));

        when(tested, "sayIt", name).thenReturn("First", "Second");

        assertEquals("First", tested.say(name));
        assertEquals("Second", tested.say(name));
    }
}
View Full Code Here

    @Test
    public void spyingOnPrivateFinalMethodsWorksWhenClassIsNotFinal() throws Exception {
        PrivateFinal tested = spy(new PrivateFinal());

        final String name = "test";
        tested.say(name);
        assertEquals("Hello " + name, tested.say(name));

        when(tested, "sayIt", name).thenReturn("First", "Second");

        assertEquals("First", tested.say(name));
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.