Skip to content

Commit

Permalink
Reworked chained add processor
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias Stamann committed Apr 4, 2024
1 parent b6e795c commit a8580a8
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 14 deletions.
33 changes: 20 additions & 13 deletions cute/src/main/java/io/toolisticon/cute/CuteApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -297,21 +297,10 @@ public interface BlackBoxTestRootInterface {

}

public interface BlackBoxTestProcessorInterface
{

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


@FluentApiInterface(CompilerTestBB.class)
public interface BlackBoxTestProcessorsInterface extends BlackBoxTestProcessorInterface{
public interface BlackBoxTestProcessorsInterface{

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


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

/**
* More obvious method not to use processors during compilation.
* Same as calling processors without values.
Expand All @@ -348,7 +345,17 @@ default BlackBoxTestSourceFilesInterface noProcessors() {
}

@FluentApiInterface(CompilerTestBB.class)
public interface BlackBoxTestSourceFilesAndProcessorInterface extends BlackBoxTestProcessorInterface, BlackBoxTestSourceFilesInterface{}
public interface BlackBoxTestSourceFilesAndProcessorInterface extends BlackBoxTestSourceFilesInterface{

/**
* Allows you to add a single annotation processor used at black-box tests compilation.
*
* @param processor the annotation processor to use. null values are prohibited and will lead to a {@link io.toolisticon.fluapigen.validation.api.ValidatorException}.
* @return the next fluent interface
*/
BlackBoxTestSourceFilesAndProcessorInterface andProcessor(@FluentApiBackingBeanMapping(value = "processors", action = MappingAction.ADD) @NotNull Class<? extends Processor> processor);

}

@FluentApiInterface(CompilerTestBB.class)
public interface BlackBoxTestSourceFilesInterface {
Expand Down
22 changes: 21 additions & 1 deletion cute/src/test/java/io/toolisticon/cute/CuteTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import io.toolisticon.cute.common.ExceptionThrowerProcessor;
import io.toolisticon.cute.common.SimpleTestProcessor1;
import io.toolisticon.cute.common.SimpleTestProcessor1Interface;
import io.toolisticon.cute.common.SimpleTestProcessor2;
import io.toolisticon.cute.testcases.SimpleTestInterface;
import io.toolisticon.fluapigen.validation.api.ValidatorException;
import org.hamcrest.MatcherAssert;
Expand All @@ -20,6 +21,7 @@
import javax.tools.StandardLocation;
import java.io.IOException;
import java.io.Writer;
import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
Expand Down Expand Up @@ -1168,7 +1170,7 @@ public void blackBoxTest_checkForExpectedException_failure_otherException() {
@Test
public void blackBoxTest_checkForExpectedException_failure_noException() {
try {
Cute.blackBoxTest().given().processor(SimpleTestProcessor1.class)
Cute.blackBoxTest().given().processor(SimpleTestProcessor1.class).andProcessor(SimpleTestProcessor2.class)
.andSourceFiles("/compiletests/exceptionthrown/ExceptionThrownUsecase.java")
.whenCompiled()
.thenExpectThat()
Expand All @@ -1181,4 +1183,22 @@ public void blackBoxTest_checkForExpectedException_failure_noException() {
}
throw new AssertionError("Expected exceptions wasn't triggered!!!");
}

@Test
public void blackBoxTest_AddMultipleProcessorsWithLinkedProcessorApi() throws NoSuchFieldException, IllegalAccessException {

CuteApi.CompilerTestExpectAndThatInterface expectThat = Cute.blackBoxTest().given()
.processor(SimpleTestProcessor1.class)
.andProcessor(SimpleTestProcessor2.class)
.andSourceFiles("/compiletests/generatedclasstest/TestClass.java")
.whenCompiled()
.thenExpectThat()
.compilationSucceeds()
.andThat().generatedClass("io.toolisticon.cute.testhelper.compiletest.TestClassGeneratedClass").exists();


expectThat.executeTest();

}

}
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package io.toolisticon.cute.testhelper.compiletest;

import io.toolisticon.cute.common.SimpleTestAnnotation1;
import io.toolisticon.cute.common.SimpleTestAnnotation2;

@SimpleTestAnnotation1("WORKS!!!")
@SimpleTestAnnotation2
public class TestClass {


Expand Down

0 comments on commit a8580a8

Please sign in to comment.