1/*
2 * Copyright (c) 2007 Mockito contributors
3 * This program is made available under the terms of the MIT License.
4 */
5package org.mockito.internal.verification;
6
7import org.mockito.internal.InOrderImpl;
8import org.mockito.internal.invocation.finder.VerifiableInvocationsFinder;
9import org.mockito.internal.verification.api.VerificationData;
10import org.mockito.internal.verification.api.VerificationDataInOrderImpl;
11import org.mockito.internal.verification.api.VerificationInOrderMode;
12import org.mockito.invocation.Invocation;
13import org.mockito.verification.VerificationMode;
14
15import java.util.List;
16
17public class InOrderWrapper implements VerificationMode {
18
19    private final VerificationInOrderMode mode;
20    private final InOrderImpl inOrder;
21
22    public InOrderWrapper(VerificationInOrderMode mode, InOrderImpl inOrder) {
23        this.mode = mode;
24        this.inOrder = inOrder;
25    }
26
27    public void verify(VerificationData data) {
28        List<Invocation> invocations = new VerifiableInvocationsFinder().find(inOrder.getMocksToBeVerifiedInOrder());
29        VerificationDataInOrderImpl dataInOrder = new VerificationDataInOrderImpl(inOrder, invocations, data.getWanted());
30        mode.verifyInOrder(dataInOrder);
31    }
32}