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

com.roscopeco.moxy.api.MoxyVerifier Maven / Gradle / Ivy

There is a newer version: 0.94.0
Show newest version
/*
 * Moxy - Lean-and-mean mocking framework for Java with a fluent API.
 *
 * Copyright 2018 Ross Bamford
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 *   The above copyright notice and this permission notice shall be included
 *   in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
package com.roscopeco.moxy.api;

import org.opentest4j.AssertionFailedError;

/**
 * 

Implementations of this interface allow mocks to be verified after * use. They are returned by the * {@link MoxyEngine#assertMock(com.roscopeco.moxy.api.InvocationRunnable)} * method.

* *

Individual engines will usually provide their own implementation * of this interface, as verifying will require internal knowledge * of the engine's mocking strategy.

* * @author Ross Bamford <roscopeco AT gmail DOT com> * @since 1.0 */ public interface MoxyVerifier { /** * Verify that the mock method was called at least once, * with the arguments specified in the call. * * Note the subtle difference from {@link #wasCalled(int)}, which * expects an exact number of calls. * * Throws {@link AssertionFailedError} if the assertion fails. * * @return this. * @since 1.0 */ public MoxyVerifier wasCalled(); /** * Verify that the mock method was called exactly times, * with the arguments specified in the call. * * Note the subtle difference from {@link #wasCalled()}, which * expects an at least one call. * * Throws {@link AssertionFailedError} if the assertion fails. * * @param times The number of expected invocations. * * @return this. * @since 1.0 */ public MoxyVerifier wasCalled(int times); /** * Verify that the mock method was not called. * * Throws {@link AssertionFailedError} if the assertion fails. * * @return this * @since 1.0 */ public MoxyVerifier wasNotCalled(); /** * Verify the mock method was called exactly once. * * Throws {@link AssertionFailedError} if the assertion fails. * * @return this * @since 1.0 */ public MoxyVerifier wasCalledOnce(); /** * Verify the mock method called exactly twice. * * Throws {@link AssertionFailedError} if the assertion fails. * * @return this * @since 1.0 */ public MoxyVerifier wasCalledTwice(); /** * Verify the mock method was called at least times. * * Throws {@link AssertionFailedError} if the assertion fails. * * @param times The number of expected invocations. * * @return this * @since 1.0 */ public MoxyVerifier wasCalledAtLeast(int times); /** * Verify the mock method was called at most times. * * Throws {@link AssertionFailedError} if the assertion fails. * * @param times The number of expected invocations. * * @return this * @since 1.0 */ public MoxyVerifier wasCalledAtMost(int times); /** * Verify the mocked method didn't throw an exception of type throwable. * * Throws {@link AssertionFailedError} if the assertion fails. * * @param throwable The exception type to check. * * @return this * @since 1.0 */ public MoxyVerifier didntThrow(Class throwable); /** * Verify the mocked method didn't throw the given throwable instance. * * Throws {@link AssertionFailedError} if the assertion fails. * * @param throwable The exception instance to check. * * @return this * @since 1.0 */ public MoxyVerifier didntThrow(Throwable throwable); /** * Verify the mocked method didn't throw any exceptions. * * Throws {@link AssertionFailedError} if the assertion fails. * * @return this * @since 1.0 */ public MoxyVerifier didntThrowAnyException(); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy