Repository: mockito/mockito
Issue: Unexpected new public API: VerificationWrapper, VerificationWrapperInOrder, VerificationCollectorImpl

It looks like some classes leaked to the public API: VerificationWrapper, VerificationWrapperInOrder, VerificationCollectorImpl

They seem like internal classes because:
a) they are concrete implementation where public API should be an interface
b) no javadoc
c) looking at their API, they don't seem like something we want to expose to the users :)

We need to fix it before 2.0, perhaps it's just the matter of moving it to internal packages.


Issue comments:
`VerificationCollectorImpl` is package-protected and is not generated in the Javadoc either: http://site.mockito.org/mockito/docs/current/org/mockito/junit/package-summary.html

The other `VerificationWrapper`s can be package-protected too.

This is a good point!

I suggest we move it to internal package anyway. This way:
- it is consistent how we manage public / private API
- it can be used more easily by devs who experiment / hack (e.g. they know what they are doing when using private API :)
- it is less error prone (e.g. when someone forgets to remove 'public' or when someone adds 'public' not realizing consequences)


Pull request review comments:

Patch that resolved the issue:
diff --git a/src/main/java/org/mockito/internal/InOrderImpl.java b/src/main/java/org/mockito/internal/InOrderImpl.java
index cb3442f373..ce37b23da4 100644
--- a/src/main/java/org/mockito/internal/InOrderImpl.java
+++ b/src/main/java/org/mockito/internal/InOrderImpl.java
@@ -14,8 +14,8 @@
 import org.mockito.internal.verification.api.VerificationInOrderMode;
 import org.mockito.invocation.Invocation;
 import org.mockito.verification.VerificationMode;
-import org.mockito.verification.VerificationWrapper;
-import org.mockito.verification.VerificationWrapperInOrderWrapper;
+import org.mockito.internal.verification.VerificationWrapper;
+import org.mockito.internal.verification.VerificationWrapperInOrderWrapper;
 
 import static org.mockito.internal.exceptions.Reporter.inOrderRequiresFamiliarMock;
 
diff --git a/src/main/java/org/mockito/junit/VerificationCollectorImpl.java b/src/main/java/org/mockito/internal/junit/VerificationCollectorImpl.java
similarity index 94%
rename from src/main/java/org/mockito/junit/VerificationCollectorImpl.java
rename to src/main/java/org/mockito/internal/junit/VerificationCollectorImpl.java
index b1ffeb8946..da9c4515f6 100644
--- a/src/main/java/org/mockito/junit/VerificationCollectorImpl.java
+++ b/src/main/java/org/mockito/internal/junit/VerificationCollectorImpl.java
@@ -1,4 +1,4 @@
-package org.mockito.junit;
+package org.mockito.internal.junit;
 
 import static org.mockito.internal.progress.ThreadSafeMockingProgress.mockingProgress;
 
@@ -7,18 +7,19 @@
 import org.mockito.exceptions.base.MockitoAssertionError;
 import org.mockito.internal.progress.MockingProgressImpl;
 import org.mockito.internal.verification.api.VerificationData;
+import org.mockito.junit.VerificationCollector;
 import org.mockito.verification.VerificationMode;
 import org.mockito.verification.VerificationStrategy;
 
 /**
  * Mockito implementation of VerificationCollector.
  */
-class VerificationCollectorImpl implements VerificationCollector {
+public class VerificationCollectorImpl implements VerificationCollector {
 
     private StringBuilder builder;
     private int numberOfFailures;
 
-    VerificationCollectorImpl() {
+    public VerificationCollectorImpl() {
         this.resetBuilder();
     }
 
diff --git a/src/main/java/org/mockito/verification/VerificationWrapper.java b/src/main/java/org/mockito/internal/verification/VerificationWrapper.java
similarity index 93%
rename from src/main/java/org/mockito/verification/VerificationWrapper.java
rename to src/main/java/org/mockito/internal/verification/VerificationWrapper.java
index d32fab221d..13ad8d8164 100644
--- a/src/main/java/org/mockito/verification/VerificationWrapper.java
+++ b/src/main/java/org/mockito/internal/verification/VerificationWrapper.java
@@ -1,7 +1,7 @@
-package org.mockito.verification;
+package org.mockito.internal.verification;
 
-import org.mockito.internal.verification.VerificationModeFactory;
 import org.mockito.internal.verification.api.VerificationData;
+import org.mockito.verification.VerificationMode;
 
 public abstract class VerificationWrapper<WrapperType extends VerificationMode> implements VerificationMode {
 
diff --git a/src/main/java/org/mockito/verification/VerificationWrapperInOrderWrapper.java b/src/main/java/org/mockito/internal/verification/VerificationWrapperInOrderWrapper.java
similarity index 91%
rename from src/main/java/org/mockito/verification/VerificationWrapperInOrderWrapper.java
rename to src/main/java/org/mockito/internal/verification/VerificationWrapperInOrderWrapper.java
index e04cfd749d..f04ebadbfb 100644
--- a/src/main/java/org/mockito/verification/VerificationWrapperInOrderWrapper.java
+++ b/src/main/java/org/mockito/internal/verification/VerificationWrapperInOrderWrapper.java
@@ -1,12 +1,10 @@
-package org.mockito.verification;
+package org.mockito.internal.verification;
 
 import org.mockito.exceptions.base.MockitoException;
 import org.mockito.internal.InOrderImpl;
-import org.mockito.internal.verification.InOrderWrapper;
-import org.mockito.internal.verification.VerificationModeFactory;
-import org.mockito.internal.verification.VerificationOverTimeImpl;
 import org.mockito.internal.verification.api.VerificationData;
 import org.mockito.internal.verification.api.VerificationInOrderMode;
+import org.mockito.verification.VerificationMode;
 
 public class VerificationWrapperInOrderWrapper implements VerificationMode {
     private final VerificationMode delegate;
diff --git a/src/main/java/org/mockito/junit/MockitoJUnit.java b/src/main/java/org/mockito/junit/MockitoJUnit.java
index 8c6c32ea6e..fac86b4572 100644
--- a/src/main/java/org/mockito/junit/MockitoJUnit.java
+++ b/src/main/java/org/mockito/junit/MockitoJUnit.java
@@ -1,6 +1,7 @@
 package org.mockito.junit;
 
 import org.mockito.internal.junit.JUnitRule;
+import org.mockito.internal.junit.VerificationCollectorImpl;
 import org.mockito.internal.util.ConsoleMockitoLogger;
 
 /**
diff --git a/src/main/java/org/mockito/verification/After.java b/src/main/java/org/mockito/verification/After.java
index cc63dfbfd5..089324ebcc 100644
--- a/src/main/java/org/mockito/verification/After.java
+++ b/src/main/java/org/mockito/verification/After.java
@@ -2,6 +2,7 @@
 
 import org.mockito.internal.verification.VerificationModeFactory;
 import org.mockito.internal.verification.VerificationOverTimeImpl;
+import org.mockito.internal.verification.VerificationWrapper;
 
 /**
  * See the javadoc for {@link VerificationAfterDelay}
diff --git a/src/main/java/org/mockito/verification/Timeout.java b/src/main/java/org/mockito/verification/Timeout.java
index dcb8b46c9b..f49765a270 100644
--- a/src/main/java/org/mockito/verification/Timeout.java
+++ b/src/main/java/org/mockito/verification/Timeout.java
@@ -9,6 +9,7 @@
 import org.mockito.internal.util.Timer;
 import org.mockito.internal.verification.VerificationModeFactory;
 import org.mockito.internal.verification.VerificationOverTimeImpl;
+import org.mockito.internal.verification.VerificationWrapper;
 
 /**
  * See the javadoc for {@link VerificationWithTimeout}


Test patch: