Skip to content

Commit

Permalink
Fix whitespace issues throughout the code (mockito#928)
Browse files Browse the repository at this point in the history
* Add missing newlines at the end of source files

At the time this patch was authored, 252 (~31%) source files in the
project did not end with a newline, while 555 (~69%) did.

This patch takes the de-facto standard of having a newline at the end
of a file and applies it to all the source files in the project.

Besides improving standardization, another contributing consideration
is the fact that many editors/IDEs add newlines at the end of files.
Using such an IDE will add a newline to the edited file, adding
"noise" to the patch and confusing potential reviewers. By explicitly
adding all the missing newlines in a single patch, this problem can be
avoided.

These changes were done automatically by applying the following shell
command:

$ find . -name "*.java" -exec sed -i -e '$a\' {} \;

* Remove whitespaces at the end of source lines

This patch takes the de-facto standard of not having any whitespaces
at the end of source lines and applies it to all the source files in
the project.

Besides improving standardization, another contributing consideration
is the fact that many editors/IDEs remove such whitespaces at end of
lines. Using such an IDE will remove these whitespaces in the edited
file, adding "noise" to the patch and confusing potential reviewers.
By explicitly removing all of them in a single patch, this problem can
be avoided.

These changes were done automatically by applying the following shell
command:

$ find . -name "*.java" -exec sed -i 's/[ \t]*$//' {} \;
  • Loading branch information
mureinik authored and TimvdLippe committed Feb 6, 2017
1 parent c73c7a0 commit e9516f4
Show file tree
Hide file tree
Showing 388 changed files with 2,051 additions and 1,944 deletions.
164 changes: 82 additions & 82 deletions src/main/java/org/mockito/AdditionalMatchers.java

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/main/java/org/mockito/Answers.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,5 @@ public Answer<Object> get() {

public Object answer(InvocationOnMock invocation) throws Throwable {
return implementation.answer(invocation);
}
}
}
}
20 changes: 10 additions & 10 deletions src/main/java/org/mockito/ArgumentCaptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
*
* <p>
* In a way ArgumentCaptor is related to custom argument matchers (see javadoc for {@link ArgumentMatcher} class).
* Both techniques can be used for making sure certain arguments where passed to mocks.
* Both techniques can be used for making sure certain arguments where passed to mocks.
* However, ArgumentCaptor may be a better fit if:
* <ul>
* <ul>
* <li>custom argument matcher is not likely to be reused</li>
* <li>you just need it to assert on argument values to complete verification</li>
* </ul>
Expand All @@ -60,7 +60,7 @@
* @since 1.8.0
*/
public class ArgumentCaptor<T> {


private final CapturingMatcher<T> capturingMatcher = new CapturingMatcher<T>();
private final Class<? extends T> clazz;
Expand All @@ -73,10 +73,10 @@ private ArgumentCaptor(Class<? extends T> clazz) {
* Use it to capture the argument. This method <b>must be used inside of verification</b>.
* <p>
* Internally, this method registers a special implementation of an {@link ArgumentMatcher}.
* This argument matcher stores the argument value so that you can use it later to perform assertions.
* This argument matcher stores the argument value so that you can use it later to perform assertions.
* <p>
* See examples in javadoc for {@link ArgumentCaptor} class.
*
*
* @return null or default values
*/
public T capture() {
Expand All @@ -90,7 +90,7 @@ public T capture() {
* If verified method was called multiple times then this method it returns the latest captured value.
* <p>
* See examples in javadoc for {@link ArgumentCaptor} class.
*
*
* @return captured argument value
*/
public T getValue() {
Expand All @@ -101,14 +101,14 @@ public T getValue() {
* Returns all captured values. Use it when capturing varargs or when the verified method was called multiple times.
* When varargs method was called multiple times, this method returns merged list of all values from all invocations.
* <p>
* Example:
* Example:
* <pre class="code"><code class="java">
* mock.doSomething(new Person("John");
* mock.doSomething(new Person("Jane");
*
* ArgumentCaptor&lt;Person&gt; peopleCaptor = ArgumentCaptor.forClass(Person.class);
* verify(mock, times(2)).doSomething(peopleCaptor.capture());
*
*
* List&lt;Person&gt; capturedPeople = peopleCaptor.getAllValues();
* assertEquals("John", capturedPeople.get(0).getName());
* assertEquals("Jane", capturedPeople.get(1).getName());
Expand All @@ -126,7 +126,7 @@ public T getValue() {
* assertEquals(expected, peopleCaptor.getAllValues());
* </code></pre>
* See more examples in javadoc for {@link ArgumentCaptor} class.
*
*
* @return captured argument value
*/
public List<T> getAllValues() {
Expand All @@ -148,4 +148,4 @@ public List<T> getAllValues() {
public static <U,S extends U> ArgumentCaptor<U> forClass(Class<S> clazz) {
return new ArgumentCaptor<U>(clazz);
}
}
}
40 changes: 20 additions & 20 deletions src/main/java/org/mockito/InOrder.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@

/**
* Allows verification in order. E.g:
*
*
* <pre class="code"><code class="java">
* InOrder inOrder = inOrder(firstMock, secondMock);
*
*
* inOrder.verify(firstMock).add("was called first");
* inOrder.verify(secondMock).add("was called second");
* </code></pre>
*
*
* As of Mockito 1.8.4 you can verifyNoMoreInteractions() in order-sensitive way. Read more: {@link InOrder#verifyNoMoreInteractions()}
* <p>
*
*
* See examples in javadoc for {@link Mockito} class
*/
public interface InOrder {
Expand All @@ -31,60 +31,60 @@ public interface InOrder {
* Example:
* <pre class="code"><code class="java">
* InOrder inOrder = inOrder(firstMock, secondMock);
*
*
* inOrder.verify(firstMock).someMethod("was called first");
* inOrder.verify(secondMock).someMethod("was called second");
* </code></pre>
*
*
* See examples in javadoc for {@link Mockito} class
*
*
* @param mock to be verified
*
*
* @return mock object itself
*/
<T> T verify(T mock);

/**
* Verifies interaction in order. E.g:
*
*
* <pre class="code"><code class="java">
* InOrder inOrder = inOrder(firstMock, secondMock);
*
*
* inOrder.verify(firstMock, times(2)).someMethod("was called first two times");
* inOrder.verify(secondMock, atLeastOnce()).someMethod("was called second at least once");
* </code></pre>
*
*
* See examples in javadoc for {@link Mockito} class
*
*
* @param mock to be verified
* @param mode for example times(x) or atLeastOnce()
*
*
* @return mock object itself
*/
<T> T verify(T mock, VerificationMode mode);


/**
* Verifies that no more interactions happened <b>in order</b>.
* Verifies that no more interactions happened <b>in order</b>.
* Different from {@link Mockito#verifyNoMoreInteractions(Object...)} because the order of verification matters.
* <p>
* Example:
* <pre class="code"><code class="java">
* mock.foo(); //1st
* mock.bar(); //2nd
* mock.baz(); //3rd
*
*
* InOrder inOrder = inOrder(mock);
*
*
* inOrder.verify(mock).bar(); //2n
* inOrder.verify(mock).baz(); //3rd (last method)
*
*
* //passes because there are no more interactions after last method:
* inOrder.verifyNoMoreInteractions();
*
*
* //however this fails because 1st method was not verified:
* Mockito.verifyNoMoreInteractions(mock);
* </code></pre>
*/
void verifyNoMoreInteractions();
}
}
2 changes: 1 addition & 1 deletion src/main/java/org/mockito/Mock.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,6 @@
String name() default "";

Class<?>[] extraInterfaces() default {};

boolean serializable() default false;
}
4 changes: 2 additions & 2 deletions src/main/java/org/mockito/MockingDetails.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* @since 1.9.5
*/
public interface MockingDetails {

/**
* Informs if the object is a mock. isMock() for null input returns false.
* @return true if the object is a mock or a spy (spy is a different kind of mock, but it is still a mock).
Expand All @@ -35,7 +35,7 @@ public interface MockingDetails {
* @since 1.9.5
*/
boolean isSpy();

/**
* All method invocations on this mock.
* Can be empty - it means there were no interactions with the mock.
Expand Down
24 changes: 12 additions & 12 deletions src/main/java/org/mockito/MockitoAnnotations.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,30 @@
* MockitoAnnotations.initMocks(this); initializes fields annotated with Mockito annotations.
* See also {@link MockitoSession} which not only initializes mocks
* but also adds extra validation for cleaner tests!
* <p>
* <p>
* <ul>
* <li>Allows shorthand creation of objects required for testing.</li>
* <li>Minimizes repetitive mock creation code.</li>
* <li>Allows shorthand creation of objects required for testing.</li>
* <li>Minimizes repetitive mock creation code.</li>
* <li>Makes the test class more readable.</li>
* <li>Makes the verification error easier to read because <b>field name</b> is used to identify the mock.</li>
* </ul>
*
*
* <pre class="code"><code class="java">
* public class ArticleManagerTest extends SampleBaseTestCase {
*
* public class ArticleManagerTest extends SampleBaseTestCase {
*
* &#064;Mock private ArticleCalculator calculator;
* &#064;Mock private ArticleDatabase database;
* &#064;Mock private UserProvider userProvider;
*
*
* private ArticleManager manager;
*
*
* &#064;Before public void setup() {
* manager = new ArticleManager(userProvider, database, calculator);
* }
* }
*
*
* public class SampleBaseTestCase {
*
*
* &#064;Before public void initMocks() {
* MockitoAnnotations.initMocks(this);
* }
Expand All @@ -48,15 +48,15 @@
* <p>
* <b><code>MockitoAnnotations.initMocks(this)</code></b> method has to called to initialize annotated fields.
* <p>
* In above example, <code>initMocks()</code> is called in &#064;Before (JUnit4) method of test's base class.
* In above example, <code>initMocks()</code> is called in &#064;Before (JUnit4) method of test's base class.
* For JUnit3 <code>initMocks()</code> can go to <code>setup()</code> method of a base class.
* You can also put initMocks() in your JUnit runner (&#064;RunWith) or use built-in runner: {@link MockitoJUnitRunner}
*/
public class MockitoAnnotations {

/**
* Initializes objects annotated with Mockito annotations for given testClass:
* &#064;{@link org.mockito.Mock}, &#064;{@link Spy}, &#064;{@link Captor}, &#064;{@link InjectMocks}
* &#064;{@link org.mockito.Mock}, &#064;{@link Spy}, &#064;{@link Captor}, &#064;{@link InjectMocks}
* <p>
* See examples in javadoc for {@link MockitoAnnotations} class.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/mockito/MockitoDebugger.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ public interface MockitoDebugger {
*/
@Deprecated
String printInvocations(Object ... mocks);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class DefaultMockitoConfiguration implements IMockitoConfiguration {
public Answer<Object> getDefaultAnswer() {
return new ReturnsEmptyValues();
}

/* (non-Javadoc)
* @see org.mockito.IMockitoConfiguration#getAnnotationEngine()
*/
Expand All @@ -41,6 +41,6 @@ public boolean cleansStackTrace() {
public boolean enableClassCache() {
return true;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*
* <p>
* In most cases you don't really need to configure Mockito. For example in case of working with legacy code,
* when you might want to have different 'mocking style' this interface might be helpful.
* when you might want to have different 'mocking style' this interface might be helpful.
* A reason of configuring Mockito might be if you disagree with the {@link org.mockito.Answers#RETURNS_DEFAULTS}
* unstubbed mocks return.
*
Expand Down Expand Up @@ -41,7 +41,7 @@ public interface IMockitoConfiguration {
* Allows configuring the default answers of unstubbed invocations
* <p>
* See javadoc for {@link IMockitoConfiguration}
*/
*/
Answer<Object> getDefaultAnswer();

/**
Expand All @@ -68,13 +68,13 @@ public interface IMockitoConfiguration {
* Mockito developers)
* <p>
* See javadoc for {@link IMockitoConfiguration}
*
*
* @return if Mockito should clean stack traces
*/
boolean cleansStackTrace();

/**
* Allow objenesis to cache classes. If you're in an environment where classes
* Allow objenesis to cache classes. If you're in an environment where classes
* are dynamically reloaded, you can disable this to avoid classcast exceptions.
*/
boolean enableClassCache();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ public MockitoAssertionError(String message) {
super(message);

unfilteredStackTrace = getStackTrace();

ConditionalStackTraceFilter filter = new ConditionalStackTraceFilter();
filter.filter(this);
}

/**
* Creates a copy of the given assertion error with the custom failure message prepended.
* @param error The assertion error to copy
Expand All @@ -50,4 +50,4 @@ public MockitoAssertionError(MockitoAssertionError error, String message) {
public StackTraceElement[] getUnfilteredStackTrace() {
return unfilteredStackTrace;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public MockitoException(String message) {

private void filterStackTrace() {
unfilteredStackTrace = getStackTrace();

ConditionalStackTraceFilter filter = new ConditionalStackTraceFilter();
filter.filter(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ public MockitoInitializationException(String message) {
public MockitoInitializationException(String message, Throwable cause) {
super(message, cause);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ public class FriendlyReminderException extends MockitoException {
public FriendlyReminderException(String message) {
super(message);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ public InvalidUseOfMatchersException(String message) {
public InvalidUseOfMatchersException() {
super("");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ public MockitoConfigurationException(String message) {
public MockitoConfigurationException(String message, Exception cause) {
super(message, cause);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import org.mockito.exceptions.base.MockitoException;

public class UnfinishedVerificationException extends MockitoException {

private static final long serialVersionUID = 1L;

public UnfinishedVerificationException(String message) {
Expand Down
Loading

0 comments on commit e9516f4

Please sign in to comment.