Skip to content

Commit

Permalink
Add a lot of javadoc which also makes the Java 21 javadoc compiler wa…
Browse files Browse the repository at this point in the history
…y happier
  • Loading branch information
henri-tremblay committed Aug 29, 2023
1 parent cef55f3 commit e4824ab
Show file tree
Hide file tree
Showing 54 changed files with 215 additions and 21 deletions.
2 changes: 1 addition & 1 deletion core/src/main/java/org/easymock/CaptureType.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
package org.easymock;

/**
* Defines how arguments will be captured by a <tt>Capture</tt> object.
* Defines how arguments will be captured by a {@link Capture} object.
*
* @author Henri Tremblay
* @see Capture
Expand Down
5 changes: 5 additions & 0 deletions core/src/main/java/org/easymock/internal/AndroidSupport.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ public final class AndroidSupport {
}
}

/**
* Returns true if the current platform is Android.
*
* @return true if running on Android
*/
public static boolean isAndroid() {
return isAndroid;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
package org.easymock.internal;

/**
* Wraps an AssertionError that was thrown by a method invocation so that EasyMock knows the difference between an invocation
* exception and an real unexpected one.
*
* @author OFFIS, Tammo Freese
*/
public class AssertionErrorWrapper extends RuntimeException {
Expand Down
10 changes: 5 additions & 5 deletions core/src/main/java/org/easymock/internal/EasyMockProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* <li>easymock.properties in classpath default package</li>
* <li>explicit call to setProperty</li>
* </ul>
*
*
* @author Henri Tremblay
*/
public final class EasyMockProperties {
Expand Down Expand Up @@ -78,7 +78,7 @@ private void loadEasyMockProperties(String propertyFileName) {
/**
* Searches for the property with the specified key. If the key is not
* found, return the default value.
*
*
* @param key
* key leading to the property
* @param defaultValue
Expand All @@ -92,7 +92,7 @@ public String getProperty(String key, String defaultValue) {
/**
* Searches for the property with the specified key. Return null if the key
* is not found.
*
*
* @param key
* key leading to the property
* @return the value found for the key or null
Expand All @@ -104,11 +104,11 @@ public String getProperty(String key) {
/**
* Add a value referenced by the provided key. A null value will remove the
* key
*
*
* @param key
* the key of the new property
* @param value
* the value corresponding to <tt>key</tt>.
* the value corresponding to <code>key</code>.
* @return the property previous value
*/
public String setProperty(String key, String value) {
Expand Down
24 changes: 24 additions & 0 deletions core/src/main/java/org/easymock/internal/ErrorMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
package org.easymock.internal;

/**
* The full content of an error message reporting to the user.
*
* @author OFFIS, Tammo Freese
*/
public class ErrorMessage {
Expand All @@ -32,18 +34,40 @@ public ErrorMessage(boolean matching, String message, int actualCount) {
this.actualCount = actualCount;
}

/**
* If the actual invocation matched the expected invocation. It will be used to write the final error message telling
* that some recording are matching but were already used.
*
* @return if the actual invocation matched the expected invocation
*/
public boolean isMatching() {
return matching;
}

/**
* The actual invocation and its result.
*
* @return the actual invocation and its result
*/
public String getMessage() {
return message;
}

/**
* How many time an expected invocation was actually invoked.
*
* @return how many time an expected invocation was actually invoked
*/
public int getActualCount() {
return actualCount;
}

/**
* Add the error message to the buffer.
*
* @param buffer the buffer to append to
* @param matches how many times an actual invocation matched expected invocation
*/
public void appendTo(StringBuilder buffer, int matches) {
buffer.append("\n ").append(message).append(", actual: ");
if (matching) {
Expand Down
11 changes: 9 additions & 2 deletions core/src/main/java/org/easymock/internal/ExpectedInvocation.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import java.util.List;

/**
* One expected invocation. It is composed of the method invoked and the matchers used to expect the arguments.
*
* @author OFFIS, Tammo Freese
*/
public class ExpectedInvocation implements Serializable {
Expand All @@ -46,8 +48,7 @@ private List<IArgumentMatcher> createMissingMatchers(Invocation invocation,
if (matchers != null) {
if (matchers.size() != invocation.getArguments().length) {
throw new IllegalStateException(
""
+ invocation.getArguments().length
invocation.getArguments().length
+ " matchers expected, "
+ matchers.size()
+ " recorded.\n"
Expand Down Expand Up @@ -87,6 +88,12 @@ public int hashCode() {
throw new UnsupportedOperationException("hashCode() is not implemented");
}

/**
* Tells if the actual invocation matches this expected invocation. It needs to be on the same mock, method and
* have the same arguments.
*
* @return the invocation to compare
*/
public boolean matches(Invocation actual) {
return this.invocation.getMock() == actual.getMock()
&& this.invocation.getMethod().equals(actual.getMethod()) && matches(actual.getArguments());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import java.io.Serializable;

/**
* One expected invocation and its result.
*
* @author OFFIS, Tammo Freese
*/
public class ExpectedInvocationAndResult implements Serializable {
Expand All @@ -40,4 +42,4 @@ public ExpectedInvocation getExpectedInvocation() {
public Result getResult() {
return result;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import java.io.Serializable;

/**
* The pair of an expected invocation and its results.
*
* @author OFFIS, Tammo Freese
*/
public class ExpectedInvocationAndResults implements Serializable {
Expand Down Expand Up @@ -45,4 +47,4 @@ public Results getResults() {
public String toString() {
return expectedInvocation.toString() + ": " + results.toString();
}
}
}
2 changes: 2 additions & 0 deletions core/src/main/java/org/easymock/internal/IMocksBehavior.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
package org.easymock.internal;

/**
* The behavior of a mock. I.e. ordered or not, thread safe or not, expectations, etc.
*
* @author OFFIS, Tammo Freese
*/
public interface IMocksBehavior {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import org.easymock.IAnswer;

/**
* Current state of a mocks control. In practice there are two implementations: record and replay.
*
* @author OFFIS, Tammo Freese
*/
public interface IMocksControlState {
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/java/org/easymock/internal/IProxyFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
import java.lang.reflect.Method;

/**
* Reponsible of creating proxies for objects. The implementation used for an object to proxy depends on its type but also
* on the JVM we are running.
*
* @author OFFIS, Tammo Freese
*/
public interface IProxyFactory {
Expand Down
17 changes: 17 additions & 0 deletions core/src/main/java/org/easymock/internal/Invocation.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import static java.lang.Character.*;

/**
* Represents a method invocation on a mock object. It's used for record one or for actual calls.
*
* @author OFFIS, Tammo Freese
*/
public class Invocation implements Serializable {
Expand Down Expand Up @@ -76,14 +78,29 @@ private static Object[] createObjectArray(Object array) {
return result;
}

/**
* Returns the mock object on which the invocation was performed.
*
* @return the mock object on which the invocation was performed.
*/
public Object getMock() {
return mock;
}

/**
* Returns the method invoked on the mock object.
*
* @return the method invoked on the mock object.
*/
public Method getMethod() {
return method;
}

/**
* Returns the arguments passed to the method invocation.
*
* @return the arguments passed to the method invocation.
*/
public Object[] getArguments() {
return arguments;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import org.easymock.ConstructorArgs;

/**
* Proxy factory creating proxies from an interface using the standard JDK proxy API.
*
* @author OFFIS, Tammo Freese
*/
public class JavaProxyFactory implements IProxyFactory {
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/java/org/easymock/internal/LastControl.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import org.easymock.internal.matchers.Or;

/**
* The last mocks control used in the current thread.
*
* @author OFFIS, Tammo Freese
*/
public final class LastControl {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import java.util.Map;

/**
* Wrapper used to serialize a <code>java.lang.reflect.Method</code> object when a mock is serialized.
*
* @author Henri Tremblay
*/
public class MethodSerializationWrapper implements Serializable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import java.lang.reflect.Method;

/**
* The handler of all invocations on a mock interface.
*
* @author OFFIS, Tammo Freese
*/
public final class MockInvocationHandler implements InvocationHandler, Serializable {
Expand Down Expand Up @@ -51,4 +53,4 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl
public MocksControl getControl() {
return control;
}
}
}
2 changes: 2 additions & 0 deletions core/src/main/java/org/easymock/internal/MocksBehavior.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import java.util.concurrent.atomic.AtomicInteger;

/**
* Default implementation of {@link IMocksBehavior}. It keeps the full behavior of mocks from the same {@link org.easymock.IMocksControl}.
*
* @author OFFIS, Tammo Freese
*/
public class MocksBehavior implements IMocksBehavior, Serializable {
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/java/org/easymock/internal/MocksControl.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
import java.util.Set;

/**
* Controls all the mocks created by {@link EasyMock}. It contains the state of the mocks.
*
* @author OFFIS, Tammo Freese
*/
public class MocksControl implements IMocksControl, IExpectationSetters<Object>, Serializable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
import java.util.function.Predicate;

/**
* The filter catching all calls to the mock. It handles <code>equals</code>, <code>hashCode</code>, <code>toString</code>,
* and <code>finalize</code> in a special way. Then, for other calls, it delegates to the mock handler.
*
* @author OFFIS, Tammo Freese
* @author Henri Tremblay
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import org.objenesis.ObjenesisHelper;

/**
* Class instantiator using Objenesis to perform the instantiation without calling any constructor.
*
* @author Henri Tremblay
*/
public class ObjenesisClassInstantiator implements IClassInstantiator {
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/java/org/easymock/internal/PrimitiveUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import java.util.Map;

/**
* Helper class for primitive types.
*
* @author Henri Tremblay
*/
public final class PrimitiveUtils {
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/java/org/easymock/internal/Range.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import java.io.Serializable;

/**
* The range of a number of invocations. It knows the expected minimum and maximum number of invocations.
*
* @author OFFIS, Tammo Freese
*/
public class Range implements Serializable {
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/java/org/easymock/internal/RecordState.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import java.util.List;

/**
* State in which a mock is recording its behavior.
*
* @author OFFIS, Tammo Freese
*/
public class RecordState implements IMocksControlState, Serializable {
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/java/org/easymock/internal/ReflectionUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import java.util.stream.Collectors;

/**
* Helper class for reflection.
*
* @author Henri Tremblay
*/
public final class ReflectionUtils {
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/java/org/easymock/internal/ReplayState.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
import java.util.concurrent.locks.ReentrantLock;

/**
* A mock has two states, record and replay. This class handles the replay state where we return all recorded invocation
* for a method call on a mock.
*
* @author OFFIS, Tammo Freese
*/
public class ReplayState implements IMocksControlState, Serializable {
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/java/org/easymock/internal/Result.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import java.lang.reflect.Method;

/**
* The result of an invocation on a mock. It can be a direct constant or the result of some computation.
*
* @author OFFIS, Tammo Freese
*/
public final class Result implements IAnswer<Object>, Serializable {
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/java/org/easymock/internal/Results.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
import java.util.List;

/**
* The results of a specific call on a mock. It's plural because a specific call can be called multiple times and so
* will return multiple results.
*
* @author OFFIS, Tammo Freese
*/
public class Results implements Serializable {
Expand Down
Loading

0 comments on commit e4824ab

Please sign in to comment.