Skip to content

Commit

Permalink
Fixes broken examples
Browse files Browse the repository at this point in the history
  • Loading branch information
gsteinacker committed Oct 24, 2018
1 parent 506c7e6 commit 648a2af
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import static org.slf4j.LoggerFactory.getLogger;

@Configuration
@EnableConfigurationProperties(MongoProperties.class)
@ConditionalOnProperty(prefix = "edison.jobs", name = "mongo.enabled", havingValue = "true")
@ConditionalOnBean(type = "com.mongodb.MongoClient")
public class MongoJobsConfiguration {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import de.otto.edison.status.indicator.StatusDetailIndicator;
import org.bson.Document;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;

Expand All @@ -17,6 +18,7 @@
import static java.util.Collections.singletonList;

@Component
@ConditionalOnBean(MongoDatabase.class)
@ConditionalOnProperty(prefix = "edison.mongo.status", name = "enabled", havingValue = "true", matchIfMissing = true)
public class MongoStatusDetailIndicator implements StatusDetailIndicator {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.bson.codecs.configuration.CodecRegistry;
import org.slf4j.Logger;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand All @@ -15,6 +16,7 @@
import static org.slf4j.LoggerFactory.getLogger;

@Configuration
@ConditionalOnProperty(prefix = "edison.mongo", name = "db")
@EnableConfigurationProperties(MongoProperties.class)
public class MongoConfiguration {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import org.slf4j.Logger;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.togglz.core.repository.StateRepository;
Expand All @@ -16,7 +15,6 @@
import static org.slf4j.LoggerFactory.getLogger;

@Configuration
@EnableConfigurationProperties(MongoProperties.class)
@ConditionalOnProperty(prefix = "edison.togglz", name = "mongo.enabled", havingValue = "true")
@ConditionalOnBean(type = "com.mongodb.MongoClient")
public class MongoTogglzConfiguration {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ class MongoTogglzConfigurationTest {
private final AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();

@ImportAutoConfiguration({TogglzConfiguration.class, MongoTogglzConfiguration.class, InMemoryFeatureStateRepositoryConfiguration.class})
private static class TogglzAutoConfiguration {
private static class TogglzTestConfiguration {
}

@ImportAutoConfiguration({MongoConfiguration.class, TogglzConfiguration.class, MongoTogglzConfiguration.class, InMemoryFeatureStateRepositoryConfiguration.class})
private static class MongoTogglzTestConfiguration {
}

@AfterEach
Expand All @@ -29,8 +33,7 @@ void close() {

@Test
public void shouldUseMongoStateRepositoryIfEnabled() {
this.context.register(MongoConfiguration.class);
this.context.register(TogglzAutoConfiguration.class);
this.context.register(MongoTogglzTestConfiguration.class);
TestPropertyValues
.of("edison.togglz.mongo.enabled=true")
.and("edison.mongo.db=db")
Expand All @@ -45,8 +48,7 @@ public void shouldUseMongoStateRepositoryIfEnabled() {

@Test
public void shouldUseInMemoryStateRepositoryIfMongoDisabled() {
this.context.register(MongoConfiguration.class);
this.context.register(TogglzAutoConfiguration.class);
this.context.register(MongoTogglzTestConfiguration.class);
TestPropertyValues
.of("edison.togglz.mongo.enabled=false")
.and("edison.mongo.db=db")
Expand All @@ -61,7 +63,7 @@ public void shouldUseInMemoryStateRepositoryIfMongoDisabled() {

@Test
public void shouldUseInMemoryStateRepositoryIfMissingMongoClient() {
this.context.register(TogglzAutoConfiguration.class);
this.context.register(TogglzTestConfiguration.class);
TestPropertyValues
.of("edison.togglz.mongo.enabled=true")
.and("edison.mongo.db=db")
Expand Down

0 comments on commit 648a2af

Please sign in to comment.