DATAMONGO-1133 - Fixed broken tests,

AggregationTests.shouldHonorFieldAliasesForFieldReferences() now correctly sets up 3 different instances of MeterData and correctly calculates the aggreated counter values.

Original pull request: #279.
This commit is contained in:
Thomas Darimont
2015-02-16 16:32:50 +01:00
committed by Oliver Gierke
parent 1c6ab25253
commit b887fa70a5
2 changed files with 4 additions and 6 deletions

View File

@@ -1057,8 +1057,7 @@ public class AggregationTests {
TypedAggregation<MeterData> agg = newAggregation(MeterData.class, //
match(where("resourceId").is("m1")), //
group("counterName").sum("counterVolume").as("totalValue") //
);
group("counterName").sum("counterVolume").as("totalValue"));
AggregationResults<DBObject> results = mongoTemplate.aggregate(agg, DBObject.class);
@@ -1066,7 +1065,7 @@ public class AggregationTests {
DBObject result = results.getMappedResults().get(0);
assertThat(result.get("_id"), is(equalTo((Object) "counter1")));
assertThat(result.get("totalValue"), is(equalTo((Object) 42.0)));
assertThat(result.get("totalValue"), is(equalTo((Object) 100.0)));
}
private void assertLikeStats(LikeStats like, String id, long count) {

View File

@@ -23,12 +23,11 @@ import org.springframework.data.mongodb.core.mapping.Field;
*/
public class MeterData {
@Id String resourceId;
@Id String id;
String resourceId;
@Field("counter_name") String counterName;
double counterVolume;
public MeterData() {}
public MeterData(String resourceId, String counterName, double counterVolume) {
this.resourceId = resourceId;