Skip to content

Commit 8da9df1

Browse files
committed
Correct test for Mongo UUID representation alignment
Closes gh-46859
1 parent 8e3fa0e commit 8da9df1

File tree

2 files changed

+55
-6
lines changed

2 files changed

+55
-6
lines changed

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/MongoAutoConfigurationTests.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -243,12 +243,6 @@ public ConnectionString getConnectionString() {
243243
.doesNotHaveBean(PropertiesMongoConnectionDetails.class));
244244
}
245245

246-
@Test
247-
void uuidRepresentationDefaultsAreAligned() {
248-
this.contextRunner.run((context) -> assertThat(getSettings(context).getUuidRepresentation())
249-
.isEqualTo(new MongoProperties().getUuidRepresentation()));
250-
}
251-
252246
private MongoClientSettings getSettings(AssertableApplicationContext context) {
253247
assertThat(context).hasSingleBean(MongoClient.class);
254248
MongoClientImpl client = (MongoClientImpl) context.getBean(MongoClient.class);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Copyright 2012-present the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.autoconfigure.mongo;
18+
19+
import org.bson.UuidRepresentation;
20+
import org.junit.jupiter.api.Test;
21+
22+
import org.springframework.data.mongodb.config.MongoConfigurationSupport;
23+
24+
import static org.assertj.core.api.Assertions.assertThat;
25+
26+
/**
27+
* Tests for {@link MongoProperties}.
28+
*
29+
* @author Andy Wilkinson
30+
*/
31+
class MongoPropertiesTests {
32+
33+
@Test
34+
void defaultUUidRepresentationIsAlignedWithSpringData() {
35+
UuidRepresentation springDataDefault = springDataDefaultUuidRepresentation();
36+
UuidRepresentation springBootDefault = new MongoProperties().getUuidRepresentation();
37+
assertThat(springBootDefault).isEqualTo(springDataDefault);
38+
}
39+
40+
private UuidRepresentation springDataDefaultUuidRepresentation() {
41+
return new MongoConfigurationSupport() {
42+
43+
@Override
44+
protected String getDatabaseName() {
45+
return "test";
46+
}
47+
48+
UuidRepresentation defaultUuidRepresentation() {
49+
return mongoClientSettings().getUuidRepresentation();
50+
}
51+
52+
}.defaultUuidRepresentation();
53+
}
54+
55+
}

0 commit comments

Comments
 (0)