-
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.
Added Cute Unit Test Implementations for Tests without passing in Ele…
…ments
- Loading branch information
1 parent
d71c389
commit 5571f36
Showing
2 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
...oolisticon/aptk/cute/APTKUnitTestProcessorForTestingAnnotationProcessorsWithouPassIn.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,48 @@ | ||
package io.toolisticon.aptk.cute; | ||
|
||
import io.toolisticon.aptk.common.ToolingProvider; | ||
import io.toolisticon.cute.UnitTestForTestingAnnotationProcessorsWithoutPassIn; | ||
|
||
import javax.annotation.processing.ProcessingEnvironment; | ||
import javax.annotation.processing.Processor; | ||
import javax.lang.model.element.Element; | ||
|
||
/** | ||
* Convenient unit test processor for testing annotation processors build with the APTK with toolisticon's cute framework. | ||
* | ||
* @param <PROCESSOR> The processor under test. init method will be called and {@link ToolingProvider} will be set. | ||
*/ | ||
public abstract class APTKUnitTestProcessorForTestingAnnotationProcessorsWithouPassIn<PROCESSOR extends Processor> implements UnitTestForTestingAnnotationProcessorsWithoutPassIn<PROCESSOR> { | ||
|
||
|
||
/** | ||
* The original unit test processor method. Contains logic to initialize the ToolingProvider. | ||
* Will be called by cute framework. Propagates call to aptkUnitTest method after initializations. | ||
* | ||
* @param processor The processor under test | ||
* @param processingEnvironment the processing environment | ||
*/ | ||
@Override | ||
public final void unitTest(PROCESSOR processor, ProcessingEnvironment processingEnvironment) { | ||
|
||
try { | ||
// do initializations | ||
ToolingProvider.setTooling(processingEnvironment); | ||
|
||
// propagate to unit test implementation | ||
this.aptkUnitTest(processor, processingEnvironment); | ||
|
||
} finally { | ||
ToolingProvider.clearTooling(); | ||
} | ||
|
||
} | ||
|
||
/** | ||
* The unit test method. | ||
* | ||
* @param unit the initialized processor under test | ||
* @param processingEnvironment the processingEnvironment | ||
*/ | ||
public abstract void aptkUnitTest(PROCESSOR unit, ProcessingEnvironment processingEnvironment); | ||
} |
38 changes: 38 additions & 0 deletions
38
cute/src/main/java/io/toolisticon/aptk/cute/APTKUnitTestProcessorWithoutPassIn.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,38 @@ | ||
package io.toolisticon.aptk.cute; | ||
|
||
import io.toolisticon.aptk.common.ToolingProvider; | ||
import io.toolisticon.cute.UnitTestWithoutPassIn; | ||
|
||
import javax.annotation.processing.ProcessingEnvironment; | ||
|
||
public abstract class APTKUnitTestProcessorWithoutPassIn implements UnitTestWithoutPassIn { | ||
|
||
/** | ||
* The original unit test processor method. Contains logic to initialize the ToolingProvider. | ||
* Will be called by cute framework. Propagates call to aptkUnitTest method after initializations. | ||
* | ||
* @param processingEnvironment the processing environment | ||
*/ | ||
@Override | ||
public final void unitTest(ProcessingEnvironment processingEnvironment) { | ||
|
||
try { | ||
// do initializations | ||
ToolingProvider.setTooling(processingEnvironment); | ||
|
||
// propagate to unit test implementation | ||
this.aptkUnitTest(processingEnvironment); | ||
|
||
} finally { | ||
ToolingProvider.clearTooling(); | ||
} | ||
|
||
} | ||
|
||
/** | ||
* The unit test method. | ||
* | ||
* @param processingEnvironment the processingEnvironment | ||
*/ | ||
public abstract void aptkUnitTest(ProcessingEnvironment processingEnvironment); | ||
} |