Class GHObjectSpyDefaultAnswer

java.lang.Object
io.quarkiverse.githubapp.testing.mockito.internal.GHObjectSpyDefaultAnswer
All Implemented Interfaces:
Serializable, org.mockito.stubbing.Answer<Object>

public final class GHObjectSpyDefaultAnswer extends Object implements org.mockito.stubbing.Answer<Object>, Serializable
The default answer for all GHObject spies.

The purpose of this default answer is to apply mocked behavior when defined (through GitHubMockContext), or failing that retrieve information from the event payload if possible (e.g. for getters), or failing that apply whatever default behavior is configured globally (e.g. return null, ...).

For GHObject#root() and GHObject.getRoot(), this will return the GitHub client mock.

For other getters, if there is a mocked behavior, this will apply that behavior. Otherwise, this will call the real method, and potentially wrap the return value with a spy using GHObjectSpyDefaultAnswer, if that return value is a GHObject.

For all other methods, this will just call the mocked behavior.

See Also:
  • Constructor Details

  • Method Details

    • answer

      public Object answer(org.mockito.invocation.InvocationOnMock invocation) throws Throwable
      Specified by:
      answer in interface org.mockito.stubbing.Answer<Object>
      Throws:
      Throwable