From 2462f67be4d53bfd2d1a4d0f798e4c77084b7091 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Fri, 29 Oct 2021 11:23:35 +0100 Subject: [PATCH] Align test for spring.data.mongodb.autoIndexCreation with new default Closes gh-28481 --- .../mongo/MongoDataAutoConfigurationTests.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/mongo/MongoDataAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/mongo/MongoDataAutoConfigurationTests.java index 27e70829309..9e3f7763458 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/mongo/MongoDataAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/mongo/MongoDataAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 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. @@ -147,13 +147,21 @@ class MongoDataAutoConfigurationTests { } @Test - void customAutoIndexCreation() { - this.contextRunner.withPropertyValues("spring.data.mongodb.autoIndexCreation:false").run((context) -> { + void defaultAutoIndexCreation() { + this.contextRunner.run((context) -> { MongoMappingContext mappingContext = context.getBean(MongoMappingContext.class); assertThat(mappingContext.isAutoIndexCreation()).isFalse(); }); } + @Test + void customAutoIndexCreation() { + this.contextRunner.withPropertyValues("spring.data.mongodb.autoIndexCreation:true").run((context) -> { + MongoMappingContext mappingContext = context.getBean(MongoMappingContext.class); + assertThat(mappingContext.isAutoIndexCreation()).isTrue(); + }); + } + @Test void interfaceFieldNamingStrategy() { this.contextRunner