Skip to content

Commit

Permalink
Remove useless test for @ValidateWith
Browse files Browse the repository at this point in the history
You cannot pass `null` as a class literal: @ValidateWith(null) results
in a compiler error.
  • Loading branch information
marcphilipp committed Dec 15, 2014
1 parent 2b61096 commit aacc443
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ public AnnotationValidator createAnnotationValidator(ValidateWith validateWithAn
}

Class<? extends AnnotationValidator> clazz = validateWithAnnotation.value();
if (clazz == null) {
throw new IllegalArgumentException("Can't create validator, value is null in annotation " + validateWithAnnotation.getClass().getName());
}
try {
AnnotationValidator annotationValidator = clazz.newInstance();
VALIDATORS_FOR_ANNOTATION_TYPES.putIfAbsent(validateWithAnnotation, annotationValidator);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
package org.junit.validator;

import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

import java.lang.annotation.Annotation;

import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsInstanceOf.instanceOf;
import static org.junit.Assert.assertThat;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

public class AnnotationValidatorFactoryTest {

Expand All @@ -22,26 +19,6 @@ public void createAnnotationValidator() {
assertThat(annotationValidator, is(instanceOf(Validator.class)));
}

@Test
public void exceptionWhenAnnotationWithNullClassIsPassedIn() {
exception.expect(IllegalArgumentException.class);
exception.expectMessage("Can't create validator, value is null in " +
"annotation org.junit.validator.AnnotationValidatorFactoryTest$ValidatorWithNullValue");

new AnnotationValidatorFactory().createAnnotationValidator(new ValidatorWithNullValue());
}


public static class ValidatorWithNullValue implements ValidateWith {
public Class<? extends AnnotationValidator> value() {
return null;
}

public Class<? extends Annotation> annotationType() {
return ValidateWith.class;
}
}

@ValidateWith(value = Validator.class)
public static class SampleTestWithValidator {
}
Expand Down

0 comments on commit aacc443

Please sign in to comment.