From 6837e7003d96368219ce79a370f3a85e9c2104db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Wed, 4 Sep 2024 15:57:38 -0600 Subject: [PATCH] Fix tests --- ...iChromaProjectGenerationConfiguration.java | 18 +++--- ...omposeProjectGenerationConfiguration.java} | 15 +++-- ...iMilvusProjectGenerationConfiguration.java | 13 +++-- ...iOllamaProjectGenerationConfiguration.java | 18 +++--- ...iQdrantProjectGenerationConfiguration.java | 18 +++--- ...ainersProjectGenerationConfiguration.java} | 15 +++-- .../dependency/springai/SpringAiVersion.java | 13 +++-- ...eaviateProjectGenerationConfiguration.java | 18 +++--- .../TestcontainersModuleRegistry.java | 2 +- .../main/resources/META-INF/spring.factories | 7 +++ ...seProjectGenerationConfigurationTests.java | 55 +++++++++++++++++++ ...sProjectGenerationConfigurationTests.java} | 7 ++- ...rsProjectGenerationConfigurationTests.java | 9 +-- .../src/test/resources/compose/chroma.yaml | 2 +- .../src/test/resources/compose/ollama.yaml | 2 +- .../src/test/resources/compose/qdrant.yaml | 2 +- .../src/test/resources/compose/weaviate.yaml | 2 +- 17 files changed, 150 insertions(+), 66 deletions(-) rename start-site/src/main/java/io/spring/start/site/extension/dependency/springai/{DockerComposeConfiguration.java => SpringAiDockerComposeProjectGenerationConfiguration.java} (75%) rename start-site/src/main/java/io/spring/start/site/extension/dependency/springai/{TestcontainersConfiguration.java => SpringAiTestcontainersProjectGenerationConfiguration.java} (72%) create mode 100644 start-site/src/test/java/io/spring/start/site/extension/dependency/springai/SpringAiDockerComposeProjectGenerationConfigurationTests.java rename start-site/src/test/java/io/spring/start/site/extension/dependency/springai/{TestcontainersConfigurationTests.java => SpringAiTestcontainersProjectGenerationConfigurationTests.java} (85%) diff --git a/start-site/src/main/java/io/spring/start/site/extension/dependency/springai/SpringAiChromaProjectGenerationConfiguration.java b/start-site/src/main/java/io/spring/start/site/extension/dependency/springai/SpringAiChromaProjectGenerationConfiguration.java index 46806b67487..129be44dbb5 100644 --- a/start-site/src/main/java/io/spring/start/site/extension/dependency/springai/SpringAiChromaProjectGenerationConfiguration.java +++ b/start-site/src/main/java/io/spring/start/site/extension/dependency/springai/SpringAiChromaProjectGenerationConfiguration.java @@ -16,22 +16,23 @@ package io.spring.start.site.extension.dependency.springai; -import io.spring.initializr.generator.buildsystem.Build; import io.spring.initializr.generator.condition.ConditionalOnRequestedDependency; +import io.spring.initializr.generator.project.ProjectDescription; +import io.spring.initializr.generator.project.ProjectGenerationConfiguration; +import io.spring.initializr.metadata.InitializrMetadata; import io.spring.start.site.container.ComposeFileCustomizer; import io.spring.start.site.container.DockerServiceResolver; import io.spring.start.site.container.ServiceConnections.ServiceConnection; import io.spring.start.site.container.ServiceConnectionsCustomizer; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; /** * Configuration for generation of projects that depend on Chroma. * * @author Eddú Meléndez */ -@Configuration(proxyBeanMethods = false) +@ProjectGenerationConfiguration @ConditionalOnRequestedDependency("spring-ai-vectordb-chroma") class SpringAiChromaProjectGenerationConfiguration { @@ -39,10 +40,10 @@ class SpringAiChromaProjectGenerationConfiguration { @Bean @ConditionalOnRequestedDependency("testcontainers") - ServiceConnectionsCustomizer chromaServiceConnectionsCustomizer(Build build, - DockerServiceResolver serviceResolver) { + ServiceConnectionsCustomizer chromaServiceConnectionsCustomizer(InitializrMetadata metadata, + ProjectDescription description, DockerServiceResolver serviceResolver) { return (serviceConnections) -> { - if (SpringAiVersion.version1OrLater(build)) { + if (SpringAiVersion.version1OrLater(metadata, description.getPlatformVersion())) { serviceResolver.doWith("chroma", (service) -> serviceConnections .addServiceConnection(ServiceConnection.ofContainer("chroma", service, TESTCONTAINERS_CLASS_NAME))); } @@ -51,9 +52,10 @@ ServiceConnectionsCustomizer chromaServiceConnectionsCustomizer(Build build, @Bean @ConditionalOnRequestedDependency("docker-compose") - ComposeFileCustomizer chromaComposeFileCustomizer(Build build, DockerServiceResolver serviceResolver) { + ComposeFileCustomizer chromaComposeFileCustomizer(InitializrMetadata metadata, ProjectDescription description, + DockerServiceResolver serviceResolver) { return (composeFile) -> { - if (SpringAiVersion.version1OrLater(build)) { + if (SpringAiVersion.version1OrLater(metadata, description.getPlatformVersion())) { serviceResolver.doWith("chroma", (service) -> composeFile.services().add("chroma", service)); } }; diff --git a/start-site/src/main/java/io/spring/start/site/extension/dependency/springai/DockerComposeConfiguration.java b/start-site/src/main/java/io/spring/start/site/extension/dependency/springai/SpringAiDockerComposeProjectGenerationConfiguration.java similarity index 75% rename from start-site/src/main/java/io/spring/start/site/extension/dependency/springai/DockerComposeConfiguration.java rename to start-site/src/main/java/io/spring/start/site/extension/dependency/springai/SpringAiDockerComposeProjectGenerationConfiguration.java index eb71c8e577a..a3160a5a3c2 100644 --- a/start-site/src/main/java/io/spring/start/site/extension/dependency/springai/DockerComposeConfiguration.java +++ b/start-site/src/main/java/io/spring/start/site/extension/dependency/springai/SpringAiDockerComposeProjectGenerationConfiguration.java @@ -20,24 +20,27 @@ import io.spring.initializr.generator.buildsystem.Dependency; import io.spring.initializr.generator.buildsystem.DependencyScope; import io.spring.initializr.generator.condition.ConditionalOnRequestedDependency; +import io.spring.initializr.generator.project.ProjectDescription; +import io.spring.initializr.generator.project.ProjectGenerationConfiguration; import io.spring.initializr.generator.spring.build.BuildCustomizer; +import io.spring.initializr.metadata.InitializrMetadata; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; /** * Configuration for generation of projects that depend on Spring AI Docker Compose. * * @author Eddú Meléndez */ -@Configuration(proxyBeanMethods = false) -class DockerComposeConfiguration { +@ProjectGenerationConfiguration +@ConditionalOnRequestedDependency("docker-compose") +class SpringAiDockerComposeProjectGenerationConfiguration { @Bean - @ConditionalOnRequestedDependency("docker-compose") - BuildCustomizer springBootTestcontainersBuildCustomizer() { + BuildCustomizer springBootTestcontainersBuildCustomizer(InitializrMetadata metadata, + ProjectDescription description) { return (build) -> { - if (SpringAiVersion.version1OrLater(build)) { + if (SpringAiVersion.version1OrLater(metadata, description.getPlatformVersion())) { build.dependencies() .add("spring-ai-docker-compose", Dependency.withCoordinates("org.springframework.ai", "spring-ai-spring-boot-docker-compose") diff --git a/start-site/src/main/java/io/spring/start/site/extension/dependency/springai/SpringAiMilvusProjectGenerationConfiguration.java b/start-site/src/main/java/io/spring/start/site/extension/dependency/springai/SpringAiMilvusProjectGenerationConfiguration.java index 773a7105fee..80973d72f5d 100644 --- a/start-site/src/main/java/io/spring/start/site/extension/dependency/springai/SpringAiMilvusProjectGenerationConfiguration.java +++ b/start-site/src/main/java/io/spring/start/site/extension/dependency/springai/SpringAiMilvusProjectGenerationConfiguration.java @@ -16,21 +16,22 @@ package io.spring.start.site.extension.dependency.springai; -import io.spring.initializr.generator.buildsystem.Build; import io.spring.initializr.generator.condition.ConditionalOnRequestedDependency; +import io.spring.initializr.generator.project.ProjectDescription; +import io.spring.initializr.generator.project.ProjectGenerationConfiguration; +import io.spring.initializr.metadata.InitializrMetadata; import io.spring.start.site.container.DockerServiceResolver; import io.spring.start.site.container.ServiceConnections.ServiceConnection; import io.spring.start.site.container.ServiceConnectionsCustomizer; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; /** * Configuration for generation of projects that depend on Milvus. * * @author Eddú Meléndez */ -@Configuration(proxyBeanMethods = false) +@ProjectGenerationConfiguration @ConditionalOnRequestedDependency("spring-ai-vectordb-milvus") class SpringAiMilvusProjectGenerationConfiguration { @@ -38,10 +39,10 @@ class SpringAiMilvusProjectGenerationConfiguration { @Bean @ConditionalOnRequestedDependency("testcontainers") - ServiceConnectionsCustomizer milvusServiceConnectionsCustomizer(Build build, - DockerServiceResolver serviceResolver) { + ServiceConnectionsCustomizer milvusServiceConnectionsCustomizer(InitializrMetadata metadata, + ProjectDescription description, DockerServiceResolver serviceResolver) { return (serviceConnections) -> { - if (SpringAiVersion.version1OrLater(build)) { + if (SpringAiVersion.version1OrLater(metadata, description.getPlatformVersion())) { serviceResolver.doWith("milvus", (service) -> serviceConnections .addServiceConnection(ServiceConnection.ofContainer("milvus", service, TESTCONTAINERS_CLASS_NAME))); } diff --git a/start-site/src/main/java/io/spring/start/site/extension/dependency/springai/SpringAiOllamaProjectGenerationConfiguration.java b/start-site/src/main/java/io/spring/start/site/extension/dependency/springai/SpringAiOllamaProjectGenerationConfiguration.java index 96e5d7c0a08..fea79e30928 100644 --- a/start-site/src/main/java/io/spring/start/site/extension/dependency/springai/SpringAiOllamaProjectGenerationConfiguration.java +++ b/start-site/src/main/java/io/spring/start/site/extension/dependency/springai/SpringAiOllamaProjectGenerationConfiguration.java @@ -16,22 +16,23 @@ package io.spring.start.site.extension.dependency.springai; -import io.spring.initializr.generator.buildsystem.Build; import io.spring.initializr.generator.condition.ConditionalOnRequestedDependency; +import io.spring.initializr.generator.project.ProjectDescription; +import io.spring.initializr.generator.project.ProjectGenerationConfiguration; +import io.spring.initializr.metadata.InitializrMetadata; import io.spring.start.site.container.ComposeFileCustomizer; import io.spring.start.site.container.DockerServiceResolver; import io.spring.start.site.container.ServiceConnections.ServiceConnection; import io.spring.start.site.container.ServiceConnectionsCustomizer; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; /** * Configuration for generation of projects that depend on Ollama. * * @author Eddú Meléndez */ -@Configuration(proxyBeanMethods = false) +@ProjectGenerationConfiguration @ConditionalOnRequestedDependency("spring-ai-ollama") class SpringAiOllamaProjectGenerationConfiguration { @@ -39,10 +40,10 @@ class SpringAiOllamaProjectGenerationConfiguration { @Bean @ConditionalOnRequestedDependency("testcontainers") - ServiceConnectionsCustomizer ollamaServiceConnectionsCustomizer(Build build, - DockerServiceResolver serviceResolver) { + ServiceConnectionsCustomizer ollamaServiceConnectionsCustomizer(InitializrMetadata metadata, + ProjectDescription description, DockerServiceResolver serviceResolver) { return (serviceConnections) -> { - if (SpringAiVersion.version1OrLater(build)) { + if (SpringAiVersion.version1OrLater(metadata, description.getPlatformVersion())) { serviceResolver.doWith("ollama", (service) -> serviceConnections .addServiceConnection(ServiceConnection.ofContainer("ollama", service, TESTCONTAINERS_CLASS_NAME))); } @@ -51,9 +52,10 @@ ServiceConnectionsCustomizer ollamaServiceConnectionsCustomizer(Build build, @Bean @ConditionalOnRequestedDependency("docker-compose") - ComposeFileCustomizer ollamaComposeFileCustomizer(Build build, DockerServiceResolver serviceResolver) { + ComposeFileCustomizer ollamaComposeFileCustomizer(InitializrMetadata metadata, ProjectDescription description, + DockerServiceResolver serviceResolver) { return (composeFile) -> { - if (SpringAiVersion.version1OrLater(build)) { + if (SpringAiVersion.version1OrLater(metadata, description.getPlatformVersion())) { serviceResolver.doWith("ollama", (service) -> composeFile.services().add("ollama", service)); } }; diff --git a/start-site/src/main/java/io/spring/start/site/extension/dependency/springai/SpringAiQdrantProjectGenerationConfiguration.java b/start-site/src/main/java/io/spring/start/site/extension/dependency/springai/SpringAiQdrantProjectGenerationConfiguration.java index fb1c254e4e4..a9a40049808 100644 --- a/start-site/src/main/java/io/spring/start/site/extension/dependency/springai/SpringAiQdrantProjectGenerationConfiguration.java +++ b/start-site/src/main/java/io/spring/start/site/extension/dependency/springai/SpringAiQdrantProjectGenerationConfiguration.java @@ -16,22 +16,23 @@ package io.spring.start.site.extension.dependency.springai; -import io.spring.initializr.generator.buildsystem.Build; import io.spring.initializr.generator.condition.ConditionalOnRequestedDependency; +import io.spring.initializr.generator.project.ProjectDescription; +import io.spring.initializr.generator.project.ProjectGenerationConfiguration; +import io.spring.initializr.metadata.InitializrMetadata; import io.spring.start.site.container.ComposeFileCustomizer; import io.spring.start.site.container.DockerServiceResolver; import io.spring.start.site.container.ServiceConnections.ServiceConnection; import io.spring.start.site.container.ServiceConnectionsCustomizer; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; /** * Configuration for generation of projects that depend on Qdrant. * * @author Eddú Meléndez */ -@Configuration(proxyBeanMethods = false) +@ProjectGenerationConfiguration @ConditionalOnRequestedDependency("spring-ai-vectordb-qdrant") class SpringAiQdrantProjectGenerationConfiguration { @@ -39,10 +40,10 @@ class SpringAiQdrantProjectGenerationConfiguration { @Bean @ConditionalOnRequestedDependency("testcontainers") - ServiceConnectionsCustomizer qdrantServiceConnectionsCustomizer(Build build, - DockerServiceResolver serviceResolver) { + ServiceConnectionsCustomizer qdrantServiceConnectionsCustomizer(InitializrMetadata metadata, + ProjectDescription description, DockerServiceResolver serviceResolver) { return (serviceConnections) -> { - if (SpringAiVersion.version1OrLater(build)) { + if (SpringAiVersion.version1OrLater(metadata, description.getPlatformVersion())) { serviceResolver.doWith("qdrant", (service) -> serviceConnections .addServiceConnection(ServiceConnection.ofContainer("qdrant", service, TESTCONTAINERS_CLASS_NAME))); } @@ -51,9 +52,10 @@ ServiceConnectionsCustomizer qdrantServiceConnectionsCustomizer(Build build, @Bean @ConditionalOnRequestedDependency("docker-compose") - ComposeFileCustomizer qdrantComposeFileCustomizer(Build build, DockerServiceResolver serviceResolver) { + ComposeFileCustomizer qdrantComposeFileCustomizer(InitializrMetadata metadata, ProjectDescription description, + DockerServiceResolver serviceResolver) { return (composeFile) -> { - if (SpringAiVersion.version1OrLater(build)) { + if (SpringAiVersion.version1OrLater(metadata, description.getPlatformVersion())) { serviceResolver.doWith("qdrant", (service) -> composeFile.services().add("qdrant", service)); } }; diff --git a/start-site/src/main/java/io/spring/start/site/extension/dependency/springai/TestcontainersConfiguration.java b/start-site/src/main/java/io/spring/start/site/extension/dependency/springai/SpringAiTestcontainersProjectGenerationConfiguration.java similarity index 72% rename from start-site/src/main/java/io/spring/start/site/extension/dependency/springai/TestcontainersConfiguration.java rename to start-site/src/main/java/io/spring/start/site/extension/dependency/springai/SpringAiTestcontainersProjectGenerationConfiguration.java index 7248b63de27..d4a04cea23d 100644 --- a/start-site/src/main/java/io/spring/start/site/extension/dependency/springai/TestcontainersConfiguration.java +++ b/start-site/src/main/java/io/spring/start/site/extension/dependency/springai/SpringAiTestcontainersProjectGenerationConfiguration.java @@ -20,24 +20,27 @@ import io.spring.initializr.generator.buildsystem.Dependency; import io.spring.initializr.generator.buildsystem.DependencyScope; import io.spring.initializr.generator.condition.ConditionalOnRequestedDependency; +import io.spring.initializr.generator.project.ProjectDescription; +import io.spring.initializr.generator.project.ProjectGenerationConfiguration; import io.spring.initializr.generator.spring.build.BuildCustomizer; +import io.spring.initializr.metadata.InitializrMetadata; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; /** * Configuration for generation of projects that depend on Spring AI Testcontainers. * * @author Eddú Meléndez */ -@Configuration(proxyBeanMethods = false) -class TestcontainersConfiguration { +@ProjectGenerationConfiguration +@ConditionalOnRequestedDependency("testcontainers") +class SpringAiTestcontainersProjectGenerationConfiguration { @Bean - @ConditionalOnRequestedDependency("testcontainers") - BuildCustomizer springBootTestcontainersBuildCustomizer() { + BuildCustomizer springAiTestcontainersBuildCustomizer(InitializrMetadata metadata, + ProjectDescription description) { return (build) -> { - if (SpringAiVersion.version1OrLater(build)) { + if (SpringAiVersion.version1OrLater(metadata, description.getPlatformVersion())) { build.dependencies() .add("spring-ai-testcontainers", Dependency.withCoordinates("org.springframework.ai", "spring-ai-spring-boot-testcontainers") diff --git a/start-site/src/main/java/io/spring/start/site/extension/dependency/springai/SpringAiVersion.java b/start-site/src/main/java/io/spring/start/site/extension/dependency/springai/SpringAiVersion.java index d002e6fc248..38b681c060e 100644 --- a/start-site/src/main/java/io/spring/start/site/extension/dependency/springai/SpringAiVersion.java +++ b/start-site/src/main/java/io/spring/start/site/extension/dependency/springai/SpringAiVersion.java @@ -16,21 +16,26 @@ package io.spring.start.site.extension.dependency.springai; -import io.spring.initializr.generator.buildsystem.Build; import io.spring.initializr.generator.version.Version; import io.spring.initializr.generator.version.VersionParser; import io.spring.initializr.generator.version.VersionRange; +import io.spring.initializr.metadata.InitializrMetadata; final class SpringAiVersion { - private static final VersionRange SPRING_AI_1_0_0_OR_LATER = VersionParser.DEFAULT.parseRange("1.0.0"); + private static final VersionRange SPRING_AI_1_0_0_OR_LATER = VersionParser.DEFAULT.parseRange("1.0.0-M2"); private SpringAiVersion() { } - static boolean version1OrLater(Build build) { - var springAiBomVersion = build.boms().get("spring-ai").getVersion().getValue(); + static boolean version1OrLater(InitializrMetadata metadata, Version platformVersion) { + var springAiBomVersion = metadata.getConfiguration() + .getEnv() + .getBoms() + .get("spring-ai") + .resolve(platformVersion) + .getVersion(); return SPRING_AI_1_0_0_OR_LATER.match(Version.parse(springAiBomVersion)); } diff --git a/start-site/src/main/java/io/spring/start/site/extension/dependency/springai/SpringAiWeaviateProjectGenerationConfiguration.java b/start-site/src/main/java/io/spring/start/site/extension/dependency/springai/SpringAiWeaviateProjectGenerationConfiguration.java index c66c644cc78..b6f4c63e15f 100644 --- a/start-site/src/main/java/io/spring/start/site/extension/dependency/springai/SpringAiWeaviateProjectGenerationConfiguration.java +++ b/start-site/src/main/java/io/spring/start/site/extension/dependency/springai/SpringAiWeaviateProjectGenerationConfiguration.java @@ -16,22 +16,23 @@ package io.spring.start.site.extension.dependency.springai; -import io.spring.initializr.generator.buildsystem.Build; import io.spring.initializr.generator.condition.ConditionalOnRequestedDependency; +import io.spring.initializr.generator.project.ProjectDescription; +import io.spring.initializr.generator.project.ProjectGenerationConfiguration; +import io.spring.initializr.metadata.InitializrMetadata; import io.spring.start.site.container.ComposeFileCustomizer; import io.spring.start.site.container.DockerServiceResolver; import io.spring.start.site.container.ServiceConnections.ServiceConnection; import io.spring.start.site.container.ServiceConnectionsCustomizer; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; /** * Configuration for generation of projects that depend on Weaviate. * * @author Eddú Meléndez */ -@Configuration(proxyBeanMethods = false) +@ProjectGenerationConfiguration @ConditionalOnRequestedDependency("spring-ai-vectordb-weaviate") class SpringAiWeaviateProjectGenerationConfiguration { @@ -39,10 +40,10 @@ class SpringAiWeaviateProjectGenerationConfiguration { @Bean @ConditionalOnRequestedDependency("testcontainers") - ServiceConnectionsCustomizer weaviateServiceConnectionsCustomizer(Build build, - DockerServiceResolver serviceResolver) { + ServiceConnectionsCustomizer weaviateServiceConnectionsCustomizer(InitializrMetadata metadata, + ProjectDescription description, DockerServiceResolver serviceResolver) { return (serviceConnections) -> { - if (SpringAiVersion.version1OrLater(build)) { + if (SpringAiVersion.version1OrLater(metadata, description.getPlatformVersion())) { serviceResolver.doWith("weaviate", (service) -> serviceConnections.addServiceConnection( ServiceConnection.ofContainer("weaviate", service, TESTCONTAINERS_CLASS_NAME))); } @@ -51,9 +52,10 @@ ServiceConnectionsCustomizer weaviateServiceConnectionsCustomizer(Build build, @Bean @ConditionalOnRequestedDependency("docker-compose") - ComposeFileCustomizer weaviateComposeFileCustomizer(Build build, DockerServiceResolver serviceResolver) { + ComposeFileCustomizer weaviateComposeFileCustomizer(InitializrMetadata metadata, ProjectDescription description, + DockerServiceResolver serviceResolver) { return (composeFile) -> { - if (SpringAiVersion.version1OrLater(build)) { + if (SpringAiVersion.version1OrLater(metadata, description.getPlatformVersion())) { serviceResolver.doWith("weaviate", (service) -> composeFile.services().add("weaviate", service)); } }; diff --git a/start-site/src/main/java/io/spring/start/site/extension/dependency/testcontainers/TestcontainersModuleRegistry.java b/start-site/src/main/java/io/spring/start/site/extension/dependency/testcontainers/TestcontainersModuleRegistry.java index 457bb7d578a..9f971aa855c 100644 --- a/start-site/src/main/java/io/spring/start/site/extension/dependency/testcontainers/TestcontainersModuleRegistry.java +++ b/start-site/src/main/java/io/spring/start/site/extension/dependency/testcontainers/TestcontainersModuleRegistry.java @@ -80,7 +80,7 @@ static Iterable create(Version platformVersion) { .customizeHelpDocument(addReferenceLink("MariaDB Module", "databases/mariadb/"))); builders.add(onDependencies("mysql").customizeBuild(addModule("mysql")) .customizeHelpDocument(addReferenceLink("MySQL Module", "databases/mysql/"))); - builders.add(onDependencies("oracle").customizeBuild(addModule("oracle-free")) + builders.add(onDependencies("oracle", "spring-ai-vectordb-oracle").customizeBuild(addModule("oracle-free")) .customizeHelpDocument(addReferenceLink("Oracle-Free Module", "databases/oraclefree/"))); builders.add(onDependencies("postgresql", "spring-ai-vectordb-pgvector").customizeBuild(addModule("postgresql")) .customizeHelpDocument(addReferenceLink("Postgres Module", "databases/postgres/"))); diff --git a/start-site/src/main/resources/META-INF/spring.factories b/start-site/src/main/resources/META-INF/spring.factories index 40924849fc3..dc801ce32c0 100644 --- a/start-site/src/main/resources/META-INF/spring.factories +++ b/start-site/src/main/resources/META-INF/spring.factories @@ -26,6 +26,13 @@ io.spring.start.site.extension.dependency.postgresql.PostgresqlProjectGeneration io.spring.start.site.extension.dependency.redis.RedisProjectGenerationConfiguration,\ io.spring.start.site.extension.dependency.sbom.SbomProjectGenerationConfiguration,\ io.spring.start.site.extension.dependency.solace.SolaceProjectGenerationConfiguration,\ +io.spring.start.site.extension.dependency.springai.SpringAiChromaProjectGenerationConfiguration,\ +io.spring.start.site.extension.dependency.springai.SpringAiDockerComposeProjectGenerationConfiguration,\ +io.spring.start.site.extension.dependency.springai.SpringAiMilvusProjectGenerationConfiguration,\ +io.spring.start.site.extension.dependency.springai.SpringAiOllamaProjectGenerationConfiguration,\ +io.spring.start.site.extension.dependency.springai.SpringAiQdrantProjectGenerationConfiguration,\ +io.spring.start.site.extension.dependency.springai.SpringAiTestcontainersProjectGenerationConfiguration,\ +io.spring.start.site.extension.dependency.springai.SpringAiWeaviateProjectGenerationConfiguration,\ io.spring.start.site.extension.dependency.springamqp.SpringAmqpProjectGenerationConfiguration,\ io.spring.start.site.extension.dependency.springazure.SpringAzureProjectGenerationConfiguration,\ io.spring.start.site.extension.dependency.springboot.SpringBootProjectGenerationConfiguration,\ diff --git a/start-site/src/test/java/io/spring/start/site/extension/dependency/springai/SpringAiDockerComposeProjectGenerationConfigurationTests.java b/start-site/src/test/java/io/spring/start/site/extension/dependency/springai/SpringAiDockerComposeProjectGenerationConfigurationTests.java new file mode 100644 index 00000000000..f687cd9a81c --- /dev/null +++ b/start-site/src/test/java/io/spring/start/site/extension/dependency/springai/SpringAiDockerComposeProjectGenerationConfigurationTests.java @@ -0,0 +1,55 @@ +/* + * Copyright 2012-2024 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. + * 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.spring.start.site.extension.dependency.springai; + +import io.spring.initializr.web.project.ProjectRequest; +import io.spring.start.site.extension.AbstractExtensionTests; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +import java.util.stream.Stream; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Tests for {@link SpringAiDockerComposeProjectGenerationConfiguration}. + * + * @author Eddú Meléndez + */ +class SpringAiDockerComposeProjectGenerationConfigurationTests extends AbstractExtensionTests { + + @ParameterizedTest + @MethodSource("supportedDockerComposeSpringAiEntriesBuild") + void springAiTestcontainersDependencyIsAdded(String springAiDependency) { + ProjectRequest projectRequest = createProject("3.3.0", "docker-compose", springAiDependency); + assertThat(mavenPom(projectRequest)).hasDependency("org.springframework.ai", + "spring-ai-spring-boot-docker-compose", null, "test"); + } + + private ProjectRequest createProject(String springBootVersion, String... styles) { + ProjectRequest projectRequest = createProjectRequest(styles); + projectRequest.setLanguage("java"); + projectRequest.setBootVersion(springBootVersion); + return projectRequest; + } + + static Stream supportedDockerComposeSpringAiEntriesBuild() { + return Stream.of("spring-ai-vectordb-chroma", "spring-ai-vectordb-milvus", "spring-ai-ollama", + "spring-ai-vectordb-qdrant", "spring-ai-vectordb-weaviate"); + } + +} diff --git a/start-site/src/test/java/io/spring/start/site/extension/dependency/springai/TestcontainersConfigurationTests.java b/start-site/src/test/java/io/spring/start/site/extension/dependency/springai/SpringAiTestcontainersProjectGenerationConfigurationTests.java similarity index 85% rename from start-site/src/test/java/io/spring/start/site/extension/dependency/springai/TestcontainersConfigurationTests.java rename to start-site/src/test/java/io/spring/start/site/extension/dependency/springai/SpringAiTestcontainersProjectGenerationConfigurationTests.java index d9caa98d0f9..a63b1ad8dff 100644 --- a/start-site/src/test/java/io/spring/start/site/extension/dependency/springai/TestcontainersConfigurationTests.java +++ b/start-site/src/test/java/io/spring/start/site/extension/dependency/springai/SpringAiTestcontainersProjectGenerationConfigurationTests.java @@ -26,17 +26,18 @@ import static org.assertj.core.api.Assertions.assertThat; /** - * Tests for {@link TestcontainersConfiguration}. + * Tests for {@link SpringAiTestcontainersProjectGenerationConfiguration}. * * @author Eddú Meléndez */ -class TestcontainersConfigurationTests extends AbstractExtensionTests { +class SpringAiTestcontainersProjectGenerationConfigurationTests extends AbstractExtensionTests { @ParameterizedTest @MethodSource("supportedTestcontainersSpringAiEntriesBuild") void springAiTestcontainersDependencyIsAdded(String springAiDependency) { ProjectRequest projectRequest = createProject("3.3.0", "testcontainers", springAiDependency); - assertThat(mavenPom(projectRequest)).hasDependency(getDependency("spring-ai-testcontainers")); + assertThat(mavenPom(projectRequest)).hasDependency("org.springframework.ai", + "spring-ai-spring-boot-testcontainers", null, "test"); } private ProjectRequest createProject(String springBootVersion, String... styles) { diff --git a/start-site/src/test/java/io/spring/start/site/extension/dependency/testcontainers/TestcontainersProjectGenerationConfigurationTests.java b/start-site/src/test/java/io/spring/start/site/extension/dependency/testcontainers/TestcontainersProjectGenerationConfigurationTests.java index fe4ce4cfedb..359eafa4ffa 100644 --- a/start-site/src/test/java/io/spring/start/site/extension/dependency/testcontainers/TestcontainersProjectGenerationConfigurationTests.java +++ b/start-site/src/test/java/io/spring/start/site/extension/dependency/testcontainers/TestcontainersProjectGenerationConfigurationTests.java @@ -95,9 +95,10 @@ static Stream supportedEntriesBuild320() { Arguments.arguments("db2", "db2"), Arguments.arguments("kafka", "kafka"), Arguments.arguments("kafka-streams", "kafka"), Arguments.arguments("mariadb", "mariadb"), Arguments.arguments("mysql", "mysql"), Arguments.arguments("postgresql", "postgresql"), - Arguments.arguments("oracle", "oracle-free"), Arguments.arguments("pulsar", "pulsar"), - Arguments.arguments("pulsar-reactive", "pulsar"), Arguments.arguments("solace", "solace"), - Arguments.arguments("spring-ai-vectordb-neo4j", "neo4j"), + Arguments.arguments("oracle", "oracle-free"), + Arguments.arguments("spring-ai-vectordb-oracle", "oracle-free"), + Arguments.arguments("pulsar", "pulsar"), Arguments.arguments("pulsar-reactive", "pulsar"), + Arguments.arguments("solace", "solace"), Arguments.arguments("spring-ai-vectordb-neo4j", "neo4j"), Arguments.arguments("spring-ai-vectordb-pgvector", "postgresql"), Arguments.arguments("sqlserver", "mssqlserver")); } @@ -109,7 +110,7 @@ static Stream supportedTestcontainersActiveMQEntriesBuild() { static Stream supportedTestcontainersSpringAiEntriesBuild() { return Stream.of(Arguments.arguments("spring-ai-vectordb-chroma", "chromadb"), Arguments.arguments("spring-ai-vectordb-milvus", "milvus"), - Arguments.arguments("spring-ai-vectordb-ollama", "ollama"), + Arguments.arguments("spring-ai-vectordb-oracle", "oracle-free"), Arguments.arguments("spring-ai-vectordb-qdrant", "qdrant"), Arguments.arguments("spring-ai-vectordb-weaviate", "weaviate")); } diff --git a/start-site/src/test/resources/compose/chroma.yaml b/start-site/src/test/resources/compose/chroma.yaml index 731d0d8f523..9f00255351c 100644 --- a/start-site/src/test/resources/compose/chroma.yaml +++ b/start-site/src/test/resources/compose/chroma.yaml @@ -1,5 +1,5 @@ services: chroma: - image: 'chromadb/chroma' + image: 'chromadb/chroma:latest' ports: - '8000' diff --git a/start-site/src/test/resources/compose/ollama.yaml b/start-site/src/test/resources/compose/ollama.yaml index a86d4f9562f..60ccf775b2f 100644 --- a/start-site/src/test/resources/compose/ollama.yaml +++ b/start-site/src/test/resources/compose/ollama.yaml @@ -1,5 +1,5 @@ services: ollama: - image: 'ollama/ollama' + image: 'ollama/ollama:latest' ports: - '11434' diff --git a/start-site/src/test/resources/compose/qdrant.yaml b/start-site/src/test/resources/compose/qdrant.yaml index 519feae3d1c..01613ae2fd7 100644 --- a/start-site/src/test/resources/compose/qdrant.yaml +++ b/start-site/src/test/resources/compose/qdrant.yaml @@ -1,5 +1,5 @@ services: qdrant: - image: 'qdrant/qdrant' + image: 'qdrant/qdrant:latest' ports: - '6334' diff --git a/start-site/src/test/resources/compose/weaviate.yaml b/start-site/src/test/resources/compose/weaviate.yaml index b51bbe037e1..4dac3a88bbf 100644 --- a/start-site/src/test/resources/compose/weaviate.yaml +++ b/start-site/src/test/resources/compose/weaviate.yaml @@ -1,5 +1,5 @@ services: weaviate: - image: 'semitechnologies/weaviate' + image: 'semitechnologies/weaviate:latest' ports: - '8080'