How can I write test cases for @Bean method?

137 views Asked by At
@Bean
public MongoTemplate method1() throws Exception { 
     return new MongoTemplate(mongoDbConnection(), databaseName);
}` @Bean
public MongoClient method2() throws Exception {
    uri = uri + "Example String";
    ConnectionString connectionString = new ConnectionString(uri);
    return MongoClients.create(connectionString);

}` how can I write the test cases for the above methods

1

There are 1 answers

1
Wang Zhenyu On

If it is an object creation class that knows the expected value, you do not need to perform a test. If you must test, you only need to verify that the object is created and initialized properly.