コード例 #1
0
 /**
  * Verifies that the actual value is not exactly a instance of given type.
  *
  * @param info contains information about the assertion.
  * @param actual the given object.
  * @param type the type to check the actual value against.
  * @throws AssertionError if the actual is exactly a instance of given type.
  * @throws NullPointerException if the actual value is null.
  * @throws NullPointerException if the given object is null.
  */
 public void assertIsNotExactlyInstanceOf(AssertionInfo info, Object actual, Class<?> type) {
   assertNotNull(info, actual);
   if (type == null) throw new NullPointerException("The given type should not be null");
   Class<?> current = actual.getClass();
   if (!type.equals(current)) return;
   throw failures.failure(info, shouldNotBeExactlyInstance(actual, type));
 }
コード例 #2
0
 /**
  * Verifies that the actual value does not have the same class as the given object.
  *
  * @param info contains information about the assertion.
  * @param actual the given object.
  * @param other the object to check type against.
  * @throws AssertionError if the actual has the same type has the given object.
  * @throws NullPointerException if the actual value is null.
  * @throws NullPointerException if the given object is null.
  */
 public void assertDoesNotHaveSameClassAs(AssertionInfo info, Object actual, Object other) {
   assertNotNull(info, actual);
   if (other == null) throw new NullPointerException("The given object should not be null");
   Class<?> actualClass = actual.getClass();
   Class<?> otherClass = other.getClass();
   if (!actualClass.equals(otherClass)) return;
   throw failures.failure(info, shouldNotHaveSameClass(actual, other));
 }