Skip to content

Commit

Permalink
add Micronaut data integration test (#137)
Browse files Browse the repository at this point in the history
  • Loading branch information
graemerocher authored Nov 6, 2024
1 parent 4fbf757 commit 7a7c93a
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 6 deletions.
1 change: 1 addition & 0 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ repositories {
}

dependencies {
implementation (libs.micronaut.gradle.plugin)
implementation (libs.kotlin.gradle.plugin)
implementation (libs.kotlin.gradle.allopen)
}
6 changes: 5 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
[versions]
micronaut = "4.7.2"
micronaut-platform = "4.6.3"
micronaut-docs = "2.0.0"
micronaut-test = "4.1.0"
micronaut-data = "4.9.6"
micronaut-validation = "4.8.0"
micronaut-gradle-plugin = "4.4.0"
managed-kotlinpoet = "2.0.0"
google-truth = "1.4.4"
google-compile-testing = "0.21.0"
Expand All @@ -13,8 +16,8 @@ ksp = '1.9.24-1.0.20'
[libraries]
# Core
micronaut-core = { module = 'io.micronaut:micronaut-core-bom', version.ref = 'micronaut' }
micronaut-data = { module = 'io.micronaut.data:micronaut-data-bom', version.ref = 'micronaut-data' }
micronaut-validation = { module = "io.micronaut.validation:micronaut-validation-bom", version.ref = "micronaut-validation" }

managed-kotlinpoet = { module = "com.squareup:kotlinpoet", version.ref = "managed-kotlinpoet" }
managed-kotlinpoet-javapoet = { module = "com.squareup:kotlinpoet-javapoet", version.ref = "managed-kotlinpoet" }

Expand All @@ -24,5 +27,6 @@ google-compile-testing = { module = "com.google.testing.compile:compile-testing"
google-jimfs = { module = "com.google.jimfs:jimfs", version.ref = "google-jimfs" }
junit-jupiter-engine = { module = "org.junit.jupiter:junit-jupiter-engine" }

micronaut-gradle-plugin = { module = "io.micronaut.gradle:micronaut-gradle-plugin", version.ref="micronaut-gradle-plugin" }
kotlin-gradle-plugin = { module = 'org.jetbrains.kotlin:kotlin-gradle-plugin', version.ref = 'kotlin' }
kotlin-gradle-allopen = { module = 'org.jetbrains.kotlin:kotlin-allopen', version.ref = 'kotlin' }
2 changes: 2 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")

configure<io.micronaut.build.MicronautBuildSettingsExtension> {
importMicronautCatalog()
importMicronautCatalog("micronaut-data")
importMicronautCatalog("micronaut-validation")
}

Expand All @@ -36,3 +37,4 @@ dependencyResolutionManagement {
mavenCentral()
}
}

18 changes: 13 additions & 5 deletions test-suite-java/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
plugins {
id("io.micronaut.build.internal.sourcegen-testsuite")
id("io.micronaut.minimal.application")
}

micronaut {
processing {
// test incremental compile
incremental(true)
}
version.set(libs.versions.micronaut.platform)
}
dependencies {
annotationProcessor(mn.micronaut.inject.java)
annotationProcessor(projects.sourcegenGeneratorJava)
annotationProcessor(projects.testSuiteCustomGenerators)
annotationProcessor(mnData.micronaut.data.processor)
annotationProcessor(mnValidation.micronaut.validation.processor)

implementation(projects.sourcegenAnnotations)
implementation(projects.testSuiteCustomAnnotations)
implementation(mnValidation.micronaut.validation)

implementation(projects.sourcegenAnnotations)
implementation(projects.testSuiteCustomAnnotations)
implementation(mnData.micronaut.data.model)
testImplementation(mnTest.micronaut.test.junit5)
testImplementation(libs.junit.jupiter.engine)
testAnnotationProcessor(mn.micronaut.inject.java.test)
Expand All @@ -23,3 +30,4 @@ dependencies {
// options.forkOptions.jvmArgs = listOf("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005")
// }
//}

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright 2017-2024 original authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.micronaut.sourcegen.example;

import io.micronaut.data.annotation.Id;
import io.micronaut.data.annotation.MappedEntity;
import io.micronaut.sourcegen.annotations.Builder;
import io.micronaut.sourcegen.annotations.Wither;

@Wither
@Builder
@MappedEntity
public record GoodModel(
@Id
long id,
String data) implements GoodModelWither {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package io.micronaut.sourcegen.example;
import static org.junit.jupiter.api.Assertions.assertEquals;

import org.junit.jupiter.api.Test;

public class GoodModelTest {
@Test
void testWither() {
GoodModel model = new GoodModel(1, "test");
GoodModel updated = model.withData("updated");
assertEquals("updated", updated.data());
}
}

0 comments on commit 7a7c93a

Please sign in to comment.