Skip to content

Commit b585783

Browse files
committed
DATAMONGO-1578 - Polishing.
Add ticket references to test methods. Extend license years in copyright header. Original pull request: #398.
1 parent 3924b6f commit b585783

File tree

1 file changed

+41
-8
lines changed

1 file changed

+41
-8
lines changed

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

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013-2015 the original author or authors.
2+
* Copyright 2013-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.
@@ -46,11 +46,17 @@ public class ProjectionOperationUnitTests {
4646
static final String DIVIDE = "$divide";
4747
static final String PROJECT = "$project";
4848

49+
/**
50+
* @see DATAMONGO-586
51+
*/
4952
@Test(expected = IllegalArgumentException.class)
5053
public void rejectsNullFields() {
5154
new ProjectionOperation(null);
5255
}
5356

57+
/**
58+
* @see DATAMONGO-586
59+
*/
5460
@Test
5561
public void declaresBackReferenceCorrectly() {
5662

@@ -62,6 +68,9 @@ public void declaresBackReferenceCorrectly() {
6268
assertThat(projectClause.get("prop"), is((Object) Fields.UNDERSCORE_ID_REF));
6369
}
6470

71+
/**
72+
* @see DATAMONGO-586
73+
*/
6574
@Test
6675
public void alwaysUsesExplicitReference() {
6776

@@ -74,6 +83,9 @@ public void alwaysUsesExplicitReference() {
7483
assertThat(projectClause.get("bar"), is((Object) "$foobar"));
7584
}
7685

86+
/**
87+
* @see DATAMONGO-586
88+
*/
7789
@Test
7890
public void aliasesSimpleFieldProjection() {
7991

@@ -85,6 +97,9 @@ public void aliasesSimpleFieldProjection() {
8597
assertThat(projectClause.get("bar"), is((Object) "$foo"));
8698
}
8799

100+
/**
101+
* @see DATAMONGO-586
102+
*/
88103
@Test
89104
public void aliasesArithmeticProjection() {
90105

@@ -100,6 +115,9 @@ public void aliasesArithmeticProjection() {
100115
assertThat(addClause.get(1), is((Object) 41));
101116
}
102117

118+
/**
119+
* @see DATAMONGO-586
120+
*/
103121
@Test
104122
public void arithmenticProjectionOperationWithoutAlias() {
105123

@@ -113,6 +131,9 @@ public void arithmenticProjectionOperationWithoutAlias() {
113131
assertThat(oper.get(ADD), is((Object) Arrays.<Object> asList("$a", 1)));
114132
}
115133

134+
/**
135+
* @see DATAMONGO-586
136+
*/
116137
@Test
117138
public void arithmenticProjectionOperationPlus() {
118139

@@ -127,6 +148,9 @@ public void arithmenticProjectionOperationPlus() {
127148
assertThat(oper.get(ADD), is((Object) Arrays.<Object> asList("$a", 1)));
128149
}
129150

151+
/**
152+
* @see DATAMONGO-586
153+
*/
130154
@Test
131155
public void arithmenticProjectionOperationMinus() {
132156

@@ -141,6 +165,9 @@ public void arithmenticProjectionOperationMinus() {
141165
assertThat(oper.get(SUBTRACT), is((Object) Arrays.<Object> asList("$a", 1)));
142166
}
143167

168+
/**
169+
* @see DATAMONGO-586
170+
*/
144171
@Test
145172
public void arithmenticProjectionOperationMultiply() {
146173

@@ -155,6 +182,9 @@ public void arithmenticProjectionOperationMultiply() {
155182
assertThat(oper.get(MULTIPLY), is((Object) Arrays.<Object> asList("$a", 1)));
156183
}
157184

185+
/**
186+
* @see DATAMONGO-586
187+
*/
158188
@Test
159189
public void arithmenticProjectionOperationDivide() {
160190

@@ -169,12 +199,18 @@ public void arithmenticProjectionOperationDivide() {
169199
assertThat(oper.get(DIVIDE), is((Object) Arrays.<Object> asList("$a", 1)));
170200
}
171201

202+
/**
203+
* @see DATAMONGO-586
204+
*/
172205
@Test(expected = IllegalArgumentException.class)
173206
public void arithmenticProjectionOperationDivideByZeroException() {
174207

175208
new ProjectionOperation().and("a").divide(0);
176209
}
177210

211+
/**
212+
* @see DATAMONGO-586
213+
*/
178214
@Test
179215
public void arithmenticProjectionOperationMod() {
180216

@@ -274,9 +310,8 @@ public void projectionExpressions() {
274310
.and("foo").as("bar"); //
275311

276312
DBObject dbObject = operation.toDBObject(Aggregation.DEFAULT_CONTEXT);
277-
assertThat(
278-
dbObject.toString(),
279-
is("{ \"$project\" : { \"grossSalesPrice\" : { \"$multiply\" : [ { \"$add\" : [ \"$netPrice\" , \"$surCharge\"]} , \"$taxrate\" , 2]} , \"bar\" : \"$foo\"}}"));
313+
assertThat(dbObject.toString(), is(
314+
"{ \"$project\" : { \"grossSalesPrice\" : { \"$multiply\" : [ { \"$add\" : [ \"$netPrice\" , \"$surCharge\"]} , \"$taxrate\" , 2]} , \"bar\" : \"$foo\"}}"));
280315
}
281316

282317
/**
@@ -331,10 +366,8 @@ public void shouldRenderDateTimeFragmentExtractionsForExpressionProjectionsCorre
331366
assertThat(dbObject, is(notNullValue()));
332367

333368
DBObject projected = exctractOperation("$project", dbObject);
334-
assertThat(
335-
projected.get("dayOfYearPlus1Day"),
336-
is((Object) new BasicDBObject("$dayOfYear", Arrays.asList(new BasicDBObject("$add", Arrays.<Object> asList(
337-
"$date", 86400000))))));
369+
assertThat(projected.get("dayOfYearPlus1Day"), is((Object) new BasicDBObject("$dayOfYear",
370+
Arrays.asList(new BasicDBObject("$add", Arrays.<Object> asList("$date", 86400000))))));
338371
}
339372

340373
/**

0 commit comments

Comments
 (0)