I want to test `validate` method and I have the following classes:

**Example class**

```
public class Example {
  private int status;

  public boolean validate(ComplexObject complexObject) {
    if (status == 1) {
        //  do something...
    }

    if (status == -1) {
        complexObject.setErrorMessage("Some error occured!");
    }

    return status != -1;
  }
}

```

**ComplexObject class**

```
public class ComplexObject {

    //  This is a complicated object which I
    //  do not want to reproduce
    String errorMessage;

    public String getErrorMessage() {
        return errorMessage;
    }

    public void setErrorMessage(String errorMessage) {
        this.errorMessage = errorMessage;
    }
}

```

**ExampleTest class**

```
@ExtendWith(MockitoExtension.class)
class ExampleTest {

    @Mock
    ComplexObject complexObject;

    @Test
    public void testValidationWithErrorMessage() {
        Example example = new Example();

        assertThat(example.validate(complexObject)).isFalse();

        //  The problem: complexObject.getErrorMessage() result is null
        assertThat(complexObject.getErrorMessage()).isEqualTo("Some error message");
    }
}

```

I want to perform a test that mocking this ComplexObject but if I have an error message, I want to get it.  

In the actual code it works, but with the mock object when it perform:

```
complexObject.setErrorMessage("Some error occured!"); 

```

I end up getting `null`.

Can I mock `ComplexObject` and still get the message error when I test it?