Skip to content

Commit

Permalink
[#18] Enhanced some unit tests for AbstractAnnotationProcessor
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasstamann committed Apr 13, 2018
1 parent de12136 commit 723e80a
Showing 1 changed file with 80 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package io.toolisticon.annotationprocessortoolkit;

import io.toolisticon.annotationprocessortoolkit.tools.corematcher.CoreMatchers;
import io.toolisticon.annotationprocessortoolkit.testhelper.AbstractAnnotationProcessorUnitTest;
import io.toolisticon.annotationprocessortoolkit.testhelper.unittest.AbstractUnitTestAnnotationProcessorClass;
import io.toolisticon.annotationprocessortoolkit.testhelper.unittest.AnnotationProcessorUnitTestConfiguration;
import io.toolisticon.annotationprocessortoolkit.testhelper.unittest.AnnotationProcessorUnitTestConfigurationBuilder;
import io.toolisticon.annotationprocessortoolkit.testhelper.unittest.TestAnnotation;
import io.toolisticon.annotationprocessortoolkit.tools.corematcher.CoreMatchers;
import io.toolisticon.annotationprocessortoolkit.tools.fluentfilter.FluentElementFilter;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
Expand Down Expand Up @@ -64,6 +65,84 @@ protected void testCase(TypeElement element) {

},

{
"createSupportedAnnotationSet : without parameters",
AnnotationProcessorUnitTestConfigurationBuilder.createTestConfig()
.compilationShouldSucceed()
.setProcessor(new AbstractUnitTestAnnotationProcessorClass() {
@Override
protected void testCase(TypeElement element) {

MatcherAssert.assertThat(AbstractAnnotationProcessor.createSupportedAnnotationSet(), Matchers.<String>empty());

}
}
)
.build()


},

{
"createSupportedAnnotationSet : with parameters",
AnnotationProcessorUnitTestConfigurationBuilder.createTestConfig()
.compilationShouldSucceed()
.setProcessor(new AbstractUnitTestAnnotationProcessorClass() {
@Override
protected void testCase(TypeElement element) {

MatcherAssert.assertThat(AbstractAnnotationProcessor.createSupportedAnnotationSet(Override.class, TestAnnotation.class), Matchers.contains(Override.class.getCanonicalName(), TestAnnotation.class.getCanonicalName()));

}
}
)
.build()


},

{
"createSupportedAnnotationSet : with null value parameters",
AnnotationProcessorUnitTestConfigurationBuilder.createTestConfig()
.compilationShouldSucceed()
.setProcessor(new AbstractUnitTestAnnotationProcessorClass() {
@Override
protected void testCase(TypeElement element) {

MatcherAssert.assertThat(AbstractAnnotationProcessor.createSupportedAnnotationSet(null), Matchers.<String>empty());
MatcherAssert.assertThat(AbstractAnnotationProcessor.createSupportedAnnotationSet(Override.class, null, TestAnnotation.class), Matchers.contains(Override.class.getCanonicalName(), TestAnnotation.class.getCanonicalName()));

}
}
)
.build()


},

{
"wrapToArray : with null value parameters",
AnnotationProcessorUnitTestConfigurationBuilder.createTestConfig()
.compilationShouldSucceed()
.setProcessor(new AbstractUnitTestAnnotationProcessorClass() {
@Override
protected void testCase(TypeElement element) {

MatcherAssert.assertThat("Should return null",AbstractAnnotationProcessor.wrapToArray((String) null)[0] == null);

Class[] resultArray = AbstractAnnotationProcessor.wrapToArray(Override.class, null, TestAnnotation.class);
MatcherAssert.assertThat(Arrays.asList(resultArray), Matchers.hasSize(3));
MatcherAssert.assertThat(resultArray[0], Matchers.equalTo((Class) Override.class));
MatcherAssert.assertThat(resultArray[1], Matchers.nullValue());
MatcherAssert.assertThat(resultArray[2], Matchers.equalTo((Class) TestAnnotation.class));

}
}
)
.build()


},

/*-
{
Expand Down

0 comments on commit 723e80a

Please sign in to comment.