Skip to content

Commit 73fbaaf

Browse files
committed
DATAMONGO-1707 - Upgrade to Reactor 3.1 M2.
Adopt to API change from Publisher.subscribe() to Publisher.toProcessor(). Adopt to changed reactor-test groupId. Provide mocks for calls that allowed previously null Publishers.
1 parent 17937b0 commit 73fbaaf

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

spring-data-mongodb/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
</dependency>
112112

113113
<dependency>
114-
<groupId>io.projectreactor.addons</groupId>
114+
<groupId>io.projectreactor</groupId>
115115
<artifactId>reactor-test</artifactId>
116116
<version>${reactor}</version>
117117
<optional>true</optional>

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/query/ReactiveMongoParameterAccessor.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016 the original author or authors.
2+
* Copyright 2016-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -15,20 +15,20 @@
1515
*/
1616
package org.springframework.data.mongodb.repository.query;
1717

18+
import reactor.core.publisher.Flux;
19+
import reactor.core.publisher.Mono;
20+
import reactor.core.publisher.MonoProcessor;
21+
1822
import java.util.ArrayList;
1923
import java.util.List;
2024

2125
import org.springframework.data.repository.util.ReactiveWrapperConverters;
2226
import org.springframework.data.repository.util.ReactiveWrappers;
2327

24-
import reactor.core.publisher.Flux;
25-
import reactor.core.publisher.Mono;
26-
import reactor.core.publisher.MonoProcessor;
27-
2828
/**
2929
* Reactive {@link org.springframework.data.repository.query.ParametersParameterAccessor} implementation that subscribes
3030
* to reactive parameter wrapper types upon creation. This class performs synchronization when acessing parameters.
31-
*
31+
*
3232
* @author Mark Paluch
3333
* @author Christoph Strobl
3434
* @since 2.0
@@ -55,9 +55,9 @@ public ReactiveMongoParameterAccessor(MongoQueryMethod method, Object[] values)
5555
}
5656

5757
if (ReactiveWrappers.isSingleValueType(value.getClass())) {
58-
subscriptions.add(ReactiveWrapperConverters.toWrapper(value, Mono.class).subscribe());
58+
subscriptions.add(ReactiveWrapperConverters.toWrapper(value, Mono.class).toProcessor());
5959
} else {
60-
subscriptions.add(ReactiveWrapperConverters.toWrapper(value, Flux.class).collectList().subscribe());
60+
subscriptions.add(ReactiveWrapperConverters.toWrapper(value, Flux.class).collectList().toProcessor());
6161
}
6262
}
6363
}

spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/ReactiveMongoTemplateUnitTests.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import static org.mockito.Mockito.any;
2222
import static org.springframework.data.mongodb.core.aggregation.Aggregation.*;
2323

24+
import reactor.core.publisher.Mono;
25+
2426
import org.bson.Document;
2527
import org.junit.Before;
2628
import org.junit.Ignore;
@@ -137,6 +139,8 @@ public void existsShouldUseCollationWhenPresent() {
137139
@Test // DATAMONGO-1518
138140
public void findAndModfiyShoudUseCollationWhenPresent() {
139141

142+
when(collection.findOneAndUpdate(any(), any(), any())).thenReturn(Mono.empty());
143+
140144
template.findAndModify(new BasicQuery("{}").collation(Collation.of("fr")), new Update(), AutogenerateableId.class)
141145
.subscribe();
142146

@@ -149,6 +153,8 @@ public void findAndModfiyShoudUseCollationWhenPresent() {
149153
@Test // DATAMONGO-1518
150154
public void findAndRemoveShouldUseCollationWhenPresent() {
151155

156+
when(collection.findOneAndDelete(any(), any())).thenReturn(Mono.empty());
157+
152158
template.findAndRemove(new BasicQuery("{}").collation(Collation.of("fr")), AutogenerateableId.class).subscribe();
153159

154160
ArgumentCaptor<FindOneAndDeleteOptions> options = ArgumentCaptor.forClass(FindOneAndDeleteOptions.class);
@@ -174,6 +180,8 @@ public void findAndRemoveManyShouldUseCollationWhenPresent() {
174180
@Test // DATAMONGO-1518
175181
public void updateOneShouldUseCollationWhenPresent() {
176182

183+
when(collection.updateOne(any(), any(), any())).thenReturn(Mono.empty());
184+
177185
template.updateFirst(new BasicQuery("{}").collation(Collation.of("fr")), new Update().set("foo", "bar"),
178186
AutogenerateableId.class).subscribe();
179187

@@ -186,6 +194,8 @@ public void updateOneShouldUseCollationWhenPresent() {
186194
@Test // DATAMONGO-1518
187195
public void updateManyShouldUseCollationWhenPresent() {
188196

197+
when(collection.updateMany(any(), any(), any())).thenReturn(Mono.empty());
198+
189199
template.updateMulti(new BasicQuery("{}").collation(Collation.of("fr")), new Update().set("foo", "bar"),
190200
AutogenerateableId.class).subscribe();
191201

@@ -199,6 +209,8 @@ public void updateManyShouldUseCollationWhenPresent() {
199209
@Test // DATAMONGO-1518
200210
public void replaceOneShouldUseCollationWhenPresent() {
201211

212+
when(collection.replaceOne(any(), any(), any())).thenReturn(Mono.empty());
213+
202214
template.updateFirst(new BasicQuery("{}").collation(Collation.of("fr")), new Update(), AutogenerateableId.class)
203215
.subscribe();
204216

0 commit comments

Comments
 (0)