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 java.util.List;
8
9import org.mockito.exceptions.Reporter;
10import org.mockito.internal.invocation.InvocationMatcher;
11import org.mockito.internal.stubbing.InvocationContainer;
12import org.mockito.internal.util.ObjectMethodsGuru;
13import org.mockito.internal.verification.api.VerificationData;
14import org.mockito.invocation.Invocation;
15
16public class VerificationDataImpl implements VerificationData {
17
18    private final InvocationMatcher wanted;
19    private final InvocationContainer invocations;
20
21    public VerificationDataImpl(InvocationContainer invocations, InvocationMatcher wanted) {
22        this.invocations = invocations;
23        this.wanted = wanted;
24        this.assertWantedIsVerifiable();
25    }
26
27    public List<Invocation> getAllInvocations() {
28        return invocations.getInvocations();
29    }
30
31    public InvocationMatcher getWanted() {
32        return wanted;
33    }
34
35    void assertWantedIsVerifiable() {
36        if (wanted == null) {
37            return;
38        }
39        ObjectMethodsGuru o = new ObjectMethodsGuru();
40        if (o.isToString(wanted.getMethod())) {
41            new Reporter().cannotVerifyToString();
42        }
43    }
44}