-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#2] Added additional unit test to test hasOf method of Validators
- Loading branch information
1 parent
dac2014
commit a0fcda8
Showing
2 changed files
with
131 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
130 changes: 130 additions & 0 deletions
130
...cessortoolkit/tools/characteristicsvalidator/GenericElementCharacteristicMatcherTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
package de.holisticon.annotationprocessortoolkit.tools.characteristicsvalidator; | ||
|
||
import org.hamcrest.MatcherAssert; | ||
import org.hamcrest.Matchers; | ||
import org.junit.Test; | ||
import org.mockito.Mockito; | ||
|
||
import javax.lang.model.element.Element; | ||
import javax.lang.model.element.Modifier; | ||
|
||
/** | ||
* Unit test of {@link GenericElementCharacteristicValidator}. | ||
*/ | ||
public class GenericElementCharacteristicMatcherTest { | ||
|
||
|
||
@Test | ||
public void testHasOf_OneOf() { | ||
|
||
GenericElementCharacteristicValidator<Modifier> spy = Mockito.spy((GenericElementCharacteristicValidator<Modifier>) Validator.getModifierValidator()); | ||
|
||
Element element = Mockito.mock(Element.class); | ||
spy.hasOf(ValidatorKind.ONE_OF, element, Modifier.ABSTRACT); | ||
|
||
Mockito.verify(spy).hasOneOf(element, Modifier.ABSTRACT); | ||
|
||
} | ||
|
||
@Test | ||
public void testHasOf_AtLeastOneOf() { | ||
|
||
GenericElementCharacteristicValidator<Modifier> spy = Mockito.spy((GenericElementCharacteristicValidator<Modifier>) Validator.getModifierValidator()); | ||
|
||
Element element = Mockito.mock(Element.class); | ||
spy.hasOf(ValidatorKind.AT_LEAST_ONE_OF, element, Modifier.ABSTRACT); | ||
|
||
Mockito.verify(spy).hasAtLeastOneOf(element, Modifier.ABSTRACT); | ||
|
||
} | ||
|
||
@Test | ||
public void testHasOf_AllOf() { | ||
|
||
GenericElementCharacteristicValidator<Modifier> spy = Mockito.spy((GenericElementCharacteristicValidator<Modifier>) Validator.getModifierValidator()); | ||
|
||
Element element = Mockito.mock(Element.class); | ||
spy.hasOf(ValidatorKind.ALL_OF, element, Modifier.ABSTRACT); | ||
|
||
Mockito.verify(spy).hasAllOf(element, Modifier.ABSTRACT); | ||
|
||
} | ||
|
||
@Test | ||
public void testHasOf_NoneOf() { | ||
|
||
GenericElementCharacteristicValidator<Modifier> spy = Mockito.spy((GenericElementCharacteristicValidator<Modifier>) Validator.getModifierValidator()); | ||
|
||
Element element = Mockito.mock(Element.class); | ||
spy.hasOf(ValidatorKind.NONE_OF, element, Modifier.ABSTRACT); | ||
|
||
Mockito.verify(spy).hasNoneOf(element, Modifier.ABSTRACT); | ||
|
||
} | ||
|
||
@Test | ||
public void testHasOf_nullValuedKind() { | ||
|
||
GenericElementCharacteristicValidator<Modifier> spy = Mockito.spy((GenericElementCharacteristicValidator<Modifier>) Validator.getModifierValidator()); | ||
|
||
Element element = Mockito.mock(Element.class); | ||
MatcherAssert.assertThat(spy.hasOf(null, element, Modifier.ABSTRACT), Matchers.is(false)); | ||
|
||
Mockito.verify(spy, Mockito.never()).hasNoneOf(element, Modifier.ABSTRACT); | ||
Mockito.verify(spy, Mockito.never()).hasOneOf(element, Modifier.ABSTRACT); | ||
Mockito.verify(spy, Mockito.never()).hasAtLeastOneOf(element, Modifier.ABSTRACT); | ||
Mockito.verify(spy, Mockito.never()).hasAllOf(element, Modifier.ABSTRACT); | ||
|
||
|
||
} | ||
|
||
@Test | ||
public void testHasOf_oneOf_nullValuedElement() { | ||
|
||
GenericElementCharacteristicValidator<Modifier> spy = Mockito.spy((GenericElementCharacteristicValidator<Modifier>) Validator.getModifierValidator()); | ||
|
||
MatcherAssert.assertThat(spy.hasOf(ValidatorKind.ONE_OF, null, Modifier.ABSTRACT), Matchers.is(false)); | ||
|
||
Mockito.verify(spy).hasOneOf(null, Modifier.ABSTRACT); | ||
|
||
|
||
} | ||
|
||
@Test | ||
public void testHasOf_atLeastOneOf_nullValuedElement() { | ||
|
||
GenericElementCharacteristicValidator<Modifier> spy = Mockito.spy((GenericElementCharacteristicValidator<Modifier>) Validator.getModifierValidator()); | ||
|
||
MatcherAssert.assertThat(spy.hasOf(ValidatorKind.AT_LEAST_ONE_OF, null, Modifier.ABSTRACT), Matchers.is(false)); | ||
|
||
Mockito.verify(spy).hasAtLeastOneOf(null, Modifier.ABSTRACT); | ||
|
||
|
||
} | ||
|
||
@Test | ||
public void testHasOf_allOf_nullValuedElement() { | ||
|
||
GenericElementCharacteristicValidator<Modifier> spy = Mockito.spy((GenericElementCharacteristicValidator<Modifier>) Validator.getModifierValidator()); | ||
|
||
MatcherAssert.assertThat(spy.hasOf(ValidatorKind.ALL_OF, null, Modifier.ABSTRACT), Matchers.is(false)); | ||
|
||
Mockito.verify(spy).hasAllOf(null, Modifier.ABSTRACT); | ||
|
||
|
||
} | ||
|
||
@Test | ||
public void testHasOf_noneOf_nullValuedElement() { | ||
|
||
GenericElementCharacteristicValidator<Modifier> spy = Mockito.spy((GenericElementCharacteristicValidator<Modifier>) Validator.getModifierValidator()); | ||
|
||
MatcherAssert.assertThat(spy.hasOf(ValidatorKind.NONE_OF, null, Modifier.ABSTRACT), Matchers.is(false)); | ||
|
||
Mockito.verify(spy).hasNoneOf(null, Modifier.ABSTRACT); | ||
|
||
|
||
} | ||
|
||
|
||
} |