1 /* 2 * Copyright (c) 2007 Mockito contributors 3 * This program is made available under the terms of the MIT License. 4 */ 5 package org.mockito.internal.verification; 6 7 import java.util.List; 8 9 import org.mockito.exceptions.Reporter; 10 import org.mockito.internal.invocation.InvocationMatcher; 11 import org.mockito.internal.stubbing.InvocationContainer; 12 import org.mockito.internal.util.ObjectMethodsGuru; 13 import org.mockito.internal.verification.api.VerificationData; 14 import org.mockito.invocation.Invocation; 15 16 public class VerificationDataImpl implements VerificationData { 17 18 private final InvocationMatcher wanted; 19 private final InvocationContainer invocations; 20 VerificationDataImpl(InvocationContainer invocations, InvocationMatcher wanted)21 public VerificationDataImpl(InvocationContainer invocations, InvocationMatcher wanted) { 22 this.invocations = invocations; 23 this.wanted = wanted; 24 this.assertWantedIsVerifiable(); 25 } 26 getAllInvocations()27 public List<Invocation> getAllInvocations() { 28 return invocations.getInvocations(); 29 } 30 getWanted()31 public InvocationMatcher getWanted() { 32 return wanted; 33 } 34 assertWantedIsVerifiable()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 }