@Test
  public void shouldPrintRealInvocationOnSpyToStdOut() {
    // given
    FooImpl fooSpy =
        mock(FooImpl.class, withSettings().spiedInstance(new FooImpl()).verboseLogging());
    doCallRealMethod().when(fooSpy).doSomething("Klipsch");

    // when
    fooSpy.doSomething("Klipsch");

    // then
    Assertions.assertThat(printed())
        .contains(getClass().getName())
        .contains(mockName(fooSpy))
        .contains("doSomething")
        .contains("Klipsch");
  }
Example #2
0
  @Override
  public void setName(String name) {

    try {

      System.out.println("set name in ExtFooImpl");
      java.util.Random random = new java.util.Random();

      int sleep = random.nextInt(1000);

      Thread.sleep(sleep);

    } catch (InterruptedException e) {
    }

    super.setName(name);
  }
  @Override
  public Object clone() {
    FooImpl fooImpl = new FooImpl();

    fooImpl.setFooId(getFooId());
    fooImpl.setGroupId(getGroupId());
    fooImpl.setCompanyId(getCompanyId());
    fooImpl.setUserId(getUserId());
    fooImpl.setUserName(getUserName());
    fooImpl.setCreateDate(getCreateDate());
    fooImpl.setModifiedDate(getModifiedDate());
    fooImpl.setField1(getField1());
    fooImpl.setField2(getField2());
    fooImpl.setField3(getField3());
    fooImpl.setField4(getField4());
    fooImpl.setField5(getField5());

    fooImpl.resetOriginalValues();

    return fooImpl;
  }