Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用Mockito测试具有lambda参数的方法的链式调用_Java_Unit Testing_Mocking_Mockito - Fatal编程技术网

Java 使用Mockito测试具有lambda参数的方法的链式调用

Java 使用Mockito测试具有lambda参数的方法的链式调用,java,unit-testing,mocking,mockito,Java,Unit Testing,Mocking,Mockito,我有以下接口: DAOFunctionCommand: @FunctionalInterface public interface DAOFunctionCommand<T, R> { R execute(T input, IDAOManager manager) throws Exception; } @functioninterface 公共接口命令 { R execute(T输入,IDooManager)抛出异常; } DAOSupplierCommand: @Fu

我有以下接口:

DAOFunctionCommand:

@FunctionalInterface
public interface DAOFunctionCommand<T, R>
{
    R execute(T input, IDAOManager manager) throws Exception;
}
@functioninterface
公共接口命令
{
R execute(T输入,IDooManager)抛出异常;
}
DAOSupplierCommand:

@FunctionalInterface
public interface DAOSupplierCommand<T>
{
    T get(IDAOManager manager) throws Exception;
}
@functioninterface
公共接口DAOSupplierCommand
{
T get(IDooManager)抛出异常;
}
ITransactionStream:

public interface ITransactionStream<T, K extends IDAOManager>
{
    <R> ITransactionStream<R, K> chain(DAOFunctionCommand<? super T, ? extends R> cmd) throws Exception;

    <R> ITransactionStream<R, K> chain(DAOSupplierCommand<? extends R> cmd) throws Exception;

    T getResult();

    T end() throws Exception;
}
公共接口ITransactionStream
{

ITransactionStream链(DAOSfunctionCommands)DAO从何处获得
m
?模拟它。@BoristheSpider'm'表示IDAOManager。
public interface ITransactionHead<T, K extends IDAOManager>
{
    ITransactionStream<T, K> start() throws Exception;
}
public interface IDAOManager
{
    ITicketDAO getTicketDAO() throws Exception;

    IParkingSpotsDAO getParkingSpotDAO() throws Exception;

    IParkingSpotCategoriesDAO getParkingSpotCategoriesDAO() throws Exception;

    ITransactionHead<Object, ? extends IDAOManager> txStream() throws Exception;
}
public Optional<ParkingSpot> occupySpot(String category) throws Exception
{
    daoManager.getParkingSpotCategoriesDAO().get(category);

    Optional<ParkingSpot> ps = daoManager.txStream()
            .start()
            .chain((m) -> m.getParkingSpotDAO().getFreeSpot(category))
            .chain((p, m) ->
            {
                if (!p.isPresent()) return Optional.<ParkingSpot>empty();
                p.get().setAvailable(false);
                m.getParkingSpotDAO().update(p.get());
                return p;
            }).end();

    if (ps.isPresent()) notifyAllListeners();
    return ps;
}