Skip to content

Generate test application when spring ai oracle is selected #1577

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* 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.
Expand All @@ -16,6 +16,7 @@

package io.spring.start.site.extension.dependency.oracle;

import io.spring.initializr.generator.buildsystem.Build;
import io.spring.initializr.generator.condition.ConditionalOnRequestedDependency;
import io.spring.start.site.container.ComposeFileCustomizer;
import io.spring.start.site.container.DockerServiceResolver;
Expand All @@ -30,26 +31,38 @@
*
* @author Moritz Halbritter
* @author Stephane Nicoll
* @author Eddú Meléndez
*/
@Configuration(proxyBeanMethods = false)
@ConditionalOnRequestedDependency("oracle")
class OracleProjectGenerationConfiguration {

private static final String TESTCONTAINERS_CLASS_NAME = "org.testcontainers.oracle.OracleContainer";

@Bean
@ConditionalOnRequestedDependency("testcontainers")
ServiceConnectionsCustomizer oracleServiceConnectionsCustomizer(DockerServiceResolver serviceResolver) {
return (serviceConnections) -> serviceResolver.doWith("oracleFree",
(service) -> serviceConnections.addServiceConnection(
ServiceConnectionsCustomizer oracleServiceConnectionsCustomizer(Build build,
DockerServiceResolver serviceResolver) {
return (serviceConnections) -> {
if (isOracleEnabled(build)) {
serviceResolver.doWith("oracleFree", (service) -> serviceConnections.addServiceConnection(
ServiceConnection.ofContainer("oracleFree", service, TESTCONTAINERS_CLASS_NAME, false)));
}
};
}

@Bean
@ConditionalOnRequestedDependency("docker-compose")
ComposeFileCustomizer oracleComposeFileCustomizer(DockerServiceResolver serviceResolver) {
return (composeFile) -> serviceResolver.doWith("oracleFree", (service) -> composeFile.services()
.add("oracle", service.andThen((builder) -> builder.environment("ORACLE_PASSWORD", "secret"))));
ComposeFileCustomizer oracleComposeFileCustomizer(Build build, DockerServiceResolver serviceResolver) {
return (composeFile) -> {
if (isOracleEnabled(build)) {
serviceResolver.doWith("oracleFree", (service) -> composeFile.services()
.add("oracle", service.andThen((builder) -> builder.environment("ORACLE_PASSWORD", "secret"))));
}
};
}

private boolean isOracleEnabled(Build build) {
return build.dependencies().has("oracle") || build.dependencies().has("spring-ai-vectordb-oracle");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ static Iterable<ImplicitDependency> 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/")));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
* Tests for {@link OracleProjectGenerationConfiguration}.
*
* @author Moritz Halbritter
* @author Eddú Meléndez
*/
class OracleProjectGenerationConfigurationTests extends AbstractExtensionTests {

Expand All @@ -48,6 +49,13 @@ void createsOracleFreeServiceWithBoot32() {
assertThat(composeFile(request)).hasSameContentAs(new ClassPathResource("compose/oracle-free.yaml"));
}

@Test
void createsOracleFreeServiceWithBoot32AndSpringAi() {
ProjectRequest request = createProjectRequest("docker-compose", "spring-ai-vectordb-oracle");
request.setBootVersion(SPRING_BOOT_VERSION);
assertThat(composeFile(request)).hasSameContentAs(new ClassPathResource("compose/oracle-free.yaml"));
}

@Test
void declaresOracleFreeContainerBeanWithBoot32() {
ProjectRequest request = createProjectRequest("testcontainers", "oracle");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ static Stream<Arguments> supportedEntriesBuild320() {
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("spring-ai-vectordb-oracle", "oracle-free"),
Arguments.arguments("spring-ai-vectordb-pgvector", "postgresql"),
Arguments.arguments("sqlserver", "mssqlserver"));
}
Expand Down