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

io.quarkus.panache.mock.PanacheStubber Maven / Gradle / Ivy

package io.quarkus.panache.mock;

import org.mockito.Mockito;
import org.mockito.stubbing.Answer;
import org.mockito.stubbing.Stubber;

public class PanacheStubber {

    private Stubber stubber;

    public PanacheStubber(Stubber stubber) {
        this.stubber = stubber;
    }

    /**
     * Allows to choose a method when stubbing in doThrow()|doAnswer()|doNothing()|doReturn() style
     * 

* Example: * *

     * 
     *   doThrow(new RuntimeException())
     *   .when(mockedList).clear();
     *
     *   //following throws RuntimeException:
     *   mockedList.clear();
     * 
     * 
* * Read more about those methods: *

* {@link Mockito#doThrow(Throwable[])} *

* {@link Mockito#doAnswer(Answer)} *

* {@link Mockito#doNothing()} *

* {@link Mockito#doReturn(Object)} *

* * See examples in javadoc for {@link Mockito} * * @param mock The mock * @return select method for stubbing */ public T when(Class mock) { return stubber.when(PanacheMock.getMock(mock)); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy