Skip to content

Commit 9f4872d

Browse files
christophstroblmp911de
authored andcommitted
DATAMONGO-2370 - Polishing.
Use JUnit Jupiter api for tests of touched classes and fix parsing errors in disabled ones. Original pull request: #803.
1 parent 7abf69e commit 9f4872d

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

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

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
import java.util.Arrays;
2121

2222
import org.bson.Document;
23-
import org.junit.Before;
24-
import org.junit.Ignore;
25-
import org.junit.Test;
23+
import org.junit.jupiter.api.BeforeEach;
24+
import org.junit.jupiter.api.Disabled;
25+
import org.junit.jupiter.api.Test;
2626
import org.springframework.data.mongodb.core.Person;
2727

2828
/**
@@ -38,8 +38,8 @@ public class SpelExpressionTransformerUnitTests {
3838

3939
Data data;
4040

41-
@Before
42-
public void setup() {
41+
@BeforeEach
42+
public void beforeEach() {
4343

4444
this.data = new Data();
4545
this.data.primitiveLongValue = 42;
@@ -108,7 +108,7 @@ public void shouldRenderNestedFieldReference() {
108108
}
109109

110110
@Test // DATAMONGO-774
111-
@Ignore
111+
@Disabled
112112
public void shouldRenderNestedIndexedFieldReference() {
113113

114114
// TODO add support for rendering nested indexed field references
@@ -161,23 +161,25 @@ public void shouldRenderParameterExpressionResults() {
161161
}
162162

163163
@Test // DATAMONGO-774
164-
@Ignore("TODO: mongo3 renders this a bit strange")
165164
public void shouldRenderNestedParameterExpressionResults() {
166165

167166
assertThat(
168167
((Document) transform("[0].primitiveLongValue + [0].primitiveDoubleValue + [0].doubleValue.longValue()", data))
169-
.toJson()).isEqualTo(Document.parse("{ \"$add\" : [ 42 , 1.2345 , 23]}").toJson());
168+
.toJson())
169+
.isEqualTo(Document
170+
.parse("{ \"$add\" : [ { $numberLong : \"42\"} , 1.2345 , { $numberLong : \"23\" } ]}").toJson());
170171
}
171172

172173
@Test // DATAMONGO-774
173-
@Ignore("TODO: mongo3 renders this a bit strange")
174174
public void shouldRenderNestedParameterExpressionResultsInNestedExpressions() {
175175

176176
assertThat(
177177
((Document) transform("((1 + [0].primitiveLongValue) + [0].primitiveDoubleValue) * [0].doubleValue.longValue()",
178-
data)).toJson()).isEqualTo(
179-
new Document("$multiply", Arrays.asList(new Document("$add", Arrays.asList(1, 42L, 1.2345D, 23L))))
180-
.toJson());
178+
data)).toJson())
179+
.isEqualTo(new Document("$multiply",
180+
Arrays.<Object> asList(
181+
new Document("$add", Arrays.<Object> asList(1, new Document("$numberLong", "42"), 1.2345D)),
182+
new Document("$numberLong", "23"))).toJson());
181183
}
182184

183185
@Test // DATAMONGO-840
@@ -680,9 +682,8 @@ public void shouldRenderMethodReferenceReverseArray() {
680682
}
681683

682684
@Test // DATAMONGO-1548
683-
@Ignore("Document API cannot render String[]")
684685
public void shouldRenderMethodReferenceReduce() {
685-
assertThat(transform("reduce(field, '', {'$concat':new String[]{'$$value','$$this'}})")).isEqualTo(Document.parse(
686+
assertThat(transform("reduce(field, '', {'$concat':{'$$value','$$this'}})")).isEqualTo(Document.parse(
686687
"{ \"$reduce\" : { \"input\" : \"$field\" , \"initialValue\" : \"\" , \"in\" : { \"$concat\" : [ \"$$value\" , \"$$this\"]}}}"));
687688
}
688689

0 commit comments

Comments
 (0)