Skip to content

Commit

Permalink
Enable examples tests, fix KSP (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
dstepanov authored Mar 21, 2023
1 parent eea7bd0 commit a8d7970
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ micronaut {
// Do not build examples against M1 since the platform is not released
version = "4.0.0-SNAPSHOT"
}

tasks.withType(Test).configureEach {
useJUnitPlatform()
}
4 changes: 3 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ jakarta-validation-tck = "3.0.1"
micronaut-reactor = { module = 'io.micronaut.reactor:micronaut-reactor-bom', version.ref = "micronaut-reactor" }
micronaut-rxjava2 = { module = 'io.micronaut.rxjava2:micronaut-rxjava2-bom', version.ref = "micronaut-rxjava2" }
micronaut-kotlin = { module = 'io.micronaut.kotlin:micronaut-kotlin-bom', version.ref = "micronaut-kotlin" }
micronaut-test-junit5 = { module = "io.micronaut.test:micronaut-test-junit5", version.ref = "micronaut-test" }

groovy-bom = { module = "org.apache.groovy:groovy-bom", version.ref = "groovy" }
groovy-json = { module = "org.apache.groovy:groovy-json" }

# TESTING

micronaut-test-junit5 = { module = "io.micronaut.test:micronaut-test-junit5", version.ref = "micronaut-test" }
micronaut-test-spock = { module = "io.micronaut.test:micronaut-test-spock", version.ref = "micronaut-test" }
junit-jupiter-api = { module = "org.junit.jupiter:junit-jupiter-api", version.ref = "junit5" }
junit-jupiter-engine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "junit5" }
kotlin-kotest-junit5 = { module = "io.kotest:kotest-runner-junit5-jvm", version.ref = "kotest" }
Expand Down
10 changes: 6 additions & 4 deletions test-suite-groovy/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
id 'io.micronaut.build.internal.validation-test-suite'
id 'groovy'
}

dependencies {
Expand All @@ -12,6 +13,7 @@ dependencies {
implementation mnReactor.micronaut.reactor

testImplementation project(":validation")
testImplementation project(":validation-processor")
testAnnotationProcessor project(":validation-processor")
testAnnotationProcessor mn.micronaut.inject.java
testImplementation libs.spotbugs
Expand All @@ -26,8 +28,8 @@ dependencies {
testImplementation mn.micronaut.inject.java.test
testImplementation mn.micronaut.jackson.databind

testImplementation("org.junit.jupiter:junit-jupiter-api")
testImplementation("io.micronaut.test:micronaut-test-junit5:3.9.2")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:{junitVersion}")
testImplementation("org.junit.jupiter:junit-jupiter-engine:{junitVersion}")
testImplementation libs.junit.jupiter.api
testImplementation libs.micronaut.test.spock
testImplementation libs.junit.jupiter.engine
testRuntimeOnly libs.junit.jupiter.engine
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package io.micronaut.docs.validation.iterable;

import java.util.*;

import io.micronaut.test.extensions.junit5.annotation.MicronautTest;
import jakarta.inject.Inject;
import jakarta.validation.ConstraintViolationException;
import org.junit.jupiter.api.Test;

import jakarta.validation.ConstraintViolationException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
Expand All @@ -28,7 +30,7 @@ void testAuthorNamesAreValidated() {
bookInfoService.setBookAuthors("My Book", authors)
);

assertEquals("setBookAuthors.authors[1]<E String>: must not be blank",
assertEquals("setBookAuthors.authors[1]<list element>: must not be blank",
exception.getMessage()); // <1>
}

Expand All @@ -42,7 +44,7 @@ void testSectionsAreValidated() {
bookInfoService.setBookSectionPages("My Book", sectionStartPages)
);

assertEquals("setBookSectionPages.sectionStartPages[]<K String>: must not be blank",
assertEquals("setBookSectionPages.sectionStartPages[]<map key>: must not be blank",
exception.getMessage()); // <2>
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,15 @@ public Map<String, Object> getAttributes() {
for (Map.Entry<?, ?> entry : values.entrySet()) {
variables.put(entry.getKey().toString(), entry.getValue());
}
final Map<CharSequence, Object> defaultValues = annotationValue.getDefaultValues();
for (Map.Entry<CharSequence, Object> entry : defaultValues.entrySet()) {
final String n = entry.getKey().toString();
if (!variables.containsKey(n)) {
final Object v = entry.getValue();
if (v != null) {
variables.put(n, v);
if (annotationValue.getDefaultValues() != null) {
final Map<CharSequence, Object> defaultValues = annotationValue.getDefaultValues();
for (Map.Entry<CharSequence, Object> entry : defaultValues.entrySet()) {
final String n = entry.getKey().toString();
if (!variables.containsKey(n)) {
final Object v = entry.getValue();
if (v != null) {
variables.put(n, v);
}
}
}
}
Expand Down

0 comments on commit a8d7970

Please sign in to comment.