Package com.google.common.testing
Class ClassSanityTester.FactoryMethodReturnValueTester
- java.lang.Object
-
- com.google.common.testing.ClassSanityTester.FactoryMethodReturnValueTester
-
- Enclosing class:
- ClassSanityTester
public final class ClassSanityTester.FactoryMethodReturnValueTester extends java.lang.Object
Runs sanity tests against return values of static factory methods declared by a class.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Class<?>
declaringClass
private ImmutableList<Invokable<?,?>>
factories
private java.lang.String
factoryMethodsDescription
private java.util.Set<java.lang.String>
packagesToTest
private java.lang.Class<?>
returnTypeToTest
-
Constructor Summary
Constructors Modifier Constructor Description private
FactoryMethodReturnValueTester(java.lang.Class<?> declaringClass, ImmutableList<Invokable<?,?>> factories, java.lang.String factoryMethodsDescription)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private ImmutableList<Invokable<?,?>>
getFactoriesToTest()
ClassSanityTester.FactoryMethodReturnValueTester
testEquals()
TestsObject.equals(java.lang.Object)
andObject.hashCode()
against the return values of the static methods, by asserting that when equal parameters are passed to the same static method, the return value should also be equal; and vice versa.ClassSanityTester.FactoryMethodReturnValueTester
testEqualsAndSerializable()
Runs equals and serialization test on the return values.ClassSanityTester.FactoryMethodReturnValueTester
testNulls()
Tests null checks against the instance methods of the return values, if any.ClassSanityTester.FactoryMethodReturnValueTester
testSerializable()
Runs serialization test on the return values of the static methods.ClassSanityTester.FactoryMethodReturnValueTester
thatReturn(java.lang.Class<?> returnType)
Specifies that only the methods that are declared to returnreturnType
or its subtype are tested.
-
-
-
Field Detail
-
packagesToTest
private final java.util.Set<java.lang.String> packagesToTest
-
declaringClass
private final java.lang.Class<?> declaringClass
-
factories
private final ImmutableList<Invokable<?,?>> factories
-
factoryMethodsDescription
private final java.lang.String factoryMethodsDescription
-
returnTypeToTest
private java.lang.Class<?> returnTypeToTest
-
-
Constructor Detail
-
FactoryMethodReturnValueTester
private FactoryMethodReturnValueTester(java.lang.Class<?> declaringClass, ImmutableList<Invokable<?,?>> factories, java.lang.String factoryMethodsDescription)
-
-
Method Detail
-
thatReturn
public ClassSanityTester.FactoryMethodReturnValueTester thatReturn(java.lang.Class<?> returnType)
Specifies that only the methods that are declared to returnreturnType
or its subtype are tested.- Returns:
- this tester object
-
testNulls
public ClassSanityTester.FactoryMethodReturnValueTester testNulls() throws java.lang.Exception
Tests null checks against the instance methods of the return values, if any.Test fails if default value cannot be determined for a constructor or factory method parameter, or if the constructor or factory method throws exception.
- Returns:
- this tester
- Throws:
java.lang.Exception
-
testEquals
public ClassSanityTester.FactoryMethodReturnValueTester testEquals() throws java.lang.Exception
TestsObject.equals(java.lang.Object)
andObject.hashCode()
against the return values of the static methods, by asserting that when equal parameters are passed to the same static method, the return value should also be equal; and vice versa.Test fails if default value cannot be determined for a constructor or factory method parameter, or if the constructor or factory method throws exception.
- Returns:
- this tester
- Throws:
java.lang.Exception
-
testSerializable
public ClassSanityTester.FactoryMethodReturnValueTester testSerializable() throws java.lang.Exception
Runs serialization test on the return values of the static methods.Test fails if default value cannot be determined for a constructor or factory method parameter, or if the constructor or factory method throws exception.
- Returns:
- this tester
- Throws:
java.lang.Exception
-
testEqualsAndSerializable
public ClassSanityTester.FactoryMethodReturnValueTester testEqualsAndSerializable() throws java.lang.Exception
Runs equals and serialization test on the return values.Test fails if default value cannot be determined for a constructor or factory method parameter, or if the constructor or factory method throws exception.
- Returns:
- this tester
- Throws:
java.lang.Exception
-
getFactoriesToTest
private ImmutableList<Invokable<?,?>> getFactoriesToTest()
-
-