Skip to content

Commit

Permalink
update audits
Browse files Browse the repository at this point in the history
  • Loading branch information
evanchooly committed Nov 15, 2024
1 parent d17602b commit 27b19b3
Show file tree
Hide file tree
Showing 18 changed files with 60 additions and 17 deletions.
3 changes: 2 additions & 1 deletion core/src/test/java/dev/morphia/test/MorphiaVersionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@
import org.semver4j.Semver;
import org.testng.annotations.Test;

import static dev.morphia.test.TestBase.GIT_ROOT;
import static java.lang.String.format;
import static org.testng.Assert.assertEquals;

public class MorphiaVersionTest {
@Test
public void testVersion() throws Exception {
MavenXpp3Reader reader = new MavenXpp3Reader();
Model model = reader.read(new FileReader(new File("../pom.xml").getAbsoluteFile()));
Model model = reader.read(new FileReader(new File(GIT_ROOT, "pom.xml").getAbsoluteFile()));

var version = Semver.parse(model.getVersion());
String minorVersion = format("%s%s", version.getMajor(), version.getMinor());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import static dev.morphia.aggregation.expressions.ArrayExpressions.array;
import static dev.morphia.aggregation.expressions.ArrayExpressions.concatArrays;
import static dev.morphia.aggregation.expressions.MathExpressions.add;
import static dev.morphia.aggregation.expressions.SystemVariables.REMOVE;
import static dev.morphia.aggregation.stages.AddFields.addFields;
import static dev.morphia.aggregation.stages.Match.match;
import static dev.morphia.query.filters.Filters.eq;
Expand Down Expand Up @@ -75,4 +76,15 @@ public void testExample4() {
addFields().field("homework", concatArrays("$homework", array(7)))));
}

/**
* test data: dev/morphia/test/aggregation/stages/addFields/example5
*
* db.labReadings.aggregate( [ { $addFields: { date: "$$REMOVE" } } ] )
*/
@Test(testName = "Remove Fields")
public void testExample5() {
testPipeline(new ActionTestOptions().removeIds(true),
aggregation -> aggregation.pipeline(addFields().field("date", REMOVE)));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,15 @@ public void testLookup() {
assertEquals(lookups.get(2).getInventoryDocs().get(1), inventories.get(5));
}

/**
* test data: dev/morphia/test/aggregation/stages/lookup/example7
*
* db.cakeFlavors.aggregate( [ { $lookup: { from: "cakeFlavors", pipeline: [ {
* $documents: [ {} ] } ], as: "test" } } ] )
*/
@Test(testName = "Namespaces in Subpipelines")
public void testExample7() {
// this is just an error case in the docs. nothing to test.
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,12 @@ public void testExample3() {
document("_id", 5).field("flavor", "vanilla").field("price", 20)))));
}

/**
* test data: dev/morphia/test/aggregation/stages/unionWith/example4
*/
@Test(testName = "Namespaces in Subpipelines")
public void testExample4() {
// this is just an error case in the docs. nothing to test.
}

}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{ "_id" : 1, "item" : "ABC1", quarter: "13Q1", "description" : "product 1" }
{ "_id" : 2, "item" : "ABC2", quarter: "13Q4", "description" : "product 2" }
{ "_id" : 3, "item" : "XYZ1", quarter: "14Q2", "description" : null }
{ _id : 1, item : "ABC1", quarter: "13Q1", description : "product 1" },
{ _id : 2, item : "ABC2", quarter: "13Q4", description : "product 2" },
{ _id : 3, item : "XYZ1", quarter: "14Q2", description : null }
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{ "_id" : 1, "itemDescription" : "ABC1 - product 1" }
{ "_id" : 2, "itemDescription" : "ABC2 - product 2" }
{ "_id" : 3, "itemDescription" : null }
{ _id : 1, itemDescription : "ABC1 - product 1" }
{ _id : 2, itemDescription : "ABC2 - product 2" }
{ _id : 3, itemDescription : null }
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "_id" : 1, "item" : "abc", "price" : 10, "quantity" : 2, "date" : ISODate("2014-01-01T08:15:39.736Z")}
{ "_id" : 1, "item" : "abc", "price" : 10, "quantity" : 2, "date" : ISODate("2014-01-01T08:15:39.736Z") }
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "_id" : 1, "item" : "abc", "price" : 10, "quantity" : 2, "date" : ISODate("2014-01-01T08:15:39.736Z")}
{ "_id" : 1, "item" : "abc", "price" : 10, "quantity" : 2, "date" : ISODate("2014-01-01T08:15:39.736Z") }
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
the docs seem to be in conflict with what's actually happening in the server
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{ "_id" : 1, "item" : "ABC1", quarter: "13Q1", "description" : "product 1" }
{ "_id" : 2, "item" : "ABC2", quarter: "13Q4", "description" : "product 2" }
{ "_id" : 1, "item" : "ABC1", quarter: "13Q1", "description" : "product 1" },
{ "_id" : 2, "item" : "ABC2", quarter: "13Q4", "description" : "product 2" },
{ "_id" : 3, "item" : "XYZ1", quarter: "14Q2", "description" : null }
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{ "_id" : 1, "item" : "ABC1", quarter: "13Q1", "description" : "PRODUCT 1" }
{ "_id" : 2, "item" : "abc2", quarter: "13Q4", "description" : "Product 2" }
{ "_id" : 1, "item" : "ABC1", quarter: "13Q1", "description" : "PRODUCT 1" },
{ "_id" : 2, "item" : "abc2", quarter: "13Q4", "description" : "Product 2" },
{ "_id" : 3, "item" : "xyz1", quarter: "14Q2", "description" : null }
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{ "_id" : 1, "item" : "ABC1", quarter: "13Q1", "description" : "PRODUCT 1" }
{ "_id" : 2, "item" : "abc2", quarter: "13Q4", "description" : "Product 2" }
{ "_id" : 1, "item" : "ABC1", quarter: "13Q1", "description" : "PRODUCT 1" },
{ "_id" : 2, "item" : "abc2", quarter: "13Q4", "description" : "Product 2" },
{ "_id" : 3, "item" : "xyz1", quarter: "14Q2", "description" : null }
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
$addFields: { date: "$$REMOVE" }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{ date: ISODate("2024-10-09"), temperature: 80 },
{ date: null, temperature: 83 },
{ date: ISODate("2024-12-09"), temperature: 85 }
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{ _id: ObjectId('671285306fd2c3b24f2e7eaa'), temperature: 80 },
{ _id: ObjectId('671285306fd2c3b24f2e7eab'), temperature: 83 },
{ _id: ObjectId('671285306fd2c3b24f2e7eac'), temperature: 85 }
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove Fields
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ version: '2', queryHash: '478AD696', planCacheKey: 'B1435201', isActive: true, works: NumberLong("5"), timeOfCreation: ISODate("2023-05-22T20:33:49.009Z"), cachedPlan: { slots: '$$RESULT=s11 env: { s3 = 1684787629009 (NOW), s6 = Nothing, s5 = Nothing, s1 = TimeZoneDatabase(Asia/Kuwait...Etc/UCT) (timeZoneDB), s10 = {"item" : 1, "price" : 1}, s2 = Nothing (SEARCH_META) }', stages: '[2] nlj inner [] [s4, s7, s8, s9, s10] \n' + ' left \n' + ' [1] cfilter {(exists(s5) && exists(s6))} \n' + ' [1] ixseek s5 s6 s9 s4 s7 s8 [] @"358822b7-c129-47b7-ad7f-40017a51b03c" @"item_1_price_1" true \n' + ' right \n' + ' [2] limit 1 \n' + ' [2] seek s4 s11 s12 s7 s8 s9 s10 none none [] @"358822b7-c129-47b7-ad7f-40017a51b03c" true false \n' }, indexFilterSet: false, isPinned: false, estimatedSizeBytes: NumberLong("7415"), host: 'mongodb1.example.net:27018' }
{ version: '2', planCacheShapeHash: '478AD696', planCacheKey: 'B1435201', isActive: true, works: NumberLong("5"), timeOfCreation: ISODate("2023-05-22T20:33:49.009Z"), cachedPlan: { slots: '$$RESULT=s11 env: { s3 = 1684787629009 (NOW), s6 = Nothing, s5 = Nothing, s1 = TimeZoneDatabase(Asia/Kuwait...Etc/UCT) (timeZoneDB), s10 = {"item" : 1, "price" : 1}, s2 = Nothing (SEARCH_META) }', stages: '[2] nlj inner [] [s4, s7, s8, s9, s10] \n' + ' left \n' + ' [1] cfilter {(exists(s5) && exists(s6))} \n' + ' [1] ixseek s5 s6 s9 s4 s7 s8 [] @"358822b7-c129-47b7-ad7f-40017a51b03c" @"item_1_price_1" true \n' + ' right \n' + ' [2] limit 1 \n' + ' [2] seek s4 s11 s12 s7 s8 s9 s10 none none [] @"358822b7-c129-47b7-ad7f-40017a51b03c" true false \n' }, indexFilterSet: false, isPinned: false, estimatedSizeBytes: NumberLong("7415"), host: 'mongodb1.example.net:27018' }
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Using ``$expr`` With Conditional Statements
Use $expr With Conditional Statements

0 comments on commit 27b19b3

Please sign in to comment.