-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#18] Added unit and integration tests for example
Did some refactorings like renaming too.
- Loading branch information
1 parent
10d38fb
commit 844a796
Showing
11 changed files
with
147 additions
and
22 deletions.
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
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
76 changes: 76 additions & 0 deletions
76
...rtoolkit/annotationprocessor/ImplementsSpecificInterfaceCheckAnnotationProcessorTest.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,76 @@ | ||
package io.toolisticon.example.annotationprocessortoolkit.annotationprocessor; | ||
|
||
import io.toolisticon.annotationprocessortoolkit.testhelper.AbstractAnnotationProcessorIntegrationTest; | ||
import io.toolisticon.annotationprocessortoolkit.testhelper.integrationtest.AnnotationProcessorIntegrationTestConfiguration; | ||
import io.toolisticon.annotationprocessortoolkit.testhelper.integrationtest.AnnotationProcessorIntegrationTestConfigurationBuilder; | ||
import io.toolisticon.annotationprocessortoolkit.tools.corematcher.CoreMatcherValidationMessages; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.Parameterized; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
/** | ||
* Integration test for {@link ImplementsSpecificInterfaceCheckAnnotationProcessor}. | ||
*/ | ||
@RunWith(Parameterized.class) | ||
public class ImplementsSpecificInterfaceCheckAnnotationProcessorTest extends AbstractAnnotationProcessorIntegrationTest<ImplementsSpecificInterfaceCheckAnnotationProcessor> { | ||
|
||
public ImplementsSpecificInterfaceCheckAnnotationProcessorTest(String description, AnnotationProcessorIntegrationTestConfiguration annotationProcessorIntegrationTestConfiguration) { | ||
super(annotationProcessorIntegrationTestConfiguration); | ||
} | ||
|
||
@Override | ||
protected ImplementsSpecificInterfaceCheckAnnotationProcessor getAnnotationProcessor() { | ||
return new ImplementsSpecificInterfaceCheckAnnotationProcessor(); | ||
} | ||
|
||
@Before | ||
public void init() { | ||
CoreMatcherValidationMessages.setPrintMessageCodes(true); | ||
} | ||
|
||
@Parameterized.Parameters(name = "{index}: \"{0}\"") | ||
public static List<Object[]> data() { | ||
|
||
return Arrays.asList(new Object[][]{ | ||
{ | ||
"Test valid usage : implements", | ||
AnnotationProcessorIntegrationTestConfigurationBuilder.createTestConfig() | ||
.setSourceFileToCompile("testcases/implementsSpecificInterfaceCheckAnnotationProcessor/ValidUsageTest.java") | ||
.compilationShouldSucceed() | ||
.build() | ||
}, | ||
{ | ||
"Test invalid usage : extends ", | ||
AnnotationProcessorIntegrationTestConfigurationBuilder.createTestConfig() | ||
.setSourceFileToCompile("testcases/implementsSpecificInterfaceCheckAnnotationProcessor/ValidUsageTestExtendsCase.java") | ||
.compilationShouldSucceed() | ||
.build() | ||
}, | ||
{ | ||
"Test invalid usage : non String parameter", | ||
AnnotationProcessorIntegrationTestConfigurationBuilder.createTestConfig() | ||
.setSourceFileToCompile("testcases/implementsSpecificInterfaceCheckAnnotationProcessor/InvalidUsageTest.java") | ||
.compilationShouldFail() | ||
.addMessageValidator() | ||
.setErrorChecks(CoreMatcherValidationMessages.IS_ASSIGNABLE_TO.getCode()) | ||
.finishMessageValidator() | ||
.build() | ||
}, | ||
|
||
|
||
}); | ||
|
||
} | ||
|
||
|
||
@Test | ||
public void test() { | ||
super.test(); | ||
} | ||
|
||
|
||
} |
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
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
11 changes: 11 additions & 0 deletions
11
...urces/testcases/implementsSpecificInterfaceCheckAnnotationProcessor/InvalidUsageTest.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,11 @@ | ||
package io.toolisticon.example.annotationprocessortoolkit; | ||
|
||
import io.toolisticon.example.annotationprocessortoolkit.annotations.ImplementsSpecificInterfaceCheckAnnotation; | ||
import io.toolisticon.example.annotationprocessortoolkit.annotations.MethodWithOneStringParameterAndVoidReturnTypeAnnotation; | ||
import io.toolisticon.example.annotationprocessortoolkit.annotations.SpecificInterface; | ||
|
||
@ImplementsSpecificInterfaceCheckAnnotation | ||
public class InvalidUsageTest { | ||
|
||
|
||
} |
15 changes: 15 additions & 0 deletions
15
...sources/testcases/implementsSpecificInterfaceCheckAnnotationProcessor/ValidUsageTest.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,15 @@ | ||
package io.toolisticon.example.annotationprocessortoolkit; | ||
|
||
import io.toolisticon.example.annotationprocessortoolkit.annotations.ImplementsSpecificInterfaceCheckAnnotation; | ||
import io.toolisticon.example.annotationprocessortoolkit.annotations.MethodWithOneStringParameterAndVoidReturnTypeAnnotation; | ||
import io.toolisticon.example.annotationprocessortoolkit.annotations.SpecificInterface; | ||
|
||
@ImplementsSpecificInterfaceCheckAnnotation | ||
public class ValidUsageTest implements SpecificInterface{ | ||
|
||
|
||
public String testMethod() { | ||
return null; | ||
} | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
...tcases/implementsSpecificInterfaceCheckAnnotationProcessor/ValidUsageTestExtendsCase.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,23 @@ | ||
package io.toolisticon.example.annotationprocessortoolkit; | ||
|
||
import io.toolisticon.example.annotationprocessortoolkit.annotations.ImplementsSpecificInterfaceCheckAnnotation; | ||
import io.toolisticon.example.annotationprocessortoolkit.annotations.SpecificInterface; | ||
|
||
|
||
public class ValidUsageTestExtendsCase { | ||
|
||
public static class SuperClass implements SpecificInterface { | ||
|
||
public String testMethod() { | ||
return null; | ||
} | ||
|
||
} | ||
|
||
|
||
@ImplementsSpecificInterfaceCheckAnnotation | ||
public static class SubClass extends SuperClass { | ||
|
||
} | ||
|
||
} |
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
2 changes: 1 addition & 1 deletion
2
...sortoolkit/annotations/SomeInterface.java → ...oolkit/annotations/SpecificInterface.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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
package io.toolisticon.example.annotationprocessortoolkit.annotations; | ||
|
||
|
||
public interface SomeInterface { | ||
public interface SpecificInterface { | ||
String testMethod(); | ||
} |
8 changes: 4 additions & 4 deletions
8
...se/src/main/java/io/toolisticon/example/annotationprocessortoolkit/usecase/TestClass.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