Skip to content

Commit

Permalink
Upgrade to newest cute version
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias Stamann committed Feb 9, 2024
1 parent d58f262 commit 18288d4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@

import io.toolisticon.aptk.tools.MessagerUtils;
import io.toolisticon.aptk.tools.corematcher.CoreMatcherValidationMessages;
import io.toolisticon.cute.CompileTestBuilder;
import io.toolisticon.cute.JavaFileObjectUtils;
import io.toolisticon.cute.Cute;
import io.toolisticon.cute.CuteApi;
import org.junit.Before;
import org.junit.Test;

import javax.tools.JavaFileObject;
import javax.tools.StandardLocation;


/**
Expand All @@ -23,54 +21,59 @@
public class ${annotationName}ProcessorTest {


CompileTestBuilder.CompilationTestBuilder compileTestBuilder;
CuteApi.BlackBoxTestSourceFilesInterface compileTestBuilder;

@Before
public void init() {
MessagerUtils.setPrintMessageCodes(true);

compileTestBuilder = CompileTestBuilder
.compilationTest()
.addProcessors(${annotationName}Processor.class);
compileTestBuilder = Cute
.blackBoxTest()
.given()
.processors(${annotationName}Processor.class);
}


@Test
public void test_valid_usage() {

compileTestBuilder
.addSources(JavaFileObjectUtils.readFromResource("testcases/TestcaseValidUsage.java"))
.compilationShouldSucceed()
.andSourceFiles("testcases/TestcaseValidUsage.java")
.whenCompiled()
.thenExpectThat().compilationSucceeds()
.executeTest();
}

@Test
public void test_invalid_usage_with_empty_value() {

compileTestBuilder
.addSources(JavaFileObjectUtils.readFromResource("testcases/TestcaseInvalidUsageWithEmptyValue.java"))
.compilationShouldFail()
.expectErrorMessageThatContains(${annotationName}ProcessorCompilerMessages.ERROR_VALUE_MUST_NOT_BE_EMPTY.getCode())
.andSourceFiles("testcases/TestcaseInvalidUsageWithEmptyValue.java")
.whenCompiled()
.thenExpectThat().compilationFails()
.andThat().compilerMessage().ofKindError().contains(${annotationName}ProcessorCompilerMessages.ERROR_VALUE_MUST_NOT_BE_EMPTY.getCode())
.executeTest();
}

@Test
public void test_invalid_usage_on_enum() {

compileTestBuilder
.addSources(JavaFileObjectUtils.readFromResource("testcases/TestcaseInvalidUsageOnEnum.java"))
.compilationShouldFail()
.expectErrorMessageThatContains(CoreMatcherValidationMessages.IS_CLASS.getCode())
.andSourceFiles("testcases/TestcaseInvalidUsageOnEnum.java")
.whenCompiled()
.thenExpectThat().compilationFails()
.andThat().compilerMessage().ofKindError().contains(CoreMatcherValidationMessages.IS_CLASS.getCode())
.executeTest();
}

@Test
public void test_Test_invalid_usage_on_interface() {

compileTestBuilder
.addSources(JavaFileObjectUtils.readFromResource("testcases/TestcaseInvalidUsageOnInterface.java"))
.compilationShouldFail()
.expectErrorMessageThatContains(CoreMatcherValidationMessages.IS_CLASS.getCode())
.andSourceFiles("testcases/TestcaseInvalidUsageOnInterface.java")
.whenCompiled()
.thenExpectThat().compilationFails()
.andThat().compilerMessage().ofKindError().contains(CoreMatcherValidationMessages.IS_CLASS.getCode())
.executeTest();
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/archetype-resources/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@


<!-- project dependency versions -->
<cute.version>0.12.0</cute.version>
<cute.version>1.0.1</cute.version>
<spiap.version>0.11.0</spiap.version>
<aptk.version>0.21.0</aptk.version>
<aptk.version>0.22.11</aptk.version>

<!-- versions of test dependencies -->
<junit.version>4.13.1</junit.version>
Expand Down

0 comments on commit 18288d4

Please sign in to comment.