Skip to content

Commit a8580a8

Browse files
author
Tobias Stamann
committed
Reworked chained add processor
1 parent b6e795c commit a8580a8

File tree

3 files changed

+43
-14
lines changed

3 files changed

+43
-14
lines changed

cute/src/main/java/io/toolisticon/cute/CuteApi.java

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -297,21 +297,10 @@ public interface BlackBoxTestRootInterface {
297297

298298
}
299299

300-
public interface BlackBoxTestProcessorInterface
301-
{
302-
303-
/**
304-
* Allows you to add a single annotation processor used at black-box tests compilation.
305-
*
306-
* @param processor the annotation processor to use. null values are prohibited and will lead to a {@link io.toolisticon.fluapigen.validation.api.ValidatorException}.
307-
* @return the next fluent interface
308-
*/
309-
BlackBoxTestSourceFilesAndProcessorInterface processor(@FluentApiBackingBeanMapping(value = "processors") @NotNull Class<? extends Processor> processor);
310-
}
311300

312301

313302
@FluentApiInterface(CompilerTestBB.class)
314-
public interface BlackBoxTestProcessorsInterface extends BlackBoxTestProcessorInterface{
303+
public interface BlackBoxTestProcessorsInterface{
315304

316305
/**
317306
* Allows you to add annotation processors used at black-box tests compilation.
@@ -335,6 +324,14 @@ public interface BlackBoxTestProcessorsInterface extends BlackBoxTestProcessorIn
335324
BlackBoxTestSourceFilesInterface processors(@FluentApiBackingBeanMapping(value = "processors") @NotNull Iterable<Class<? extends Processor>> processors);
336325

337326

327+
/**
328+
* Allows you to add a single annotation processor used at black-box tests compilation.
329+
*
330+
* @param processor the annotation processor to use. null values are prohibited and will lead to a {@link io.toolisticon.fluapigen.validation.api.ValidatorException}.
331+
* @return the next fluent interface
332+
*/
333+
BlackBoxTestSourceFilesAndProcessorInterface processor(@FluentApiBackingBeanMapping(value = "processors") @NotNull Class<? extends Processor> processor);
334+
338335
/**
339336
* More obvious method not to use processors during compilation.
340337
* Same as calling processors without values.
@@ -348,7 +345,17 @@ default BlackBoxTestSourceFilesInterface noProcessors() {
348345
}
349346

350347
@FluentApiInterface(CompilerTestBB.class)
351-
public interface BlackBoxTestSourceFilesAndProcessorInterface extends BlackBoxTestProcessorInterface, BlackBoxTestSourceFilesInterface{}
348+
public interface BlackBoxTestSourceFilesAndProcessorInterface extends BlackBoxTestSourceFilesInterface{
349+
350+
/**
351+
* Allows you to add a single annotation processor used at black-box tests compilation.
352+
*
353+
* @param processor the annotation processor to use. null values are prohibited and will lead to a {@link io.toolisticon.fluapigen.validation.api.ValidatorException}.
354+
* @return the next fluent interface
355+
*/
356+
BlackBoxTestSourceFilesAndProcessorInterface andProcessor(@FluentApiBackingBeanMapping(value = "processors", action = MappingAction.ADD) @NotNull Class<? extends Processor> processor);
357+
358+
}
352359

353360
@FluentApiInterface(CompilerTestBB.class)
354361
public interface BlackBoxTestSourceFilesInterface {

cute/src/test/java/io/toolisticon/cute/CuteTest.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import io.toolisticon.cute.common.ExceptionThrowerProcessor;
44
import io.toolisticon.cute.common.SimpleTestProcessor1;
55
import io.toolisticon.cute.common.SimpleTestProcessor1Interface;
6+
import io.toolisticon.cute.common.SimpleTestProcessor2;
67
import io.toolisticon.cute.testcases.SimpleTestInterface;
78
import io.toolisticon.fluapigen.validation.api.ValidatorException;
89
import org.hamcrest.MatcherAssert;
@@ -20,6 +21,7 @@
2021
import javax.tools.StandardLocation;
2122
import java.io.IOException;
2223
import java.io.Writer;
24+
import java.lang.reflect.Field;
2325
import java.util.Arrays;
2426
import java.util.Collection;
2527
import java.util.Collections;
@@ -1168,7 +1170,7 @@ public void blackBoxTest_checkForExpectedException_failure_otherException() {
11681170
@Test
11691171
public void blackBoxTest_checkForExpectedException_failure_noException() {
11701172
try {
1171-
Cute.blackBoxTest().given().processor(SimpleTestProcessor1.class)
1173+
Cute.blackBoxTest().given().processor(SimpleTestProcessor1.class).andProcessor(SimpleTestProcessor2.class)
11721174
.andSourceFiles("/compiletests/exceptionthrown/ExceptionThrownUsecase.java")
11731175
.whenCompiled()
11741176
.thenExpectThat()
@@ -1181,4 +1183,22 @@ public void blackBoxTest_checkForExpectedException_failure_noException() {
11811183
}
11821184
throw new AssertionError("Expected exceptions wasn't triggered!!!");
11831185
}
1186+
1187+
@Test
1188+
public void blackBoxTest_AddMultipleProcessorsWithLinkedProcessorApi() throws NoSuchFieldException, IllegalAccessException {
1189+
1190+
CuteApi.CompilerTestExpectAndThatInterface expectThat = Cute.blackBoxTest().given()
1191+
.processor(SimpleTestProcessor1.class)
1192+
.andProcessor(SimpleTestProcessor2.class)
1193+
.andSourceFiles("/compiletests/generatedclasstest/TestClass.java")
1194+
.whenCompiled()
1195+
.thenExpectThat()
1196+
.compilationSucceeds()
1197+
.andThat().generatedClass("io.toolisticon.cute.testhelper.compiletest.TestClassGeneratedClass").exists();
1198+
1199+
1200+
expectThat.executeTest();
1201+
1202+
}
1203+
11841204
}

cute/src/test/resources/compiletests/generatedclasstest/TestClass.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package io.toolisticon.cute.testhelper.compiletest;
22

33
import io.toolisticon.cute.common.SimpleTestAnnotation1;
4+
import io.toolisticon.cute.common.SimpleTestAnnotation2;
45

56
@SimpleTestAnnotation1("WORKS!!!")
7+
@SimpleTestAnnotation2
68
public class TestClass {
79

810

0 commit comments

Comments
 (0)