diff --git a/initializr-generator-spring/src/test/java/io/spring/initializr/generator/spring/code/kotlin/KotlinJpaGradleBuildCustomizerTests.java b/initializr-generator-spring/src/test/java/io/spring/initializr/generator/spring/code/kotlin/KotlinJpaGradleBuildCustomizerTests.java index c2c8421960..ab8639d414 100644 --- a/initializr-generator-spring/src/test/java/io/spring/initializr/generator/spring/code/kotlin/KotlinJpaGradleBuildCustomizerTests.java +++ b/initializr-generator-spring/src/test/java/io/spring/initializr/generator/spring/code/kotlin/KotlinJpaGradleBuildCustomizerTests.java @@ -61,33 +61,17 @@ void customizeWhenJpaFacetAbsentShouldNotAddKotlinJpaPlugin() { assertThat(build.plugins().values()).isEmpty(); } - private GradleBuild getCustomizedBuild(Dependency dependency) { - InitializrMetadata metadata = InitializrMetadataTestBuilder.withDefaults() - .addDependencyGroup("test", dependency) - .build(); - SimpleKotlinProjectSettings settings = new SimpleKotlinProjectSettings("1.2.70"); - MutableProjectDescription projectDescription = new MutableProjectDescription(); - projectDescription.setPlatformVersion(Version.parse("1.0.0")); - KotlinJpaGradleBuildCustomizer customizer = new KotlinJpaGradleBuildCustomizer(metadata, settings, - projectDescription); - GradleBuild build = new GradleBuild(new MetadataBuildItemResolver(metadata, Version.parse("2.0.0.RELEASE"))); - build.dependencies().add("foo"); - customizer.customize(build); - return build; - } - @Test void customizeWhenJakartaPersistencePresentShouldCustomizeAllOpenWithJakarta() { Dependency dependency = Dependency.withId("foo", "jakarta.persistence", "jakarta.persistence-api"); dependency.setFacets(Collections.singletonList("jpa")); GradleBuild build = getCustomizedBuild(dependency); - assertThat(build.plugins().values()).singleElement().satisfies((plugin) -> { - assertThat(plugin.getId()).isEqualTo("org.jetbrains.kotlin.plugin.jpa"); - }); + assertThat(build.plugins().values()).singleElement() + .satisfies((plugin) -> assertThat(plugin.getId()).isEqualTo("org.jetbrains.kotlin.plugin.jpa")); assertThat(build.extensions().values()).singleElement().satisfies((extension) -> { assertThat(extension.getName()).isEqualTo("allOpen"); assertThat(extension.getInvocations()) - .filteredOn(invocation -> Objects.equals(invocation.getTarget(), "annotation")) + .filteredOn((invocation) -> Objects.equals(invocation.getTarget(), "annotation")) .extracting("arguments") .containsExactlyInAnyOrder(List.of("jakarta.persistence.Entity"), List.of("jakarta.persistence.MappedSuperclass"), List.of("jakarta.persistence.Embeddable")); @@ -99,18 +83,32 @@ void customizeWhenJavaxPersistencePresentShouldCustomizeAllOpenWithJavax() { Dependency dependency = Dependency.withId("foo", "javax.persistence", "javax.persistence-api"); dependency.setFacets(Collections.singletonList("jpa")); GradleBuild build = getCustomizedBuild(dependency); - assertThat(build.plugins().values()).singleElement().satisfies((plugin) -> { - assertThat(plugin.getId()).isEqualTo("org.jetbrains.kotlin.plugin.jpa"); - }); + assertThat(build.plugins().values()).singleElement() + .satisfies((plugin) -> assertThat(plugin.getId()).isEqualTo("org.jetbrains.kotlin.plugin.jpa")); assertThat(build.extensions().values()).singleElement().satisfies((extension) -> { assertThat(extension.getName()).isEqualTo("allOpen"); assertThat(extension.getInvocations()) - .filteredOn(invocation -> Objects.equals(invocation.getTarget(), "annotation")) + .filteredOn((invocation) -> Objects.equals(invocation.getTarget(), "annotation")) .extracting("arguments") - .containsExactlyInAnyOrder("javax.persistence.Entity", "javax.persistence.MappedSuperclass", - "javax.persistence.Embeddable"); + .containsExactlyInAnyOrder(List.of("javax.persistence.Entity"), + List.of("javax.persistence.MappedSuperclass"), List.of("javax.persistence.Embeddable")); }); } + private GradleBuild getCustomizedBuild(Dependency dependency) { + InitializrMetadata metadata = InitializrMetadataTestBuilder.withDefaults() + .addDependencyGroup("test", dependency) + .build(); + SimpleKotlinProjectSettings settings = new SimpleKotlinProjectSettings("1.2.70"); + MutableProjectDescription projectDescription = new MutableProjectDescription(); + projectDescription.setPlatformVersion(Version.parse("1.0.0")); + KotlinJpaGradleBuildCustomizer customizer = new KotlinJpaGradleBuildCustomizer(metadata, settings, + projectDescription); + GradleBuild build = new GradleBuild(new MetadataBuildItemResolver(metadata, Version.parse("2.0.0.RELEASE"))); + build.dependencies().add("foo"); + customizer.customize(build); + return build; + } + } diff --git a/initializr-generator-spring/src/test/java/io/spring/initializr/generator/spring/code/kotlin/KotlinJpaMavenBuildCustomizerTests.java b/initializr-generator-spring/src/test/java/io/spring/initializr/generator/spring/code/kotlin/KotlinJpaMavenBuildCustomizerTests.java index a1d45dc686..5e42c807df 100644 --- a/initializr-generator-spring/src/test/java/io/spring/initializr/generator/spring/code/kotlin/KotlinJpaMavenBuildCustomizerTests.java +++ b/initializr-generator-spring/src/test/java/io/spring/initializr/generator/spring/code/kotlin/KotlinJpaMavenBuildCustomizerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2024 the original author or authors. + * Copyright 2012-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,12 +31,6 @@ import static org.assertj.core.api.Assertions.assertThat; -/** - * Tests for {@link KotlinJpaMavenBuildCustomizer}. - * - * @author Madhura Bhave - * @author Sebastien Deleuze - */ class KotlinJpaMavenBuildCustomizerTests { @Test @@ -80,7 +74,7 @@ void customizeWhenJakartaPersistencePresentShouldCustomizeAllOpenWithJakarta() { MavenPlugin.Configuration configuration = plugin.getConfiguration(); assertThat(configuration.getSettings() .stream() - .filter(setting -> "option".equals(setting.getName())) + .filter((setting) -> "option".equals(setting.getName())) .map(MavenPlugin.Setting::getValue)) .containsExactlyInAnyOrder("all-open:annotation=jakarta.persistence.Entity", "all-open:annotation=jakarta.persistence.MappedSuperclass", @@ -101,7 +95,7 @@ void customizeWhenJavaxPersistencePresentShouldCustomizeAllOpenWithJavax() { MavenPlugin.Configuration configuration = plugin.getConfiguration(); assertThat(configuration.getSettings() .stream() - .filter(setting -> "option".equals(setting.getName())) + .filter((setting) -> "option".equals(setting.getName())) .map(MavenPlugin.Setting::getValue)) .containsExactlyInAnyOrder("all-open:annotation=javax.persistence.Entity", "all-open:annotation=javax.persistence.MappedSuperclass",