All Downloads are FREE. Search and download functionalities are using the official Maven repository.

guru.mocker.java.internal.result.ValidResult Maven / Gradle / Ivy

The newest version!
package guru.mocker.java.internal.result;

import static guru.mocker.java.api.util.TestFrameworkUtil.*;

public record ValidResult(Object result) implements Result
{

    @Override
    public void assertEqual(Result realResult)
    {
        assertResults(result, realResult.result());
    }
    private  void assertResults(R mockResult, R realResult)
    {
        if (null == mockResult)
            assertNull(realResult);
        else
            assertNonNullResults(mockResult, realResult);
    }

    private  void assertNonNullResults(R mockResult, R realResult)
    {
        assertEquals(mockResult, realResult);
//TODO evaluate do we need it?        assertThat(realResult, samePropertyValuesAs(mockResult));
    }


    @Override
    public void assertionFailed(Result realResult)
    {
        fail("No exception expected to be thrown", (Throwable) realResult.result());
    }
}