Skip to content

Commit

Permalink
add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
qing-wq committed Nov 21, 2024
1 parent a4e3e89 commit 2d9e602
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package dev.langchain4j.service.spring.mode.automatic.Issue2133;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
* @author: qing
* @Date: 2024/11/20
*/
@SpringBootApplication
public class TestAutowireAiServiceApplication {

@Autowired
TestAutowireConfiguration testAutowireConfiguration;

public static void main(String[] args) {
SpringApplication.run(TestAutowireAiServiceApplication.class, args);
}

TestAutowireConfiguration getConfiguration() {
return testAutowireConfiguration;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package dev.langchain4j.service.spring.mode.automatic.Issue2133;

import dev.langchain4j.service.spring.AiServicesAutoConfig;
import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;

import static org.junit.jupiter.api.Assertions.assertNotNull;

class TestAutowireClassAiServiceIT {

ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(AiServicesAutoConfig.class));

@Test
void should_get_configuration_class() {
contextRunner
.withUserConfiguration(TestAutowireAiServiceApplication.class)
.withBean(TestAutowireConfiguration.class)
.run(context -> {
// given
TestAutowireAiServiceApplication application = context.getBean(TestAutowireAiServiceApplication.class);

// should get the configuration class
assertNotNull(application.getConfiguration(), "TestConfiguration class should be not null");
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package dev.langchain4j.service.spring.mode.automatic.Issue2133;

import org.springframework.context.annotation.Configuration;

/**
* @author: qing
* @Date: 2024/11/20
*/
@Configuration
class TestAutowireConfiguration {
}

0 comments on commit 2d9e602

Please sign in to comment.