Skip to content

Commit

Permalink
Fix test setup so that temporal conversions use symmetric timezone se…
Browse files Browse the repository at this point in the history
…tting.

Closes: #4446
Original Pull Request: #4447
  • Loading branch information
sxhinzvc authored and christophstrobl committed Jul 17, 2023
1 parent 77a9622 commit 529a0c7
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import java.net.URL;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.time.temporal.ChronoUnit;
import java.util.*;

Expand Down Expand Up @@ -110,6 +109,7 @@
* @author Mark Paluch
* @author Roman Puchkovskiy
* @author Heesu Jung
* @author Julia Lee
*/
@ExtendWith(MockitoExtension.class)
class MappingMongoConverterUnitTests {
Expand Down Expand Up @@ -2623,7 +2623,7 @@ void readsMapThatDoesNotComeAsDocument() {
void projectShouldReadSimpleInterfaceProjection() {

org.bson.Document source = new org.bson.Document("birthDate",
Date.from(LocalDate.of(1999, 12, 1).atStartOfDay().toInstant(ZoneOffset.UTC))).append("foo", "Walter");
Date.from(LocalDate.of(1999, 12, 1).atStartOfDay(systemDefault()).toInstant())).append("foo", "Walter");

EntityProjectionIntrospector discoverer = EntityProjectionIntrospector.create(converter.getProjectionFactory(),
EntityProjectionIntrospector.ProjectionPredicate.typeHierarchy()
Expand All @@ -2641,7 +2641,7 @@ void projectShouldReadSimpleInterfaceProjection() {
void projectShouldReadSimpleDtoProjection() {

org.bson.Document source = new org.bson.Document("birthDate",
Date.from(LocalDate.of(1999, 12, 1).atStartOfDay().toInstant(ZoneOffset.UTC))).append("foo", "Walter");
Date.from(LocalDate.of(1999, 12, 1).atStartOfDay(systemDefault()).toInstant())).append("foo", "Walter");

EntityProjectionIntrospector introspector = EntityProjectionIntrospector.create(converter.getProjectionFactory(),
EntityProjectionIntrospector.ProjectionPredicate.typeHierarchy()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@

/**
* @author Christoph Strobl
* @author Julia Lee
*/
public abstract class AbstractEncryptionTestBase {

Expand Down Expand Up @@ -450,7 +451,8 @@ public MongoClient mongoClient() {
protected void configureConverters(MongoConverterConfigurationAdapter converterConfigurationAdapter) {

converterConfigurationAdapter
.registerPropertyValueConverterFactory(PropertyValueConverterFactory.beanFactoryAware(applicationContext));
.registerPropertyValueConverterFactory(PropertyValueConverterFactory.beanFactoryAware(applicationContext))
.useNativeDriverJavaTimeCodecs();
}

@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
* Encryption tests for client having {@link AutoEncryptionSettings#isBypassAutoEncryption()}.
*
* @author Christoph Strobl
* @author Julia Lee
*/
@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = Config.class)
Expand Down Expand Up @@ -78,7 +79,8 @@ protected void configureClientSettings(Builder builder) {
protected void configureConverters(MongoConverterConfigurationAdapter converterConfigurationAdapter) {

converterConfigurationAdapter
.registerPropertyValueConverterFactory(PropertyValueConverterFactory.beanFactoryAware(applicationContext));
.registerPropertyValueConverterFactory(PropertyValueConverterFactory.beanFactoryAware(applicationContext))
.useNativeDriverJavaTimeCodecs();
}

@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@

/**
* @author Christoph Strobl
* @author Julia Lee
*/
@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = Config.class)
Expand All @@ -82,7 +83,8 @@ public MongoClient mongoClient() {
protected void configureConverters(MongoConverterConfigurationAdapter converterConfigurationAdapter) {

converterConfigurationAdapter
.registerPropertyValueConverterFactory(PropertyValueConverterFactory.beanFactoryAware(applicationContext));
.registerPropertyValueConverterFactory(PropertyValueConverterFactory.beanFactoryAware(applicationContext))
.useNativeDriverJavaTimeCodecs();
}

@Bean
Expand Down

0 comments on commit 529a0c7

Please sign in to comment.