diff --git a/audits/src/main/kotlin/dev/morphia/audits/RstAuditor.kt b/audits/src/main/kotlin/dev/morphia/audits/RstAuditor.kt index e6e9dc303c7..f8cc2bf7192 100644 --- a/audits/src/main/kotlin/dev/morphia/audits/RstAuditor.kt +++ b/audits/src/main/kotlin/dev/morphia/audits/RstAuditor.kt @@ -251,7 +251,7 @@ class RstAuditor(val type: OperatorType) { } else { method.setBody( """ - |testPipeline(dev.morphia.test.ServerVersion.ANY, false, true, aggregation -> aggregation + |testPipeline(new dev.morphia.test.util.ActionTestOptions().serverVersion(dev.morphia.test.ServerVersion.ANY).removeIds(false).orderMatters(true), aggregation -> aggregation | .pipeline( | |)); """ diff --git a/core/src/test/java/dev/morphia/test/TemplatedTestBase.java b/core/src/test/java/dev/morphia/test/TemplatedTestBase.java index 74fc8670d10..7796992ac3a 100644 --- a/core/src/test/java/dev/morphia/test/TemplatedTestBase.java +++ b/core/src/test/java/dev/morphia/test/TemplatedTestBase.java @@ -12,18 +12,14 @@ import java.util.List; import java.util.Objects; import java.util.function.Function; -import java.util.regex.Pattern; import com.fasterxml.jackson.databind.ObjectMapper; import com.mongodb.client.MongoCollection; -import com.mongodb.client.result.UpdateResult; -import com.mongodb.lang.NonNull; import com.mongodb.lang.Nullable; import dev.morphia.UpdateOptions; import dev.morphia.aggregation.Aggregation; import dev.morphia.aggregation.AggregationImpl; -import dev.morphia.mapping.codec.reader.DocumentReader; import dev.morphia.query.FindOptions; import dev.morphia.query.MorphiaQuery; import dev.morphia.query.Query; @@ -33,14 +29,10 @@ import org.bson.BsonInvalidOperationException; import org.bson.Document; -import org.bson.codecs.DecoderContext; import org.bson.json.JsonParseException; import org.bson.json.JsonWriterSettings; import org.jetbrains.annotations.NotNull; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import static java.lang.Character.toLowerCase; @@ -51,52 +43,40 @@ import static java.util.stream.Collectors.toList; import static org.bson.json.JsonWriterSettings.builder; import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; import static org.testng.Assert.fail; public abstract class TemplatedTestBase extends TestBase { - private static final Logger LOG = LoggerFactory.getLogger(TemplatedTestBase.class); - public static final JsonWriterSettings JSON_WRITER_SETTINGS = builder() .indent(true) .build(); protected static final String EXAMPLE_TEST_COLLECTION = "example_test"; - private static final Pattern ACTION = Pattern.compile("^db\\.\\w+\\.\\w+\\(.*$"); - protected final ObjectMapper mapper = new ObjectMapper(); - protected boolean skipActionCheck = false; - @Deprecated - protected boolean skipDataCheck = false; public TemplatedTestBase() { buildConfig() .codecProvider(new ZDTCodecProvider()); } - @NotNull - public static File rootToCore(String path) { - return new File(CORE_ROOT, path); - } - - @BeforeMethod - public void resetSkip() { - skipActionCheck = false; - } - - public final String prefix() { - String root = getClass().getSimpleName().replace("Test", ""); - return toLowerCase(root.charAt(0)) + root.substring(1); + protected static String toString(List actual, String prefix) { + return actual.stream() + .map(c -> c.toJson(JSON_WRITER_SETTINGS)) + .collect(joining("\n\t", prefix, "")); } - @Deprecated - public void skipDataCheck() { - skipDataCheck = true; - } + private static List unwrapArray(List resource) { + String line = resource.get(0).trim(); + if (line.startsWith("[")) { + resource.set(0, line.trim().substring(1)); + } + var last = resource.size() - 1; + line = resource.get(last).trim(); + if (line.endsWith("]")) { + resource.set(last, line.substring(0, line.length() - 1)); + } - public void skipActionCheck() { - skipActionCheck = true; + return resource; } @AfterClass @@ -134,26 +114,100 @@ public void testCoverage() { } } - protected static String toString(List actual, String prefix) { - return actual.stream() - .map(c -> c.toJson(JSON_WRITER_SETTINGS)) - .collect(joining("\n\t", prefix, "")); + @NotNull + public static File rootToCore(String path) { + return new File(CORE_ROOT, path); } - @Deprecated - public void testQuery(MorphiaQuery query, FindOptions options, boolean orderMatters) { - var resourceName = discoverResourceName(); + public void testPipeline(Function, Aggregation> pipeline) { + testPipeline(new ActionTestOptions(), pipeline); + } - loadData(resourceName, getDs().getCollection(query.getEntityClass()).getNamespace().getCollectionName()); + public void testPipeline(ActionTestOptions options, + Function, Aggregation> pipeline) { + var resourceName = prepareDatabase(options); + + validateTestName(resourceName); - List actual = runQuery(resourceName, query, options); + List actual = runPipeline(options, resourceName, pipeline.apply(getDs().aggregate(EXAMPLE_TEST_COLLECTION))); - List expected = map(query.getEntityClass(), loadExpected(resourceName)); + checkExpected(options, resourceName, actual); + } - if (orderMatters) { - assertEquals(actual, expected); + protected String discoverResourceName() { + var method = findTestMethod(); + String methodName = method.getName(); + + if (methodName.startsWith("test")) { + methodName = methodName.substring(4); + methodName = methodName.substring(0, 1).toLowerCase() + methodName.substring(1); + } + return methodName; + } + + protected void loadData(String resourceName, String collection) { + insert(collection, loadJson(format("%s/%s/data.json", prefix(), resourceName), "data", true)); + } + + protected void loadData(String collection, int index) { + insert(collection, loadJson(format("%s/%s/data%d.json", prefix(), discoverResourceName(), index), "data", true)); + } + + protected @NotNull List loadExpected(String resourceName) { + return loadJson("%s/%s/expected.json".formatted(prefix(), resourceName), "expected", true); + } + + protected Method findTestMethod() { + return stream(new Exception().getStackTrace()) + .map(this::isTestMethod) + .filter(Objects::nonNull) + .findFirst() + .get(); + } + + @NotNull + protected List loadJson(String name, String type, boolean failOnMissing) { + List data = new ArrayList<>(); + InputStream stream = getClass().getResourceAsStream(name); + if (stream == null) { + if (failOnMissing) { + fail(format("missing " + type + " file: src/test/resources/%s/%s", + getClass().getPackageName().replace('.', '/'), name)); + } } else { - assertListEquals(actual, expected); + try (BufferedReader reader = new BufferedReader(new InputStreamReader(stream))) { + while (reader.ready()) { + String json = reader.readLine(); + try { + if (json.startsWith("[") && json.endsWith("]")) { + json = json.substring(1, json.length() - 1); + } + data.add(Document.parse(json)); + } catch (JsonParseException e) { + throw new JsonParseException(e.getMessage() + "\n" + json, e); + } + } + } catch (IOException e) { + throw new RuntimeException(e.getMessage(), e); + } + } + return data; + } + + public final String prefix() { + String root = getClass().getSimpleName().replace("Test", ""); + return toLowerCase(root.charAt(0)) + root.substring(1); + } + + @Nullable + private Method isTestMethod(StackTraceElement element) { + try { + Class klass = Class.forName(element.getClassName()); + Method method = klass.getDeclaredMethod(element.getMethodName()); + + return method.getAnnotation(Test.class) != null ? method : null; + } catch (ReflectiveOperationException e) { + return null; } } @@ -189,100 +243,63 @@ public void testUpdate(ActionTestOptions options, checkExpected(options, resourceName, actual); } - protected void loadData(String resourceName, String collection) { - if (!skipDataCheck) { - insert(collection, loadJson(format("%s/%s/data.json", prefix(), resourceName), "data", true)); - } + protected List loadAction(String actionName) { + return extractDocuments(unwrapArray(loadResource(actionName))); } - protected void loadData(String collection, int index) { - if (!skipDataCheck) { + protected void loadData(ActionTestOptions options, String collection, int index) { + if (!options.skipDataCheck()) { insert(collection, loadJson(format("%s/%s/data%d.json", prefix(), discoverResourceName(), index), "data", true)); } } - protected void loadData(String resourceName, String collection, int index) { - if (!skipDataCheck) { - insert(collection, loadJson(format("%s/%s/data%d.json", prefix(), resourceName, index), "data", true)); - } - } - protected void loadIndex(String resourceName, String collectionName) { - final StackTraceElement[] stackTrace = new Exception().getStackTrace(); MongoCollection collection = getDatabase().getCollection(collectionName); List documents = loadJson("%s/%s/index.json".formatted(prefix(), resourceName), "index", false); - documents.forEach(document -> { - collection.createIndex(document); - }); - } - - protected @NotNull List loadExpected(String resourceName) { - return loadJson("%s/%s/expected.json".formatted(prefix(), resourceName), "expected", true); + documents.forEach(document -> collection.createIndex(document)); } - protected @NotNull List loadExpected(Class type, String resourceName) { - return loadJson(type, format("%s/%s/expected.json", prefix(), resourceName)); + protected Document loadQuery(String pipelineName) { + return loadAction(pipelineName).get(0); } - @NotNull - protected List loadJson(String name, String type, boolean failOnMissing) { - List data = new ArrayList<>(); - InputStream stream = getClass().getResourceAsStream(name); + protected List loadResource(String pipelineName) { + InputStream stream = getClass().getResourceAsStream(pipelineName); if (stream == null) { - if (failOnMissing) { - fail(format("missing " + type + " file: src/test/resources/%s/%s", - getClass().getPackageName().replace('.', '/'), name)); - } - } else { - try (BufferedReader reader = new BufferedReader(new InputStreamReader(stream))) { - while (reader.ready()) { - String json = reader.readLine(); - try { - if (json.startsWith("[") && json.endsWith("]")) { - json = json.substring(1, json.length() - 1); - } - data.add(Document.parse(json)); - } catch (JsonParseException e) { - throw new JsonParseException(e.getMessage() + "\n" + json, e); - } - } - } catch (IOException e) { - throw new RuntimeException(e.getMessage(), e); - } + fail(format("missing action file: src/test/resources/%s/%s", getClass().getPackageName().replace('.', '/'), + pipelineName)); } - return data; + return new BufferedReader(new InputStreamReader(stream)) + .lines() + .collect(toList()); } - @NotNull - protected List loadJson(Class type, String name) { - List data = new ArrayList<>(); + protected String loadTestName(String resourceName) { + String name = format("%s/%s/name", prefix(), resourceName); + InputStream stream = getClass().getResourceAsStream(name); if (stream == null) { - fail("missing data file: " + name); + fail(format("missing name file: %s", name)); } - ObjectMapper mapper = new ObjectMapper(); - try (BufferedReader reader = new BufferedReader(new InputStreamReader(stream))) { - while (reader.ready()) { - data.add(mapper.readValue(reader.readLine(), type)); - } + try (var reader = new BufferedReader(new InputStreamReader(stream))) { + return reader.readLine(); } catch (IOException e) { - throw new RuntimeException(e.getMessage(), e); + throw new RuntimeException(e); } - return data; } @SuppressWarnings({ "unchecked", "rawtypes" }) - protected List runPipeline(String pipelineTemplate, Aggregation aggregation) { + protected List runPipeline(ActionTestOptions options, String pipelineTemplate, Aggregation aggregation) { String pipelineName = format("%s/%s/action.json", prefix(), pipelineTemplate); List pipeline = ((AggregationImpl) aggregation).pipeline(); - if (!skipActionCheck) { + if (!options.skipActionCheck()) { List target = loadAction(pipelineName); assertEquals(toJson(pipeline), toJson(target), "Should generate the same pipeline"); } - if (!skipDataCheck) { + if (!options.skipDataCheck()) { try (var cursor = aggregation.execute(Document.class)) { return cursor.toList(); } @@ -291,12 +308,12 @@ protected List runPipeline(String pipelineTemplate, Aggregation runQuery(ActionTestOptions testOptions, String pipelineTemplate, Query query, FindOptions options) { String resourceName = format("%s/%s/action.json", prefix(), pipelineTemplate); Document document = ((MorphiaQuery) query).toDocument(); - if (!skipActionCheck && !testOptions.skipActionCheck()) { + if (!testOptions.skipActionCheck()) { Document target = loadQuery(resourceName); assertEquals(toJson(document), toJson(target), "Should generate the same query document"); } @@ -310,14 +327,14 @@ protected List runQuery(ActionTestOptions testOptions, String pipeline } } - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings({ "rawtypes" }) protected List runUpdate(ActionTestOptions testOptions, String pipelineTemplate, Query query, FindOptions options, UpdateOperator... operators) { String resourceName = format("%s/%s/action.json", prefix(), pipelineTemplate); Document document = ((MorphiaQuery) query).toDocument(); List action = loadAction(resourceName); - if (!skipActionCheck && !testOptions.skipActionCheck()) { + if (!testOptions.skipActionCheck()) { assertEquals(toJson(document), toJson(action.get(0)), "Should generate the same query document"); } @@ -325,7 +342,7 @@ protected List runUpdate(ActionTestOptions testOptions, String pipelin var others = Arrays.copyOfRange(operators, 1, operators.length); if (!testOptions.skipDataCheck()) { var resource = loadResource(resourceName); - UpdateResult update = query.update(new UpdateOptions().multi(resource.contains("updateMany")), first, others); + query.update(new UpdateOptions().multi(resource.contains("updateMany")), first, others); try (var cursor = getDs().find(EXAMPLE_TEST_COLLECTION, Document.class).iterator()) { return cursor.toList(); } @@ -334,6 +351,10 @@ protected List runUpdate(ActionTestOptions testOptions, String pipelin } } + protected String toJson(Document document) { + return document.toJson(JSON_WRITER_SETTINGS, getDatabase().getCodecRegistry().get(Document.class)); + } + protected void validateTestName(String resourceName) { Method method = findTestMethod(); Test test = method.getAnnotation(Test.class); @@ -343,6 +364,19 @@ protected void validateTestName(String resourceName) { method.getName())); } + private boolean balanced(String input) { + int open = 0; + int close = 0; + for (char c : input.toCharArray()) { + if (c == '{') + open++; + if (c == '}') + close++; + } + + return open != 0 && open == close; + } + private void checkExpected(ActionTestOptions options, String resourceName, List actual) { if (!options.skipDataCheck()) { List expected = loadExpected(resourceName); @@ -359,62 +393,6 @@ private void checkExpected(ActionTestOptions options, String resourceName, List< } } - private String prepareDatabase(ActionTestOptions options) { - checkMinServerVersion(options.serverVersion()); - checkMinDriverVersion(options.minDriver()); - var resourceName = discoverResourceName(); - validateTestName(resourceName); - if (!options.skipDataCheck()) { - loadData(resourceName, EXAMPLE_TEST_COLLECTION); - } - loadIndex(resourceName, EXAMPLE_TEST_COLLECTION); - return resourceName; - } - - private String toJson(List pipeline) { - return pipeline.stream() - .map(d -> d.toJson(JSON_WRITER_SETTINGS, getDatabase().getCodecRegistry().get(Document.class))) - .collect(joining("\n, ", "[\n", "\n]")); - } - - protected String toJson(Document document) { - return document.toJson(JSON_WRITER_SETTINGS, getDatabase().getCodecRegistry().get(Document.class)); - } - - protected Document loadQuery(String pipelineName) { - return loadAction(pipelineName).get(0); - } - - protected String loadTestName(String resourceName) { - String name = format("%s/%s/name", prefix(), resourceName); - - InputStream stream = getClass().getResourceAsStream(name); - if (stream == null) { - fail(format("missing name file: %s", name)); - } - - try (var reader = new BufferedReader(new InputStreamReader(stream))) { - return reader.readLine(); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - protected List loadAction(String actionName) { - return extractDocuments(unwrapArray(loadResource(actionName))); - } - - protected List loadResource(String pipelineName) { - InputStream stream = getClass().getResourceAsStream(pipelineName); - if (stream == null) { - fail(format("missing action file: src/test/resources/%s/%s", getClass().getPackageName().replace('.', '/'), - pipelineName)); - } - return new BufferedReader(new InputStreamReader(stream)) - .lines() - .collect(toList()); - } - private List extractDocuments(List resource) { var line = resource.get(0).trim(); if (line.startsWith("db.")) { @@ -442,94 +420,21 @@ private List extractDocuments(List resource) { return docs; } - private static List unwrapArray(List resource) { - String line = resource.get(0).trim(); - if (line.startsWith("[")) { - resource.set(0, line.trim().substring(1)); - } - var last = resource.size() - 1; - line = resource.get(last).trim(); - if (line.endsWith("]")) { - resource.set(last, line.substring(0, line.length() - 1)); - } - - return resource; - } - - private boolean balanced(String input) { - int open = 0; - int close = 0; - for (char c : input.toCharArray()) { - if (c == '{') - open++; - if (c == '}') - close++; - } - - return open != 0 && open == close; - } - - @NonNull - protected List runQuery(@NonNull String queryTemplate, @NonNull MorphiaQuery query, @NonNull FindOptions options) { - String queryName = format("%s/%s/query.json", prefix(), queryTemplate); - try { - - InputStream stream = getClass().getResourceAsStream(queryName); - assertNotNull(stream, "Could not find query template: " + queryName); - Document expectedQuery; - try (InputStreamReader reader = new InputStreamReader(stream)) { - expectedQuery = Document.parse(new BufferedReader(reader).readLine()); - } - - assertDocumentEquals(query.toDocument(), expectedQuery); - - try (var cursor = query.iterator(options)) { - return cursor.toList(); - } - } catch (IOException e) { - throw new RuntimeException(e.getMessage(), e); - } - } - - protected String discoverResourceName() { - var method = findTestMethod(); - String methodName = method.getName(); - - if (methodName.startsWith("test")) { - methodName = methodName.substring(4); - methodName = methodName.substring(0, 1).toLowerCase() + methodName.substring(1); - } - return methodName; - } - - protected Method findTestMethod() { - return stream(new Exception().getStackTrace()) - .map(this::isTestMethod) - .filter(Objects::nonNull) - .findFirst() - .get(); - } - - @Nullable - private Method isTestMethod(StackTraceElement element) { - try { - Class klass = Class.forName(element.getClassName()); - Method method = klass.getDeclaredMethod(element.getMethodName()); - - return method.getAnnotation(Test.class) != null ? method : null; - } catch (ReflectiveOperationException e) { - return null; + private String prepareDatabase(ActionTestOptions options) { + checkMinServerVersion(options.serverVersion()); + checkMinDriverVersion(options.minDriver()); + var resourceName = discoverResourceName(); + validateTestName(resourceName); + if (!options.skipDataCheck()) { + loadData(resourceName, EXAMPLE_TEST_COLLECTION); } + loadIndex(resourceName, EXAMPLE_TEST_COLLECTION); + return resourceName; } - private List map(Class entityClass, List documents) { - var codec = getDs().getCodecRegistry().get(entityClass); - - DecoderContext context = DecoderContext.builder().build(); - return documents.stream() - .map(document -> { - return codec.decode(new DocumentReader(document), context); - }) - .collect(toList()); + private String toJson(List pipeline) { + return pipeline.stream() + .map(d -> d.toJson(JSON_WRITER_SETTINGS, getDatabase().getCodecRegistry().get(Document.class))) + .collect(joining("\n, ", "[\n", "\n]")); } } diff --git a/core/src/test/java/dev/morphia/test/TestBase.java b/core/src/test/java/dev/morphia/test/TestBase.java index a7061ded1aa..bb32b272257 100644 --- a/core/src/test/java/dev/morphia/test/TestBase.java +++ b/core/src/test/java/dev/morphia/test/TestBase.java @@ -63,8 +63,6 @@ public abstract class TestBase extends MorphiaTestSetup { } } - protected DriverVersion minDriver = DriverVersion.v41; - public TestBase() { } @@ -362,11 +360,6 @@ private void assertSameType(String path, Object actual, Object expected) { } } - @BeforeMethod - private void setDriverMinimum() { - minDriver = DriverVersion.v43; - } - public static class ZDTCodecProvider implements CodecProvider { @Override public Codec get(Class clazz, CodecRegistry registry) { diff --git a/core/src/test/java/dev/morphia/test/TestTransactions.java b/core/src/test/java/dev/morphia/test/TestTransactions.java index 5c5bc576391..ea1306cb70a 100644 --- a/core/src/test/java/dev/morphia/test/TestTransactions.java +++ b/core/src/test/java/dev/morphia/test/TestTransactions.java @@ -13,7 +13,6 @@ import dev.morphia.annotations.Id; import dev.morphia.annotations.Reference; import dev.morphia.query.filters.Filters; -import dev.morphia.test.aggregation.AggregationTest; import dev.morphia.test.mapping.lazy.TestLazyCircularReference.ReferencedEntity; import dev.morphia.test.mapping.lazy.TestLazyCircularReference.RootEntity; import dev.morphia.test.models.Rectangle; @@ -34,7 +33,7 @@ import static org.testng.Assert.assertNull; //@Tags(@Tag("transactions")) -public class TestTransactions extends AggregationTest { +public class TestTransactions extends dev.morphia.test.TemplatedTestBase { @BeforeMethod public void before() { checkForReplicaSet(); @@ -168,14 +167,16 @@ public void merge() { @Test(testName = "transactional aggregations") public void aggregation() { getDs().withTransaction(session -> { - testPipeline(ServerVersion.ANY, false, false, aggregation -> { - loadData("aggTest2", 2); - return aggregation - .lookup(Lookup.lookup("aggTest2") - .localField("item") - .foreignField("sku") - .as("inventory_docs")); - }); + testPipeline( + new dev.morphia.test.util.ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(false), + aggregation -> { + loadData("aggTest2", 2); + return aggregation + .lookup(Lookup.lookup("aggTest2") + .localField("item") + .foreignField("sku") + .as("inventory_docs")); + }); return null; }); } diff --git a/core/src/test/java/dev/morphia/test/aggregation/AggregationTest.java b/core/src/test/java/dev/morphia/test/aggregation/AggregationTest.java index 5dc18167cff..f2534d2e388 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/AggregationTest.java +++ b/core/src/test/java/dev/morphia/test/aggregation/AggregationTest.java @@ -16,50 +16,9 @@ package dev.morphia.test.aggregation; -import java.util.List; -import java.util.function.Function; - -import dev.morphia.aggregation.Aggregation; -import dev.morphia.test.ServerVersion; import dev.morphia.test.TemplatedTestBase; -import dev.morphia.test.util.Comparanator; - -import org.bson.Document; @SuppressWarnings({ "unused", "MismatchedQueryAndUpdateOfCollection" }) public class AggregationTest extends TemplatedTestBase { - public void testPipeline(ServerVersion serverVersion, - Function, Aggregation> pipeline) { - testPipeline(serverVersion, true, true, pipeline); - } - - public void testPipeline(ServerVersion serverVersion, - boolean removeIds, - boolean orderMatters, - Function, Aggregation> pipeline) { - checkMinServerVersion(serverVersion); - checkMinDriverVersion(minDriver); - var resourceName = discoverResourceName(); - validateTestName(resourceName); - loadData(resourceName, EXAMPLE_TEST_COLLECTION); - loadIndex(resourceName, EXAMPLE_TEST_COLLECTION); - - List actual = runPipeline(resourceName, pipeline.apply(getDs().aggregate(EXAMPLE_TEST_COLLECTION))); - - if (!skipDataCheck) { - List expected = loadExpected(resourceName); - - actual = removeIds ? removeIds(actual) : actual; - expected = removeIds ? removeIds(expected) : expected; - - try { - Comparanator.of(null, actual, expected, orderMatters).compare(); - } catch (AssertionError e) { - throw new AssertionError("%s\n\n actual: %s".formatted(e.getMessage(), toString(actual, "\n\t")), - e); - } - } - } - } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestAbs.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestAbs.java index 92b15ee7ca4..ca427499f55 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestAbs.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestAbs.java @@ -1,6 +1,7 @@ package dev.morphia.test.aggregation.expressions; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -9,15 +10,16 @@ import static dev.morphia.aggregation.stages.Projection.project; import static dev.morphia.test.ServerVersion.ANY; -public class TestAbs extends AggregationTest { +public class TestAbs extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/abs/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ANY, false, true, aggregation -> aggregation - .pipeline(project().include("delta", abs(subtract("$startTemp", "$endTemp"))))); + testPipeline(new ActionTestOptions().serverVersion(ANY).removeIds(false).orderMatters(true), + aggregation -> aggregation + .pipeline(project().include("delta", abs(subtract("$startTemp", "$endTemp"))))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestAccumulator.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestAccumulator.java index 80b89a8b1b2..12411dbc7b6 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestAccumulator.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestAccumulator.java @@ -3,22 +3,23 @@ import java.util.List; import dev.morphia.aggregation.stages.Group; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.expressions.AccumulatorExpressions.accumulator; import static dev.morphia.test.ServerVersion.ANY; -public class TestAccumulator extends AggregationTest { +public class TestAccumulator extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/accumulator/example1 * */ @Test(testName = "Use ``$accumulator`` to Implement the ``$avg`` Operator") public void testExample1() { - skipActionCheck(); - testPipeline(ANY, false, false, + testPipeline( + new ActionTestOptions().serverVersion(ANY).removeIds(false).orderMatters(false).skipActionCheck(true), aggregation -> aggregation.pipeline(Group.group(Group.id("$author")).field("avgCopies", accumulator(""" function() { return { count: 0, sum: 0 } @@ -47,29 +48,32 @@ public void testExample1() { */ @Test(testName = "Use ``initArgs`` to Vary the Initial State by Group") public void testExample2() { - skipActionCheck(); - testPipeline(ANY, false, false, aggregation -> aggregation - .pipeline(Group.group(Group.id().field("city", "$city")).field("restaurants", accumulator(""" - function(city, userProfileCity) { \s - return { - max: city === userProfileCity ? 3 : 1, \s - restaurants: [] \s - }\s - }""", """ - function(state, restaurantName) { \s - if (state.restaurants.length < state.max) { - state.restaurants.push(restaurantName); - } - return state; - }""", List.of("$name"), """ - function(state1, state2) { \s - return { - max: state1.max, - restaurants: state1.restaurants.concat(state2.restaurants).slice(0, state1.max) - }\s - }""").initArgs(List.of("$city", "Bettles")).finalizeFunction(""" - function(state) { - return state.restaurants - }""")))); + testPipeline( + new ActionTestOptions().serverVersion(ANY).removeIds(false).orderMatters(false).skipActionCheck(true), + aggregation -> aggregation.pipeline(Group.group(Group.id().field("city", "$city")).field("restaurants", + accumulator(""" + function(city, userProfileCity) { \s + return { + max: city === userProfileCity ? 3 : 1, \s + restaurants: [] \s + }\s + }""", """ + function(state, restaurantName) { \s + if (state.restaurants.length < state.max) { + state.restaurants.push(restaurantName); + } + return state; + }""", List.of("$name"), + """ + function(state1, state2) { \s + return { + max: state1.max, + restaurants: state1.restaurants.concat(state2.restaurants).slice(0, state1.max) + }\s + }""") + .initArgs(List.of("$city", "Bettles")).finalizeFunction(""" + function(state) { + return state.restaurants + }""")))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestAcos.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestAcos.java index bf4e357a535..b9ca4ae4778 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestAcos.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestAcos.java @@ -1,6 +1,7 @@ package dev.morphia.test.aggregation.expressions; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -10,15 +11,16 @@ import static dev.morphia.aggregation.stages.AddFields.addFields; import static dev.morphia.test.ServerVersion.ANY; -public class TestAcos extends AggregationTest { +public class TestAcos extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/acos/example1 * */ @Test(testName = "main :: Inverse Cosine of Value in Degrees") public void testExample1() { - testPipeline(ANY, false, true, aggregation -> aggregation - .pipeline(addFields().field("angle_a", radiansToDegrees(acos(divide("$side_b", "$hypotenuse")))))); + testPipeline(new ActionTestOptions().serverVersion(ANY).removeIds(false).orderMatters(true), + aggregation -> aggregation.pipeline( + addFields().field("angle_a", radiansToDegrees(acos(divide("$side_b", "$hypotenuse")))))); } @@ -28,8 +30,9 @@ public void testExample1() { */ @Test(testName = "main :: Inverse Cosine of Value in Radians") public void testExample2() { - testPipeline(ANY, false, true, aggregation -> aggregation - .pipeline(addFields().field("angle_a", acos(divide("$side_b", "$hypotenuse"))))); + testPipeline(new ActionTestOptions().serverVersion(ANY).removeIds(false).orderMatters(true), + aggregation -> aggregation + .pipeline(addFields().field("angle_a", acos(divide("$side_b", "$hypotenuse"))))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestAcosh.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestAcosh.java index e23e4da27d8..40b7fc9dce6 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestAcosh.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestAcosh.java @@ -1,6 +1,7 @@ package dev.morphia.test.aggregation.expressions; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -9,15 +10,16 @@ import static dev.morphia.aggregation.stages.AddFields.addFields; import static dev.morphia.test.ServerVersion.ANY; -public class TestAcosh extends AggregationTest { +public class TestAcosh extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/acosh/example1 * */ @Test(testName = "main :: Inverse Hyperbolic Cosine in Degrees") public void testExample1() { - testPipeline(ANY, false, true, aggregation -> aggregation - .pipeline(addFields().field("y-coordinate", radiansToDegrees(acosh("$x-coordinate"))))); + testPipeline(new ActionTestOptions().serverVersion(ANY).removeIds(false).orderMatters(true), + aggregation -> aggregation + .pipeline(addFields().field("y-coordinate", radiansToDegrees(acosh("$x-coordinate"))))); } @@ -27,7 +29,7 @@ public void testExample1() { */ @Test(testName = "main :: Inverse Hyperbolic Cosine in Radians") public void testExample2() { - testPipeline(ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ANY).removeIds(false).orderMatters(true), aggregation -> aggregation.pipeline(addFields().field("y-coordinate", acosh("$x-coordinate")))); } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestAdd.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestAdd.java index 56ffde10d45..a0c16976298 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestAdd.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestAdd.java @@ -1,6 +1,7 @@ package dev.morphia.test.aggregation.expressions; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -8,15 +9,16 @@ import static dev.morphia.aggregation.stages.Projection.project; import static dev.morphia.test.ServerVersion.ANY; -public class TestAdd extends AggregationTest { +public class TestAdd extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/add/example1 * */ @Test(testName = "Add Numbers") public void testExample1() { - testPipeline(ANY, false, true, (aggregation) -> aggregation - .pipeline(project().include("item").include("total", add("$price", "$fee")))); + testPipeline(new ActionTestOptions().serverVersion(ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation + .pipeline(project().include("item").include("total", add("$price", "$fee")))); } /** @@ -25,8 +27,9 @@ public void testExample1() { */ @Test(testName = "Perform Addition on a Date") public void testExample2() { - testPipeline(ANY, false, true, aggregation -> aggregation - .pipeline(project().include("item", 1).include("billing_date", add("$date", 259200000)))); + testPipeline(new ActionTestOptions().serverVersion(ANY).removeIds(false).orderMatters(true), + aggregation -> aggregation + .pipeline(project().include("item", 1).include("billing_date", add("$date", 259200000)))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestAddToSet.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestAddToSet.java index cfff707c04a..98cba8cce30 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestAddToSet.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestAddToSet.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.aggregation.stages.Group; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -14,14 +15,14 @@ import static dev.morphia.query.Sort.ascending; import static dev.morphia.test.ServerVersion.ANY; -public class TestAddToSet extends AggregationTest { +public class TestAddToSet extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/addToSet/example1 * */ @Test(testName = "Use in ``$group`` Stage") public void testExample1() { - testPipeline(ANY, false, false, + testPipeline(new ActionTestOptions().serverVersion(ANY).removeIds(false).orderMatters(false), aggregation -> aggregation .pipeline(group(Group.id().field("day", dayOfYear("$date")).field("year", year("$date"))) .field("itemsSold", addToSet("$item"))) @@ -38,7 +39,7 @@ public void testExample1() { public void testExample2() { if (1 == 1) return; - testPipeline(ANY, false, false, + testPipeline(new ActionTestOptions().serverVersion(ANY).removeIds(false).orderMatters(false), aggregation -> aggregation.setWindowFields(setWindowFields().partitionBy("$state") .sortBy(ascending("orderDate")).output(output("cakeTypesForState").operator(addToSet("$type")) .window().documents("unbounded", "current")))); diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestAllElementsTrue.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestAllElementsTrue.java index 0095c71d735..08decd593ed 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestAllElementsTrue.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestAllElementsTrue.java @@ -1,22 +1,24 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.aggregation.stages.Projection; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.expressions.SetExpressions.allElementsTrue; import static dev.morphia.test.ServerVersion.ANY; -public class TestAllElementsTrue extends AggregationTest { +public class TestAllElementsTrue extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/allElementsTrue/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ANY, false, false, aggregation -> aggregation.pipeline(Projection.project().suppressId() - .include("responses").include("isAllTrue", allElementsTrue("$responses")))); + testPipeline(new ActionTestOptions().serverVersion(ANY).removeIds(false).orderMatters(false), + aggregation -> aggregation.pipeline(Projection.project().suppressId().include("responses") + .include("isAllTrue", allElementsTrue("$responses")))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestAnd.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestAnd.java index 7a7bf13fb24..1e132808201 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestAnd.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestAnd.java @@ -1,6 +1,7 @@ package dev.morphia.test.aggregation.expressions; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -10,15 +11,16 @@ import static dev.morphia.aggregation.stages.Projection.project; import static dev.morphia.test.ServerVersion.ANY; -public class TestAnd extends AggregationTest { +public class TestAnd extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/and/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ANY, false, true, aggregation -> aggregation.pipeline( - project().include("item").include("qty").include("result", and(gt("$qty", 100), lt("$qty", 250))))); + testPipeline(new ActionTestOptions().serverVersion(ANY).removeIds(false).orderMatters(true), + aggregation -> aggregation.pipeline(project().include("item").include("qty").include("result", + and(gt("$qty", 100), lt("$qty", 250))))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestAnyElementTrue.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestAnyElementTrue.java index b42ea2541d8..d0c6d1845e6 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestAnyElementTrue.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestAnyElementTrue.java @@ -1,6 +1,7 @@ package dev.morphia.test.aggregation.expressions; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -8,15 +9,16 @@ import static dev.morphia.aggregation.stages.Projection.project; import static dev.morphia.test.ServerVersion.ANY; -public class TestAnyElementTrue extends AggregationTest { +public class TestAnyElementTrue extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/anyElementTrue/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ANY, false, true, aggregation -> aggregation.pipeline( - project().suppressId().include("responses").include("isAnyTrue", anyElementTrue("$responses")))); + testPipeline(new ActionTestOptions().serverVersion(ANY).removeIds(false).orderMatters(true), + aggregation -> aggregation.pipeline(project().suppressId().include("responses").include("isAnyTrue", + anyElementTrue("$responses")))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestArrayElemAt.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestArrayElemAt.java index e1265b18084..8bf95a515a9 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestArrayElemAt.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestArrayElemAt.java @@ -1,21 +1,23 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.expressions.ArrayExpressions.elementAt; import static dev.morphia.aggregation.stages.Projection.project; -public class TestArrayElemAt extends AggregationTest { +public class TestArrayElemAt extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/arrayElemAt/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation.pipeline(project().include("name") - .include("first", elementAt("$favorites", 0)).include("last", elementAt("$favorites", -1)))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation.pipeline(project().include("name") + .include("first", elementAt("$favorites", 0)).include("last", elementAt("$favorites", -1)))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestArrayToObject.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestArrayToObject.java index a1cdfe5843d..95316119282 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestArrayToObject.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestArrayToObject.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -14,15 +15,16 @@ import static dev.morphia.aggregation.stages.AddFields.addFields; import static dev.morphia.aggregation.stages.Projection.project; -public class TestArrayToObject extends AggregationTest { +public class TestArrayToObject extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/arrayToObject/example1 * */ @Test(testName = "``$arrayToObject`` Example") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(project().include("item").include("dimensions", arrayToObject("$dimensions")))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation + .pipeline(project().include("item").include("dimensions", arrayToObject("$dimensions")))); } /** @@ -31,7 +33,7 @@ public void testExample1() { */ @Test(testName = "``$objectToArray`` + ``$arrayToObject`` Example") public void testExample2() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(addFields().field("instock", objectToArray("$instock")), addFields().field("instock", concatArrays("$instock", diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestAsin.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestAsin.java index 6cd7ae32915..d488dcef498 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestAsin.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestAsin.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -10,15 +11,16 @@ import static dev.morphia.aggregation.expressions.TrigonometryExpressions.radiansToDegrees; import static dev.morphia.aggregation.stages.AddFields.addFields; -public class TestAsin extends AggregationTest { +public class TestAsin extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/asin/example1 * */ @Test(testName = "main :: Inverse Sine of Value in Degrees") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(addFields().field("angle_a", radiansToDegrees(asin(divide("$side_a", "$hypotenuse")))))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation.pipeline( + addFields().field("angle_a", radiansToDegrees(asin(divide("$side_a", "$hypotenuse")))))); } /** @@ -27,8 +29,9 @@ public void testExample1() { */ @Test(testName = "main :: Inverse Sine of Value in Radians") public void testExample2() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(addFields().field("angle_a", asin(divide("$side_a", "$hypotenuse"))))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation + .pipeline(addFields().field("angle_a", asin(divide("$side_a", "$hypotenuse"))))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestAsinh.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestAsinh.java index ff4aaf97ad1..90acef3a9c6 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestAsinh.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestAsinh.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -9,15 +10,16 @@ import static dev.morphia.aggregation.expressions.TrigonometryExpressions.radiansToDegrees; import static dev.morphia.aggregation.stages.AddFields.addFields; -public class TestAsinh extends AggregationTest { +public class TestAsinh extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/asinh/example1 * */ @Test(testName = "main :: Inverse Hyperbolic Sine in Degrees") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(addFields().field("y-coordinate", radiansToDegrees(asinh("$x-coordinate"))))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation + .pipeline(addFields().field("y-coordinate", radiansToDegrees(asinh("$x-coordinate"))))); } /** @@ -26,7 +28,7 @@ public void testExample1() { */ @Test(testName = "main :: Inverse Hyperbolic Sine in Radians") public void testExample2() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(addFields().field("y-coordinate", asinh("$x-coordinate")))); } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestAtan.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestAtan.java index 9d8f155bd03..4112140669e 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestAtan.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestAtan.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -10,15 +11,16 @@ import static dev.morphia.aggregation.expressions.TrigonometryExpressions.radiansToDegrees; import static dev.morphia.aggregation.stages.AddFields.addFields; -public class TestAtan extends AggregationTest { +public class TestAtan extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/atan/example1 * */ @Test(testName = "main :: Inverse Tangent of Value in Degrees") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(addFields().field("angle_a", radiansToDegrees(atan(divide("$side_b", "$side_a")))))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation + .pipeline(addFields().field("angle_a", radiansToDegrees(atan(divide("$side_b", "$side_a")))))); } /** @@ -27,8 +29,9 @@ public void testExample1() { */ @Test(testName = "main :: Inverse Tangent of Value in Radians") public void testExample2() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(addFields().field("angle_a", atan(divide("$side_b", "$side_a"))))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation + .pipeline(addFields().field("angle_a", atan(divide("$side_b", "$side_a"))))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestAtan2.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestAtan2.java index 2d483ad7fc1..05dadee4248 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestAtan2.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestAtan2.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -9,15 +10,16 @@ import static dev.morphia.aggregation.expressions.TrigonometryExpressions.radiansToDegrees; import static dev.morphia.aggregation.stages.AddFields.addFields; -public class TestAtan2 extends AggregationTest { +public class TestAtan2 extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/atan2/example1 * */ @Test(testName = "main :: Inverse Tangent of Value in Degrees") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(addFields().field("angle_a", radiansToDegrees(atan2("$side_b", "$side_a"))))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation + .pipeline(addFields().field("angle_a", radiansToDegrees(atan2("$side_b", "$side_a"))))); } /** @@ -26,7 +28,7 @@ public void testExample1() { */ @Test(testName = "main :: Inverse Tangent of Value in Radians") public void testExample2() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(addFields().field("angle_a", atan2("$side_b", "$side_a")))); } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestAtanh.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestAtanh.java index ae67345b81f..148dc80644b 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestAtanh.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestAtanh.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -9,15 +10,16 @@ import static dev.morphia.aggregation.expressions.TrigonometryExpressions.radiansToDegrees; import static dev.morphia.aggregation.stages.AddFields.addFields; -public class TestAtanh extends AggregationTest { +public class TestAtanh extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/atanh/example1 * */ @Test(testName = "main :: Inverse Hyperbolic Tangent in Degrees") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(addFields().field("y-coordinate", radiansToDegrees(atanh("$x-coordinate"))))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation + .pipeline(addFields().field("y-coordinate", radiansToDegrees(atanh("$x-coordinate"))))); } /** @@ -26,7 +28,7 @@ public void testExample1() { */ @Test(testName = "main :: Inverse Hyperbolic Tangent in Radians") public void testExample2() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(addFields().field("y-coordinate", atanh("$x-coordinate")))); } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestAvg.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestAvg.java index 9407b2ae63a..c0c0b8cf394 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestAvg.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestAvg.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.aggregation.stages.Projection; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -11,15 +12,17 @@ import static dev.morphia.aggregation.stages.Group.id; import static dev.morphia.test.ServerVersion.ANY; -public class TestAvg extends AggregationTest { +public class TestAvg extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/avg/example1 * */ @Test(testName = "Use in ``$group`` Stage") public void testExample1() { - testPipeline(ANY, false, false, aggregation -> aggregation.pipeline(group(id("$item")) - .field("avgAmount", avg(multiply("$price", "$quantity"))).field("avgQuantity", avg("$quantity")))); + testPipeline(new ActionTestOptions().serverVersion(ANY).removeIds(false).orderMatters(false), + aggregation -> aggregation + .pipeline(group(id("$item")).field("avgAmount", avg(multiply("$price", "$quantity"))) + .field("avgQuantity", avg("$quantity")))); } @@ -29,7 +32,7 @@ public void testExample1() { */ @Test(testName = "Use in ``$project`` Stage") public void testExample2() { - testPipeline(ANY, false, false, + testPipeline(new ActionTestOptions().serverVersion(ANY).removeIds(false).orderMatters(false), aggregation -> aggregation.project(Projection.project().include("quizAvg", avg("$quizzes")) .include("labAvg", avg("$labs")).include("examAvg", avg("$final", "$midterm")))); @@ -43,7 +46,9 @@ public void testExample2() { public void testExample3() { // this has an include and throws off the parser /* - * testPipeline(v50, false, false, aggregation -> aggregation + * testPipeline(new + * dev.morphia.test.util.ActionTestOptions().serverVersion(v50).removeIds(false) + * .orderMatters(false), aggregation -> aggregation * .setWindowFields(SetWindowFields.setWindowFields() .partitionBy("$state") * .sortBy(ascending("orderDate")) .output(output("averageQuantityForState") * .operator(avg("$quantity")) .window() .documents("unbounded", "current")) diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestBinarySize.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestBinarySize.java index 741f7dc9e56..d2cc3b0640e 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestBinarySize.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestBinarySize.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -10,15 +11,16 @@ import static dev.morphia.aggregation.stages.Projection.project; import static dev.morphia.aggregation.stages.Sort.sort; -public class TestBinarySize extends AggregationTest { +public class TestBinarySize extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/binarySize/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(project().include("name", "$name").include("imageSize", binarySize("$binary")))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation + .pipeline(project().include("name", "$name").include("imageSize", binarySize("$binary")))); } /** @@ -27,7 +29,7 @@ public void testExample1() { */ @Test(testName = "Find Largest Binary Data") public void testExample2() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline( project().include("name", "$name").include("imageSize", binarySize("$binary")), sort().descending("imageSize"), limit(1))); diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestBitAnd.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestBitAnd.java index 9a6ea506552..a18e4769eac 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestBitAnd.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestBitAnd.java @@ -2,23 +2,23 @@ import java.io.FileNotFoundException; -import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.expressions.MathExpressions.bitAnd; import static dev.morphia.aggregation.stages.Projection.project; -import static dev.morphia.test.ServerVersion.v63; +import static dev.morphia.test.ServerVersion.v70; -public class TestBitAnd extends AggregationTest { +public class TestBitAnd extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/bitAnd/example1 */ @Test(testName = "Bitwise ``AND`` with Two Integers ") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(v70).removeIds(false).orderMatters(true), aggregation -> aggregation.pipeline(project().include("result", bitAnd("$a", "$b")))); } @@ -28,7 +28,7 @@ public void testExample1() { */ @Test(testName = "Bitwise ``AND`` with a Long and Integer ") public void testExample2() throws FileNotFoundException { - testPipeline(v63, false, true, + testPipeline(new ActionTestOptions().serverVersion(v70).removeIds(false).orderMatters(true), aggregation -> aggregation.project(project().include("result", bitAnd("$a", 63L)))); } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestBitNot.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestBitNot.java index 37eef5e008f..30e6e19b3da 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestBitNot.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestBitNot.java @@ -1,6 +1,7 @@ package dev.morphia.test.aggregation.expressions; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -8,7 +9,7 @@ import static dev.morphia.aggregation.stages.Projection.project; import static dev.morphia.test.ServerVersion.v63; -public class TestBitNot extends AggregationTest { +public class TestBitNot extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/bitNot/example1 @@ -16,6 +17,7 @@ public class TestBitNot extends AggregationTest { */ @Test(testName = "main") public void testExample1() { - testPipeline(v63, false, true, aggregation -> aggregation.pipeline(project().include("result", bitNot("$a")))); + testPipeline(new ActionTestOptions().serverVersion(v63), + aggregation -> aggregation.pipeline(project().include("result", bitNot("$a")))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestBitOr.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestBitOr.java index 387462a1425..719af64152e 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestBitOr.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestBitOr.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -9,14 +10,14 @@ import static dev.morphia.aggregation.stages.Projection.project; import static dev.morphia.test.ServerVersion.v63; -public class TestBitOr extends AggregationTest { +public class TestBitOr extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/bitOr/example1 */ @Test(testName = "Bitwise ``OR`` with Two Integers ") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), aggregation -> aggregation.pipeline(project().include("result", bitOr("$a", "$b")))); } @@ -26,7 +27,7 @@ public void testExample1() { */ @Test(testName = "Bitwise ``OR`` with a Long and Integer ", enabled = false, description = "this is getting odd unexpected results from the server") public void testExample2() { - testPipeline(v63, true, false, + testPipeline(new ActionTestOptions().serverVersion(v63).removeIds(true).orderMatters(false), aggregation -> aggregation.project(project().include("result", bitOr("$a", 63L)))); } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestBitXor.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestBitXor.java index 785941d8f35..ecaff635683 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestBitXor.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestBitXor.java @@ -1,6 +1,7 @@ package dev.morphia.test.aggregation.expressions; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -8,7 +9,7 @@ import static dev.morphia.aggregation.stages.Projection.project; import static dev.morphia.test.ServerVersion.v63; -public class TestBitXor extends AggregationTest { +public class TestBitXor extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/bitXor/example1 @@ -16,7 +17,7 @@ public class TestBitXor extends AggregationTest { */ @Test(testName = "main") public void testExample1() { - testPipeline(v63, false, true, + testPipeline(new ActionTestOptions().serverVersion(v63).removeIds(false).orderMatters(true), aggregation -> aggregation.pipeline(project().include("result", bitXor("$a", "$b")))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestBottom.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestBottom.java index 09c933d0338..5c520a8084d 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestBottom.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestBottom.java @@ -1,6 +1,7 @@ package dev.morphia.test.aggregation.expressions; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -13,15 +14,16 @@ import static dev.morphia.query.filters.Filters.eq; import static dev.morphia.test.ServerVersion.v52; -public class TestBottom extends AggregationTest { +public class TestBottom extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/bottom/example1 * */ @Test(testName = "Find the Bottom ``Score``") public void testExample1() { - testPipeline(v52, false, false, (aggregation) -> aggregation.pipeline(match(eq("gameId", "G1")), - group(id("$gameId")).field("playerId", bottom(array("$playerId", "$score"), descending("score"))))); + testPipeline(new ActionTestOptions().serverVersion(v52).removeIds(false).orderMatters(false), + (aggregation) -> aggregation.pipeline(match(eq("gameId", "G1")), group(id("$gameId")).field("playerId", + bottom(array("$playerId", "$score"), descending("score"))))); } /** @@ -30,8 +32,9 @@ public void testExample1() { */ @Test(testName = "Finding the Bottom ``Score`` Across Multiple Games") public void testExample2() { - testPipeline(v52, false, false, (aggregation) -> aggregation.pipeline( - group(id("$gameId")).field("playerId", bottom(array("$playerId", "$score"), descending("score"))))); + testPipeline(new ActionTestOptions().serverVersion(v52).removeIds(false).orderMatters(false), + (aggregation) -> aggregation.pipeline(group(id("$gameId")).field("playerId", + bottom(array("$playerId", "$score"), descending("score"))))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestBottomN.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestBottomN.java index 41977709e0c..1588b0041b2 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestBottomN.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestBottomN.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.query.filters.Filters; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -16,15 +17,16 @@ import static dev.morphia.query.Sort.descending; import static dev.morphia.test.ServerVersion.v52; -public class TestBottomN extends AggregationTest { +public class TestBottomN extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/bottomN/example1 * */ @Test(testName = "Find the Three Lowest ``Scores``") public void testExample1() { - testPipeline(v52, false, false, (aggregation) -> aggregation.pipeline(match(Filters.eq("gameId", "G1")), - group(id("$gameId")).field("playerId", bottomN(3, array("$playerId", "$score"), descending("score"))))); + testPipeline(new ActionTestOptions().serverVersion(v52).removeIds(false).orderMatters(false), + (aggregation) -> aggregation.pipeline(match(Filters.eq("gameId", "G1")), group(id("$gameId")) + .field("playerId", bottomN(3, array("$playerId", "$score"), descending("score"))))); } /** @@ -33,8 +35,9 @@ public void testExample1() { */ @Test(testName = "Finding the Three Lowest Score Documents Across Multiple Games") public void testExample2() { - testPipeline(v52, false, false, (aggregation) -> aggregation.pipeline( - group(id("$gameId")).field("playerId", bottomN(3, array("$playerId", "$score"), descending("score"))))); + testPipeline(new ActionTestOptions().serverVersion(v52).removeIds(false).orderMatters(false), + (aggregation) -> aggregation.pipeline(group(id("$gameId")).field("playerId", + bottomN(3, array("$playerId", "$score"), descending("score"))))); } /** @@ -43,8 +46,9 @@ public void testExample2() { */ @Test(testName = "Computing ``n`` Based on the Group Key for ``$group``") public void testExample3() { - testPipeline(v52, false, false, (aggregation) -> aggregation.pipeline(group(id(document("gameId", "$gameId"))) - .field("gamescores", bottomN(condition(eq("$gameId", "G2"), 1, 3), "$score", descending("score"))))); + testPipeline(new ActionTestOptions().serverVersion(v52).removeIds(false).orderMatters(false), + (aggregation) -> aggregation.pipeline(group(id(document("gameId", "$gameId"))).field("gamescores", + bottomN(condition(eq("$gameId", "G2"), 1, 3), "$score", descending("score"))))); } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestBsonSize.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestBsonSize.java index b7ad6ea962b..8f572ba4238 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestBsonSize.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestBsonSize.java @@ -1,6 +1,7 @@ package dev.morphia.test.aggregation.expressions; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -14,14 +15,14 @@ import static dev.morphia.aggregation.stages.Sort.sort; import static dev.morphia.test.ServerVersion.ANY; -public class TestBsonSize extends AggregationTest { +public class TestBsonSize extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/bsonSize/example1 * */ @Test(testName = "Return Sizes of Documents") public void testExample1() { - testPipeline(ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ANY).removeIds(false).orderMatters(true), aggregation -> aggregation.pipeline(project().include("name").include("object_size", bsonSize(ROOT)))); } @@ -32,8 +33,9 @@ public void testExample1() { */ @Test(testName = "Return Combined Size of All Documents in a Collection") public void testExample2() { - testPipeline(ANY, false, true, aggregation -> aggregation - .pipeline(group(id(null)).field("combined_object_size", sum(bsonSize(ROOT))))); + testPipeline(new ActionTestOptions().serverVersion(ANY).removeIds(false).orderMatters(true), + aggregation -> aggregation + .pipeline(group(id(null)).field("combined_object_size", sum(bsonSize(ROOT))))); } @@ -43,7 +45,7 @@ public void testExample2() { */ @Test(testName = "Return Document with Largest Specified Field") public void testExample3() { - testPipeline(ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ANY).removeIds(false).orderMatters(true), aggregation -> aggregation.pipeline( project().include("name", "$name").include("task_object_size", bsonSize("$$CURRENT")), sort().descending("task_object_size"), limit(1))); diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestCeil.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestCeil.java index ade24ad1d72..85a79778e63 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestCeil.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestCeil.java @@ -1,22 +1,24 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.expressions.MathExpressions.ceil; import static dev.morphia.aggregation.stages.Projection.project; -public class TestCeil extends AggregationTest { +public class TestCeil extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/ceil/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(project().include("value").include("ceilingValue", ceil("$value")))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation + .pipeline(project().include("value").include("ceilingValue", ceil("$value")))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestCmp.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestCmp.java index a73ac400acf..5d81d23602d 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestCmp.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestCmp.java @@ -1,22 +1,24 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.expressions.ComparisonExpressions.cmp; import static dev.morphia.aggregation.stages.Projection.project; -public class TestCmp extends AggregationTest { +public class TestCmp extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/cmp/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(project().suppressId().include("item").include("qty").include("cmpTo250", cmp("$qty", 250)))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation.pipeline( + project().suppressId().include("item").include("qty").include("cmpTo250", cmp("$qty", 250)))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestConcat.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestConcat.java index 4b8ed0486f6..4c74c1dbad2 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestConcat.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestConcat.java @@ -1,22 +1,24 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.expressions.StringExpressions.concat; import static dev.morphia.aggregation.stages.Projection.project; -public class TestConcat extends AggregationTest { +public class TestConcat extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/concat/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(project().include("itemDescription", concat("$item", " - ", "$description")))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation + .pipeline(project().include("itemDescription", concat("$item", " - ", "$description")))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestConcatArrays.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestConcatArrays.java index 72f73db3723..1a07a56dea7 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestConcatArrays.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestConcatArrays.java @@ -1,22 +1,24 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.expressions.ArrayExpressions.concatArrays; import static dev.morphia.aggregation.stages.Projection.project; -public class TestConcatArrays extends AggregationTest { +public class TestConcatArrays extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/concatArrays/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(project().include("items", concatArrays("$instock", "$ordered")))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation + .pipeline(project().include("items", concatArrays("$instock", "$ordered")))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestCond.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestCond.java index a3c99b55ccd..3ac76ce23dd 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestCond.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestCond.java @@ -1,6 +1,7 @@ package dev.morphia.test.aggregation.expressions; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -9,15 +10,16 @@ import static dev.morphia.aggregation.stages.Projection.project; import static dev.morphia.test.ServerVersion.ANY; -public class TestCond extends AggregationTest { +public class TestCond extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/cond/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ANY, false, true, aggregation -> aggregation - .pipeline(project().include("item").include("discount", condition(gte("$qty", 250), 30, 20)))); + testPipeline(new ActionTestOptions().serverVersion(ANY).removeIds(false).orderMatters(true), + aggregation -> aggregation + .pipeline(project().include("item").include("discount", condition(gte("$qty", 250), 30, 20)))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestConvert.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestConvert.java index d3cde969606..534eb98f562 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestConvert.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestConvert.java @@ -2,7 +2,8 @@ import dev.morphia.aggregation.expressions.StringExpressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -17,22 +18,27 @@ import static dev.morphia.aggregation.stages.AddFields.addFields; import static dev.morphia.aggregation.stages.Projection.project; -public class TestConvert extends AggregationTest { +public class TestConvert extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/convert/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation.pipeline( - addFields().field("convertedPrice", convert("$price", DECIMAL).onError("Error").onNull(0.0)) - .field("convertedQty", - convert("$qty", INT).onError(concat("Could not convert ", - StringExpressions.toString("$qty"), " to type integer.")).onNull(0)), - project().include("totalPrice", - switchExpression().branch(eq(type("$convertedPrice"), "string"), "NaN") - .branch(eq(type("$convertedQty"), "string"), "NaN") - .defaultCase(multiply("$convertedPrice", "$convertedQty"))))); + testPipeline( + new ActionTestOptions().serverVersion( + ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation.pipeline( + addFields().field("convertedPrice", convert("$price", DECIMAL).onError("Error").onNull(0.0)) + .field("convertedQty", + convert("$qty", INT) + .onError(concat("Could not convert ", + StringExpressions.toString("$qty"), " to type integer.")) + .onNull(0)), + project().include("totalPrice", + switchExpression().branch(eq(type("$convertedPrice"), "string"), "NaN") + .branch(eq(type("$convertedQty"), "string"), "NaN") + .defaultCase(multiply("$convertedPrice", "$convertedQty"))))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestCos.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestCos.java index ca99459f929..360f36e29ee 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestCos.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestCos.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -10,15 +11,16 @@ import static dev.morphia.aggregation.expressions.TrigonometryExpressions.degreesToRadians; import static dev.morphia.aggregation.stages.AddFields.addFields; -public class TestCos extends AggregationTest { +public class TestCos extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/cos/example1 * */ @Test(testName = "main :: Cosine of Value in Degrees") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(addFields().field("side_a", multiply(cos(degreesToRadians("$angle_a")), "$hypotenuse")))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation.pipeline( + addFields().field("side_a", multiply(cos(degreesToRadians("$angle_a")), "$hypotenuse")))); } /** @@ -27,8 +29,9 @@ public void testExample1() { */ @Test(testName = "main :: Cosine of Value in Radians") public void testExample2() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(addFields().field("side_b", multiply(cos("$angle_a"), "$hypotenuse")))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation + .pipeline(addFields().field("side_b", multiply(cos("$angle_a"), "$hypotenuse")))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestCosh.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestCosh.java index 98b332ebba6..c8359dd62ed 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestCosh.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestCosh.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -9,15 +10,16 @@ import static dev.morphia.aggregation.expressions.TrigonometryExpressions.degreesToRadians; import static dev.morphia.aggregation.stages.AddFields.addFields; -public class TestCosh extends AggregationTest { +public class TestCosh extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/cosh/example1 * */ @Test(testName = "main :: Hyperbolic Cosine in Degrees") public void testExample1() { - testPipeline(ServerVersion.ANY, true, true, (aggregation) -> aggregation - .pipeline(addFields().field("cosh_output", cosh(degreesToRadians("$angle"))))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(true).orderMatters(true), + (aggregation) -> aggregation + .pipeline(addFields().field("cosh_output", cosh(degreesToRadians("$angle"))))); } /** @@ -26,7 +28,7 @@ public void testExample1() { */ @Test(testName = "main :: Hyperbolic Cosine in Radians") public void testExample2() { - testPipeline(ServerVersion.ANY, true, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(true).orderMatters(true), (aggregation) -> aggregation.pipeline(addFields().field("cosh_output", cosh("$angle")))); } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestCount.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestCount.java index 3437a951c88..2a0fe1ed6ab 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestCount.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestCount.java @@ -3,7 +3,8 @@ import dev.morphia.aggregation.expressions.AccumulatorExpressions; import dev.morphia.aggregation.stages.Group; import dev.morphia.query.Sort; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -12,15 +13,16 @@ import static dev.morphia.aggregation.stages.SetWindowFields.setWindowFields; import static dev.morphia.test.ServerVersion.v50; -public class TestCount extends AggregationTest { +public class TestCount extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/count/example1 * */ @Test(testName = "Use in ``$group`` Stage") public void testExample1() { - testPipeline(v50, false, false, aggregation -> aggregation.pipeline( - group(Group.id("$state")).field("countNumberOfDocumentsForState", AccumulatorExpressions.count()))); + testPipeline(new ActionTestOptions().serverVersion(v50).removeIds(false).orderMatters(false), + aggregation -> aggregation.pipeline(group(Group.id("$state")).field("countNumberOfDocumentsForState", + AccumulatorExpressions.count()))); } @@ -30,7 +32,7 @@ public void testExample1() { */ @Test(testName = "Use in ``$setWindowFields`` Stage") public void testExample2() { - testPipeline(v50, false, false, + testPipeline(new ActionTestOptions().serverVersion(v50).removeIds(false).orderMatters(false), aggregation -> aggregation.setWindowFields(setWindowFields().partitionBy(("$state")) .sortBy(Sort.ascending("orderDate")).output(output("countNumberOfDocumentsForState") .operator(AccumulatorExpressions.count()).window().documents("unbounded", "current")))); diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestCovariancePop.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestCovariancePop.java index d47bb5eea87..decce8a4cb9 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestCovariancePop.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestCovariancePop.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -11,14 +12,14 @@ import static dev.morphia.aggregation.stages.SetWindowFields.setWindowFields; import static dev.morphia.query.Sort.ascending; -public class TestCovariancePop extends AggregationTest { +public class TestCovariancePop extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/covariancePop/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation .pipeline(setWindowFields().partitionBy("$state").sortBy(ascending("orderDate")) .output(output("covariancePopForState") diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestCovarianceSamp.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestCovarianceSamp.java index 1a3bb36e1b1..0a50cd452d4 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestCovarianceSamp.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestCovarianceSamp.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -11,14 +12,14 @@ import static dev.morphia.aggregation.stages.SetWindowFields.setWindowFields; import static dev.morphia.query.Sort.ascending; -public class TestCovarianceSamp extends AggregationTest { +public class TestCovarianceSamp extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/covarianceSamp/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation .pipeline(setWindowFields().partitionBy("$state").sortBy(ascending("orderDate")) .output(output("covarianceSampForState") diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDateAdd.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDateAdd.java index 8a763d506dc..390a242f559 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDateAdd.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDateAdd.java @@ -1,8 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.aggregation.expressions.TimeUnit; -import dev.morphia.test.DriverVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -12,18 +12,19 @@ import static dev.morphia.aggregation.stages.Match.match; import static dev.morphia.aggregation.stages.Projection.project; import static dev.morphia.query.filters.Filters.expr; +import static dev.morphia.test.DriverVersion.v42; import static dev.morphia.test.ServerVersion.ANY; -public class TestDateAdd extends AggregationTest { +public class TestDateAdd extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/dateAdd/example1 * */ @Test(testName = "Add a Future Date") public void testExample1() { - minDriver = DriverVersion.v42; - testPipeline(ANY, true, true, aggregation -> aggregation - .pipeline(project().include("expectedDeliveryDate", dateAdd("$purchaseDate", 3, TimeUnit.DAY)))); + testPipeline(new ActionTestOptions().serverVersion(ANY).removeIds(true).orderMatters(true).minDriver(v42), + aggregation -> aggregation.pipeline( + project().include("expectedDeliveryDate", dateAdd("$purchaseDate", 3, TimeUnit.DAY)))); } @@ -33,7 +34,7 @@ public void testExample1() { */ @Test(testName = "Filter on a Date Range") public void testExample2() { - testPipeline(ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ANY).removeIds(false).orderMatters(true), aggregation -> aggregation.pipeline( match(expr(gt("$deliveryDate", dateAdd("$purchaseDate", 5, TimeUnit.DAY)))), @@ -51,20 +52,23 @@ public void testExample2() { */ @Test(testName = "Adjust for Daylight Savings Time") public void testExample3() { - testPipeline(ANY, false, true, aggregation -> aggregation.pipeline(project().suppressId().include("location") - .include("start", dateToString().date("$login").format("%Y-%m-%d %H:%M")) - .include("days", - dateToString().date(dateAdd("$login", 1, TimeUnit.DAY).timezone("$location")) - .format("%Y-%m-%d %H:%M")) - .include("hours", - dateToString().date(dateAdd("$login", 24, TimeUnit.HOUR).timezone("$location")) - .format("%Y-%m-%d %H:%M")) - .include("startTZInfo", dateToString().date("$login").format("%Y-%m-%d %H:%M").timeZone("$location")) - .include("daysTZInfo", - dateToString().date(dateAdd("$login", 1, TimeUnit.DAY).timezone("$location")) - .format("%Y-%m-%d %H:%M").timeZone("$location")) - .include("hoursTZInfo", dateToString().date(dateAdd("$login", 24, TimeUnit.HOUR).timezone("$location")) - .format("%Y-%m-%d %H:%M").timeZone("$location"))) + testPipeline(new ActionTestOptions().serverVersion(ANY).removeIds(false).orderMatters(true), + aggregation -> aggregation.pipeline(project().suppressId().include("location") + .include("start", dateToString().date("$login").format("%Y-%m-%d %H:%M")) + .include("days", + dateToString().date(dateAdd("$login", 1, TimeUnit.DAY).timezone("$location")) + .format("%Y-%m-%d %H:%M")) + .include("hours", + dateToString().date(dateAdd("$login", 24, TimeUnit.HOUR).timezone("$location")) + .format("%Y-%m-%d %H:%M")) + .include("startTZInfo", + dateToString().date("$login").format("%Y-%m-%d %H:%M").timeZone("$location")) + .include("daysTZInfo", + dateToString().date(dateAdd("$login", 1, TimeUnit.DAY).timezone("$location")) + .format("%Y-%m-%d %H:%M").timeZone("$location")) + .include("hoursTZInfo", + dateToString().date(dateAdd("$login", 24, TimeUnit.HOUR).timezone("$location")) + .format("%Y-%m-%d %H:%M").timeZone("$location"))) ); diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDateDiff.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDateDiff.java index 5b6b49ff112..59ab264bc01 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDateDiff.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDateDiff.java @@ -2,7 +2,8 @@ import dev.morphia.aggregation.expressions.TimeUnit; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -19,14 +20,14 @@ import static java.time.DayOfWeek.*; import static java.time.DayOfWeek.FRIDAY; -public class TestDateDiff extends AggregationTest { +public class TestDateDiff extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/dateDiff/example1 * */ @Test(testName = "Elapsed Time") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline( group(id(null)).field("averageTime", avg(dateDiff("$purchased", "$delivered", TimeUnit.DAY))), project().suppressId().include("numDays", trunc("$averageTime", 1)) @@ -40,7 +41,7 @@ public void testExample1() { */ @Test(testName = "Result Precision") public void testExample2() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(project().suppressId().include("start", "$start") .include("end", "$end").include("years", dateDiff("$start", "$end", YEAR)) .include("months", dateDiff("$start", "$end", MONTH)) @@ -53,7 +54,7 @@ public void testExample2() { */ @Test(testName = "Weeks Per Month") public void testExample3() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation .pipeline(project().suppressId().include("wks_default", dateDiff("$start", "$end", WEEK)) .include("wks_monday", dateDiff("$start", "$end", WEEK).startOfWeek(MONDAY)) diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDateFromParts.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDateFromParts.java index de9e3dd1131..a86ed6b47e5 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDateFromParts.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDateFromParts.java @@ -1,25 +1,28 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.expressions.DateExpressions.dateFromParts; import static dev.morphia.aggregation.stages.Projection.project; -public class TestDateFromParts extends AggregationTest { +public class TestDateFromParts extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/dateFromParts/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(project().include("date", dateFromParts().year(2017).month(2).day(8).hour(12)) - .include("date_iso", dateFromParts().isoWeekYear(2017).isoWeek(6).isoDayOfWeek(3).hour(12)) - .include("date_timezone", dateFromParts().year(2016).month(12).day(31).hour(23).minute(46) - .second(12).timezone("America/New_York")))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation + .pipeline(project().include("date", dateFromParts().year(2017).month(2).day(8).hour(12)) + .include("date_iso", + dateFromParts().isoWeekYear(2017).isoWeek(6).isoDayOfWeek(3).hour(12)) + .include("date_timezone", dateFromParts().year(2016).month(12).day(31).hour(23) + .minute(46).second(12).timezone("America/New_York")))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDateFromString.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDateFromString.java index 9357f0ba5b8..6f21dc14c1e 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDateFromString.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDateFromString.java @@ -1,22 +1,24 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.expressions.DateExpressions.dateFromString; import static dev.morphia.aggregation.stages.Projection.project; -public class TestDateFromString extends AggregationTest { +public class TestDateFromString extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/dateFromString/example1 * */ @Test(testName = "Converting Dates") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation.pipeline( - project().include("date", dateFromString().dateString("$date").timeZone("America/New_York")))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation.pipeline( + project().include("date", dateFromString().dateString("$date").timeZone("America/New_York")))); } /** @@ -25,7 +27,7 @@ public void testExample1() { */ @Test(testName = "``onError``") public void testExample2() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation.pipeline(project().include("date", + testPipeline((aggregation) -> aggregation.pipeline(project().include("date", dateFromString().dateString("$date").timeZone("$timezone").onError("$date")))); } @@ -35,10 +37,11 @@ public void testExample2() { */ @Test(testName = "``onNull``") public void testExample3() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation.pipeline( - project().include("date", dateFromString().dateString("$date").timeZone("$timezone").onNull("oops")) + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation.pipeline(project().include("date", + dateFromString().dateString("$date").timeZone("$timezone").onNull("oops")) - )); + )); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDateSubtract.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDateSubtract.java index c1cc96a3a24..226ccdcfcfe 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDateSubtract.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDateSubtract.java @@ -1,8 +1,8 @@ package dev.morphia.test.aggregation.expressions; -import dev.morphia.test.DriverVersion; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -16,20 +16,17 @@ import static dev.morphia.aggregation.stages.Match.match; import static dev.morphia.aggregation.stages.Projection.project; import static dev.morphia.query.filters.Filters.expr; +import static dev.morphia.test.DriverVersion.v42; import static dev.morphia.test.ServerVersion.v50; -public class TestDateSubtract extends AggregationTest { - public TestDateSubtract() { - minDriver = DriverVersion.v42; - } - +public class TestDateSubtract extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/dateSubtract/example1 * */ @Test(testName = "Subtract A Fixed Amount") public void testExample1() { - testPipeline(v50, true, false, + testPipeline(new ActionTestOptions().serverVersion(v50).removeIds(true).orderMatters(false).minDriver(v42), (aggregation) -> aggregation.pipeline( match(expr(eq(year("$logout"), 2021)), expr(eq(month("$logout"), 1))), project().include("logoutTime", dateSubtract("$logout", 3, HOUR)))); @@ -43,8 +40,10 @@ public void testExample1() { public void testExample2() { // $$NOW is a little pointless /* - * testPipeline(v50, false, true, (aggregation) -> { var epochTime = - * LocalDate.of(2021, Month.FEBRUARY, 22) .toEpochDay(); + * testPipeline(new + * dev.morphia.test.util.ActionTestOptions().serverVersion(v50).removeIds(false) + * .orderMatters(true), (aggregation) -> { var epochTime = LocalDate.of(2021, + * Month.FEBRUARY, 22) .toEpochDay(); * * return aggregation.pipeline( match(expr(gt(field("logoutTime"), * dateSubtract(value(epochTime), 1, WEEK)))), project() .suppressId() @@ -59,20 +58,25 @@ public void testExample2() { */ @Test(testName = "Adjust for Daylight Savings Time") public void testExample3() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation.pipeline(project().suppressId() - .include("location").include("start", dateToString().date("$login").format("%Y-%m-%d %H:%M")) - .include("days", - dateToString().date(dateSubtract("$login", 1, DAY).timezone("$location")) - .format("%Y-%m-%d %H:%M")) - .include("hours", - dateToString().date(dateSubtract("$login", 24, HOUR).timezone("$location")) - .format("%Y-%m-%d %H:%M")) - .include("startTZInfo", dateToString().date("$login").format("%Y-%m-%d %H:%M").timeZone("$location")) - .include("daysTZInfo", - dateToString().date(dateSubtract("$login", 1, DAY).timezone("$location")) - .format("%Y-%m-%d %H:%M").timeZone("$location")) - .include("hoursTZInfo", dateToString().date(dateSubtract("$login", 24, HOUR).timezone("$location")) - .format("%Y-%m-%d %H:%M").timeZone("$location")))); + testPipeline( + new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true) + .minDriver(v42), + (aggregation) -> aggregation.pipeline(project().suppressId().include("location") + .include("start", dateToString().date("$login").format("%Y-%m-%d %H:%M")) + .include("days", + dateToString().date(dateSubtract("$login", 1, DAY).timezone("$location")) + .format("%Y-%m-%d %H:%M")) + .include("hours", + dateToString().date(dateSubtract("$login", 24, HOUR).timezone("$location")) + .format("%Y-%m-%d %H:%M")) + .include("startTZInfo", + dateToString().date("$login").format("%Y-%m-%d %H:%M").timeZone("$location")) + .include("daysTZInfo", + dateToString().date(dateSubtract("$login", 1, DAY).timezone("$location")) + .format("%Y-%m-%d %H:%M").timeZone("$location")) + .include("hoursTZInfo", + dateToString().date(dateSubtract("$login", 24, HOUR).timezone("$location")) + .format("%Y-%m-%d %H:%M").timeZone("$location")))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDateToParts.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDateToParts.java index 864c485b11f..701b9e1f7e2 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDateToParts.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDateToParts.java @@ -1,21 +1,22 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.expressions.DateExpressions.dateToParts; import static dev.morphia.aggregation.stages.Projection.project; -public class TestDateToParts extends AggregationTest { +public class TestDateToParts extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/dateToParts/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(project().include("date", dateToParts("$date")) .include("date_iso", dateToParts("$date").iso8601(true)) .include("date_timezone", dateToParts("$date").timezone("America/New_York")))); diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDateToString.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDateToString.java index 4c91789638d..58225461560 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDateToString.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDateToString.java @@ -1,29 +1,33 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.expressions.DateExpressions.dateToString; import static dev.morphia.aggregation.stages.Projection.project; -public class TestDateToString extends AggregationTest { +public class TestDateToString extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/dateToString/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.v70, false, true, (aggregation) -> aggregation.pipeline(project() - .include("yearMonthDayUTC", dateToString().date("$date").format("%Y-%m-%d")) - .include("timewithOffsetNY", - dateToString().date("$date").format("%H:%M:%S:%L%z").timeZone("America/New_York")) - .include("timewithOffset430", dateToString().date("$date").format("%H:%M:%S:%L%z").timeZone("+04:30")) - .include("minutesOffsetNY", dateToString().date("$date").format("%Z").timeZone("America/New_York")) - .include("minutesOffset430", dateToString().date("$date").format("%Z").timeZone("+04:30")) - .include("abbreviated_month", dateToString().date("$date").format("%b").timeZone("+04:30")) - .include("full_month", dateToString().date("$date").format("%B").timeZone("+04:30")))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.v70).removeIds(false).orderMatters(true), + (aggregation) -> aggregation.pipeline(project() + .include("yearMonthDayUTC", dateToString().date("$date").format("%Y-%m-%d")) + .include("timewithOffsetNY", + dateToString().date("$date").format("%H:%M:%S:%L%z").timeZone("America/New_York")) + .include("timewithOffset430", + dateToString().date("$date").format("%H:%M:%S:%L%z").timeZone("+04:30")) + .include("minutesOffsetNY", + dateToString().date("$date").format("%Z").timeZone("America/New_York")) + .include("minutesOffset430", dateToString().date("$date").format("%Z").timeZone("+04:30")) + .include("abbreviated_month", dateToString().date("$date").format("%b").timeZone("+04:30")) + .include("full_month", dateToString().date("$date").format("%B").timeZone("+04:30")))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDateTrunc.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDateTrunc.java index 4bd81636cb0..b6ce20d33ed 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDateTrunc.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDateTrunc.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -13,14 +14,14 @@ import static dev.morphia.aggregation.stages.Projection.project; import static java.time.DayOfWeek.*; -public class TestDateTrunc extends AggregationTest { +public class TestDateTrunc extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/dateTrunc/example1 * */ @Test(testName = "Truncate Order Dates in a ``$project`` Pipeline Stage") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(project().include("_id").include("orderDate").include( "truncatedOrderDate", dateTrunc("$orderDate", WEEK).binSize(2).timezone("America/Los_Angeles").startOfWeek(MONDAY)))); @@ -32,7 +33,7 @@ public void testExample1() { */ @Test(testName = "Truncate Order Dates and Obtain Quantity Sum in a ``$group`` Pipeline Stage") public void testExample2() { - testPipeline(ServerVersion.ANY, false, false, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(false), (aggregation) -> aggregation .pipeline(group(id().field("truncatedOrderDate", dateTrunc("$orderDate", MONTH).binSize(6))) .field("sumQuantity", sum("$quantity")))); diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDayOfMonth.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDayOfMonth.java index be187dc7a5e..4a4112df15f 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDayOfMonth.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDayOfMonth.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -17,18 +18,20 @@ import static dev.morphia.aggregation.expressions.DateExpressions.year; import static dev.morphia.aggregation.stages.Projection.project; -public class TestDayOfMonth extends AggregationTest { +public class TestDayOfMonth extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/dayOfMonth/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation.pipeline(project() - .include("year", year("$date")).include("month", month("$date")).include("day", dayOfMonth("$date")) - .include("hour", hour("$date")).include("minutes", minute("$date")).include("seconds", second("$date")) - .include("milliseconds", milliseconds("$date")).include("dayOfYear", dayOfYear("$date")) - .include("dayOfWeek", dayOfWeek("$date")).include("week", week("$date")))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation + .pipeline(project().include("year", year("$date")).include("month", month("$date")) + .include("day", dayOfMonth("$date")).include("hour", hour("$date")) + .include("minutes", minute("$date")).include("seconds", second("$date")) + .include("milliseconds", milliseconds("$date")).include("dayOfYear", dayOfYear("$date")) + .include("dayOfWeek", dayOfWeek("$date")).include("week", week("$date")))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDayOfWeek.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDayOfWeek.java index 3409283878e..e10fefdee3f 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDayOfWeek.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDayOfWeek.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -17,18 +18,20 @@ import static dev.morphia.aggregation.expressions.DateExpressions.year; import static dev.morphia.aggregation.stages.Projection.project; -public class TestDayOfWeek extends AggregationTest { +public class TestDayOfWeek extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/dayOfWeek/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation.pipeline(project() - .include("year", year("$date")).include("month", month("$date")).include("day", dayOfMonth("$date")) - .include("hour", hour("$date")).include("minutes", minute("$date")).include("seconds", second("$date")) - .include("milliseconds", milliseconds("$date")).include("dayOfYear", dayOfYear("$date")) - .include("dayOfWeek", dayOfWeek("$date")).include("week", week("$date")))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation + .pipeline(project().include("year", year("$date")).include("month", month("$date")) + .include("day", dayOfMonth("$date")).include("hour", hour("$date")) + .include("minutes", minute("$date")).include("seconds", second("$date")) + .include("milliseconds", milliseconds("$date")).include("dayOfYear", dayOfYear("$date")) + .include("dayOfWeek", dayOfWeek("$date")).include("week", week("$date")))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDayOfYear.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDayOfYear.java index bafadd9e238..f5a102a6ed9 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDayOfYear.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDayOfYear.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -17,18 +18,20 @@ import static dev.morphia.aggregation.expressions.DateExpressions.year; import static dev.morphia.aggregation.stages.Projection.project; -public class TestDayOfYear extends AggregationTest { +public class TestDayOfYear extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/dayOfYear/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation.pipeline(project() - .include("year", year("$date")).include("month", month("$date")).include("day", dayOfMonth("$date")) - .include("hour", hour("$date")).include("minutes", minute("$date")).include("seconds", second("$date")) - .include("milliseconds", milliseconds("$date")).include("dayOfYear", dayOfYear("$date")) - .include("dayOfWeek", dayOfWeek("$date")).include("week", week("$date")))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation + .pipeline(project().include("year", year("$date")).include("month", month("$date")) + .include("day", dayOfMonth("$date")).include("hour", hour("$date")) + .include("minutes", minute("$date")).include("seconds", second("$date")) + .include("milliseconds", milliseconds("$date")).include("dayOfYear", dayOfYear("$date")) + .include("dayOfWeek", dayOfWeek("$date")).include("week", week("$date")))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDegreesToRadians.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDegreesToRadians.java index 1fa1ab3f874..55a39e7d7aa 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDegreesToRadians.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDegreesToRadians.java @@ -1,21 +1,22 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.expressions.TrigonometryExpressions.degreesToRadians; import static dev.morphia.aggregation.stages.AddFields.addFields; -public class TestDegreesToRadians extends AggregationTest { +public class TestDegreesToRadians extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/degreesToRadians/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, true, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(true).orderMatters(true), (aggregation) -> aggregation.pipeline(addFields().field("angle_a_rad", degreesToRadians("$angle_a")) .field("angle_b_rad", degreesToRadians("$angle_b")) .field("angle_c_rad", degreesToRadians("$angle_c")))); diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDenseRank.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDenseRank.java index f063e43d478..6da304dd655 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDenseRank.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDenseRank.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -10,14 +11,14 @@ import static dev.morphia.aggregation.stages.SetWindowFields.setWindowFields; import static dev.morphia.query.Sort.*; -public class TestDenseRank extends AggregationTest { +public class TestDenseRank extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/denseRank/example1 * */ @Test(testName = "Dense Rank Partitions by an Integer Field") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation .pipeline(setWindowFields().partitionBy("$state").sortBy(descending("quantity")) .output(output("denseRankQuantityForState").operator(denseRank())))); @@ -29,7 +30,7 @@ public void testExample1() { */ @Test(testName = "Dense Rank Partitions by a Date Field") public void testExample2() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation .pipeline(setWindowFields().partitionBy("$state").sortBy(ascending("orderDate")) .output(output("denseRankOrderDateForState").operator(denseRank())))); @@ -41,7 +42,7 @@ public void testExample2() { */ @Test(testName = "Dense Rank for Duplicate, Null, and Missing Values") public void testExample3() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation .pipeline(setWindowFields().partitionBy("$state").sortBy(descending("quantity")) .output(output("denseRankQuantityForState").operator(denseRank())))); diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDerivative.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDerivative.java index d8f0d6a255d..ead76717611 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDerivative.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDerivative.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -14,14 +15,14 @@ import static dev.morphia.query.Sort.ascending; import static dev.morphia.query.filters.Filters.gt; -public class TestDerivative extends AggregationTest { +public class TestDerivative extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/derivative/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, true, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(true).orderMatters(true), (aggregation) -> aggregation.pipeline(setWindowFields().partitionBy("$truckID") .sortBy(ascending("timeStamp")).output(output("truckAverageSpeed") .operator(derivative("$miles").unit(HOUR)).window().range(-30, 0, SECOND)), diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDivide.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDivide.java index 02d5c179bff..33918fbe623 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDivide.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDivide.java @@ -1,22 +1,24 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.expressions.MathExpressions.divide; import static dev.morphia.aggregation.stages.Projection.project; -public class TestDivide extends AggregationTest { +public class TestDivide extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/divide/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(project().include("city").include("workdays", divide("$hours", 8)))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation + .pipeline(project().include("city").include("workdays", divide("$hours", 8)))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDocumentNumber.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDocumentNumber.java index f40fc9e1bf4..3901ab97106 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDocumentNumber.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestDocumentNumber.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -10,14 +11,14 @@ import static dev.morphia.aggregation.stages.SetWindowFields.setWindowFields; import static dev.morphia.query.Sort.*; -public class TestDocumentNumber extends AggregationTest { +public class TestDocumentNumber extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/documentNumber/example1 * */ @Test(testName = "Document Number for Each State") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation .pipeline(setWindowFields().partitionBy("$state").sortBy(descending("quantity")) .output(output("documentNumberForState").operator(documentNumber())))); @@ -29,7 +30,7 @@ public void testExample1() { */ @Test(testName = "Document Number for Duplicate, Null, and Missing Values") public void testExample2() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation .pipeline(setWindowFields().partitionBy("$state").sortBy(descending("quantity")) .output(output("documentNumberForState").operator(documentNumber())))); diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestEq.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestEq.java index d1f4787baa2..b799eeac252 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestEq.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestEq.java @@ -1,22 +1,24 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.expressions.ComparisonExpressions.eq; import static dev.morphia.aggregation.stages.Projection.project; -public class TestEq extends AggregationTest { +public class TestEq extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/eq/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(project().suppressId().include("item").include("qty").include("qtyEq250", eq("$qty", 250)))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation.pipeline( + project().suppressId().include("item").include("qty").include("qtyEq250", eq("$qty", 250)))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestExp.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestExp.java index 8ff9378d797..112e5919247 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestExp.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestExp.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -9,15 +10,16 @@ import static dev.morphia.aggregation.expressions.MathExpressions.subtract; import static dev.morphia.aggregation.stages.Projection.project; -public class TestExp extends AggregationTest { +public class TestExp extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/exp/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(project().include("effectiveRate", subtract(exp("$interestRate"), 1)))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation + .pipeline(project().include("effectiveRate", subtract(exp("$interestRate"), 1)))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestExpMovingAvg.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestExpMovingAvg.java index e25836052e3..a424acd3755 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestExpMovingAvg.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestExpMovingAvg.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -10,14 +11,14 @@ import static dev.morphia.aggregation.stages.SetWindowFields.setWindowFields; import static dev.morphia.query.Sort.*; -public class TestExpMovingAvg extends AggregationTest { +public class TestExpMovingAvg extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/expMovingAvg/example1 * */ @Test(testName = "Exponential Moving Average Using ``N``") public void testExample1() { - testPipeline(ServerVersion.ANY, true, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(true).orderMatters(true), (aggregation) -> aggregation.pipeline(setWindowFields().partitionBy("$stock").sortBy(ascending("date")) .output(output("expMovingAvgForStock").operator(expMovingAvg("$price", 2))))); } @@ -28,7 +29,7 @@ public void testExample1() { */ @Test(testName = "Exponential Moving Average Using ``alpha``") public void testExample2() { - testPipeline(ServerVersion.ANY, true, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(true).orderMatters(true), (aggregation) -> aggregation.pipeline(setWindowFields().partitionBy("$stock").sortBy(ascending("date")) .output(output("expMovingAvgForStock").operator(expMovingAvg("$price", 0.75))))); } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestFilter.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestFilter.java index af904d828e1..dc130f8d494 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestFilter.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestFilter.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -12,15 +13,16 @@ import static dev.morphia.aggregation.stages.Projection.project; import static dev.morphia.test.ServerVersion.v52; -public class TestFilter extends AggregationTest { +public class TestFilter extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/filter/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(v52, false, true, (aggregation) -> aggregation - .pipeline(project().include("items", filter("$items", gte("$$item.price", 100)).as("item")))); + testPipeline(new ActionTestOptions().serverVersion(v52).removeIds(false).orderMatters(true), + (aggregation) -> aggregation + .pipeline(project().include("items", filter("$items", gte("$$item.price", 100)).as("item")))); } /** @@ -29,8 +31,9 @@ public void testExample1() { */ @Test(testName = "Use the limit Field") public void testExample2() { - testPipeline(v52, false, true, (aggregation) -> aggregation - .pipeline(project().include("items", filter("$items", gte("$$item.price", 100)).as("item").limit(1)))); + testPipeline(new ActionTestOptions().serverVersion(v52).removeIds(false).orderMatters(true), + (aggregation) -> aggregation.pipeline( + project().include("items", filter("$items", gte("$$item.price", 100)).as("item").limit(1)))); } /** @@ -49,8 +52,9 @@ public void testExample3() { */ @Test(testName = "Filter Based on String Equality Match") public void testExample4() { - testPipeline(v52, false, true, (aggregation) -> aggregation - .pipeline(project().include("items", filter("$items", eq("$$item.name", "pen")).as("item")))); + testPipeline(new ActionTestOptions().serverVersion(v52).removeIds(false).orderMatters(true), + (aggregation) -> aggregation + .pipeline(project().include("items", filter("$items", eq("$$item.name", "pen")).as("item")))); } /** @@ -58,7 +62,8 @@ public void testExample4() { */ @Test(testName = "Filter Based on Regular Expression Match") public void testExample5() { - testPipeline(ServerVersion.ANY, false, true, aggregation -> aggregation.pipeline( - project().include("items", filter("$items", regexMatch("$$item.name").pattern("^p")).as("item")))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + aggregation -> aggregation.pipeline(project().include("items", + filter("$items", regexMatch("$$item.name").pattern("^p")).as("item")))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestFirst.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestFirst.java index a721ad4c8bc..8b7a5b8ff2b 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestFirst.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestFirst.java @@ -1,6 +1,7 @@ package dev.morphia.test.aggregation.expressions; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -10,7 +11,7 @@ import static dev.morphia.aggregation.stages.Sort.sort; import static dev.morphia.test.ServerVersion.v50; -public class TestFirst extends AggregationTest { +public class TestFirst extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/first/example1 @@ -18,8 +19,9 @@ public class TestFirst extends AggregationTest { */ @Test(testName = "Use in ``$group`` Stage") public void testExample1() { - testPipeline(v50, false, false, (aggregation) -> aggregation.pipeline(sort().ascending("item", "date"), - group(id("$item")).field("firstSale", first("$date")))); + testPipeline(new ActionTestOptions().serverVersion(v50).removeIds(false).orderMatters(false), + (aggregation) -> aggregation.pipeline(sort().ascending("item", "date"), + group(id("$item")).field("firstSale", first("$date")))); } /** @@ -28,10 +30,11 @@ public void testExample1() { */ @Test(testName = "Missing Data") public void testExample2() { - testPipeline(v50, false, false, (aggregation) -> aggregation.pipeline(sort().ascending("item", "price"), - group(id("$item")).field("inStock", first("$quantity")) + testPipeline(new ActionTestOptions().serverVersion(v50).removeIds(false).orderMatters(false), + (aggregation) -> aggregation.pipeline(sort().ascending("item", "price"), + group(id("$item")).field("inStock", first("$quantity")) - )); + )); } /** @@ -44,9 +47,10 @@ public void testExample3() { // I care // to make the parser support. we have working examples already. /* - * testPipeline(ServerVersion.ANY, false, true, (aggregation) -> - * aggregation.pipeline( setWindowFields() .partitionBy("$state") - * .sortBy(Sort.ascending("orderDate")) + * testPipeline(new + * dev.morphia.test.util.ActionTestOptions().serverVersion(ServerVersion.ANY). + * removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline( + * setWindowFields() .partitionBy("$state") .sortBy(Sort.ascending("orderDate")) * .output(Output.output("firstOrderTypeForState") .operator(first("$type")) * .window() .documents("unbounded", "current")))); */ diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestFirstN.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestFirstN.java index 5b923b95beb..4df8630993a 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestFirstN.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestFirstN.java @@ -2,7 +2,8 @@ import dev.morphia.aggregation.expressions.ComparisonExpressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -19,59 +20,64 @@ import static dev.morphia.query.filters.Filters.eq; import static dev.morphia.test.ServerVersion.v52; -public class TestFirstN extends AggregationTest { +public class TestFirstN extends TemplatedTestBase { @Test(testName = "Find the First Three Player Scores for a Single Game") public void testExample1() { - testPipeline(v52, false, false, (aggregation) -> aggregation.pipeline( - match(eq("gameId", "G1")), - group(id("$gameId")) - .field("firstThreeScores", firstN( - 3, - array("$playerId", "$score"))))); + testPipeline(new ActionTestOptions().serverVersion(v52).removeIds(false).orderMatters(false), + (aggregation) -> aggregation.pipeline( + match(eq("gameId", "G1")), + group(id("$gameId")) + .field("firstThreeScores", firstN( + 3, + array("$playerId", "$score"))))); } @Test(testName = "Finding the First Three Player Scores Across Multiple Games") public void testExample2() { - testPipeline(v52, false, false, (aggregation) -> aggregation.pipeline( - group(id("$gameId")) - .field("playerId", firstN( - 3, - array("$playerId", "$score"))))); + testPipeline(new ActionTestOptions().serverVersion(v52).removeIds(false).orderMatters(false), + (aggregation) -> aggregation.pipeline( + group(id("$gameId")) + .field("playerId", firstN( + 3, + array("$playerId", "$score"))))); } @Test(testName = "Using ``$sort`` With ``$firstN``") public void testExample3() { - testPipeline(v52, false, false, (aggregation) -> aggregation.pipeline( - sort().descending("score"), - group(id("$gameId")) - .field("playerId", firstN( - 3, - array("$playerId", "$score"))))); + testPipeline(new ActionTestOptions().serverVersion(v52).removeIds(false).orderMatters(false), + (aggregation) -> aggregation.pipeline( + sort().descending("score"), + group(id("$gameId")) + .field("playerId", firstN( + 3, + array("$playerId", "$score"))))); } @Test(testName = "Computing ``n`` Based on the Group Key for ``$group``") public void testExample4() { - testPipeline(v52, false, false, (aggregation) -> aggregation.pipeline( - group(id() - .field("gameId", "$gameId")) - .field("gamescores", firstN( - condition( - ComparisonExpressions.eq("$gameId", "G2"), - 1, - 3), - "$score")))); + testPipeline(new ActionTestOptions().serverVersion(v52).removeIds(false).orderMatters(false), + (aggregation) -> aggregation.pipeline( + group(id() + .field("gameId", "$gameId")) + .field("gamescores", firstN( + condition( + ComparisonExpressions.eq("$gameId", "G2"), + 1, + 3), + "$score")))); } @Test(enabled = false, description = "this needs to run against the db rather than a collection and that requires fixes in the agg code") public void testExample5() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation.pipeline( - documents(document().field("array", array(10, 20, 30, 40))), - project() - .include("firstThreeElements", firstN(3, "$array")) + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation.pipeline( + documents(document().field("array", array(10, 20, 30, 40))), + project() + .include("firstThreeElements", firstN(3, "$array")) - )); + )); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestFloor.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestFloor.java index 168048012dc..b7c8fc44d3d 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestFloor.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestFloor.java @@ -1,22 +1,24 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.expressions.MathExpressions.floor; import static dev.morphia.aggregation.stages.Projection.project; -public class TestFloor extends AggregationTest { +public class TestFloor extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/floor/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(project().include("value").include("floorValue", floor("$value")))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation + .pipeline(project().include("value").include("floorValue", floor("$value")))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestFunction.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestFunction.java index cd1d6399177..20af3e6754e 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestFunction.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestFunction.java @@ -1,22 +1,24 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.expressions.AccumulatorExpressions.function; import static dev.morphia.aggregation.stages.AddFields.addFields; -public class TestFunction extends AggregationTest { +public class TestFunction extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/function/example1 * */ @Test(testName = "Example 1: Usage Example") public void testExample1() { - skipActionCheck = true; - testPipeline(ServerVersion.ANY, false, true, + testPipeline( + new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true) + .skipActionCheck(true), (aggregation) -> aggregation.pipeline(addFields().field("isFound", function(""" function(name) { return hex_md5(name) == "15b0a220baa16331e8d80e15367677ad" diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestGetField.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestGetField.java index cc49f819134..74c4a2681dd 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestGetField.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestGetField.java @@ -2,7 +2,8 @@ import dev.morphia.test.DriverVersion; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -13,15 +14,16 @@ import static dev.morphia.aggregation.stages.Match.match; import static dev.morphia.query.filters.Filters.expr; -public class TestGetField extends AggregationTest { +public class TestGetField extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/getField/example1 * */ @Test(testName = "Query Fields that Contain Periods (``.``)") public void testExample1() { - minDriver = DriverVersion.v43; - testPipeline(ServerVersion.ANY, false, true, + testPipeline( + new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true) + .minDriver(DriverVersion.v43), (aggregation) -> aggregation.pipeline(match(expr(gt(getField("price.usd"), 200))))); } @@ -31,7 +33,7 @@ public void testExample1() { */ @Test(testName = "Query Fields that Start with a Dollar Sign (``$``)") public void testExample2() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(match(expr(gt(getField(literal("$price")), 200))))); } @@ -41,8 +43,9 @@ public void testExample2() { */ @Test(testName = "Query a Field in a Sub-document") public void testExample3() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(match(expr(lte(getField(literal("$small")).input("$quantity"), 20))))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation + .pipeline(match(expr(lte(getField(literal("$small")).input("$quantity"), 20))))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestGt.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestGt.java index 6d452c96cf2..af01c19d955 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestGt.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestGt.java @@ -1,22 +1,24 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.expressions.ComparisonExpressions.gt; import static dev.morphia.aggregation.stages.Projection.project; -public class TestGt extends AggregationTest { +public class TestGt extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/gt/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(project().suppressId().include("item").include("qty").include("qtyGt250", gt("$qty", 250)))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation.pipeline( + project().suppressId().include("item").include("qty").include("qtyGt250", gt("$qty", 250)))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestGte.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestGte.java index 82f248c6afe..9f74fef9540 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestGte.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestGte.java @@ -1,22 +1,24 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.expressions.ComparisonExpressions.gte; import static dev.morphia.aggregation.stages.Projection.project; -public class TestGte extends AggregationTest { +public class TestGte extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/gte/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation.pipeline( - project().suppressId().include("item").include("qty").include("qtyGte250", gte("$qty", 250)))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation.pipeline( + project().suppressId().include("item").include("qty").include("qtyGte250", gte("$qty", 250)))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestHour.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestHour.java index a213b1e63a0..9847dd70d58 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestHour.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestHour.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -16,14 +17,14 @@ import static dev.morphia.aggregation.expressions.DateExpressions.year; import static dev.morphia.aggregation.stages.Projection.project; -public class TestHour extends AggregationTest { +public class TestHour extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/hour/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(project().include("year", year("$date")) .include("month", month("$date")).include("day", dayOfMonth("$date")) .include("hour", hour("$date")).include("minutes", minute("$date")) diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestIfNull.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestIfNull.java index 301505b7850..cb3d6811cb9 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestIfNull.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestIfNull.java @@ -1,22 +1,24 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.expressions.ConditionalExpressions.ifNull; import static dev.morphia.aggregation.stages.Projection.project; -public class TestIfNull extends AggregationTest { +public class TestIfNull extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/ifNull/example1 * */ @Test(testName = "Single Input Expression") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation.pipeline(project().include("item") - .include("description", ifNull().target("$description").replacement("Unspecified")))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation.pipeline(project().include("item").include("description", + ifNull().target("$description").replacement("Unspecified")))); } /** @@ -25,8 +27,9 @@ public void testExample1() { */ @Test(testName = "Multiple Input Expressions") public void testExample2() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation.pipeline(project().include("item") - .include("value", ifNull().input("$description", "$quantity").replacement("Unspecified")))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation.pipeline(project().include("item").include("value", + ifNull().input("$description", "$quantity").replacement("Unspecified")))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestIn.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestIn.java index 87f47852971..853026d6041 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestIn.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestIn.java @@ -1,22 +1,24 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.expressions.ArrayExpressions.in; import static dev.morphia.aggregation.stages.Projection.project; -public class TestIn extends AggregationTest { +public class TestIn extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/in/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation.pipeline( - project().include("store location", "$location").include("has bananas", in("bananas", "$in_stock")))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation.pipeline(project().include("store location", "$location") + .include("has bananas", in("bananas", "$in_stock")))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestIndexOfArray.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestIndexOfArray.java index e01c73ab970..fafd96d1f6f 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestIndexOfArray.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestIndexOfArray.java @@ -1,21 +1,22 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.expressions.ArrayExpressions.indexOfArray; import static dev.morphia.aggregation.stages.Projection.project; -public class TestIndexOfArray extends AggregationTest { +public class TestIndexOfArray extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/indexOfArray/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(project().include("index", indexOfArray("$items", 2)))); } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestIndexOfBytes.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestIndexOfBytes.java index cfebef39bd4..05dde4ad8ec 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestIndexOfBytes.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestIndexOfBytes.java @@ -1,21 +1,22 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.expressions.StringExpressions.indexOfBytes; import static dev.morphia.aggregation.stages.Projection.project; -public class TestIndexOfBytes extends AggregationTest { +public class TestIndexOfBytes extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/indexOfBytes/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, false, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(false), (aggregation) -> aggregation.pipeline(project().include("byteLocation", indexOfBytes("$item", "foo")))); } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestIndexOfCP.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestIndexOfCP.java index 0761c4509cc..71e049cd5ea 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestIndexOfCP.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestIndexOfCP.java @@ -1,21 +1,22 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.expressions.StringExpressions.indexOfCP; import static dev.morphia.aggregation.stages.Projection.project; -public class TestIndexOfCP extends AggregationTest { +public class TestIndexOfCP extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/indexOfCP/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, false, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(false), (aggregation) -> aggregation.pipeline(project().include("cpLocation", indexOfCP("$item", "foo")))); } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestIntegral.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestIntegral.java index 18f49785bbb..d6157d311af 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestIntegral.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestIntegral.java @@ -2,7 +2,8 @@ import dev.morphia.query.Sort; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -11,14 +12,14 @@ import static dev.morphia.aggregation.stages.SetWindowFields.Output.output; import static dev.morphia.aggregation.stages.SetWindowFields.setWindowFields; -public class TestIntegral extends AggregationTest { +public class TestIntegral extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/integral/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, true, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(true).orderMatters(true), (aggregation) -> aggregation .pipeline(setWindowFields().partitionBy("$powerMeterID").sortBy(Sort.ascending("timeStamp")) .output(output("powerMeterKilowattHours").operator(integral("$kilowatts").unit(HOUR)) diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestIsArray.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestIsArray.java index b6d300f1cf0..942d33a8daa 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestIsArray.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestIsArray.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -11,14 +12,14 @@ import static dev.morphia.aggregation.expressions.ConditionalExpressions.condition; import static dev.morphia.aggregation.stages.Projection.project; -public class TestIsArray extends AggregationTest { +public class TestIsArray extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/isArray/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation .pipeline(project().include("items", condition(and(isArray("$instock"), isArray("$ordered")), concatArrays("$instock", "$ordered"), "One or more fields is not an array.")))); diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestIsNumber.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestIsNumber.java index d4ad8dde1f9..67eeaa1d69f 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestIsNumber.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestIsNumber.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -15,15 +16,16 @@ import static dev.morphia.aggregation.stages.Group.group; import static dev.morphia.aggregation.stages.Group.id; -public class TestIsNumber extends AggregationTest { +public class TestIsNumber extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/isNumber/example1 * */ @Test(testName = "Use $isNumber to Check if a Field is Numeric") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(addFields().field("isNumber", isNumber("$reading")).field("hasType", type("$reading")))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation.pipeline( + addFields().field("isNumber", isNumber("$reading")).field("hasType", type("$reading")))); } /** @@ -32,7 +34,7 @@ public void testExample1() { */ @Test(testName = "Conditionally Modify Fields using $isNumber") public void testExample2() { - testPipeline(ServerVersion.ANY, false, false, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(false), (aggregation) -> aggregation.pipeline( addFields().field("points", condition(isNumber("$grade"), "$grade", diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestIsoDayOfWeek.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestIsoDayOfWeek.java index cab3408f873..f9e2ac68fcc 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestIsoDayOfWeek.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestIsoDayOfWeek.java @@ -1,22 +1,24 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.expressions.DateExpressions.isoDayOfWeek; import static dev.morphia.aggregation.stages.Projection.project; -public class TestIsoDayOfWeek extends AggregationTest { +public class TestIsoDayOfWeek extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/isoDayOfWeek/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation.pipeline( - project().suppressId().include("name", "$name").include("dayOfWeek", isoDayOfWeek("$birthday")))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation.pipeline(project().suppressId().include("name", "$name") + .include("dayOfWeek", isoDayOfWeek("$birthday")))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestIsoWeek.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestIsoWeek.java index f4274a40036..a2f57e8c5e6 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestIsoWeek.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestIsoWeek.java @@ -1,22 +1,24 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.expressions.DateExpressions.isoWeek; import static dev.morphia.aggregation.stages.Projection.project; -public class TestIsoWeek extends AggregationTest { +public class TestIsoWeek extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/isoWeek/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(project().suppressId().include("city", "$city").include("weekNumber", isoWeek("$date")))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation.pipeline( + project().suppressId().include("city", "$city").include("weekNumber", isoWeek("$date")))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestIsoWeekYear.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestIsoWeekYear.java index 54a8e286e20..ad566f049dc 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestIsoWeekYear.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestIsoWeekYear.java @@ -1,21 +1,22 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.expressions.DateExpressions.isoWeekYear; import static dev.morphia.aggregation.stages.Projection.project; -public class TestIsoWeekYear extends AggregationTest { +public class TestIsoWeekYear extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/isoWeekYear/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(project().include("yearNumber", isoWeekYear("$date")))); } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestLast.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestLast.java index 21ae49f4589..c42c1e22714 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestLast.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestLast.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -12,14 +13,14 @@ import static dev.morphia.aggregation.stages.Sort.sort; import static dev.morphia.query.Sort.*; -public class TestLast extends AggregationTest { +public class TestLast extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/last/example1 * */ @Test(testName = "Use in ``$group`` Stage") public void testExample1() { - testPipeline(ServerVersion.ANY, false, false, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(false), (aggregation) -> aggregation.pipeline(sort().ascending("item").ascending("date"), group(id("$item")).field("lastSalesDate", last("$date")))); } @@ -34,10 +35,12 @@ public void testExample2() { // I care // to make the parser support. we have working examples already. /* - * testPipeline(ServerVersion.ANY, false, true, (aggregation) -> - * aggregation.pipeline( setWindowFields() .partitionBy("$state") - * .sortBy(ascending("orderDate")) .output(output("lastOrderTypeForState") - * .operator(last("$type")) .window() .documents("current", "unbounded")))); + * testPipeline(new + * dev.morphia.test.util.ActionTestOptions().serverVersion(ServerVersion.ANY). + * removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline( + * setWindowFields() .partitionBy("$state") .sortBy(ascending("orderDate")) + * .output(output("lastOrderTypeForState") .operator(last("$type")) .window() + * .documents("current", "unbounded")))); */ } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestLastN.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestLastN.java index 0ab078597a3..04fb3946e41 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestLastN.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestLastN.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.aggregation.expressions.ComparisonExpressions; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -15,49 +16,53 @@ import static dev.morphia.query.filters.Filters.eq; import static dev.morphia.test.ServerVersion.v52; -public class TestLastN extends AggregationTest { +public class TestLastN extends TemplatedTestBase { @Test(testName = "Find the Last Three Player Scores for a Single Game") public void testExample1() { - testPipeline(v52, false, false, (aggregation) -> aggregation - .pipeline( - match(eq("gameId", "G1")), - group(id("$gameId")) - .field("lastThreeScores", lastN( - 3, - array("$playerId", "$score"))))); + testPipeline(new ActionTestOptions().serverVersion(v52).removeIds(false).orderMatters(false), + (aggregation) -> aggregation + .pipeline( + match(eq("gameId", "G1")), + group(id("$gameId")) + .field("lastThreeScores", lastN( + 3, + array("$playerId", "$score"))))); } @Test(testName = "Finding the Last Three Player Scores Across Multiple Games") public void testExample2() { - testPipeline(v52, false, false, (aggregation) -> aggregation - .pipeline(group(id("$gameId")) - .field("playerId", lastN( - 3, - array("$playerId", "$score"))))); + testPipeline(new ActionTestOptions().serverVersion(v52).removeIds(false).orderMatters(false), + (aggregation) -> aggregation + .pipeline(group(id("$gameId")) + .field("playerId", lastN( + 3, + array("$playerId", "$score"))))); } @Test(testName = "Using ``$sort`` With ``$lastN``") public void testExample3() { - testPipeline(v52, false, false, (aggregation) -> aggregation - .pipeline( - sort().descending("score"), - group(id("$gameId")) - .field("playerId", lastN( - 3, - array("$playerId", "$score"))))); + testPipeline(new ActionTestOptions().serverVersion(v52).removeIds(false).orderMatters(false), + (aggregation) -> aggregation + .pipeline( + sort().descending("score"), + group(id("$gameId")) + .field("playerId", lastN( + 3, + array("$playerId", "$score"))))); } @Test(testName = "Computing ``n`` Based on the Group Key for ``$group``") public void testExample4() { - testPipeline(v52, false, false, (aggregation) -> aggregation - .pipeline(group(id().field("gameId", "$gameId")) - .field("gamescores", lastN( - condition(ComparisonExpressions.eq("$gameId", "G2"), 1, 3), - "$score")))); + testPipeline(new ActionTestOptions().serverVersion(v52).removeIds(false).orderMatters(false), + (aggregation) -> aggregation + .pipeline(group(id().field("gameId", "$gameId")) + .field("gamescores", lastN( + condition(ComparisonExpressions.eq("$gameId", "G2"), 1, 3), + "$score")))); } @Test diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestLet.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestLet.java index 20b0b2b4d48..4c2c23a8f42 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestLet.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestLet.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -11,14 +12,14 @@ import static dev.morphia.aggregation.expressions.VariableExpressions.let; import static dev.morphia.aggregation.stages.Projection.project; -public class TestLet extends AggregationTest { +public class TestLet extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/let/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(project().include("finalTotal", let(multiply("$$total", "$$discounted")).variable("total", add("$price", "$tax")) .variable("discounted", condition("$applyDiscount", 0.9, 1))))); diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestLinearFill.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestLinearFill.java index 1af6c40c530..ac6c012ad86 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestLinearFill.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestLinearFill.java @@ -1,6 +1,7 @@ package dev.morphia.test.aggregation.expressions; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -11,14 +12,15 @@ import static dev.morphia.query.Sort.ascending; import static dev.morphia.test.ServerVersion.v53; -public class TestLinearFill extends AggregationTest { +public class TestLinearFill extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/linearFill/example1 */ @Test(testName = "Fill Missing Values with Linear Interpolation") public void testExample1() { - testPipeline(v53, true, false, (aggregation) -> aggregation.pipeline( - setWindowFields().sortBy(ascending("time")).output(output("price").operator(linearFill("$price"))))); + testPipeline(new ActionTestOptions().serverVersion(v53).removeIds(true).orderMatters(false), + (aggregation) -> aggregation.pipeline(setWindowFields().sortBy(ascending("time")) + .output(output("price").operator(linearFill("$price"))))); } @@ -28,7 +30,7 @@ public void testExample1() { */ @Test(testName = "Use Multiple Fill Methods in a Single Stage") public void testExample2() { - testPipeline(v53, true, false, + testPipeline(new ActionTestOptions().serverVersion(v53).removeIds(true).orderMatters(false), (aggregation) -> aggregation.pipeline(setWindowFields().sortBy(ascending("time")).output( output("linearFillPrice").operator(linearFill("$price")), output("locfPrice").operator(locf("$price"))))); diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestLiteral.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestLiteral.java index 29558c558c4..45e6351ddcf 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestLiteral.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestLiteral.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -9,15 +10,16 @@ import static dev.morphia.aggregation.expressions.Expressions.literal; import static dev.morphia.aggregation.stages.Projection.project; -public class TestLiteral extends AggregationTest { +public class TestLiteral extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/literal/example1 * */ @Test(testName = "Treat ``$`` as a Literal") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(project().include("costsOneDollar", eq("$price", literal("$1"))))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation + .pipeline(project().include("costsOneDollar", eq("$price", literal("$1"))))); } /** @@ -26,7 +28,7 @@ public void testExample1() { */ @Test(testName = "Project a New Field with Value ``1``") public void testExample2() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(project().include("title").include("editionNumber", literal(1)))); } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestLn.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestLn.java index 87b1078408e..87618e53835 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestLn.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestLn.java @@ -1,21 +1,22 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.expressions.MathExpressions.ln; import static dev.morphia.aggregation.stages.Projection.project; -public class TestLn extends AggregationTest { +public class TestLn extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/ln/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(project().include("x", "$year").include("y", ln("$sales")))); } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestLocf.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestLocf.java index bd8c6c1ce1c..1a3d3eeca12 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestLocf.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestLocf.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -12,15 +13,16 @@ import static dev.morphia.query.Sort.ascending; import static dev.morphia.test.ServerVersion.v52; -public class TestLocf extends AggregationTest { +public class TestLocf extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/locf/example1 * */ @Test(testName = "Fill Missing Values with the Last Observed Value") public void testExample1() { - testPipeline(v52, true, false, (aggregation) -> aggregation.pipeline( - setWindowFields().sortBy(ascending("time")).output(output("price").operator(locf("$price"))))); + testPipeline(new ActionTestOptions().serverVersion(v52).removeIds(true).orderMatters(false), + (aggregation) -> aggregation.pipeline( + setWindowFields().sortBy(ascending("time")).output(output("price").operator(locf("$price"))))); } /** @@ -29,7 +31,7 @@ public void testExample1() { */ @Test(testName = "Use Multiple Fill Methods in a Single Stage") public void testExample2() { - testPipeline(ServerVersion.v52, true, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.v52).removeIds(true).orderMatters(true), (aggregation) -> aggregation.pipeline(setWindowFields().sortBy(ascending("time")).output( output("linearFillPrice").operator(linearFill("$price")), output("locfPrice").operator(locf("$price"))))); diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestLog.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestLog.java index f6401de4a21..080b5c1d197 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestLog.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestLog.java @@ -2,7 +2,8 @@ import dev.morphia.aggregation.expressions.impls.Expression; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -11,7 +12,7 @@ import static dev.morphia.aggregation.expressions.MathExpressions.log; import static dev.morphia.aggregation.stages.Projection.project; -public class TestLog extends AggregationTest { +public class TestLog extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/log/example1 * @@ -19,7 +20,7 @@ public class TestLog extends AggregationTest { @Test(testName = "main") public void testExample1() { Expression value; - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(project().include("bitsNeeded", floor(add(1, log("$int", 2)))))); } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestLog10.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestLog10.java index 4f1dbf3547b..7f738b80703 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestLog10.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestLog10.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -9,14 +10,14 @@ import static dev.morphia.aggregation.expressions.MathExpressions.multiply; import static dev.morphia.aggregation.stages.Projection.project; -public class TestLog10 extends AggregationTest { +public class TestLog10 extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/log10/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(project().include("pH", multiply(-1, log10("$H3O"))))); } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestLt.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestLt.java index db3e54cd986..21782ef36f1 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestLt.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestLt.java @@ -1,22 +1,24 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.expressions.ComparisonExpressions.lt; import static dev.morphia.aggregation.stages.Projection.project; -public class TestLt extends AggregationTest { +public class TestLt extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/lt/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(project().suppressId().include("item").include("qty").include("qtyLt250", lt("$qty", 250)))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation.pipeline( + project().suppressId().include("item").include("qty").include("qtyLt250", lt("$qty", 250)))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestLte.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestLte.java index 279ee4ba18a..0187b7cff79 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestLte.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestLte.java @@ -1,22 +1,24 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.expressions.ComparisonExpressions.lte; import static dev.morphia.aggregation.stages.Projection.project; -public class TestLte extends AggregationTest { +public class TestLte extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/lte/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation.pipeline( - project().suppressId().include("item").include("qty").include("qtyLte250", lte("$qty", 250)))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation.pipeline( + project().suppressId().include("item").include("qty").include("qtyLte250", lte("$qty", 250)))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestLtrim.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestLtrim.java index 636d08952fe..d61be31f307 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestLtrim.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestLtrim.java @@ -1,22 +1,24 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.expressions.StringExpressions.ltrim; import static dev.morphia.aggregation.stages.Projection.project; -public class TestLtrim extends AggregationTest { +public class TestLtrim extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/ltrim/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(project().include("item").include("description", ltrim("$description")))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation + .pipeline(project().include("item").include("description", ltrim("$description")))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestMap.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestMap.java index 9bb60783ece..ec4c78fe3e1 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestMap.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestMap.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -12,15 +13,16 @@ import static dev.morphia.aggregation.stages.AddFields.addFields; import static dev.morphia.aggregation.stages.Projection.project; -public class TestMap extends AggregationTest { +public class TestMap extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/map/example1 * */ @Test(testName = "Add to Each Element of an Array") public void testExample1() { - testPipeline(ServerVersion.ANY, true, true, (aggregation) -> aggregation - .pipeline(project().include("adjustedGrades", map("$quizzes", add("$$grade", 2)).as("grade")))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(true).orderMatters(true), + (aggregation) -> aggregation + .pipeline(project().include("adjustedGrades", map("$quizzes", add("$$grade", 2)).as("grade")))); } /** @@ -29,7 +31,7 @@ public void testExample1() { */ @Test(testName = "Truncate Each Array Element") public void testExample2() { - testPipeline(ServerVersion.ANY, true, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(true).orderMatters(true), (aggregation) -> aggregation.pipeline(project().include("city", "$city").include("integerValues", map("$distances", trunc("$$decimalValue")).as("decimalValue")))); } @@ -40,7 +42,8 @@ public void testExample2() { */ @Test(testName = "Convert Celsius Temperatures to Fahrenheit") public void testExample3() { - testPipeline(ServerVersion.ANY, true, true, (aggregation) -> aggregation.pipeline(addFields().field("tempsF", - map("$tempsC", add(multiply("$$tempInCelsius", 1.8), 32)).as("tempInCelsius")))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(true).orderMatters(true), + (aggregation) -> aggregation.pipeline(addFields().field("tempsF", + map("$tempsC", add(multiply("$$tempInCelsius", 1.8), 32)).as("tempInCelsius")))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestMax.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestMax.java index 6f3fe4d9ded..f0c77767d32 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestMax.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestMax.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -14,15 +15,17 @@ import static dev.morphia.aggregation.stages.SetWindowFields.setWindowFields; import static dev.morphia.query.Sort.ascending; -public class TestMax extends AggregationTest { +public class TestMax extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/max/example1 * */ @Test(testName = "Use in ``$group`` Stage") public void testExample1() { - testPipeline(ServerVersion.ANY, false, false, (aggregation) -> aggregation.pipeline(group(id("$item")) - .field("maxTotalAmount", max(multiply("$price", "$quantity"))).field("maxQuantity", max("$quantity")))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(false), + (aggregation) -> aggregation + .pipeline(group(id("$item")).field("maxTotalAmount", max(multiply("$price", "$quantity"))) + .field("maxQuantity", max("$quantity")))); } /** @@ -31,7 +34,7 @@ public void testExample1() { */ @Test(testName = "Use in ``$project`` Stage") public void testExample2() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(project().include("quizMax", max("$quizzes")) .include("labMax", max("$labs")).include("examMax", max("$final", "$midterm")))); } @@ -42,7 +45,7 @@ public void testExample2() { */ @Test(testName = "Use in ``$setWindowFields`` Stage") public void testExample3() { - testPipeline(ServerVersion.v50, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.v50).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(setWindowFields().partitionBy("$state") .sortBy(ascending("orderDate")).output(output("maximumQuantityForState") .operator(max("$quantity")).window().documents("unbounded", "current")))); diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestMaxN.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestMaxN.java index 84f89de7155..130aadba10d 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestMaxN.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestMaxN.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.aggregation.expressions.ComparisonExpressions; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -15,15 +16,16 @@ import static dev.morphia.query.filters.Filters.eq; import static dev.morphia.test.ServerVersion.v52; -public class TestMaxN extends AggregationTest { +public class TestMaxN extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/maxN/example1 * */ @Test(testName = "Find the Maximum Three ``Scores`` for a Single Game") public void testExample1() { - testPipeline(v52, false, false, (aggregation) -> aggregation.pipeline(match(eq("gameId", "G1")), - group(id("$gameId")).field("maxThreeScores", maxN(3, array("$score", "$playerId"))))); + testPipeline(new ActionTestOptions().serverVersion(v52).removeIds(false).orderMatters(false), + (aggregation) -> aggregation.pipeline(match(eq("gameId", "G1")), + group(id("$gameId")).field("maxThreeScores", maxN(3, array("$score", "$playerId"))))); } @@ -33,8 +35,9 @@ public void testExample1() { */ @Test(testName = "Finding the Maximum Three Scores Across Multiple Games") public void testExample2() { - testPipeline(v52, false, false, (aggregation) -> aggregation - .pipeline(group(id("$gameId")).field("maxScores", maxN(3, array("$score", "$playerId"))))); + testPipeline(new ActionTestOptions().serverVersion(v52).removeIds(false).orderMatters(false), + (aggregation) -> aggregation + .pipeline(group(id("$gameId")).field("maxScores", maxN(3, array("$score", "$playerId"))))); } @@ -44,7 +47,7 @@ public void testExample2() { */ @Test(testName = "Computing ``n`` Based on the Group Key for ``$group``") public void testExample3() { - testPipeline(v52, false, false, + testPipeline(new ActionTestOptions().serverVersion(v52).removeIds(false).orderMatters(false), (aggregation) -> aggregation.pipeline(group(id().field("gameId", "$gameId")).field("gamescores", maxN( condition(ComparisonExpressions.eq("$gameId", "G2"), 1, 3), array("$score", "$playerId"))))); } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestMedian.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestMedian.java index eb7a1987a63..52cde6a6494 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestMedian.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestMedian.java @@ -1,6 +1,7 @@ package dev.morphia.test.aggregation.expressions; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -14,13 +15,13 @@ import static dev.morphia.test.ServerVersion.ANY; import static dev.morphia.test.ServerVersion.v70; -public class TestMedian extends AggregationTest { +public class TestMedian extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/median/example1 */ @Test(testName = "Use |operatorName| as an Accumulator") public void testExample1() { - testPipeline(ANY, false, false, + testPipeline(new ActionTestOptions().serverVersion(ANY).removeIds(false).orderMatters(false), aggregation -> aggregation.pipeline(group().field("test01_median", median("$test01")))); } @@ -30,8 +31,9 @@ public void testExample1() { */ @Test(testName = "Use |operatorName| in a ``$project`` Stage") public void testExample2() { - testPipeline(v70, false, true, aggregation -> aggregation.pipeline(project().suppressId().include("studentId") - .include("testMedians", median(array("$test01", "$test02", "$test03"))))); + testPipeline(new ActionTestOptions().serverVersion(v70).removeIds(false).orderMatters(true), + aggregation -> aggregation.pipeline(project().suppressId().include("studentId").include("testMedians", + median(array("$test01", "$test02", "$test03"))))); } /** @@ -40,7 +42,7 @@ public void testExample2() { */ @Test(testName = "Use |operatorName| in a ``$setWindowField`` Stage") public void testExample3() { - testPipeline(v70, false, true, + testPipeline(new ActionTestOptions().serverVersion(v70).removeIds(false).orderMatters(true), aggregation -> aggregation.pipeline( setWindowFields().sortBy(ascending("test01")) .output(output("test01_median").operator(median("$test01")).window().range(-3, 3)), diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestMergeObjects.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestMergeObjects.java index 4d0c3f5c8da..e05a915eb19 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestMergeObjects.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestMergeObjects.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -14,7 +15,7 @@ import static dev.morphia.aggregation.stages.Projection.project; import static dev.morphia.aggregation.stages.ReplaceRoot.replaceRoot; -public class TestMergeObjects extends AggregationTest { +public class TestMergeObjects extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/mergeObjects/example1 * @@ -22,7 +23,7 @@ public class TestMergeObjects extends AggregationTest { @Test(testName = "``$mergeObjects``") public void testExample1() { loadData("items", 2); - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline( lookup("items").foreignField("item").localField("item").as("fromItems"), replaceRoot(mergeObjects().add(elementAt("$fromItems", 0)).add(ROOT)), @@ -35,8 +36,9 @@ public void testExample1() { */ @Test(testName = "``$mergeObjects`` as an Accumulator") public void testExample2() { - testPipeline(ServerVersion.ANY, false, false, (aggregation) -> aggregation - .pipeline(group(id("$item")).field("mergedSales", mergeObjects().add("$quantity")))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(false), + (aggregation) -> aggregation + .pipeline(group(id("$item")).field("mergedSales", mergeObjects().add("$quantity")))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestMeta.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestMeta.java index 787c6c3b035..3f3500b87a8 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestMeta.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestMeta.java @@ -3,7 +3,7 @@ import dev.morphia.query.FindOptions; import dev.morphia.query.Meta; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -19,14 +19,14 @@ import static dev.morphia.query.filters.Filters.gte; import static dev.morphia.query.filters.Filters.text; -public class TestMeta extends AggregationTest { +public class TestMeta extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/meta/example1 * */ @Test(testName = "``$meta: \"textScore\"`` :: Aggregation") public void testExample1() { - testPipeline(ServerVersion.ANY, false, false, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(false), (aggregation) -> aggregation.pipeline(match(text("cake")), group(id(meta())).field("count", sum(1)))); } @@ -47,8 +47,8 @@ public void testExample2() { */ @Test(testName = "``$meta: \"indexKey\"`` :: Aggregation") public void testExample3() { - testPipeline(ServerVersion.ANY, true, true, aggregation -> aggregation.pipeline(match(eq("type", "apparel")), - addFields().field("idxKey", meta(INDEXKEY)))); + testPipeline(new ActionTestOptions().removeIds(true), aggregation -> aggregation + .pipeline(match(eq("type", "apparel")), addFields().field("idxKey", meta(INDEXKEY)))); } /** @@ -67,8 +67,8 @@ public void testExample4() { */ @Test(testName = "``$meta: \"indexKey\"`` :: Aggregation [1]") public void testExample5() { - testPipeline(ServerVersion.ANY, true, true, (aggregation) -> aggregation.pipeline(match(gte("price", 10)), - addFields().field("idxKey", meta(INDEXKEY)))); + testPipeline(new ActionTestOptions().removeIds(true), (aggregation) -> aggregation + .pipeline(match(gte("price", 10)), addFields().field("idxKey", meta(INDEXKEY)))); } /** diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestMillisecond.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestMillisecond.java index 80ca7d223fc..4aca0ca9cae 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestMillisecond.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestMillisecond.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -17,18 +18,20 @@ import static dev.morphia.aggregation.expressions.DateExpressions.year; import static dev.morphia.aggregation.stages.Projection.project; -public class TestMillisecond extends AggregationTest { +public class TestMillisecond extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/millisecond/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation.pipeline(project() - .include("year", year("$date")).include("month", month("$date")).include("day", dayOfMonth("$date")) - .include("hour", hour("$date")).include("minutes", minute("$date")).include("seconds", second("$date")) - .include("milliseconds", milliseconds("$date")).include("dayOfYear", dayOfYear("$date")) - .include("dayOfWeek", dayOfWeek("$date")).include("week", week("$date")))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation + .pipeline(project().include("year", year("$date")).include("month", month("$date")) + .include("day", dayOfMonth("$date")).include("hour", hour("$date")) + .include("minutes", minute("$date")).include("seconds", second("$date")) + .include("milliseconds", milliseconds("$date")).include("dayOfYear", dayOfYear("$date")) + .include("dayOfWeek", dayOfWeek("$date")).include("week", week("$date")))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestMin.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestMin.java index c7388d33a30..f4070f317d6 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestMin.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestMin.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.query.Sort; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -13,14 +14,14 @@ import static dev.morphia.aggregation.stages.SetWindowFields.setWindowFields; import static dev.morphia.test.ServerVersion.v50; -public class TestMin extends AggregationTest { +public class TestMin extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/min/example1 * */ @Test(testName = "Use in ``$group`` Stage") public void testExample1() { - testPipeline(v50, false, false, + testPipeline(new ActionTestOptions().serverVersion(v50).removeIds(false).orderMatters(false), (aggregation) -> aggregation.pipeline(group(id("$item")).field("minQuantity", min("$quantity")))); } @@ -30,7 +31,7 @@ public void testExample1() { */ @Test(testName = "Use in ``$project`` Stage") public void testExample2() { - testPipeline(v50, false, true, + testPipeline(new ActionTestOptions().serverVersion(v50).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(project().include("quizMin", min("$quizzes")) .include("labMin", min("$labs")).include("examMin", min("$final", "$midterm")))); } @@ -41,7 +42,7 @@ public void testExample2() { */ @Test(testName = "Use in ``$setWindowFields`` Stage") public void testExample3() { - testPipeline(v50, false, true, + testPipeline(new ActionTestOptions().serverVersion(v50).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(setWindowFields().partitionBy("$state") .sortBy(Sort.ascending("orderDate")).output(output("minimumQuantityForState") .operator(min("$quantity")).window().documents("unbounded", "current")))); diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestMinN.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestMinN.java index 03585f57d43..984c661d8a4 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestMinN.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestMinN.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.aggregation.expressions.ComparisonExpressions; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -14,7 +15,7 @@ import static dev.morphia.query.filters.Filters.eq; import static dev.morphia.test.ServerVersion.v52; -public class TestMinN extends AggregationTest { +public class TestMinN extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/minN/example1 @@ -22,8 +23,9 @@ public class TestMinN extends AggregationTest { */ @Test(testName = "Find the Minimum Three ``Scores`` for a Single Game") public void testExample1() { - testPipeline(v52, false, false, (aggregation) -> aggregation.pipeline(match(eq("gameId", "G1")), - group(id("$gameId")).field("minScores", minN(3, array("$score", "$playerId"))))); + testPipeline(new ActionTestOptions().serverVersion(v52).orderMatters(false), + (aggregation) -> aggregation.pipeline(match(eq("gameId", "G1")), + group(id("$gameId")).field("minScores", minN(3, array("$score", "$playerId"))))); } @@ -33,8 +35,9 @@ public void testExample1() { */ @Test(testName = "Finding the Minimum Three Documents Across Multiple Games") public void testExample2() { - testPipeline(v52, false, false, (aggregation) -> aggregation - .pipeline(group(id("$gameId")).field("minScores", minN(3, array("$score", "$playerId"))))); + testPipeline(new ActionTestOptions().serverVersion(v52).removeIds(false).orderMatters(false), + (aggregation) -> aggregation + .pipeline(group(id("$gameId")).field("minScores", minN(3, array("$score", "$playerId"))))); } @@ -44,7 +47,7 @@ public void testExample2() { */ @Test(testName = "Computing ``n`` Based on the Group Key for ``$group``") public void testExample3() { - testPipeline(v52, false, false, + testPipeline(new ActionTestOptions().serverVersion(v52).removeIds(false).orderMatters(false), (aggregation) -> aggregation.pipeline(group(id().field("gameId", "$gameId")).field("gamescores", minN( condition(ComparisonExpressions.eq("$gameId", "G2"), 1, 3), array("$score", "$playerId"))))); } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestMinute.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestMinute.java index 1b9beb2fe2c..d2c5145f390 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestMinute.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestMinute.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -17,18 +18,20 @@ import static dev.morphia.aggregation.expressions.DateExpressions.year; import static dev.morphia.aggregation.stages.Projection.project; -public class TestMinute extends AggregationTest { +public class TestMinute extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/minute/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation.pipeline(project() - .include("year", year("$date")).include("month", month("$date")).include("day", dayOfMonth("$date")) - .include("hour", hour("$date")).include("minutes", minute("$date")).include("seconds", second("$date")) - .include("milliseconds", milliseconds("$date")).include("dayOfYear", dayOfYear("$date")) - .include("dayOfWeek", dayOfWeek("$date")).include("week", week("$date")))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation + .pipeline(project().include("year", year("$date")).include("month", month("$date")) + .include("day", dayOfMonth("$date")).include("hour", hour("$date")) + .include("minutes", minute("$date")).include("seconds", second("$date")) + .include("milliseconds", milliseconds("$date")).include("dayOfYear", dayOfYear("$date")) + .include("dayOfWeek", dayOfWeek("$date")).include("week", week("$date")))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestMod.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestMod.java index 94b76ccbe70..12a896fbc40 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestMod.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestMod.java @@ -1,21 +1,22 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.expressions.MathExpressions.mod; import static dev.morphia.aggregation.stages.Projection.project; -public class TestMod extends AggregationTest { +public class TestMod extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/mod/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(project().include("remainder", mod("$hours", "$tasks")))); } @@ -25,7 +26,7 @@ public void testExample1() { */ @Test(testName = "Negative Dividend") public void testExample2() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(project().include("remainder", mod("$dividend", "$divisor")))); } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestMonth.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestMonth.java index 64f7fe67a1b..a2fcdbfb1d6 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestMonth.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestMonth.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -17,18 +18,20 @@ import static dev.morphia.aggregation.expressions.DateExpressions.year; import static dev.morphia.aggregation.stages.Projection.project; -public class TestMonth extends AggregationTest { +public class TestMonth extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/month/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation.pipeline(project() - .include("year", year("$date")).include("month", month("$date")).include("day", dayOfMonth("$date")) - .include("hour", hour("$date")).include("minutes", minute("$date")).include("seconds", second("$date")) - .include("milliseconds", milliseconds("$date")).include("dayOfYear", dayOfYear("$date")) - .include("dayOfWeek", dayOfWeek("$date")).include("week", week("$date")))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation + .pipeline(project().include("year", year("$date")).include("month", month("$date")) + .include("day", dayOfMonth("$date")).include("hour", hour("$date")) + .include("minutes", minute("$date")).include("seconds", second("$date")) + .include("milliseconds", milliseconds("$date")).include("dayOfYear", dayOfYear("$date")) + .include("dayOfWeek", dayOfWeek("$date")).include("week", week("$date")))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestMultiply.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestMultiply.java index c38e5ee412a..74c1eea9655 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestMultiply.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestMultiply.java @@ -1,22 +1,24 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.expressions.MathExpressions.multiply; import static dev.morphia.aggregation.stages.Projection.project; -public class TestMultiply extends AggregationTest { +public class TestMultiply extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/multiply/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(project().include("date").include("item").include("total", multiply("$price", "$quantity")))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation.pipeline( + project().include("date").include("item").include("total", multiply("$price", "$quantity")))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestNe.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestNe.java index 4ac982570f8..18a20e4b1b7 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestNe.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestNe.java @@ -1,22 +1,24 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.expressions.ComparisonExpressions.ne; import static dev.morphia.aggregation.stages.Projection.project; -public class TestNe extends AggregationTest { +public class TestNe extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/ne/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(project().suppressId().include("item").include("qty").include("qtyNe250", ne("$qty", 250)))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation.pipeline( + project().suppressId().include("item").include("qty").include("qtyNe250", ne("$qty", 250)))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestNot.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestNot.java index c9ddcd0e588..a1334846a0e 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestNot.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestNot.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -9,15 +10,16 @@ import static dev.morphia.aggregation.expressions.ComparisonExpressions.gt; import static dev.morphia.aggregation.stages.Projection.project; -public class TestNot extends AggregationTest { +public class TestNot extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/not/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(project().include("item").include("result", not(gt("$qty", 250))))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation + .pipeline(project().include("item").include("result", not(gt("$qty", 250))))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestObjectToArray.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestObjectToArray.java index 8193889e7b1..e91b0e89358 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestObjectToArray.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestObjectToArray.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -17,15 +18,16 @@ import static dev.morphia.aggregation.stages.Projection.project; import static dev.morphia.aggregation.stages.Unwind.unwind; -public class TestObjectToArray extends AggregationTest { +public class TestObjectToArray extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/objectToArray/example1 * */ @Test(testName = "``$objectToArray`` Example") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(project().include("item").include("dimensions", objectToArray("$dimensions")))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation + .pipeline(project().include("item").include("dimensions", objectToArray("$dimensions")))); } /** @@ -34,7 +36,7 @@ public void testExample1() { */ @Test(testName = "``$objectToArray`` to Sum Nested Fields") public void testExample2() { - testPipeline(ServerVersion.ANY, false, false, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(false), (aggregation) -> aggregation.pipeline(project().include("warehouses", objectToArray("$instock")), unwind("warehouses"), group(id("$warehouses.k")).field("total", sum("$warehouses.v")))); } @@ -45,7 +47,7 @@ public void testExample2() { */ @Test(testName = "``$objectToArray`` + ``$arrayToObject`` Example") public void testExample3() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(addFields().field("instock", objectToArray("$instock")), addFields().field("instock", concatArrays("$instock", diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestOr.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestOr.java index 8c7f9735e1d..018fbaec5cc 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestOr.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestOr.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -10,15 +11,16 @@ import static dev.morphia.aggregation.expressions.ComparisonExpressions.lt; import static dev.morphia.aggregation.stages.Projection.project; -public class TestOr extends AggregationTest { +public class TestOr extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/or/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(project().include("item").include("result", or(gt("$qty", 250), lt("$qty", 200))))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation + .pipeline(project().include("item").include("result", or(gt("$qty", 250), lt("$qty", 200))))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestPercentile.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestPercentile.java index c70fab771e6..8d64d8dc153 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestPercentile.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestPercentile.java @@ -2,7 +2,8 @@ import java.util.List; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -15,14 +16,15 @@ import static dev.morphia.test.ServerVersion.v70; import static java.util.List.of; -public class TestPercentile extends AggregationTest { +public class TestPercentile extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/percentile/example1 */ @Test(testName = "Calculate a Single Value as an Accumulator") public void testExample1() { - testPipeline(v70, false, false, aggregation -> aggregation - .pipeline(group().field("test01_percentiles", percentile("$test01", of(0.95))))); + testPipeline(new ActionTestOptions().serverVersion(v70).removeIds(false).orderMatters(false), + aggregation -> aggregation + .pipeline(group().field("test01_percentiles", percentile("$test01", of(0.95))))); } /** @@ -31,7 +33,7 @@ public void testExample1() { */ @Test(testName = "Calculate Multiple Values as an Accumulator") public void testExample2() { - testPipeline(v70, false, false, + testPipeline(new ActionTestOptions().serverVersion(v70).removeIds(false).orderMatters(false), aggregation -> aggregation .pipeline(group().field("test01_percentiles", percentile("$test01", of(0.5, 0.75, 0.9, 0.95))) .field("test02_percentiles", percentile("$test02", of(0.5, 0.75, 0.9, 0.95))) @@ -45,8 +47,9 @@ public void testExample2() { */ @Test(testName = "Use |operatorName| in a ``$project`` Stage") public void testExample3() { - testPipeline(v70, false, false, aggregation -> aggregation.pipeline(project().suppressId().include("studentId") - .include("testPercentiles", percentile(List.of("$test01", "$test02", "$test03"), of(0.5, 0.95))))); + testPipeline(new ActionTestOptions().serverVersion(v70).removeIds(false).orderMatters(false), + aggregation -> aggregation.pipeline(project().suppressId().include("studentId").include( + "testPercentiles", percentile(List.of("$test01", "$test02", "$test03"), of(0.5, 0.95))))); } /** @@ -56,7 +59,7 @@ public void testExample3() { @Test(testName = "Use |operatorName| in a ``$setWindowField`` Stage") public void testExample4() { - testPipeline(v70, false, false, + testPipeline(new ActionTestOptions().serverVersion(v70).removeIds(false).orderMatters(false), aggregation -> aggregation.pipeline( setWindowFields().sortBy(ascending("test01")) .output(output("test01_95percentile").operator(percentile("$test01", List.of(0.95))) diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestPow.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestPow.java index 57826d66c59..cedf9bb2744 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestPow.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestPow.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -9,15 +10,16 @@ import static dev.morphia.aggregation.expressions.WindowExpressions.stdDevPop; import static dev.morphia.aggregation.stages.Projection.project; -public class TestPow extends AggregationTest { +public class TestPow extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/pow/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(project().include("variance", pow(stdDevPop("$scores.score"), 2)))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation + .pipeline(project().include("variance", pow(stdDevPop("$scores.score"), 2)))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestPush.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestPush.java index 177d09f7aef..6084d81a9ad 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestPush.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestPush.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -16,14 +17,14 @@ import static dev.morphia.aggregation.stages.Sort.sort; import static dev.morphia.query.Sort.*; -public class TestPush extends AggregationTest { +public class TestPush extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/push/example1 * */ @Test(testName = "Use in ``$group`` Stage") public void testExample1() { - testPipeline(ServerVersion.ANY, false, false, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(false), (aggregation) -> aggregation.pipeline(sort().ascending("date").ascending("item"), group(id().field("day", dayOfYear("$date")).field("year", year("$date"))).field("itemsSold", push(document().field("item", "$item").field("quantity", "$quantity"))))); @@ -35,7 +36,7 @@ public void testExample1() { */ @Test(testName = "Use in ``$setWindowFields`` Stage") public void testExample2() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(setWindowFields().partitionBy("$state") .sortBy(ascending("orderDate")).output(output("quantitiesForState").operator(push("$quantity")) .window().documents("unbounded", "current")))); diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestRadiansToDegrees.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestRadiansToDegrees.java index 263c61cd3bf..25fb7f492ee 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestRadiansToDegrees.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestRadiansToDegrees.java @@ -1,21 +1,22 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.expressions.TrigonometryExpressions.radiansToDegrees; import static dev.morphia.aggregation.stages.AddFields.addFields; -public class TestRadiansToDegrees extends AggregationTest { +public class TestRadiansToDegrees extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/radiansToDegrees/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, true, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(true).orderMatters(true), (aggregation) -> aggregation.pipeline(addFields().field("angle_a_deg", radiansToDegrees("$angle_a")) .field("angle_b_deg", radiansToDegrees("$angle_b")) .field("angle_c_deg", radiansToDegrees("$angle_c")))); diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestRand.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestRand.java index 10fac24b615..7e315b399a1 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestRand.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestRand.java @@ -2,7 +2,8 @@ import dev.morphia.test.DriverVersion; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -17,19 +18,16 @@ import static dev.morphia.query.filters.Filters.eq; import static dev.morphia.query.filters.Filters.expr; -public class TestRand extends AggregationTest { - public TestRand() { - skipDataCheck(); - minDriver = DriverVersion.v43; - } - +public class TestRand extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/rand/example1 * */ @Test(testName = "Generate Random Data Points") public void testExample1() { - testPipeline(ServerVersion.ANY, true, false, + testPipeline( + new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(true).orderMatters(false) + .minDriver(DriverVersion.v43).skipDataCheck(true), (aggregation) -> aggregation.pipeline(set().field("amount", multiply(rand(), 100)), set().field("amount", floor("$amount")), merge("donors"))); } @@ -40,8 +38,9 @@ public void testExample1() { */ @Test(testName = "Select Random Items From a Collection") public void testExample2() { - testPipeline(ServerVersion.ANY, false, false, (aggregation) -> aggregation.pipeline(match(eq("district", 3)), - match(expr(lt(0.5, rand()))), project().suppressId().include("name").include("registered"))); + testPipeline(new ActionTestOptions().orderMatters(false).minDriver(DriverVersion.v43).skipDataCheck(true), + (aggregation) -> aggregation.pipeline(match(eq("district", 3)), match(expr(lt(0.5, rand()))), + project().suppressId().include("name").include("registered"))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestRange.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestRange.java index 4e0fb86b67b..2fa03a757b0 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestRange.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestRange.java @@ -1,22 +1,24 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.expressions.ArrayExpressions.range; import static dev.morphia.aggregation.stages.Projection.project; -public class TestRange extends AggregationTest { +public class TestRange extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/range/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation.pipeline( - project().suppressId().include("city").include("Rest stops", range(0, "$distance").step(25)))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation.pipeline( + project().suppressId().include("city").include("Rest stops", range(0, "$distance").step(25)))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestRank.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestRank.java index fae32ca034b..11b349757fb 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestRank.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestRank.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -11,14 +12,14 @@ import static dev.morphia.query.Sort.ascending; import static dev.morphia.query.Sort.descending; -public class TestRank extends AggregationTest { +public class TestRank extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/rank/example1 * */ @Test(testName = "Rank Partitions by an Integer Field") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(setWindowFields().partitionBy("$state") .sortBy(descending("quantity")).output(output("rankQuantityForState").operator(rank())))); } @@ -29,7 +30,7 @@ public void testExample1() { */ @Test(testName = "Rank Partitions by a Date Field") public void testExample2() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(setWindowFields().partitionBy("$state") .sortBy(ascending("orderDate")).output(output("rankOrderDateForState").operator(rank())))); } @@ -40,7 +41,7 @@ public void testExample2() { */ @Test(testName = "Rank Partitions Containing Duplicate Values, Nulls, or Missing Data") public void testExample3() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(setWindowFields().partitionBy("$state") .sortBy(descending("quantity")).output(output("rankQuantityForState").operator(rank())))); } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestReduce.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestReduce.java index 8a875028eb4..44e68d3896b 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestReduce.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestReduce.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -19,14 +20,14 @@ import static dev.morphia.aggregation.stages.Projection.project; import static dev.morphia.query.filters.Filters.gt; -public class TestReduce extends AggregationTest { +public class TestReduce extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/reduce/example1 * */ @Test(testName = "Multiplication") public void testExample1() { - testPipeline(ServerVersion.ANY, false, false, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(false), (aggregation) -> aggregation.pipeline( group(id("$experimentId")).field("probabilityArr", push("$probability")), project().include("description").include("results", @@ -39,10 +40,11 @@ public void testExample1() { */ @Test(testName = "String Concatenation") public void testExample2() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation.pipeline( - match(gt("hobbies", array())), - project().include("name").include("bio", reduce("$hobbies", "My hobbies include:", - concat("$$value", condition(eq("$$value", "My hobbies include:"), " ", ", "), "$$this"))))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation.pipeline(match(gt("hobbies", array())), + project().include("name").include("bio", + reduce("$hobbies", "My hobbies include:", concat("$$value", + condition(eq("$$value", "My hobbies include:"), " ", ", "), "$$this"))))); } /** @@ -51,8 +53,9 @@ public void testExample2() { */ @Test(testName = "Array Concatenation") public void testExample3() { - testPipeline(ServerVersion.ANY, false, false, (aggregation) -> aggregation - .pipeline(project().include("collapsed", reduce("$arr", array(), concatArrays("$$value", "$$this"))))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(false), + (aggregation) -> aggregation.pipeline( + project().include("collapsed", reduce("$arr", array(), concatArrays("$$value", "$$this"))))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestRegexFind.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestRegexFind.java index 1499563530d..1bb4236a1a5 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestRegexFind.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestRegexFind.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -18,15 +19,16 @@ import static dev.morphia.aggregation.stages.Sort.sort; import static dev.morphia.aggregation.stages.Unwind.unwind; -public class TestRegexFind extends AggregationTest { +public class TestRegexFind extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/regexFind/example1 * */ @Test(testName = "``$regexFind`` and Its Options") public void testExample1() { - testPipeline(ServerVersion.ANY, false, false, (aggregation) -> aggregation - .pipeline(addFields().field("returnObject", regexFind("$description").pattern("line")))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(false), + (aggregation) -> aggregation + .pipeline(addFields().field("returnObject", regexFind("$description").pattern("line")))); } /** @@ -35,7 +37,7 @@ public void testExample1() { */ @Test(testName = "Use ``$regexFind`` to Parse Email from String") public void testExample2() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline( addFields().field("email", regexFind("$comment") .pattern("[a-z0-9_.+-]+@[a-z0-9_.+-]+\\.[a-z0-9_.+-]+").options("i")), @@ -48,25 +50,16 @@ public void testExample2() { */ @Test(testName = "Apply ``$regexFind`` to String Elements of an Array") public void testExample3() { - testPipeline( - ServerVersion.ANY, false, true, ( - aggregation) -> aggregation - .pipeline(unwind("details"), - addFields() - .field("regexemail", - regexFind("$details") - .pattern( - "^[a-z0-9_.+-]+@[a-z0-9_.+-]+\\.[a-z0-9_.+-]+$") - .options("i")) - .field("regexphone", - regexFind("$details") - .pattern("^[+]{0,1}[0-9]*\\-?[0-9_\\-]+$")), - project().include("_id").include("name").include("details", - document().field("email", "$regexemail.match").field("phone", - "$regexphone.match")), - group(id("$_id")).field("name", first("$name")).field("details", - mergeObjects().add("$details")), - sort().ascending("_id"))); + testPipeline((aggregation) -> aggregation.pipeline(unwind("details"), + addFields() + .field("regexemail", + regexFind("$details").pattern("^[a-z0-9_.+-]+@[a-z0-9_.+-]+\\.[a-z0-9_.+-]+$") + .options("i")) + .field("regexphone", regexFind("$details").pattern("^[+]{0,1}[0-9]*\\-?[0-9_\\-]+$")), + project().include("_id").include("name").include("details", + document().field("email", "$regexemail.match").field("phone", "$regexphone.match")), + group(id("$_id")).field("name", first("$name")).field("details", mergeObjects().add("$details")), + sort().ascending("_id"))); } /** @@ -75,7 +68,7 @@ public void testExample3() { */ @Test(testName = "Use Captured Groupings to Parse User Name") public void testExample4() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation .pipeline( addFields().field("username", diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestRegexFindAll.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestRegexFindAll.java index 7aba66dee75..0ad021471e2 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestRegexFindAll.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestRegexFindAll.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -12,15 +13,16 @@ import static dev.morphia.aggregation.stages.AddFields.addFields; import static dev.morphia.aggregation.stages.Set.set; -public class TestRegexFindAll extends AggregationTest { +public class TestRegexFindAll extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/regexFindAll/example1 * */ @Test(testName = "``$regexFindAll`` and Its Options") public void testExample1() { - testPipeline(ServerVersion.ANY, false, false, (aggregation) -> aggregation - .pipeline(addFields().field("returnObject", regexFindAll("$description").pattern("line")))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(false), + (aggregation) -> aggregation + .pipeline(addFields().field("returnObject", regexFindAll("$description").pattern("line")))); } @@ -30,7 +32,7 @@ public void testExample1() { */ @Test(testName = "Use ``$regexFindAll`` to Parse Email from String") public void testExample2() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline( addFields().field("email", regexFindAll("$comment") .pattern("[a-z0-9_.+-]+@[a-z0-9_.+-]+\\.[a-z0-9_.+-]+").options("i")), @@ -43,7 +45,7 @@ public void testExample2() { */ @Test(testName = "Use Captured Groupings to Parse User Name") public void testExample3() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline( addFields().field("names", regexFindAll("$comment").pattern("([a-z0-9_.+-]+)@[a-z0-9_.+-]+\\.[a-z0-9_.+-]+") diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestRegexMatch.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestRegexMatch.java index b4e2f55b3d7..a40f9e637dd 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestRegexMatch.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestRegexMatch.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -9,15 +10,16 @@ import static dev.morphia.aggregation.expressions.StringExpressions.regexMatch; import static dev.morphia.aggregation.stages.AddFields.addFields; -public class TestRegexMatch extends AggregationTest { +public class TestRegexMatch extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/regexMatch/example1 * */ @Test(testName = "``$regexMatch`` and Its Options") public void testExample1() { - testPipeline(ServerVersion.ANY, false, false, (aggregation) -> aggregation - .pipeline(addFields().field("result", regexMatch("$description").pattern("line")))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(false), + (aggregation) -> aggregation + .pipeline(addFields().field("result", regexMatch("$description").pattern("line")))); } @@ -27,7 +29,7 @@ public void testExample1() { */ @Test(testName = "Use ``$regexMatch`` to Check Email Address") public void testExample2() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(addFields().field("category", condition(regexMatch("$comment").pattern("[a-z0-9_.+-]+@mongodb.com").options("i"), "Employee", "External")))); diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestReplaceAll.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestReplaceAll.java index 3e4b9daab1e..4cc183ebead 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestReplaceAll.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestReplaceAll.java @@ -1,22 +1,24 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.expressions.StringExpressions.replaceAll; import static dev.morphia.aggregation.stages.Projection.project; -public class TestReplaceAll extends AggregationTest { +public class TestReplaceAll extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/replaceAll/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(project().include("item", replaceAll("$item", "blue paint", "red paint")))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation + .pipeline(project().include("item", replaceAll("$item", "blue paint", "red paint")))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestReplaceOne.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestReplaceOne.java index ef922f8cca1..8a2cdae41e2 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestReplaceOne.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestReplaceOne.java @@ -1,22 +1,24 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.expressions.StringExpressions.replaceOne; import static dev.morphia.aggregation.stages.Projection.project; -public class TestReplaceOne extends AggregationTest { +public class TestReplaceOne extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/replaceOne/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(project().include("item", replaceOne("$item", "blue paint", "red paint")))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation + .pipeline(project().include("item", replaceOne("$item", "blue paint", "red paint")))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestReverseArray.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestReverseArray.java index 557e4f5f071..1894d05648e 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestReverseArray.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestReverseArray.java @@ -1,22 +1,24 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.expressions.ArrayExpressions.reverseArray; import static dev.morphia.aggregation.stages.Projection.project; -public class TestReverseArray extends AggregationTest { +public class TestReverseArray extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/reverseArray/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(project().include("name").include("reverseFavorites", reverseArray("$favorites")))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation + .pipeline(project().include("name").include("reverseFavorites", reverseArray("$favorites")))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestRound.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestRound.java index 56fb8982040..deb6273440e 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestRound.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestRound.java @@ -1,21 +1,22 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.expressions.MathExpressions.round; import static dev.morphia.aggregation.stages.Projection.project; -public class TestRound extends AggregationTest { +public class TestRound extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/round/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(project().include("roundedValue", round("$value", 1)))); } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestRtrim.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestRtrim.java index 4cd65cfd070..a6bffd41141 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestRtrim.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestRtrim.java @@ -1,22 +1,24 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.expressions.StringExpressions.rtrim; import static dev.morphia.aggregation.stages.Projection.project; -public class TestRtrim extends AggregationTest { +public class TestRtrim extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/rtrim/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(project().include("item").include("description", rtrim("$description")))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation + .pipeline(project().include("item").include("description", rtrim("$description")))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSampleRate.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSampleRate.java index 879a5598305..a421122a2ad 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSampleRate.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSampleRate.java @@ -2,7 +2,8 @@ import dev.morphia.aggregation.stages.Count; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -10,15 +11,16 @@ import static dev.morphia.aggregation.stages.Count.*; import static dev.morphia.aggregation.stages.Match.match; -public class TestSampleRate extends AggregationTest { +public class TestSampleRate extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/sampleRate/example1 * */ @Test(testName = "main") public void testExample1() { - skipDataCheck(); - testPipeline(ServerVersion.ANY, false, true, + testPipeline( + new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true) + .skipDataCheck(true), (aggregation) -> aggregation.pipeline(match(sampleRate(0.33)), Count.count("numMatches"))); } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSecond.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSecond.java index ae431eca15c..15bd5248980 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSecond.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSecond.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -17,18 +18,20 @@ import static dev.morphia.aggregation.expressions.DateExpressions.year; import static dev.morphia.aggregation.stages.Projection.project; -public class TestSecond extends AggregationTest { +public class TestSecond extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/second/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation.pipeline(project() - .include("year", year("$date")).include("month", month("$date")).include("day", dayOfMonth("$date")) - .include("hour", hour("$date")).include("minutes", minute("$date")).include("seconds", second("$date")) - .include("milliseconds", milliseconds("$date")).include("dayOfYear", dayOfYear("$date")) - .include("dayOfWeek", dayOfWeek("$date")).include("week", week("$date")))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation + .pipeline(project().include("year", year("$date")).include("month", month("$date")) + .include("day", dayOfMonth("$date")).include("hour", hour("$date")) + .include("minutes", minute("$date")).include("seconds", second("$date")) + .include("milliseconds", milliseconds("$date")).include("dayOfYear", dayOfYear("$date")) + .include("dayOfWeek", dayOfWeek("$date")).include("week", week("$date")))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSetDifference.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSetDifference.java index 8ba7844d734..bb633ad8eb5 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSetDifference.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSetDifference.java @@ -1,21 +1,22 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.expressions.SetExpressions.setDifference; import static dev.morphia.aggregation.stages.Projection.project; -public class TestSetDifference extends AggregationTest { +public class TestSetDifference extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/setDifference/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, false, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(false), (aggregation) -> aggregation.pipeline(project().suppressId().include("flowerFieldA") .include("flowerFieldB").include("inBOnly", setDifference("$flowerFieldB", "$flowerFieldA")))); } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSetEquals.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSetEquals.java index e7e4f23b1e2..bd8044a5cdd 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSetEquals.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSetEquals.java @@ -1,22 +1,24 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.expressions.SetExpressions.setEquals; import static dev.morphia.aggregation.stages.Projection.project; -public class TestSetEquals extends AggregationTest { +public class TestSetEquals extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/setEquals/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation.pipeline(project().suppressId() - .include("cakes").include("cupcakes").include("sameFlavors", setEquals("$cakes", "$cupcakes")))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation.pipeline(project().suppressId().include("cakes").include("cupcakes") + .include("sameFlavors", setEquals("$cakes", "$cupcakes")))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSetField.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSetField.java index cae04137760..cb652628b96 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSetField.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSetField.java @@ -2,7 +2,8 @@ import dev.morphia.test.DriverVersion; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -14,19 +15,18 @@ import static dev.morphia.aggregation.stages.Unset.unset; import static dev.morphia.query.filters.Filters.eq; -public class TestSetField extends AggregationTest { - public TestSetField() { - minDriver = DriverVersion.v43; - } - +public class TestSetField extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/setField/example1 * */ @Test(testName = "Add Fields that Contain Periods (``.``)") public void testExample1() { - testPipeline(ServerVersion.v50, false, true, (aggregation) -> aggregation - .pipeline(replaceWith(setField("price.usd", ROOT, "$price")), unset("price"))); + testPipeline( + new ActionTestOptions().serverVersion(ServerVersion.v50).removeIds(false).orderMatters(true) + .minDriver(DriverVersion.v43), + (aggregation) -> aggregation.pipeline(replaceWith(setField("price.usd", ROOT, "$price")), + unset("price"))); } /** @@ -35,8 +35,11 @@ public void testExample1() { */ @Test(testName = "Add Fields that Start with a Dollar Sign (``$``)") public void testExample2() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(replaceWith(setField(literal("$price"), ROOT, "$price")), unset("price"))); + testPipeline( + new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true) + .minDriver(DriverVersion.v43), + (aggregation) -> aggregation.pipeline(replaceWith(setField(literal("$price"), ROOT, "$price")), + unset("price"))); } /** @@ -45,8 +48,11 @@ public void testExample2() { */ @Test(testName = "Update Fields that Contain Periods (``.``)") public void testExample3() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation.pipeline(match(eq("_id", 1)), - replaceWith(setField("price.usd", ROOT, 49.99)))); + testPipeline( + new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true) + .minDriver(DriverVersion.v43), + (aggregation) -> aggregation.pipeline(match(eq("_id", 1)), + replaceWith(setField("price.usd", ROOT, 49.99)))); } /** @@ -55,8 +61,11 @@ public void testExample3() { */ @Test(testName = "Update Fields that Start with a Dollar Sign (``$``)") public void testExample4() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation.pipeline(match(eq("_id", 1)), - replaceWith(setField(literal("$price"), ROOT, 49.99)))); + testPipeline( + new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true) + .minDriver(DriverVersion.v43), + (aggregation) -> aggregation.pipeline(match(eq("_id", 1)), + replaceWith(setField(literal("$price"), ROOT, 49.99)))); } /** @@ -65,7 +74,7 @@ public void testExample4() { */ @Test(testName = "Remove Fields that Contain Periods (``.``)") public void testExample5() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(replaceWith(setField("price.usd", ROOT, REMOVE)))); } @@ -75,7 +84,7 @@ public void testExample5() { */ @Test(testName = "Remove Fields that Start with a Dollar Sign (``$``)") public void testExample6() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(replaceWith(setField(literal("$price"), ROOT, REMOVE)))); } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSetIntersection.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSetIntersection.java index 827f866bbf6..b6a8aec2ba2 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSetIntersection.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSetIntersection.java @@ -1,21 +1,22 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.expressions.SetExpressions.setIntersection; import static dev.morphia.aggregation.stages.Projection.project; -public class TestSetIntersection extends AggregationTest { +public class TestSetIntersection extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/setIntersection/example1 * */ @Test(testName = "Elements Array Example") public void testExample1() { - testPipeline(ServerVersion.ANY, false, false, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(false), (aggregation) -> aggregation .pipeline(project().suppressId().include("flowerFieldA").include("flowerFieldB") .include("commonToBoth", setIntersection("$flowerFieldA", "$flowerFieldB")))); diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSetIsSubset.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSetIsSubset.java index f758139b9c2..817d5e69eda 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSetIsSubset.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSetIsSubset.java @@ -1,21 +1,22 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.expressions.SetExpressions.setIsSubset; import static dev.morphia.aggregation.stages.Projection.project; -public class TestSetIsSubset extends AggregationTest { +public class TestSetIsSubset extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/setIsSubset/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, false, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(false), (aggregation) -> aggregation.pipeline(project().suppressId().include("flowerFieldA") .include("flowerFieldB").include("AisSubset", setIsSubset("$flowerFieldA", "$flowerFieldB")))); } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSetUnion.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSetUnion.java index d43095611b8..d4bdfe38c38 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSetUnion.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSetUnion.java @@ -1,21 +1,22 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.expressions.SetExpressions.setUnion; import static dev.morphia.aggregation.stages.Projection.project; -public class TestSetUnion extends AggregationTest { +public class TestSetUnion extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/setUnion/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, false, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(false), (aggregation) -> aggregation.pipeline(project().suppressId().include("flowerFieldA") .include("flowerFieldB").include("allValues", setUnion("$flowerFieldA", "$flowerFieldB")))); } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestShift.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestShift.java index a23aee1ceb4..cea3604eb58 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestShift.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestShift.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -10,14 +11,14 @@ import static dev.morphia.aggregation.stages.SetWindowFields.setWindowFields; import static dev.morphia.query.Sort.descending; -public class TestShift extends AggregationTest { +public class TestShift extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/shift/example1 * */ @Test(testName = "Shift Using a Positive Integer") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation .pipeline(setWindowFields().partitionBy("$state").sortBy(descending("quantity")).output( output("shiftQuantityForState").operator(shift("$quantity", 1, "Not available"))))); @@ -29,7 +30,7 @@ public void testExample1() { */ @Test(testName = "Shift Using a Negative Integer") public void testExample2() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation .pipeline(setWindowFields().partitionBy("$state").sortBy(descending("quantity")).output( output("shiftQuantityForState").operator(shift("$quantity", -1, "Not available"))))); diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSin.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSin.java index 62d74827f2e..ce027c10866 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSin.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSin.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -10,15 +11,16 @@ import static dev.morphia.aggregation.expressions.TrigonometryExpressions.sin; import static dev.morphia.aggregation.stages.AddFields.addFields; -public class TestSin extends AggregationTest { +public class TestSin extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/sin/example1 * */ @Test(testName = "main :: Sine of Value in Degrees") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(addFields().field("side_b", multiply(sin(degreesToRadians("$angle_a")), "$hypotenuse")))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation.pipeline( + addFields().field("side_b", multiply(sin(degreesToRadians("$angle_a")), "$hypotenuse")))); } /** @@ -27,8 +29,9 @@ public void testExample1() { */ @Test(testName = "main :: Sine of Value in Radians") public void testExample2() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(addFields().field("side_b", multiply(sin("$angle_a"), "$hypotenuse")))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation + .pipeline(addFields().field("side_b", multiply(sin("$angle_a"), "$hypotenuse")))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSinh.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSinh.java index 80df9f6317a..344475beace 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSinh.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSinh.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -9,15 +10,16 @@ import static dev.morphia.aggregation.expressions.TrigonometryExpressions.sinh; import static dev.morphia.aggregation.stages.AddFields.addFields; -public class TestSinh extends AggregationTest { +public class TestSinh extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/sinh/example1 * */ @Test(testName = "main :: Hyperbolic Sine of Value in Degrees") public void testExample1() { - testPipeline(ServerVersion.ANY, true, true, (aggregation) -> aggregation - .pipeline(addFields().field("sinh_output", sinh(degreesToRadians("$angle"))))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(true).orderMatters(true), + (aggregation) -> aggregation + .pipeline(addFields().field("sinh_output", sinh(degreesToRadians("$angle"))))); } /** @@ -26,7 +28,7 @@ public void testExample1() { */ @Test(testName = "main :: Hyperbolic Sine of Value in Radians") public void testExample2() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(addFields().field("sinh_output", sinh("$angle")))); } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSize.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSize.java index 4b5dae23dd1..dfcd8522dbf 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSize.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSize.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -10,15 +11,16 @@ import static dev.morphia.aggregation.expressions.ConditionalExpressions.condition; import static dev.morphia.aggregation.stages.Projection.project; -public class TestSize extends AggregationTest { +public class TestSize extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/size/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation.pipeline(project().include("item") - .include("numberOfColors", condition(isArray("$colors"), size("$colors"), "NA")))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation.pipeline(project().include("item").include("numberOfColors", + condition(isArray("$colors"), size("$colors"), "NA")))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSlice.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSlice.java index c869a3850f0..448740b7449 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSlice.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSlice.java @@ -1,22 +1,24 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.expressions.ArrayExpressions.slice; import static dev.morphia.aggregation.stages.Projection.project; -public class TestSlice extends AggregationTest { +public class TestSlice extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/slice/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(project().include("name").include("threeFavorites", slice("$favorites", 3)))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation + .pipeline(project().include("name").include("threeFavorites", slice("$favorites", 3)))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSortArray.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSortArray.java index cc6a90c4998..e93696125ae 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSortArray.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSortArray.java @@ -1,6 +1,7 @@ package dev.morphia.test.aggregation.expressions; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -13,14 +14,14 @@ import static dev.morphia.query.Sort.naturalAscending; import static dev.morphia.test.ServerVersion.v52; -public class TestSortArray extends AggregationTest { +public class TestSortArray extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/sortArray/example1 * */ @Test(testName = "Sort on a Field ") public void testExample1() { - testPipeline(v52, (aggregation) -> aggregation + testPipeline(new ActionTestOptions().serverVersion(v52), (aggregation) -> aggregation .pipeline(project().suppressId().include("result", sortArray("$team", ascending("name"))))); } @@ -31,7 +32,7 @@ public void testExample1() { */ @Test(testName = "Sort on a Subfield") public void testExample2() { - testPipeline(v52, (aggregation) -> { + testPipeline(new ActionTestOptions().serverVersion(v52), (aggregation) -> { return aggregation .project(project().suppressId().include("result", sortArray("$team", descending("address.city")))); }); @@ -44,7 +45,7 @@ public void testExample2() { */ @Test(testName = "Sort on Multiple Fields") public void testExample3() { - testPipeline(v52, (aggregation) -> aggregation.pipeline( + testPipeline(new ActionTestOptions().serverVersion(v52), (aggregation) -> aggregation.pipeline( project().suppressId().include("result", sortArray("$team", descending("age"), ascending("name"))))); } @@ -54,7 +55,7 @@ public void testExample3() { */ @Test(testName = "Sort an Array of Integers") public void testExample4() { - testPipeline(v52, (aggregation) -> { + testPipeline(new ActionTestOptions().serverVersion(v52), (aggregation) -> { return aggregation.project( project().suppressId().include("result", sortArray(array(1, 4, 1, 6, 12, 5), naturalAscending()))); }); @@ -68,7 +69,7 @@ public void testExample4() { @Test(testName = "Sort on Mixed Type Fields") public void testExample5() { testPipeline( - v52, false, false, ( + new ActionTestOptions().serverVersion(v52).removeIds(false).orderMatters(false), ( aggregation) -> aggregation .pipeline( project().suppressId() diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSplit.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSplit.java index 3b6ee08589b..8fd87f26f4e 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSplit.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSplit.java @@ -1,14 +1,13 @@ package dev.morphia.test.aggregation.expressions; -import dev.morphia.aggregation.expressions.impls.RegexExpression; import dev.morphia.query.filters.Filters; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.expressions.AccumulatorExpressions.sum; -import static dev.morphia.aggregation.expressions.StringExpressions.regexMatch; import static dev.morphia.aggregation.expressions.StringExpressions.split; import static dev.morphia.aggregation.stages.Group.group; import static dev.morphia.aggregation.stages.Group.id; @@ -17,21 +16,21 @@ import static dev.morphia.aggregation.stages.Sort.sort; import static dev.morphia.aggregation.stages.Unwind.unwind; -public class TestSplit extends AggregationTest { +public class TestSplit extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/split/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> { - RegexExpression regex = regexMatch("$city_state").pattern("[A-Z]{2}"); - skipActionCheck = true; - return aggregation.pipeline(project().include("city_state", split("$city", ", ")).include("qty"), - unwind("city_state"), match(Filters.regex("city_state", "[A-Z]{2}")), - group(id().field("state", "$city_state")).field("total_qty", sum("$qty")), - sort().descending("total_qty")); - }); + testPipeline( + new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true) + .skipActionCheck(true), + (aggregation) -> aggregation.pipeline( + project().include("city_state", split("$city", ", ")).include("qty"), unwind("city_state"), + match(Filters.regex("city_state", "[A-Z]{2}")), + group(id().field("state", "$city_state")).field("total_qty", sum("$qty")), + sort().descending("total_qty"))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSqrt.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSqrt.java index d8bdea9c4ec..0f02e509f93 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSqrt.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSqrt.java @@ -1,7 +1,6 @@ package dev.morphia.test.aggregation.expressions; -import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; import org.testng.annotations.Test; @@ -11,14 +10,14 @@ import static dev.morphia.aggregation.expressions.MathExpressions.subtract; import static dev.morphia.aggregation.stages.Projection.project; -public class TestSqrt extends AggregationTest { +public class TestSqrt extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/sqrt/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation.pipeline(project().include("distance", + testPipeline((aggregation) -> aggregation.pipeline(project().include("distance", sqrt(add(pow(subtract("$p2.y", "$p1.y"), 2), pow(subtract("$p2.x", "$p1.x"), 2)))))); } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestStdDevPop.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestStdDevPop.java index f042f9623d2..11f903678b4 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestStdDevPop.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestStdDevPop.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -13,14 +14,14 @@ import static dev.morphia.aggregation.stages.SetWindowFields.setWindowFields; import static dev.morphia.query.Sort.*; -public class TestStdDevPop extends AggregationTest { +public class TestStdDevPop extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/stdDevPop/example1 * */ @Test(testName = "Use in ``$group`` Stage") public void testExample1() { - testPipeline(ServerVersion.ANY, false, false, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(false), (aggregation) -> aggregation.pipeline(group(id("$quiz")).field("stdDev", stdDevPop("$score")))); } @@ -30,7 +31,7 @@ public void testExample1() { */ @Test(testName = "Use in ``$project`` Stage") public void testExample2() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(project().include("stdDev", stdDevPop("$scores.score")))); } @@ -40,7 +41,7 @@ public void testExample2() { */ @Test(testName = "Use in ``$setWindowFields`` Stage") public void testExample3() { - testPipeline(ServerVersion.ANY, false, false, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(false), (aggregation) -> aggregation.pipeline(setWindowFields().partitionBy("$state") .sortBy(ascending("orderDate")).output(output("stdDevPopQuantityForState") .operator(stdDevPop("$quantity")).window().documents("unbounded", "current")) diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestStdDevSamp.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestStdDevSamp.java index 214fc3f9f5c..4b6ef164cdd 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestStdDevSamp.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestStdDevSamp.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -13,14 +14,14 @@ import static dev.morphia.aggregation.stages.SetWindowFields.setWindowFields; import static dev.morphia.query.Sort.*; -public class TestStdDevSamp extends AggregationTest { +public class TestStdDevSamp extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/stdDevSamp/example1 * */ @Test(testName = "Use in ``$group`` Stage") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation.pipeline(sample(100), + testPipeline((aggregation) -> aggregation.pipeline(sample(100), group(id(null)).field("ageStdDev", stdDevSamp("$age")))); } @@ -30,7 +31,7 @@ public void testExample1() { */ @Test(testName = "Use in ``$setWindowFields`` Stage") public void testExample2() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(setWindowFields().partitionBy("$state") .sortBy(ascending("orderDate")).output(output("stdDevSampQuantityForState") .operator(stdDevSamp("$quantity")).window().documents("unbounded", "current")))); diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestStrLenBytes.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestStrLenBytes.java index bae4771bc9b..06213f13b2d 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestStrLenBytes.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestStrLenBytes.java @@ -1,22 +1,24 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.expressions.StringExpressions.strLenBytes; import static dev.morphia.aggregation.stages.Projection.project; -public class TestStrLenBytes extends AggregationTest { +public class TestStrLenBytes extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/strLenBytes/example1 * */ @Test(testName = "Single-Byte and Multibyte Character Set") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(project().include("name").include("length", strLenBytes("$name")))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation + .pipeline(project().include("name").include("length", strLenBytes("$name")))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestStrLenCP.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestStrLenCP.java index 26f75c9ee4f..a19d51d6870 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestStrLenCP.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestStrLenCP.java @@ -1,21 +1,22 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.expressions.StringExpressions.strLenCP; import static dev.morphia.aggregation.stages.Projection.project; -public class TestStrLenCP extends AggregationTest { +public class TestStrLenCP extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/strLenCP/example1 * */ @Test(testName = "Single-Byte and Multibyte Character Set") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(project().include("name").include("length", strLenCP("$name")))); } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestStrcasecmp.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestStrcasecmp.java index 3844a54de49..1774ddce8a4 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestStrcasecmp.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestStrcasecmp.java @@ -1,22 +1,24 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.expressions.StringExpressions.strcasecmp; import static dev.morphia.aggregation.stages.Projection.project; -public class TestStrcasecmp extends AggregationTest { +public class TestStrcasecmp extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/strcasecmp/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(project().include("item").include("comparisonResult", strcasecmp("$quarter", "13q4")))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation.pipeline( + project().include("item").include("comparisonResult", strcasecmp("$quarter", "13q4")))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSubstrBytes.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSubstrBytes.java index b403db8a27b..356e7d1b7d4 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSubstrBytes.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSubstrBytes.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -10,14 +11,14 @@ import static dev.morphia.aggregation.expressions.StringExpressions.substrBytes; import static dev.morphia.aggregation.stages.Projection.project; -public class TestSubstrBytes extends AggregationTest { +public class TestSubstrBytes extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/substrBytes/example1 * */ @Test(testName = "Single-Byte Character Set") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline( project().include("item").include("yearSubstring", substrBytes("$quarter", 0, 2)).include( "quarterSubtring", substrBytes("$quarter", 2, subtract(strLenBytes("$quarter"), 2))))); @@ -29,8 +30,9 @@ public void testExample1() { */ @Test(testName = "Single-Byte and Multibyte Character Set") public void testExample2() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(project().include("name").include("menuCode", substrBytes("$name", 0, 3)))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation + .pipeline(project().include("name").include("menuCode", substrBytes("$name", 0, 3)))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSubstrCP.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSubstrCP.java index 97f06b82f5e..bb72b9a95d2 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSubstrCP.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSubstrCP.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -10,14 +11,14 @@ import static dev.morphia.aggregation.expressions.StringExpressions.substrCP; import static dev.morphia.aggregation.stages.Projection.project; -public class TestSubstrCP extends AggregationTest { +public class TestSubstrCP extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/substrCP/example1 * */ @Test(testName = "Single-Byte Character Set") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline( project().include("item").include("yearSubstring", substrCP("$quarter", 0, 2)).include( "quarterSubtring", substrCP("$quarter", 2, subtract(strLenCP("$quarter"), 2))))); @@ -29,8 +30,9 @@ public void testExample1() { */ @Test(testName = "Single-Byte and Multibyte Character Set") public void testExample2() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(project().include("name").include("menuCode", substrCP("$name", 0, 3)))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation + .pipeline(project().include("name").include("menuCode", substrCP("$name", 0, 3)))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSubtract.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSubtract.java index f38236adc3c..28e429a5080 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSubtract.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSubtract.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -9,15 +10,16 @@ import static dev.morphia.aggregation.expressions.MathExpressions.subtract; import static dev.morphia.aggregation.stages.Projection.project; -public class TestSubtract extends AggregationTest { +public class TestSubtract extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/subtract/example1 * */ @Test(testName = "Subtract Numbers") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(project().include("item").include("total", subtract(add("$price", "$fee"), "$discount")))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation.pipeline( + project().include("item").include("total", subtract(add("$price", "$fee"), "$discount")))); } /** @@ -26,9 +28,11 @@ public void testExample1() { */ @Test(testName = "Subtract Two Dates") public void testExample2() { - skipDataCheck(); - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(project().include("item").include("dateDifference", subtract("$$NOW", "$date")))); + testPipeline( + new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true) + .skipDataCheck(true), + (aggregation) -> aggregation + .pipeline(project().include("item").include("dateDifference", subtract("$$NOW", "$date")))); } /** @@ -37,7 +41,8 @@ public void testExample2() { */ @Test(testName = "Subtract Milliseconds from a Date") public void testExample3() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(project().include("item").include("dateDifference", subtract("$date", 5 * 60 * 1000)))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation.pipeline( + project().include("item").include("dateDifference", subtract("$date", 5 * 60 * 1000)))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSum.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSum.java index a749dd5ae7a..fe54d8afe75 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSum.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSum.java @@ -2,7 +2,8 @@ import dev.morphia.query.Sort; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -18,14 +19,14 @@ import static dev.morphia.aggregation.stages.SetWindowFields.setWindowFields; import static dev.morphia.test.ServerVersion.v50; -public class TestSum extends AggregationTest { +public class TestSum extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/sum/example1 * */ @Test(testName = "Use in ``$group`` Stage") public void testExample1() { - testPipeline(v50, false, false, + testPipeline(new ActionTestOptions().serverVersion(v50).removeIds(false).orderMatters(false), (aggregation) -> aggregation .pipeline(group(id(document().field("day", dayOfYear("$date")).field("year", year("$date")))) .field("totalAmount", sum(multiply("$price", "$quantity"))).field("count", sum(1)))); @@ -37,7 +38,7 @@ public void testExample1() { */ @Test(testName = "Use in ``$project`` Stage") public void testExample2() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(project().include("quizTotal", sum("$quizzes")) .include("labTotal", sum("$labs")).include("examTotal", sum("$final", "$midterm")))); } @@ -48,7 +49,7 @@ public void testExample2() { */ @Test(testName = "Use in ``$setWindowFields`` Stage") public void testExample3() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(setWindowFields().partitionBy("$state") .sortBy(Sort.ascending("orderDate")).output(output("sumQuantityForState") .operator(sum("$quantity")).window().documents("unbounded", "current")))); diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSwitch.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSwitch.java index 649ce21e200..d7bc6ed64b3 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSwitch.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestSwitch.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -12,17 +13,19 @@ import static dev.morphia.aggregation.expressions.ConditionalExpressions.switchExpression; import static dev.morphia.aggregation.stages.Projection.project; -public class TestSwitch extends AggregationTest { +public class TestSwitch extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/switch/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation.pipeline(project().include("name") - .include("summary", switchExpression().branch(gte(avg("$scores"), 90), "Doing great!") - .branch(and(gte(avg("$scores"), 80), lt(avg("$scores"), 90)), "Doing pretty well.") - .branch(lt(avg("$scores"), 80), "Needs improvement.").defaultCase("No scores found.")))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation.pipeline(project().include("name").include("summary", + switchExpression().branch(gte(avg("$scores"), 90), "Doing great!") + .branch(and(gte(avg("$scores"), 80), lt(avg("$scores"), 90)), "Doing pretty well.") + .branch(lt(avg("$scores"), 80), "Needs improvement.") + .defaultCase("No scores found.")))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestTan.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestTan.java index 1214bf671a4..f00b9c9e83e 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestTan.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestTan.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -10,15 +11,16 @@ import static dev.morphia.aggregation.expressions.TrigonometryExpressions.tan; import static dev.morphia.aggregation.stages.AddFields.addFields; -public class TestTan extends AggregationTest { +public class TestTan extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/tan/example1 * */ @Test(testName = "main :: Tangent of Value in Degrees") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(addFields().field("side_b", multiply(tan(degreesToRadians("$angle_a")), "$side_a")))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation + .pipeline(addFields().field("side_b", multiply(tan(degreesToRadians("$angle_a")), "$side_a")))); } /** @@ -27,8 +29,9 @@ public void testExample1() { */ @Test(testName = "main :: Tangent of Value in Radians") public void testExample2() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(addFields().field("side_b", multiply(tan("$angle_a"), "$side_a")))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation + .pipeline(addFields().field("side_b", multiply(tan("$angle_a"), "$side_a")))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestTanh.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestTanh.java index ffcc80a2bab..3897051a660 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestTanh.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestTanh.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -9,15 +10,16 @@ import static dev.morphia.aggregation.expressions.TrigonometryExpressions.tanh; import static dev.morphia.aggregation.stages.AddFields.addFields; -public class TestTanh extends AggregationTest { +public class TestTanh extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/tanh/example1 * */ @Test(testName = "main :: Hyperbolic Tangent in Degrees") public void testExample1() { - testPipeline(ServerVersion.ANY, true, true, (aggregation) -> aggregation - .pipeline(addFields().field("tanh_output", tanh(degreesToRadians("$angle"))))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(true).orderMatters(true), + (aggregation) -> aggregation + .pipeline(addFields().field("tanh_output", tanh(degreesToRadians("$angle"))))); } /** @@ -26,7 +28,7 @@ public void testExample1() { */ @Test(testName = "main :: Hyperbolic Tangent in Radians") public void testExample2() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(addFields().field("tanh_output", tanh("$angle")))); } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestToBool.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestToBool.java index 231c64ef6ce..3fb38abf692 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestToBool.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestToBool.java @@ -2,7 +2,8 @@ import dev.morphia.query.filters.Filters; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -12,14 +13,14 @@ import static dev.morphia.aggregation.stages.AddFields.addFields; import static dev.morphia.aggregation.stages.Match.match; -public class TestToBool extends AggregationTest { +public class TestToBool extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/toBool/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline( addFields().field("convertedShippedFlag", switchExpression().branch(eq("$shipped", "false"), false) diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestToDate.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestToDate.java index a75c91f98a6..39578ac1443 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestToDate.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestToDate.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -9,14 +10,14 @@ import static dev.morphia.aggregation.stages.AddFields.addFields; import static dev.morphia.aggregation.stages.Sort.sort; -public class TestToDate extends AggregationTest { +public class TestToDate extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/toDate/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(addFields().field("convertedDate", toDate("$order_date")), sort().ascending("convertedDate"))); } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestToDecimal.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestToDecimal.java index 3c1f12d235e..e2495324ca8 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestToDecimal.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestToDecimal.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -11,14 +12,14 @@ import static dev.morphia.aggregation.stages.AddFields.addFields; import static dev.morphia.aggregation.stages.Projection.project; -public class TestToDecimal extends AggregationTest { +public class TestToDecimal extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/toDecimal/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline( addFields().field("convertedPrice", toDecimal("$price")).field("convertedQty", toInt("$qty")), project().include("item").include("totalPrice", multiply("$convertedPrice", "$convertedQty")))); diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestToDouble.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestToDouble.java index dc3f48282a7..1dec76d7f6d 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestToDouble.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestToDouble.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -9,15 +10,16 @@ import static dev.morphia.aggregation.expressions.TypeExpressions.toDouble; import static dev.morphia.aggregation.stages.AddFields.addFields; -public class TestToDouble extends AggregationTest { +public class TestToDouble extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/toDouble/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(addFields().field("degrees", toDouble(substrBytes("$temp", 0, 4))))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation + .pipeline(addFields().field("degrees", toDouble(substrBytes("$temp", 0, 4))))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestToInt.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestToInt.java index 78e9e086d75..ba61efd0525 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestToInt.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestToInt.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -11,14 +12,14 @@ import static dev.morphia.aggregation.stages.AddFields.addFields; import static dev.morphia.aggregation.stages.Projection.project; -public class TestToInt extends AggregationTest { +public class TestToInt extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/toInt/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline( addFields().field("convertedPrice", toDecimal("$price")).field("convertedQty", toInt("$qty")), project().include("item").include("totalPrice", multiply("$convertedPrice", "$convertedQty")))); diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestToLong.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestToLong.java index 74c673eb340..aba4678a282 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestToLong.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestToLong.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -9,15 +10,16 @@ import static dev.morphia.aggregation.stages.AddFields.addFields; import static dev.morphia.aggregation.stages.Sort.sort; -public class TestToLong extends AggregationTest { +public class TestToLong extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/toLong/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(addFields().field("convertedQty", toLong("$qty")), sort().descending("convertedQty"))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation.pipeline(addFields().field("convertedQty", toLong("$qty")), + sort().descending("convertedQty"))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestToLower.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestToLower.java index 1703de2eb74..260920ef31b 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestToLower.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestToLower.java @@ -1,22 +1,24 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.expressions.StringExpressions.toLower; import static dev.morphia.aggregation.stages.Projection.project; -public class TestToLower extends AggregationTest { +public class TestToLower extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/toLower/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(project().include("item", toLower("$item")).include("description", toLower("$description")))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation.pipeline( + project().include("item", toLower("$item")).include("description", toLower("$description")))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestToObjectId.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestToObjectId.java index 6ffa5999392..5b26ca79e03 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestToObjectId.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestToObjectId.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -9,15 +10,16 @@ import static dev.morphia.aggregation.stages.AddFields.addFields; import static dev.morphia.aggregation.stages.Sort.sort; -public class TestToObjectId extends AggregationTest { +public class TestToObjectId extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/toObjectId/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(addFields().field("convertedId", toObjectId("$_id")), sort().descending("convertedId"))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation.pipeline(addFields().field("convertedId", toObjectId("$_id")), + sort().descending("convertedId"))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestToString.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestToString.java index db0ec7f4348..6ea9528606f 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestToString.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestToString.java @@ -2,21 +2,22 @@ import dev.morphia.aggregation.expressions.StringExpressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.stages.AddFields.addFields; import static dev.morphia.aggregation.stages.Sort.sort; -public class TestToString extends AggregationTest { +public class TestToString extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/toString/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline( addFields().field("convertedZipCode", StringExpressions.toString("$zipcode")), sort().ascending("convertedZipCode"))); diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestToUpper.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestToUpper.java index e8a349fbc0a..cd9546520b8 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestToUpper.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestToUpper.java @@ -1,22 +1,24 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.expressions.StringExpressions.toUpper; import static dev.morphia.aggregation.stages.Projection.project; -public class TestToUpper extends AggregationTest { +public class TestToUpper extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/toUpper/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(project().include("item", toUpper("$item")).include("description", toUpper("$description")))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation.pipeline( + project().include("item", toUpper("$item")).include("description", toUpper("$description")))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestTop.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestTop.java index c6660714bf9..1237f7d2cb1 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestTop.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestTop.java @@ -1,6 +1,7 @@ package dev.morphia.test.aggregation.expressions; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -13,15 +14,16 @@ import static dev.morphia.query.filters.Filters.eq; import static dev.morphia.test.ServerVersion.v52; -public class TestTop extends AggregationTest { +public class TestTop extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/top/example1 * */ @Test(testName = "Find the Top ``Score``") public void testExample1() { - testPipeline(v52, false, false, (aggregation) -> aggregation.pipeline(match(eq("gameId", "G1")), - group(id("$gameId")).field("playerId", top(array("$playerId", "$score"), descending("score"))))); + testPipeline(new ActionTestOptions().serverVersion(v52).removeIds(false).orderMatters(false), + (aggregation) -> aggregation.pipeline(match(eq("gameId", "G1")), group(id("$gameId")).field("playerId", + top(array("$playerId", "$score"), descending("score"))))); } /** @@ -30,8 +32,9 @@ public void testExample1() { */ @Test(testName = "Find the Top ``Score`` Across Multiple Games") public void testExample2() { - testPipeline(v52, false, false, (aggregation) -> aggregation.pipeline( - group(id("$gameId")).field("playerId", top(array("$playerId", "$score"), descending("score"))))); + testPipeline(new ActionTestOptions().serverVersion(v52).removeIds(false).orderMatters(false), + (aggregation) -> aggregation.pipeline(group(id("$gameId")).field("playerId", + top(array("$playerId", "$score"), descending("score"))))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestTopN.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestTopN.java index ececf82cd18..8e8cce5ffce 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestTopN.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestTopN.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.aggregation.expressions.ComparisonExpressions; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -17,15 +18,16 @@ import static dev.morphia.query.filters.Filters.eq; import static dev.morphia.test.ServerVersion.v52; -public class TestTopN extends AggregationTest { +public class TestTopN extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/topN/example1 * */ @Test(testName = "Find the Three Highest ``Scores``") public void testExample1() { - testPipeline(v52, false, false, (aggregation) -> aggregation.pipeline(match(eq("gameId", "G1")), - group(id("$gameId")).field("playerId", topN(3, array("$playerId", "$score"), descending("score"))))); + testPipeline(new ActionTestOptions().serverVersion(v52).removeIds(false).orderMatters(false), + (aggregation) -> aggregation.pipeline(match(eq("gameId", "G1")), group(id("$gameId")).field("playerId", + topN(3, array("$playerId", "$score"), descending("score"))))); } /** @@ -34,10 +36,9 @@ public void testExample1() { */ @Test(testName = "Finding the Three Highest Score Documents Across Multiple Games") public void testExample2() { - testPipeline(v52, false, false, (aggregation) -> { - return aggregation.group( - group(id("$gameId")).field("playerId", topN(3, array("$playerId", "$score"), descending("score")))); - }); + testPipeline(new ActionTestOptions().serverVersion(v52).removeIds(false).orderMatters(false), + (aggregation) -> aggregation.group(group(id("$gameId")).field("playerId", + topN(3, array("$playerId", "$score"), descending("score"))))); } /** @@ -46,9 +47,8 @@ public void testExample2() { */ @Test(testName = "Computing ``n`` Based on the Group Key for ``$group``") public void testExample3() { - testPipeline(v52, false, false, (aggregation) -> { - return aggregation.group(group(id(document("gameId", "$gameId"))).field("gamescores", - topN(condition(ComparisonExpressions.eq("$gameId", "G2"), 1, 3), "$score", descending("score")))); - }); + testPipeline(new ActionTestOptions().serverVersion(v52).removeIds(false).orderMatters(false), + (aggregation) -> aggregation.group(group(id(document("gameId", "$gameId"))).field("gamescores", topN( + condition(ComparisonExpressions.eq("$gameId", "G2"), 1, 3), "$score", descending("score"))))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestTrim.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestTrim.java index 1afd0b2025d..c96f5cdc22c 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestTrim.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestTrim.java @@ -1,22 +1,24 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.expressions.StringExpressions.trim; import static dev.morphia.aggregation.stages.Projection.project; -public class TestTrim extends AggregationTest { +public class TestTrim extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/trim/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, false, (aggregation) -> aggregation - .pipeline(project().include("item").include("description", trim("$description")))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(false), + (aggregation) -> aggregation + .pipeline(project().include("item").include("description", trim("$description")))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestTrunc.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestTrunc.java index 471480d8c30..796d10d6d08 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestTrunc.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestTrunc.java @@ -1,21 +1,22 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.expressions.MathExpressions.trunc; import static dev.morphia.aggregation.stages.Projection.project; -public class TestTrunc extends AggregationTest { +public class TestTrunc extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/trunc/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(project().include("truncatedValue", trunc("$value", 1)))); } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestTsIncrement.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestTsIncrement.java index 51f67897f8c..f9ba98e9458 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestTsIncrement.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestTsIncrement.java @@ -1,6 +1,7 @@ package dev.morphia.test.aggregation.expressions; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -8,14 +9,13 @@ import static dev.morphia.aggregation.stages.Projection.project; import static dev.morphia.test.ServerVersion.v51; -public class TestTsIncrement extends AggregationTest { +public class TestTsIncrement extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/tsIncrement/example1 - * */ @Test(testName = "Obtain the Incrementing Ordinal from a Timestamp Field") public void testExample1() { - testPipeline(v51, (aggregation) -> aggregation.pipeline(project().suppressId().include("saleTimestamp") - .include("saleIncrement", tsIncrement("$saleTimestamp")))); + testPipeline(new ActionTestOptions().serverVersion(v51), (aggregation) -> aggregation.pipeline(project() + .suppressId().include("saleTimestamp").include("saleIncrement", tsIncrement("$saleTimestamp")))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestTsSecond.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestTsSecond.java index af3e845a314..2e2b2cc9771 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestTsSecond.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestTsSecond.java @@ -1,6 +1,7 @@ package dev.morphia.test.aggregation.expressions; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -8,14 +9,14 @@ import static dev.morphia.aggregation.stages.Projection.project; import static dev.morphia.test.ServerVersion.v51; -public class TestTsSecond extends AggregationTest { +public class TestTsSecond extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/tsSecond/example1 * */ @Test(testName = "Obtain the Number of Seconds from a Timestamp Field") public void testExample1() { - testPipeline(v51, (aggregation) -> aggregation.pipeline( + testPipeline(new ActionTestOptions().serverVersion(v51), (aggregation) -> aggregation.pipeline( project().suppressId().include("saleTimestamp").include("saleSeconds", tsSecond("$saleTimestamp")))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestType.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestType.java index d57c9996b03..e10eee99e89 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestType.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestType.java @@ -1,21 +1,22 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.expressions.TypeExpressions.type; import static dev.morphia.aggregation.stages.Projection.project; -public class TestType extends AggregationTest { +public class TestType extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/type/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, false, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(false), (aggregation) -> aggregation.pipeline(project().include("a", type("$a")))); } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestUnsetField.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestUnsetField.java index 8e5114251f2..595c19a0a00 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestUnsetField.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestUnsetField.java @@ -1,8 +1,8 @@ package dev.morphia.test.aggregation.expressions; -import dev.morphia.test.DriverVersion; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -12,16 +12,17 @@ import static dev.morphia.aggregation.expressions.Miscellaneous.unsetField; import static dev.morphia.aggregation.expressions.SystemVariables.*; import static dev.morphia.aggregation.stages.ReplaceWith.replaceWith; +import static dev.morphia.test.DriverVersion.v43; -public class TestUnsetField extends AggregationTest { +public class TestUnsetField extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/unsetField/example1 * */ @Test(testName = "Remove Fields that Contain Periods (``.``)") public void testExample1() { - checkMinDriverVersion(DriverVersion.v43); - testPipeline(ServerVersion.ANY, false, true, + checkMinDriverVersion(v43); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(replaceWith(unsetField("price.usd", ROOT)))); } @@ -31,8 +32,8 @@ public void testExample1() { */ @Test(testName = "Remove Fields that Start with a Dollar Sign (``$``)") public void testExample2() { - minDriver = DriverVersion.v43; - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true) + .minDriver(v43), (aggregation) -> aggregation.pipeline(replaceWith(unsetField(literal("$price"), ROOT)))); } @@ -42,8 +43,9 @@ public void testExample2() { */ @Test(testName = "Remove A Subfield") public void testExample3() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(replaceWith(setField("price", ROOT, unsetField("euro", getField("price")))))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation + .pipeline(replaceWith(setField("price", ROOT, unsetField("euro", getField("price")))))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestWeek.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestWeek.java index fef873a9df2..72ef9945249 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestWeek.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestWeek.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -17,18 +18,20 @@ import static dev.morphia.aggregation.expressions.DateExpressions.year; import static dev.morphia.aggregation.stages.Projection.project; -public class TestWeek extends AggregationTest { +public class TestWeek extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/week/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation.pipeline(project() - .include("year", year("$date")).include("month", month("$date")).include("day", dayOfMonth("$date")) - .include("hour", hour("$date")).include("minutes", minute("$date")).include("seconds", second("$date")) - .include("milliseconds", milliseconds("$date")).include("dayOfYear", dayOfYear("$date")) - .include("dayOfWeek", dayOfWeek("$date")).include("week", week("$date")))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation + .pipeline(project().include("year", year("$date")).include("month", month("$date")) + .include("day", dayOfMonth("$date")).include("hour", hour("$date")) + .include("minutes", minute("$date")).include("seconds", second("$date")) + .include("milliseconds", milliseconds("$date")).include("dayOfYear", dayOfYear("$date")) + .include("dayOfWeek", dayOfWeek("$date")).include("week", week("$date")))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestYear.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestYear.java index dbdbd2c2bd7..7fb6f5818a0 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestYear.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestYear.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -17,18 +18,20 @@ import static dev.morphia.aggregation.expressions.DateExpressions.year; import static dev.morphia.aggregation.stages.Projection.project; -public class TestYear extends AggregationTest { +public class TestYear extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/year/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation.pipeline(project() - .include("year", year("$date")).include("month", month("$date")).include("day", dayOfMonth("$date")) - .include("hour", hour("$date")).include("minutes", minute("$date")).include("seconds", second("$date")) - .include("milliseconds", milliseconds("$date")).include("dayOfYear", dayOfYear("$date")) - .include("dayOfWeek", dayOfWeek("$date")).include("week", week("$date")))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation + .pipeline(project().include("year", year("$date")).include("month", month("$date")) + .include("day", dayOfMonth("$date")).include("hour", hour("$date")) + .include("minutes", minute("$date")).include("seconds", second("$date")) + .include("milliseconds", milliseconds("$date")).include("dayOfYear", dayOfYear("$date")) + .include("dayOfWeek", dayOfWeek("$date")).include("week", week("$date")))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestZip.java b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestZip.java index 47db56e81f1..bc8d384f626 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/expressions/TestZip.java +++ b/core/src/test/java/dev/morphia/test/aggregation/expressions/TestZip.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.expressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -14,14 +15,14 @@ import static dev.morphia.aggregation.expressions.VariableExpressions.let; import static dev.morphia.aggregation.stages.Projection.project; -public class TestZip extends AggregationTest { +public class TestZip extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/expressions/zip/example1 * */ @Test(testName = "Matrix Transposition") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(project().suppressId().include("transposed", zip(elementAt("$matrix", 0), elementAt("$matrix", 1), elementAt("$matrix", 2))))); } @@ -32,12 +33,13 @@ public void testExample1() { */ @Test(testName = "Filtering and Preserving Indexes") public void testExample2() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> { - return aggregation.pipeline(project().suppressId().include("pages", - filter(zip("$pages", range(0, size("$pages"))), - let(gte("$$page.reviews", 1)).variable("page", elementAt("$$pageWithIndex", 0))) - .as("pageWithIndex"))); - }); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> { + return aggregation.pipeline(project().suppressId().include("pages", + filter(zip("$pages", range(0, size("$pages"))), + let(gte("$$page.reviews", 1)).variable("page", elementAt("$$pageWithIndex", 0))) + .as("pageWithIndex"))); + }); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/stages/TestAddFields.java b/core/src/test/java/dev/morphia/test/aggregation/stages/TestAddFields.java index ded8196772f..b5958213011 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/stages/TestAddFields.java +++ b/core/src/test/java/dev/morphia/test/aggregation/stages/TestAddFields.java @@ -3,8 +3,9 @@ import java.util.List; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; import dev.morphia.test.aggregation.model.Score; +import dev.morphia.test.util.ActionTestOptions; import org.bson.Document; import org.testng.annotations.Test; @@ -19,7 +20,7 @@ import static org.bson.Document.parse; import static org.testng.Assert.assertEquals; -public class TestAddFields extends AggregationTest { +public class TestAddFields extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/stages/addFields/example1 * @@ -52,7 +53,7 @@ public void testExample1() { */ @Test(testName = "Adding Fields to an Embedded Document") public void testExample2() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(addFields().field("specs.fuel_type", "unleaded"))); } @@ -62,7 +63,7 @@ public void testExample2() { */ @Test(testName = "Overwriting an existing field") public void testExample3() { - testPipeline(ServerVersion.ANY, false, false, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(false), (aggregation) -> aggregation.pipeline(addFields().field("cats", 20))); } @@ -72,7 +73,7 @@ public void testExample3() { */ @Test(testName = "Add Element to an Array") public void testExample4() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation.pipeline(match(eq("_id", 1)), + testPipeline((aggregation) -> aggregation.pipeline(match(eq("_id", 1)), addFields().field("homework", concatArrays("$homework", array(7))))); } diff --git a/core/src/test/java/dev/morphia/test/aggregation/stages/TestBucket.java b/core/src/test/java/dev/morphia/test/aggregation/stages/TestBucket.java index ced4a42696b..312d786cca2 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/stages/TestBucket.java +++ b/core/src/test/java/dev/morphia/test/aggregation/stages/TestBucket.java @@ -6,9 +6,10 @@ import dev.morphia.annotations.Entity; import dev.morphia.annotations.Id; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; import dev.morphia.test.aggregation.model.Artwork; import dev.morphia.test.aggregation.model.Book; +import dev.morphia.test.util.ActionTestOptions; import org.bson.Document; import org.testng.Assert; @@ -27,24 +28,18 @@ import static org.bson.Document.parse; import static org.testng.Assert.assertEquals; -public class TestBucket extends AggregationTest { +public class TestBucket extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/stages/bucket/example1 * */ @Test(testName = "Bucket by Year and Filter by Bucket Results") public void testExample1() { - testPipeline( - ServerVersion.ANY, false, true, ( - aggregation) -> aggregation - .pipeline( - bucket().groupBy("$year_born").boundaries(1840, 1850, 1860, 1870, 1880) - .defaultValue("Other").outputField("count", - sum(1)) - .outputField("artists", - push().field("name", concat("$first_name", " ", "$last_name")) - .field("year_born", "$year_born")), - match(gt("count", 3)))); + testPipeline((aggregation) -> aggregation.pipeline(bucket() + .groupBy("$year_born").boundaries(1840, 1850, 1860, 1870, 1880).defaultValue("Other") + .outputField("count", sum(1)).outputField("artists", push() + .field("name", concat("$first_name", " ", "$last_name")).field("year_born", "$year_born")), + match(gt("count", 3)))); } /** @@ -53,7 +48,9 @@ public void testExample1() { */ @Test(testName = "Use $bucket with $facet to Bucket by Multiple Fields") public void testExample2() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline( + new ActionTestOptions().serverVersion( + ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(facet() .field("price", bucket().groupBy("$price").boundaries(0, 200, 400).defaultValue("Other") diff --git a/core/src/test/java/dev/morphia/test/aggregation/stages/TestBucketAuto.java b/core/src/test/java/dev/morphia/test/aggregation/stages/TestBucketAuto.java index 533b82c75c1..29058d8d6c6 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/stages/TestBucketAuto.java +++ b/core/src/test/java/dev/morphia/test/aggregation/stages/TestBucketAuto.java @@ -5,10 +5,11 @@ import com.mongodb.client.model.BucketGranularity; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; import dev.morphia.test.aggregation.model.Book; import dev.morphia.test.aggregation.model.BooksBucketResult; import dev.morphia.test.aggregation.model.BucketAutoResult; +import dev.morphia.test.util.ActionTestOptions; import org.testng.Assert; import org.testng.annotations.Test; @@ -22,14 +23,14 @@ import static java.util.Arrays.asList; import static java.util.Collections.singleton; -public class TestBucketAuto extends AggregationTest { +public class TestBucketAuto extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/stages/bucketAuto/example1 * */ @Test(testName = "Single Facet Aggregation") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(autoBucket().groupBy("$price").buckets(4))); } @@ -39,7 +40,7 @@ public void testExample1() { */ @Test(testName = "Multi-Faceted Aggregation") public void testExample2() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(facet().field("price", autoBucket().groupBy("$price").buckets(4)) .field("year", autoBucket().groupBy("$year").buckets(3).outputField("count", sum(1)) @@ -50,7 +51,7 @@ public void testExample2() { @Test(testName = "Multi-Faceted Aggregation") public void testExample3() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(facet().field("price", autoBucket().groupBy("$price").buckets(4)) .field("year", autoBucket().groupBy("$year").buckets(3).outputField("count", sum(1)) diff --git a/core/src/test/java/dev/morphia/test/aggregation/stages/TestChangeStream.java b/core/src/test/java/dev/morphia/test/aggregation/stages/TestChangeStream.java index cd1c57b591d..62cbb9ccfe0 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/stages/TestChangeStream.java +++ b/core/src/test/java/dev/morphia/test/aggregation/stages/TestChangeStream.java @@ -11,7 +11,7 @@ import dev.morphia.aggregation.stages.ChangeStream; import dev.morphia.mapping.codec.writer.DocumentWriter; import dev.morphia.query.MorphiaCursor; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; import org.bson.Document; import org.bson.codecs.Codec; @@ -25,7 +25,7 @@ import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; -public class TestChangeStream extends AggregationTest { +public class TestChangeStream extends TemplatedTestBase { @Test @SuppressWarnings("unchecked") public void testChangeStream() { diff --git a/core/src/test/java/dev/morphia/test/aggregation/stages/TestCount.java b/core/src/test/java/dev/morphia/test/aggregation/stages/TestCount.java index 84e1fd3f691..a9855165de0 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/stages/TestCount.java +++ b/core/src/test/java/dev/morphia/test/aggregation/stages/TestCount.java @@ -2,7 +2,8 @@ import dev.morphia.aggregation.stages.Count; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -10,14 +11,14 @@ import static dev.morphia.aggregation.stages.Match.match; import static dev.morphia.query.filters.Filters.gt; -public class TestCount extends AggregationTest { +public class TestCount extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/stages/count/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(match(gt("score", 80)), Count.count("passing_scores"))); } diff --git a/core/src/test/java/dev/morphia/test/aggregation/stages/TestCurrentOp.java b/core/src/test/java/dev/morphia/test/aggregation/stages/TestCurrentOp.java index 09301e061cd..9bb7bd979bf 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/stages/TestCurrentOp.java +++ b/core/src/test/java/dev/morphia/test/aggregation/stages/TestCurrentOp.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.stages; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -10,17 +11,15 @@ import static dev.morphia.query.filters.Filters.eq; import static dev.morphia.query.filters.Filters.exists; -public class TestCurrentOp extends AggregationTest { - public TestCurrentOp() { - skipDataCheck(); - } - +public class TestCurrentOp extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/stages/currentOp/example1 */ @Test(testName = "Inactive Sessions :: Replica Set") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline( + new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true) + .skipDataCheck(true), (aggregation) -> aggregation.pipeline(currentOp().allUsers(true).idleSessions(true), match(eq("active", false), exists("transaction")))); } @@ -30,7 +29,9 @@ public void testExample1() { */ @Test(testName = "Inactive Sessions :: Sharded Cluster (localOps: true)") public void testExample2() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline( + new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true) + .skipDataCheck(true), (aggregation) -> aggregation.pipeline(currentOp().allUsers(true).idleSessions(true), match(eq("active", false), exists("transaction")))); } @@ -40,7 +41,9 @@ public void testExample2() { */ @Test(testName = "Inactive Sessions :: Sharded Cluster") public void testExample3() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline( + new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true) + .skipDataCheck(true), (aggregation) -> aggregation.pipeline(currentOp().allUsers(true).idleSessions(true), match(eq("active", false), exists("transaction")))); } @@ -50,8 +53,11 @@ public void testExample3() { */ @Test(testName = "Sampled Queries :: Replica Set") public void testExample4() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(currentOp().allUsers(true).localOps(true), match(eq("desc", "query analyzer")))); + testPipeline( + new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true) + .skipDataCheck(true), + (aggregation) -> aggregation.pipeline(currentOp().allUsers(true).localOps(true), + match(eq("desc", "query analyzer")))); } /** @@ -59,8 +65,11 @@ public void testExample4() { */ @Test(testName = "Sampled Queries :: Sharded Cluster: mongos") public void testExample5() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(currentOp().allUsers(true).localOps(true), match(eq("desc", "query analyzer")))); + testPipeline( + new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true) + .skipDataCheck(true), + (aggregation) -> aggregation.pipeline(currentOp().allUsers(true).localOps(true), + match(eq("desc", "query analyzer")))); } /** @@ -68,7 +77,10 @@ public void testExample5() { */ @Test(testName = "Sampled Queries :: Sharded Cluster: mongod --shardsvr") public void testExample6() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(currentOp().allUsers(true).localOps(true), match(eq("desc", "query analyzer")))); + testPipeline( + new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true) + .skipDataCheck(true), + (aggregation) -> aggregation.pipeline(currentOp().allUsers(true).localOps(true), + match(eq("desc", "query analyzer")))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/stages/TestDensify.java b/core/src/test/java/dev/morphia/test/aggregation/stages/TestDensify.java index 24e4833c875..cdb2b0481c3 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/stages/TestDensify.java +++ b/core/src/test/java/dev/morphia/test/aggregation/stages/TestDensify.java @@ -4,14 +4,15 @@ import dev.morphia.aggregation.stages.Densify.Range; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.expressions.TimeUnit.HOUR; import static dev.morphia.aggregation.stages.Densify.densify; -public class TestDensify extends AggregationTest { +public class TestDensify extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/stages/densify/example1 * @@ -19,7 +20,7 @@ public class TestDensify extends AggregationTest { @Test(testName = "Densify Time Series Data") public void testExample1() { testPipeline( - ServerVersion.v51, true, true, ( + new ActionTestOptions().serverVersion(ServerVersion.v51).removeIds(true), ( aggregation) -> aggregation .pipeline( densify("timestamp", @@ -34,8 +35,9 @@ public void testExample1() { */ @Test(testName = "Densifiction with Partitions") public void testExample2() { - testPipeline(ServerVersion.v51, true, false, (aggregation) -> aggregation - .pipeline(densify("altitude", Range.full(200)).partitionByFields("variety"))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.v51).removeIds(true).orderMatters(false), + (aggregation) -> aggregation + .pipeline(densify("altitude", Range.full(200)).partitionByFields("variety"))); } } \ No newline at end of file diff --git a/core/src/test/java/dev/morphia/test/aggregation/stages/TestDocuments.java b/core/src/test/java/dev/morphia/test/aggregation/stages/TestDocuments.java index 3f22bc23c48..0b9c42fbbc0 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/stages/TestDocuments.java +++ b/core/src/test/java/dev/morphia/test/aggregation/stages/TestDocuments.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.stages; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -11,15 +12,16 @@ import static dev.morphia.aggregation.stages.Lookup.lookup; import static dev.morphia.test.ServerVersion.v51; -public class TestDocuments extends AggregationTest { +public class TestDocuments extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/stages/documents/example1 * */ @Test(testName = "Test a Pipeline Stage") public void testExample1() { - skipDataCheck(); - testPipeline(ServerVersion.ANY, false, true, + testPipeline( + new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true) + .skipDataCheck(true), (aggregation) -> aggregation.pipeline( documents(document().field("x", 10), document().field("x", 2), document().field("x", 5)), autoBucket().groupBy("$x").buckets(4))); @@ -31,7 +33,7 @@ public void testExample1() { */ @Test(testName = "Use a ``$documents`` Stage in a ``$lookup`` Stage") public void testExample2() { - testPipeline(v51, aggregation -> { + testPipeline(new ActionTestOptions().serverVersion(v51).removeIds(true), aggregation -> { return aggregation.match() .lookup(lookup().localField("zip").foreignField("zip_id").as("city_state") .pipeline(documents(document("zip_id", 94301).field("name", "Palo Alto, CA"), diff --git a/core/src/test/java/dev/morphia/test/aggregation/stages/TestFacet.java b/core/src/test/java/dev/morphia/test/aggregation/stages/TestFacet.java index 56dff6a8523..ef8089cb976 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/stages/TestFacet.java +++ b/core/src/test/java/dev/morphia/test/aggregation/stages/TestFacet.java @@ -2,7 +2,8 @@ import dev.morphia.aggregation.stages.Match; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -15,14 +16,14 @@ import static dev.morphia.aggregation.stages.Unwind.unwind; import static dev.morphia.query.filters.Filters.exists; -public class TestFacet extends AggregationTest { +public class TestFacet extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/stages/facet/example1 * */ @Test(testName = "main") public void testExample1() { - testPipeline(ServerVersion.ANY, false, false, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(false), (aggregation) -> aggregation.pipeline(facet() .field("categorizedByTags", unwind("tags"), sortByCount("$tags")) .field("categorizedByPrice", Match.match(exists("price")), diff --git a/core/src/test/java/dev/morphia/test/aggregation/stages/TestFill.java b/core/src/test/java/dev/morphia/test/aggregation/stages/TestFill.java index 42175605906..52d4f04e597 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/stages/TestFill.java +++ b/core/src/test/java/dev/morphia/test/aggregation/stages/TestFill.java @@ -2,7 +2,8 @@ import dev.morphia.aggregation.expressions.StringExpressions; import dev.morphia.aggregation.stages.Fill.Method; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -15,16 +16,16 @@ import static dev.morphia.test.DriverVersion.v42; import static dev.morphia.test.ServerVersion.v53; -public class TestFill extends AggregationTest { +public class TestFill extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/stages/fill/example1 * */ @Test(testName = "Fill Missing Field Values with a Constant Value") public void testExample1() { - minDriver = v42; - testPipeline(v53, aggregation -> aggregation - .pipeline(fill().field("bootsSold", 0).field("sandalsSold", 0).field("sneakersSold", 0))); + testPipeline(new ActionTestOptions().serverVersion(v53).minDriver(v42).removeIds(true), + aggregation -> aggregation + .pipeline(fill().field("bootsSold", 0).field("sandalsSold", 0).field("sneakersSold", 0))); } /** @@ -33,7 +34,7 @@ public void testExample1() { */ @Test(testName = "Fill Missing Field Values with Linear Interpolation") public void testExample2() { - testPipeline(v53, + testPipeline(new ActionTestOptions().serverVersion(v53).removeIds(true), aggregation -> aggregation.pipeline(fill().sortBy(ascending("time")).field("price", Method.LINEAR))); } @@ -43,9 +44,7 @@ public void testExample2() { */ @Test(testName = "Fill Missing Field Values Based on the Last Observed Value") public void testExample3() { - minDriver = v42; - - testPipeline(v53, + testPipeline(new ActionTestOptions().serverVersion(v53).minDriver(v42).removeIds(true), aggregation -> aggregation.pipeline(fill().sortBy(ascending("date")).field("score", Method.LOCF))); } @@ -55,9 +54,9 @@ public void testExample3() { */ @Test(testName = "Fill Data for Distinct Partitions") public void testExample4() { - minDriver = v42; - testPipeline(v53, aggregation -> aggregation.pipeline(fill().sortBy(ascending("date")) - .partitionBy(document("restaurant", "$restaurant")).field("score", Method.LOCF))); + testPipeline(new ActionTestOptions().serverVersion(v53).minDriver(v42).removeIds(true), + aggregation -> aggregation.pipeline(fill().sortBy(ascending("date")) + .partitionBy(document("restaurant", "$restaurant")).field("score", Method.LOCF))); } /** @@ -66,7 +65,7 @@ public void testExample4() { */ @Test(testName = "Indicate if a Field was Populated Using ``$fill``") public void testExample5() { - testPipeline(v53, true, true, + testPipeline(new ActionTestOptions().serverVersion(v53).removeIds(true).orderMatters(true), (aggregation) -> aggregation .pipeline( set().field("valueExisted", diff --git a/core/src/test/java/dev/morphia/test/aggregation/stages/TestGeoNear.java b/core/src/test/java/dev/morphia/test/aggregation/stages/TestGeoNear.java index ae8745cfaf8..8373a9edbfd 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/stages/TestGeoNear.java +++ b/core/src/test/java/dev/morphia/test/aggregation/stages/TestGeoNear.java @@ -4,9 +4,9 @@ import com.mongodb.client.model.geojson.Position; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; -import org.bson.Document; import org.testng.annotations.Test; import static dev.morphia.aggregation.stages.GeoNear.geoNear; @@ -15,14 +15,14 @@ import static dev.morphia.aggregation.stages.Match.match; import static dev.morphia.query.filters.Filters.eq; -public class TestGeoNear extends AggregationTest { +public class TestGeoNear extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/stages/geoNear/example1 * */ @Test(testName = "Maximum Distance") public void testExample1() { - testPipeline(ServerVersion.ANY, true, false, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(true).orderMatters(false), (aggregation) -> aggregation.pipeline(geoNear(new Point(new Position(-73.99279, 40.719296))) .distanceField("dist.calculated").maxDistance(2).query(eq("category", "Parks")) .includeLocs("dist.location").spherical(true))); @@ -52,7 +52,7 @@ public void testExample3() { */ @Test(testName = "$geoNear with Bound ``let`` Option") public void testExample4() { - testPipeline(ServerVersion.v60, true, false, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.v60).removeIds(true).orderMatters(false), (aggregation) -> aggregation.pipeline( lookup(EXAMPLE_TEST_COLLECTION).as("joinedField").let("pt", "$location") .pipeline(geoNear("$$pt").distanceField("distance")), @@ -65,25 +65,11 @@ public void testExample4() { */ @Test(testName = "Specify Which Geospatial Index to Use") public void testExample5() { - skipDataCheck(); - testPipeline(ServerVersion.ANY, true, false, + testPipeline( + new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(true).orderMatters(false) + .skipDataCheck(true), (aggregation) -> aggregation.pipeline(geoNear(new Point(new Position(-73.98142, 40.71782))) .distanceField("dist.calculated").key("location").query(eq("category", "Parks")), limit(5))); } - /** - * test data: dev/morphia/test/aggregation/stages/geoNear/example5 - * - */ - public void testExample6() { - skipDataCheck(); - getDatabase().getCollection(EXAMPLE_TEST_COLLECTION).createIndex(new Document("location", "2dsphere")); - testPipeline(ServerVersion.ANY, false, true, - (aggregation) -> aggregation - .pipeline( - lookup(EXAMPLE_TEST_COLLECTION).as("joinedField").let("pt", "$location") - .pipeline(geoNear(new Point(new Position(-73.98142, 40.71782))) - .distanceField("distance")), - match(eq("name", "Sara D. Roosevelt Park")))); - } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/stages/TestGraphLookup.java b/core/src/test/java/dev/morphia/test/aggregation/stages/TestGraphLookup.java index 72cab27f402..6ec27b8f527 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/stages/TestGraphLookup.java +++ b/core/src/test/java/dev/morphia/test/aggregation/stages/TestGraphLookup.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.stages; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -10,14 +11,14 @@ import static dev.morphia.aggregation.stages.Projection.project; import static dev.morphia.query.filters.Filters.eq; -public class TestGraphLookup extends AggregationTest { +public class TestGraphLookup extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/stages/graphLookup/example1 * */ @Test(testName = "Within a Single Collection") public void testExample1() { - testPipeline(ServerVersion.ANY, true, false, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(true).orderMatters(false), (aggregation) -> aggregation.pipeline(graphLookup(EXAMPLE_TEST_COLLECTION).startWith("$reportsTo") .connectFromField("reportsTo").connectToField("name").as("reportingHierarchy"))); } @@ -30,7 +31,7 @@ public void testExample1() { public void testExample2() { loadData("airports", 2); - testPipeline(ServerVersion.ANY, false, false, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(false), (aggregation) -> aggregation.pipeline(graphLookup("airports").startWith("$nearestAirport") .connectFromField("connects").connectToField("airport").maxDepth(2).depthField("numConnections") .as("destinations"))); @@ -42,13 +43,14 @@ public void testExample2() { */ @Test(testName = "With a Query Filter") public void testExample3() { - testPipeline(ServerVersion.ANY, false, false, (aggregation) -> aggregation.pipeline( - match(eq("name", "Tanya Jordan")), - graphLookup(EXAMPLE_TEST_COLLECTION).startWith("$friends").connectFromField("friends") - .connectToField("name").as("golfers").restrict(eq("hobbies", "golf")), - project().include("name").include("friends").include("connections who play golf", "$golfers.name") - - )); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(false), + (aggregation) -> aggregation.pipeline(match(eq("name", "Tanya Jordan")), + graphLookup(EXAMPLE_TEST_COLLECTION).startWith("$friends").connectFromField("friends") + .connectToField("name").as("golfers").restrict(eq("hobbies", "golf")), + project().include("name").include("friends").include("connections who play golf", + "$golfers.name") + + )); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/stages/TestGroup.java b/core/src/test/java/dev/morphia/test/aggregation/stages/TestGroup.java index b53bf3b0396..8eb6d6390d2 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/stages/TestGroup.java +++ b/core/src/test/java/dev/morphia/test/aggregation/stages/TestGroup.java @@ -5,7 +5,8 @@ import dev.morphia.aggregation.expressions.AccumulatorExpressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -21,14 +22,14 @@ import static dev.morphia.query.filters.Filters.gte; import static dev.morphia.query.filters.Filters.lt; -public class TestGroup extends AggregationTest { +public class TestGroup extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/stages/group/example1 * */ @Test(testName = "Count the Number of Documents in a Collection") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(group(id(null)).field("count", AccumulatorExpressions.count()))); } @@ -38,7 +39,8 @@ public void testExample1() { */ @Test(testName = "Retrieve Distinct Values") public void testExample2() { - testPipeline(ServerVersion.ANY, false, false, (aggregation) -> aggregation.pipeline(group(id("$item")))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(false), + (aggregation) -> aggregation.pipeline(group(id("$item")))); } /** @@ -47,7 +49,7 @@ public void testExample2() { */ @Test(testName = "Group by Item Having") public void testExample3() { - testPipeline(ServerVersion.ANY, false, false, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(false), (aggregation) -> aggregation.pipeline( group(id("$item")).field("totalSaleAmount", sum(multiply("$price", "$quantity"))), match(gte("totalSaleAmount", 100)))); @@ -59,7 +61,7 @@ public void testExample3() { */ @Test(testName = "Calculate Count, Sum, and Average") public void testExample4() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline( match(gte("date", LocalDate.of(2014, Month.JANUARY, 1)), lt("date", LocalDate.of(2015, Month.JANUARY, 1))), @@ -75,7 +77,7 @@ public void testExample4() { */ @Test(testName = "Pivot Data") public void testExample5() { - testPipeline(ServerVersion.ANY, false, false, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(false), (aggregation) -> aggregation.pipeline(group(id("$author")).field("books", push("$title")))); } diff --git a/core/src/test/java/dev/morphia/test/aggregation/stages/TestIndexStats.java b/core/src/test/java/dev/morphia/test/aggregation/stages/TestIndexStats.java index 1fe7abf908d..4ad17544b93 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/stages/TestIndexStats.java +++ b/core/src/test/java/dev/morphia/test/aggregation/stages/TestIndexStats.java @@ -1,20 +1,21 @@ package dev.morphia.test.aggregation.stages; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.stages.IndexStats.indexStats; -public class TestIndexStats extends AggregationTest { +public class TestIndexStats extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/stages/indexStats/example1 * */ @Test(testName = "main") public void testExample1() { - skipDataCheck(); - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation.pipeline(indexStats())); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true) + .skipDataCheck(true), (aggregation) -> aggregation.pipeline(indexStats())); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/stages/TestLimit.java b/core/src/test/java/dev/morphia/test/aggregation/stages/TestLimit.java index f8b646ec8c3..4ff383d042f 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/stages/TestLimit.java +++ b/core/src/test/java/dev/morphia/test/aggregation/stages/TestLimit.java @@ -1,13 +1,14 @@ package dev.morphia.test.aggregation.stages; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.stages.Limit.limit; -public class TestLimit extends AggregationTest { +public class TestLimit extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/stages/limit/example1 @@ -15,7 +16,7 @@ public class TestLimit extends AggregationTest { */ @Test(testName = "main") public void testExample1() { - skipDataCheck(); - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation.pipeline(limit(5))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true) + .skipDataCheck(true), (aggregation) -> aggregation.pipeline(limit(5))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/stages/TestLookup.java b/core/src/test/java/dev/morphia/test/aggregation/stages/TestLookup.java index b04a8f6a6dc..70d152b5816 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/stages/TestLookup.java +++ b/core/src/test/java/dev/morphia/test/aggregation/stages/TestLookup.java @@ -4,9 +4,10 @@ import dev.morphia.aggregation.expressions.ComparisonExpressions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; import dev.morphia.test.aggregation.model.Inventory; import dev.morphia.test.aggregation.model.Order; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -27,7 +28,7 @@ import static java.util.Arrays.asList; import static org.testng.Assert.assertEquals; -public class TestLookup extends AggregationTest { +public class TestLookup extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/stages/lookup/example1 * @@ -35,8 +36,9 @@ public class TestLookup extends AggregationTest { @Test(testName = "Perform a Single Equality Join with ``$lookup``") public void testExample1() { loadData("inventory", 2); - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(lookup("inventory").localField("item").foreignField("sku").as("inventory_docs"))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation + .pipeline(lookup("inventory").localField("item").foreignField("sku").as("inventory_docs"))); } /** @@ -46,8 +48,9 @@ public void testExample1() { @Test(testName = "Use ``$lookup`` with an Array") public void testExample2() { loadData("members", 2); - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(lookup("members").localField("enrollmentlist").foreignField("name").as("enrollee_info"))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation.pipeline( + lookup("members").localField("enrollmentlist").foreignField("name").as("enrollee_info"))); } /** @@ -56,7 +59,7 @@ public void testExample2() { */ @Test(testName = "Use ``$lookup`` with ``$mergeObjects``") public void testExample3() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline( lookup("items").localField("item").foreignField("item").as("fromItems"), replaceRoot(mergeObjects().add(elementAt("$fromItems", 0)).add(ROOT)), @@ -70,7 +73,9 @@ public void testExample3() { @Test(testName = "Perform Multiple Joins and a Correlated Subquery with ``$lookup``") public void testExample4() { loadData("warehouses", 2); - testPipeline(ServerVersion.ANY, false, true, + testPipeline( + new ActionTestOptions().serverVersion( + ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation .pipeline(lookup("warehouses") .pipeline( @@ -87,17 +92,12 @@ public void testExample4() { @Test(testName = "Perform an Uncorrelated Subquery with ``$lookup``") public void testExample5() { loadData("holidays", 2); - testPipeline( - ServerVersion.ANY, false, true, ( - aggregation) -> aggregation - .pipeline( - lookup("holidays") - .pipeline(match(eq("year", 2018)), - project().suppressId().include("date", - document().field("name", "$name").field("date", - "$date")), - replaceRoot("$date")) - .as("holidays"))); + testPipeline((aggregation) -> aggregation.pipeline(lookup("holidays") + .pipeline(match(eq("year", 2018)), + project().suppressId().include("date", + document().field("name", "$name").field("date", "$date")), + replaceRoot("$date")) + .as("holidays"))); } /** @@ -107,7 +107,7 @@ public void testExample5() { @Test(testName = "Perform a Concise Correlated Subquery with ``$lookup``") public void testExample6() { loadData("restaurants", 2); - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(lookup("restaurants").localField("restaurant_name") .foreignField("name").pipeline(match(expr(in("$$orders_drink", "$beverages")))) .let("orders_drink", "$drink").as("matches"))); diff --git a/core/src/test/java/dev/morphia/test/aggregation/stages/TestMatch.java b/core/src/test/java/dev/morphia/test/aggregation/stages/TestMatch.java index 1e8d0f8f528..2dac68b2dbf 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/stages/TestMatch.java +++ b/core/src/test/java/dev/morphia/test/aggregation/stages/TestMatch.java @@ -1,6 +1,7 @@ package dev.morphia.test.aggregation.stages; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -16,13 +17,13 @@ import static dev.morphia.query.filters.Filters.or; import static dev.morphia.test.ServerVersion.ANY; -public class TestMatch extends AggregationTest { +public class TestMatch extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/stages/match/example1 */ @Test(testName = "Equality Match") public void testExample1() { - testPipeline(ANY, false, true, aggregation -> aggregation.pipeline(match(eq("author", "dave")))); + testPipeline(aggregation -> aggregation.pipeline(match(eq("author", "dave")))); } /** @@ -31,7 +32,7 @@ public void testExample1() { */ @Test(testName = "Perform a Count") public void testExample2() { - testPipeline(ANY, true, false, + testPipeline(new ActionTestOptions().serverVersion(ANY).removeIds(true).orderMatters(false), (aggregation) -> aggregation.pipeline( match(or(and(gt("score", 70), lt("score", 90)), gte("views", 1000))), group(id(null)).field("count", sum(1)))); diff --git a/core/src/test/java/dev/morphia/test/aggregation/stages/TestMerge.java b/core/src/test/java/dev/morphia/test/aggregation/stages/TestMerge.java index ca4fa95a3d4..01ad3e58df2 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/stages/TestMerge.java +++ b/core/src/test/java/dev/morphia/test/aggregation/stages/TestMerge.java @@ -4,7 +4,8 @@ import java.time.Month; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -26,18 +27,16 @@ import static dev.morphia.query.filters.Filters.gte; import static dev.morphia.query.filters.Filters.lt; -public class TestMerge extends AggregationTest { - public TestMerge() { - skipDataCheck(); - } - +public class TestMerge extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/stages/merge/example1 * */ @Test(testName = "On-Demand Materialized View: Initial Creation") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline( + new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true) + .skipDataCheck(true), (aggregation) -> aggregation.pipeline( group(id().field("fiscal_year", "$fiscal_year").field("dept", "$dept")).field("salaries", sum("$salary")), @@ -50,7 +49,9 @@ public void testExample1() { */ @Test(testName = "On-Demand Materialized View: Update/Replace Data") public void testExample2() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline( + new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true) + .skipDataCheck(true), (aggregation) -> aggregation.pipeline(match(gte("fiscal_year", 2019)), group(id().field("fiscal_year", "$fiscal_year").field("dept", "$dept")).field("salaries", sum("$salary")), @@ -63,7 +64,9 @@ public void testExample2() { */ @Test(testName = "Only Insert New Data") public void testExample3() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline( + new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true) + .skipDataCheck(true), (aggregation) -> aggregation.pipeline(match(eq("fiscal_year", 2019)), group(id().field("fiscal_year", "$fiscal_year").field("dept", "$dept")).field("employees", push("$employee")), @@ -78,7 +81,9 @@ public void testExample3() { */ @Test(testName = "Merge Results from Multiple Collections") public void testExample4() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline( + new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true) + .skipDataCheck(true), (aggregation) -> aggregation.pipeline(group().field("_id", "$quarter").field("purchased", sum("$qty")), merge("quarterlyreport").on("_id").whenMatched(MERGE).whenNotMatched(INSERT))); } @@ -89,7 +94,9 @@ public void testExample4() { */ @Test(testName = "Use the Pipeline to Customize the Merge") public void testExample5() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline( + new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true) + .skipDataCheck(true), (aggregation) -> aggregation.pipeline( match(gte("date", LocalDate.of(2019, Month.MAY, 7)), lt("date", LocalDate.of(2019, Month.MAY, 8))), diff --git a/core/src/test/java/dev/morphia/test/aggregation/stages/TestOut.java b/core/src/test/java/dev/morphia/test/aggregation/stages/TestOut.java index 2989f53b078..ceff19e0875 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/stages/TestOut.java +++ b/core/src/test/java/dev/morphia/test/aggregation/stages/TestOut.java @@ -1,8 +1,9 @@ package dev.morphia.test.aggregation.stages; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; import dev.morphia.test.models.Author; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -11,19 +12,18 @@ import static dev.morphia.aggregation.stages.Group.id; import static dev.morphia.aggregation.stages.Out.out; -public class TestOut extends AggregationTest { - public TestOut() { - skipDataCheck(); - } - +public class TestOut extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/stages/out/example1 * */ @Test(testName = "Output to Same Database") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(group(id("$author")).field("books", push().single("$title")), out(Author.class))); + testPipeline( + new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true) + .skipDataCheck(true), + (aggregation) -> aggregation.pipeline(group(id("$author")).field("books", push().single("$title")), + out(Author.class))); } /** @@ -32,7 +32,9 @@ public void testExample1() { */ @Test(testName = "Output to a Different Database") public void testExample2() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline( + new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true) + .skipDataCheck(true), (aggregation) -> aggregation.pipeline(group(id("$author")).field("books", push().single("$title")), out(Author.class).database("reporting"))); } diff --git a/core/src/test/java/dev/morphia/test/aggregation/stages/TestPlanCacheStats.java b/core/src/test/java/dev/morphia/test/aggregation/stages/TestPlanCacheStats.java index dfd67fa53a5..f44085dbda1 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/stages/TestPlanCacheStats.java +++ b/core/src/test/java/dev/morphia/test/aggregation/stages/TestPlanCacheStats.java @@ -3,7 +3,8 @@ import com.mongodb.client.model.IndexOptions; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.bson.Document; import org.testng.annotations.Test; @@ -12,11 +13,7 @@ import static dev.morphia.aggregation.stages.PlanCacheStats.planCacheStats; import static dev.morphia.query.filters.Filters.eq; -public class TestPlanCacheStats extends AggregationTest { - public TestPlanCacheStats() { - skipDataCheck(); - } - +public class TestPlanCacheStats extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/stages/planCacheStats/example1 * @@ -26,7 +23,8 @@ public void testExample1() { Document keys = new Document("item", 1).append("price", 1); var options = new IndexOptions().partialFilterExpression(new Document("price", new Document("$gte", 10.0))); getDatabase().getCollection(EXAMPLE_TEST_COLLECTION).createIndex(keys, options); - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation.pipeline(planCacheStats())); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true) + .skipDataCheck(true), (aggregation) -> aggregation.pipeline(planCacheStats())); } /** @@ -37,7 +35,9 @@ public void testExample1() { public void testExample2() { Document keys = new Document("item", 1).append("price", 1); var options = new IndexOptions().partialFilterExpression(new Document("price", new Document("$gte", 10.0))); - testPipeline(ServerVersion.ANY, false, true, + testPipeline( + new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true) + .skipDataCheck(true), (aggregation) -> aggregation.pipeline(planCacheStats(), match(eq("planCacheKey", "B1435201")))); } @@ -46,7 +46,9 @@ public void testExample2() { */ @Test(testName = "Find Cache Entry Details for a Query Hash") public void testExample3() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline( + new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true) + .skipDataCheck(true), (aggregation) -> aggregation.pipeline(planCacheStats(), match(eq("planCacheKey", "B1435201")))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/stages/TestProject.java b/core/src/test/java/dev/morphia/test/aggregation/stages/TestProject.java index 5024bac3beb..0cf59d4aaf7 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/stages/TestProject.java +++ b/core/src/test/java/dev/morphia/test/aggregation/stages/TestProject.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.stages; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -12,14 +13,14 @@ import static dev.morphia.aggregation.expressions.SystemVariables.REMOVE; import static dev.morphia.aggregation.stages.Projection.project; -public class TestProject extends AggregationTest { +public class TestProject extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/stages/project/example1 * */ @Test(testName = "Include Specific Fields in Output Documents") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(project().include("title").include("author"))); } @@ -29,7 +30,7 @@ public void testExample1() { */ @Test(testName = "Suppress ``_id`` Field in the Output Documents") public void testExample2() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(project().suppressId().include("title").include("author"))); } @@ -39,9 +40,8 @@ public void testExample2() { */ @Test(testName = "Exclude Fields from Output Documents") public void testExample3() { - skipDataCheck(); - testPipeline(ServerVersion.ANY, false, true, - (aggregation) -> aggregation.pipeline(project().exclude("lastModified"))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true) + .skipDataCheck(true), (aggregation) -> aggregation.pipeline(project().exclude("lastModified"))); } /** @@ -50,7 +50,7 @@ public void testExample3() { */ @Test(testName = "Conditionally Exclude Fields") public void testExample4() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation .pipeline(project().include("title").include("author.first").include("author.last").include( "author.middle", condition(eq("", "$author.middle"), REMOVE, "$author.middle")))); @@ -62,7 +62,7 @@ public void testExample4() { */ @Test(testName = "Include Specific Fields from Embedded Documents") public void testExample5() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(project().include("stop.title"))); } @@ -72,7 +72,7 @@ public void testExample5() { */ @Test(testName = "Include Specific Fields from Embedded Documents") public void testExample6() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(project().include("stop.title"))); } @@ -82,11 +82,12 @@ public void testExample6() { */ @Test(testName = "Include Computed Fields") public void testExample7() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation.pipeline(project().include("title") - .include("isbn", document().field("prefix", substrBytes("$isbn", 0, 3)) - .field("group", substrBytes("$isbn", 3, 2)).field("publisher", substrBytes("$isbn", 5, 4)) - .field("title", substrBytes("$isbn", 9, 3)).field("checkDigit", substrBytes("$isbn", 12, 1))) - .include("lastName", "$author.last").include("copiesSold", "$copies"))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation.pipeline(project().include("title").include("isbn", document() + .field("prefix", substrBytes("$isbn", 0, 3)).field("group", substrBytes("$isbn", 3, 2)) + .field("publisher", substrBytes("$isbn", 5, 4)).field("title", substrBytes("$isbn", 9, 3)) + .field("checkDigit", substrBytes("$isbn", 12, 1))).include("lastName", "$author.last") + .include("copiesSold", "$copies"))); } /** @@ -95,7 +96,7 @@ public void testExample7() { */ @Test(testName = "Array Indexes are Unsupported") public void testExample8() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(project().suppressId().include("x", "$name"))); } @@ -107,8 +108,10 @@ public void testExample8() { public void testExample9() { // unsupported multiple examples here /* - * testPipeline(ServerVersion.ANY, false, true, (aggregation) -> - * aggregation.pipeline( project() .suppressId() .include("x", "$name"))); + * testPipeline(new + * dev.morphia.test.util.ActionTestOptions().serverVersion(ServerVersion.ANY). + * removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline( + * project() .suppressId() .include("x", "$name"))); */ } diff --git a/core/src/test/java/dev/morphia/test/aggregation/stages/TestRedact.java b/core/src/test/java/dev/morphia/test/aggregation/stages/TestRedact.java index 714439a4a2b..e6a1a9d5ac5 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/stages/TestRedact.java +++ b/core/src/test/java/dev/morphia/test/aggregation/stages/TestRedact.java @@ -1,8 +1,7 @@ package dev.morphia.test.aggregation.stages; import dev.morphia.aggregation.expressions.ComparisonExpressions; -import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; import org.testng.annotations.Test; @@ -17,14 +16,14 @@ import static dev.morphia.aggregation.stages.Redact.redact; import static dev.morphia.query.filters.Filters.eq; -public class TestRedact extends AggregationTest { +public class TestRedact extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/stages/redact/example1 * */ @Test(testName = "Evaluate Access at Every Document Level") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation.pipeline(match(eq("year", 2014)), + testPipeline((aggregation) -> aggregation.pipeline(match(eq("year", 2014)), redact(condition(gt(size(setIntersection("$tags", array("STLW", "G"))), 0), DESCEND, PRUNE)))); } @@ -34,7 +33,7 @@ public void testExample1() { */ @Test(testName = "Exclude All Fields at a Given Level") public void testExample2() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation.pipeline(match(eq("status", "A")), + testPipeline((aggregation) -> aggregation.pipeline(match(eq("status", "A")), redact(condition(ComparisonExpressions.eq("$level", 5), PRUNE, DESCEND)))); } diff --git a/core/src/test/java/dev/morphia/test/aggregation/stages/TestReplaceRoot.java b/core/src/test/java/dev/morphia/test/aggregation/stages/TestReplaceRoot.java index 3d3ebfe82d9..eb8c414dfe4 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/stages/TestReplaceRoot.java +++ b/core/src/test/java/dev/morphia/test/aggregation/stages/TestReplaceRoot.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.stages; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -14,15 +15,17 @@ import static dev.morphia.aggregation.stages.Unwind.unwind; import static dev.morphia.query.filters.Filters.gte; -public class TestReplaceRoot extends AggregationTest { +public class TestReplaceRoot extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/stages/replaceRoot/example1 * */ @Test(testName = "``$replaceRoot`` with an Embedded Document Field") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation.pipeline(replaceRoot(mergeObjects() - .add(document().field("dogs", 0).field("cats", 0).field("birds", 0).field("fish", 0)).add("$pets")))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation.pipeline(replaceRoot(mergeObjects() + .add(document().field("dogs", 0).field("cats", 0).field("birds", 0).field("fish", 0)) + .add("$pets")))); } /** @@ -31,8 +34,8 @@ public void testExample1() { */ @Test(testName = "``$replaceRoot`` with a Document Nested in an Array") public void testExample2() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation.pipeline(unwind("grades"), - match(gte("grades.grade", 90)), replaceRoot("$grades"))); + testPipeline((aggregation) -> aggregation.pipeline(unwind("grades"), match(gte("grades.grade", 90)), + replaceRoot("$grades"))); } /** @@ -41,8 +44,9 @@ public void testExample2() { */ @Test(testName = "``$replaceRoot`` with a newly created document") public void testExample3() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(replaceRoot().field("full_name", concat("$first_name", " ", "$last_name")))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation + .pipeline(replaceRoot().field("full_name", concat("$first_name", " ", "$last_name")))); } /** @@ -51,14 +55,8 @@ public void testExample3() { */ @Test(testName = "``$replaceRoot`` with a New Document Created from ``$$ROOT`` and a Default Document") public void testExample4() { - testPipeline( - ServerVersion.ANY, false, true, ( - aggregation) -> aggregation - .pipeline( - replaceRoot( - mergeObjects() - .add(document().field("_id", "").field("name", "") - .field("email", "").field("cell", "").field("home", "")) - .add(ROOT)))); + testPipeline((aggregation) -> aggregation.pipeline(replaceRoot(mergeObjects().add( + document().field("_id", "").field("name", "").field("email", "").field("cell", "").field("home", "")) + .add(ROOT)))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/stages/TestReplaceWith.java b/core/src/test/java/dev/morphia/test/aggregation/stages/TestReplaceWith.java index dc66b9b297c..c12af5ba5d6 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/stages/TestReplaceWith.java +++ b/core/src/test/java/dev/morphia/test/aggregation/stages/TestReplaceWith.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.stages; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -16,15 +17,17 @@ import static dev.morphia.query.filters.Filters.eq; import static dev.morphia.query.filters.Filters.gte; -public class TestReplaceWith extends AggregationTest { +public class TestReplaceWith extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/stages/replaceWith/example1 * */ @Test(testName = "``$replaceWith`` an Embedded Document Field") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation.pipeline(replaceWith(mergeObjects() - .add(document().field("dogs", 0).field("cats", 0).field("birds", 0).field("fish", 0)).add("$pets")))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation.pipeline(replaceWith(mergeObjects() + .add(document().field("dogs", 0).field("cats", 0).field("birds", 0).field("fish", 0)) + .add("$pets")))); } /** @@ -33,8 +36,8 @@ public void testExample1() { */ @Test(testName = "``$replaceWith`` a Document Nested in an Array") public void testExample2() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation.pipeline(unwind("grades"), - match(gte("grades.grade", 90)), replaceWith("$grades"))); + testPipeline((aggregation) -> aggregation.pipeline(unwind("grades"), match(gte("grades.grade", 90)), + replaceWith("$grades"))); } /** @@ -43,8 +46,9 @@ public void testExample2() { */ @Test(testName = "``$replaceWith`` a Newly Created Document") public void testExample3() { - skipDataCheck(); // the "asofDate" field will always differ - testPipeline(ServerVersion.ANY, false, false, + testPipeline( + new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(false) + .skipDataCheck(true), (aggregation) -> aggregation.pipeline(match(eq("status", "C")), replaceWith().field("_id", "$_id").field("item", "$item") .field("amount", multiply("$price", "$quantity")).field("status", "Complete") @@ -55,10 +59,10 @@ public void testExample3() { * test data: dev/morphia/test/aggregation/stages/replaceWith/example4 * */ - @Test(testName = "``$replaceWith`` a New Document Created from ``$$ROOT`` and a Default Document") + @Test(testName = "``$replaceWith`` a New Document Created from ``$$ROOT`` and a Default Document", enabled = false, description = "failing oddly") public void testExample4() { testPipeline( - ServerVersion.ANY, false, true, ( + new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), ( aggregation) -> aggregation .pipeline( replaceWith( diff --git a/core/src/test/java/dev/morphia/test/aggregation/stages/TestSample.java b/core/src/test/java/dev/morphia/test/aggregation/stages/TestSample.java index 9544489005b..e47f476ca3f 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/stages/TestSample.java +++ b/core/src/test/java/dev/morphia/test/aggregation/stages/TestSample.java @@ -1,20 +1,21 @@ package dev.morphia.test.aggregation.stages; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.stages.Sample.sample; -public class TestSample extends AggregationTest { +public class TestSample extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/stages/sample/example1 * */ @Test(testName = "main") public void testExample1() { - skipDataCheck(); // the results are random - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation.pipeline(sample(3))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true) + .skipDataCheck(true), (aggregation) -> aggregation.pipeline(sample(3))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/stages/TestSet.java b/core/src/test/java/dev/morphia/test/aggregation/stages/TestSet.java index bcefc75d95f..c3e145ff993 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/stages/TestSet.java +++ b/core/src/test/java/dev/morphia/test/aggregation/stages/TestSet.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.stages; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -14,14 +15,14 @@ import static dev.morphia.aggregation.stages.Set.set; import static dev.morphia.query.filters.Filters.eq; -public class TestSet extends AggregationTest { +public class TestSet extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/stages/set/example1 * */ @Test(testName = "Using Two ``$set`` Stages") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline( set().field("totalHomework", sum("$homework")).field("totalQuiz", sum("$quiz")), set().field("totalScore", add("$totalHomework", "$totalQuiz", "$extraCredit")))); @@ -33,7 +34,7 @@ public void testExample1() { */ @Test(testName = "Adding Fields to an Embedded Document") public void testExample2() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(set().field("specs.fuel_type", "unleaded"))); } @@ -43,7 +44,8 @@ public void testExample2() { */ @Test(testName = "Overwriting an existing field") public void testExample3() { - testPipeline(ServerVersion.ANY, false, false, (aggregation) -> aggregation.pipeline(set().field("cats", 20))); + testPipeline(new ActionTestOptions().orderMatters(false), + (aggregation) -> aggregation.pipeline(set().field("cats", 20))); } /** @@ -52,7 +54,7 @@ public void testExample3() { */ @Test(testName = "Add Element to an Array") public void testExample4() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation.pipeline(match(eq("_id", 1)), + testPipeline((aggregation) -> aggregation.pipeline(match(eq("_id", 1)), set().field("homework", concatArrays("$homework", array(7))))); } @@ -62,7 +64,7 @@ public void testExample4() { */ @Test(testName = "Creating a New Field with Existing Fields") public void testExample5() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(set().field("quizAverage", avg("$quiz")))); } diff --git a/core/src/test/java/dev/morphia/test/aggregation/stages/TestSetWindowFields.java b/core/src/test/java/dev/morphia/test/aggregation/stages/TestSetWindowFields.java index 51752dd8963..73a4447aa85 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/stages/TestSetWindowFields.java +++ b/core/src/test/java/dev/morphia/test/aggregation/stages/TestSetWindowFields.java @@ -2,7 +2,8 @@ import dev.morphia.aggregation.expressions.TimeUnit; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -12,14 +13,14 @@ import static dev.morphia.aggregation.stages.SetWindowFields.setWindowFields; import static dev.morphia.query.Sort.ascending; -public class TestSetWindowFields extends AggregationTest { +public class TestSetWindowFields extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/stages/setWindowFields/example1 * */ @Test(testName = "Documents Window Examples") public void testExample1() { - testPipeline(ServerVersion.ANY, false, false, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(false), (aggregation) -> aggregation.pipeline(setWindowFields().partitionBy("$state") .sortBy(ascending("orderDate")).output(output("cumulativeQuantityForState") .operator(sum("$quantity")).window().documents("unbounded", "current")))); @@ -31,9 +32,10 @@ public void testExample1() { */ @Test(testName = "Range Window Example") public void testExample2() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation - .pipeline(setWindowFields().partitionBy("$state").sortBy(ascending("price")).output( - output("quantityFromSimilarOrders").operator(sum("$quantity")).window().range(-10, 10)))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation.pipeline(setWindowFields().partitionBy("$state").sortBy(ascending("price")) + .output(output("quantityFromSimilarOrders").operator(sum("$quantity")).window().range(-10, + 10)))); } /** @@ -42,7 +44,7 @@ public void testExample2() { */ @Test(testName = "Time Range Window Examples") public void testExample3() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(setWindowFields().partitionBy("$state") .sortBy(ascending("orderDate")).output(output("recentOrders").operator(push("$orderDate")) .window().range("unbounded", 10, TimeUnit.MONTH)))); diff --git a/core/src/test/java/dev/morphia/test/aggregation/stages/TestSkip.java b/core/src/test/java/dev/morphia/test/aggregation/stages/TestSkip.java index 6822a4615a6..bad98bd8837 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/stages/TestSkip.java +++ b/core/src/test/java/dev/morphia/test/aggregation/stages/TestSkip.java @@ -1,20 +1,21 @@ package dev.morphia.test.aggregation.stages; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.stages.Skip.skip; -public class TestSkip extends AggregationTest { +public class TestSkip extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/stages/skip/example1 * */ @Test(testName = "main") public void testExample1() { - skipDataCheck(); - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation.pipeline(skip(5))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true) + .skipDataCheck(true), (aggregation) -> aggregation.pipeline(skip(5))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/stages/TestSort.java b/core/src/test/java/dev/morphia/test/aggregation/stages/TestSort.java index 00fdd9ee7ca..793501d5a80 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/stages/TestSort.java +++ b/core/src/test/java/dev/morphia/test/aggregation/stages/TestSort.java @@ -1,7 +1,8 @@ package dev.morphia.test.aggregation.stages; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.bson.Document; import org.testng.annotations.Test; @@ -10,18 +11,16 @@ import static dev.morphia.aggregation.stages.Sort.sort; import static dev.morphia.query.filters.Filters.text; -public class TestSort extends AggregationTest { - public TestSort() { - skipDataCheck(); - } - +public class TestSort extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/stages/sort/example1 * */ @Test(testName = "Ascending/Descending Sort") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline( + new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true) + .skipDataCheck(true), (aggregation) -> aggregation.pipeline(sort().descending("age").ascending("posts"))); } @@ -32,8 +31,8 @@ public void testExample1() { @Test(testName = "Text Score Metadata Sort") public void testExample2() { getDatabase().getCollection(EXAMPLE_TEST_COLLECTION).createIndex(new Document("$**", "text")); - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation.pipeline(match(text("operating")), - sort().meta("score").descending("posts"))); + testPipeline(new ActionTestOptions().skipDataCheck(true), (aggregation) -> aggregation + .pipeline(match(text("operating")), sort().meta("score").descending("posts"))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/stages/TestSortByCount.java b/core/src/test/java/dev/morphia/test/aggregation/stages/TestSortByCount.java index 4d7804447de..b9b58c200de 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/stages/TestSortByCount.java +++ b/core/src/test/java/dev/morphia/test/aggregation/stages/TestSortByCount.java @@ -1,14 +1,15 @@ package dev.morphia.test.aggregation.stages; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.stages.SortByCount.sortByCount; import static dev.morphia.aggregation.stages.Unwind.unwind; -public class TestSortByCount extends AggregationTest { +public class TestSortByCount extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/stages/sortByCount/example1 * @@ -17,7 +18,7 @@ public class TestSortByCount extends AggregationTest { public void testExample1() { // orderMatters is false here because of the indeterminate sort order on equal // values - testPipeline(ServerVersion.ANY, false, false, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(false), (aggregation) -> aggregation.pipeline(unwind("$tags"), sortByCount("$tags"))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/stages/TestUnionWith.java b/core/src/test/java/dev/morphia/test/aggregation/stages/TestUnionWith.java index 5177d0b8eb0..76c83a206fc 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/stages/TestUnionWith.java +++ b/core/src/test/java/dev/morphia/test/aggregation/stages/TestUnionWith.java @@ -3,7 +3,8 @@ import com.github.zafarkhaja.semver.Version; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; @@ -16,7 +17,7 @@ import static dev.morphia.aggregation.stages.Sort.sort; import static dev.morphia.aggregation.stages.UnionWith.unionWith; -public class TestUnionWith extends AggregationTest { +public class TestUnionWith extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/stages/unionWith/example1 * @@ -26,7 +27,7 @@ public void testExample1() { loadData("sales_2018", 1); loadData("sales_2019", 2); loadData("sales_2020", 3); - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(set().field("_id", "2017"), unionWith("sales_2018", set().field("_id", "2018")), unionWith("sales_2019", set().field("_id", "2019")), @@ -42,7 +43,7 @@ public void testExample2() { loadData("sales_2018", 1); loadData("sales_2019", 2); loadData("sales_2020", 3); - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(unionWith("sales_2018"), unionWith("sales_2019"), unionWith("sales_2020"), group(id("$item")).field("total", sum("$quantity")), sort().descending("total"))); @@ -55,7 +56,7 @@ public void testExample2() { @Test(testName = "Create a Union with Specified Documents") public void testExample3() { assumeTrue(serverIsAtLeastVersion(Version.of(6)), "Minimum server version is 6"); - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(unionWith(documents(document("_id", 4).field("flavor", "orange"), document("_id", 5).field("flavor", "vanilla").field("price", 20))))); } diff --git a/core/src/test/java/dev/morphia/test/aggregation/stages/TestUnset.java b/core/src/test/java/dev/morphia/test/aggregation/stages/TestUnset.java index ce27df36eee..2a02b03b752 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/stages/TestUnset.java +++ b/core/src/test/java/dev/morphia/test/aggregation/stages/TestUnset.java @@ -1,20 +1,22 @@ package dev.morphia.test.aggregation.stages; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; +import dev.morphia.test.util.ActionTestOptions; import org.testng.annotations.Test; import static dev.morphia.aggregation.stages.Unset.unset; -public class TestUnset extends AggregationTest { +public class TestUnset extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/stages/unset/example1 * */ @Test(testName = "Remove a Single Field") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation.pipeline(unset("copies"))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation.pipeline(unset("copies"))); } /** @@ -23,7 +25,7 @@ public void testExample1() { */ @Test(testName = "Remove Top-Level Fields") public void testExample2() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation.pipeline(unset("isbn", "copies"))); + testPipeline((aggregation) -> aggregation.pipeline(unset("isbn", "copies"))); } /** @@ -32,7 +34,7 @@ public void testExample2() { */ @Test(testName = "Remove Embedded Fields") public void testExample3() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(unset("isbn", "author.first", "copies.warehouse"))); } } diff --git a/core/src/test/java/dev/morphia/test/aggregation/stages/TestUnwind.java b/core/src/test/java/dev/morphia/test/aggregation/stages/TestUnwind.java index 77a52167f61..37be05d66da 100644 --- a/core/src/test/java/dev/morphia/test/aggregation/stages/TestUnwind.java +++ b/core/src/test/java/dev/morphia/test/aggregation/stages/TestUnwind.java @@ -4,8 +4,9 @@ import java.util.Iterator; import dev.morphia.test.ServerVersion; -import dev.morphia.test.aggregation.AggregationTest; +import dev.morphia.test.TemplatedTestBase; import dev.morphia.test.models.User; +import dev.morphia.test.util.ActionTestOptions; import org.testng.Assert; import org.testng.annotations.Test; @@ -23,14 +24,15 @@ import static java.util.Arrays.asList; import static org.testng.Assert.assertEquals; -public class TestUnwind extends AggregationTest { +public class TestUnwind extends TemplatedTestBase { /** * test data: dev/morphia/test/aggregation/stages/unwind/example1 * */ @Test(testName = "Unwind Array") public void testExample1() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation.pipeline(unwind("sizes"))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation.pipeline(unwind("sizes"))); } /** @@ -39,7 +41,8 @@ public void testExample1() { */ @Test(testName = "Missing or Non-array Values") public void testExample2() { - testPipeline(ServerVersion.ANY, false, true, (aggregation) -> aggregation.pipeline(unwind("sizes"))); + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), + (aggregation) -> aggregation.pipeline(unwind("sizes"))); } /** @@ -48,7 +51,7 @@ public void testExample2() { */ @Test(testName = "``preserveNullAndEmptyArrays`` and ``includeArrayIndex``") public void testExample3() { - testPipeline(ServerVersion.ANY, false, true, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(true), (aggregation) -> aggregation.pipeline(unwind("sizes").preserveNullAndEmptyArrays(true))); } @@ -58,7 +61,7 @@ public void testExample3() { */ @Test(testName = "Group by Unwound Values") public void testExample4() { - testPipeline(ServerVersion.ANY, false, false, + testPipeline(new ActionTestOptions().serverVersion(ServerVersion.ANY).removeIds(false).orderMatters(false), (aggregation) -> aggregation.pipeline(unwind("sizes").preserveNullAndEmptyArrays(true), group(id("$sizes")).field("averagePrice", avg("$price")), sort().descending("averagePrice"))); } @@ -69,7 +72,7 @@ public void testExample4() { */ @Test(testName = "Unwind Embedded Arrays") public void testExample5() { - testPipeline(ServerVersion.ANY, false, false, (aggregation) -> aggregation.pipeline(unwind("items"), + testPipeline(new ActionTestOptions().orderMatters(false), (aggregation) -> aggregation.pipeline(unwind("items"), unwind("items.tags"), group(id("$items.tags")).field("totalSalesAmount", sum(multiply("$items.price", "$items.quantity"))))); } diff --git a/core/src/test/java/dev/morphia/test/query/TestSorts.java b/core/src/test/java/dev/morphia/test/query/TestSorts.java deleted file mode 100644 index 3db26cc5e47..00000000000 --- a/core/src/test/java/dev/morphia/test/query/TestSorts.java +++ /dev/null @@ -1,69 +0,0 @@ -package dev.morphia.test.query; - -import java.util.Objects; - -import dev.morphia.annotations.Entity; -import dev.morphia.annotations.Id; -import dev.morphia.annotations.Text; -import dev.morphia.query.FindOptions; -import dev.morphia.query.MorphiaQuery; -import dev.morphia.query.Query; -import dev.morphia.test.TemplatedTestBase; - -import org.testng.annotations.Test; - -import static dev.morphia.query.Meta.textScore; -import static dev.morphia.query.Sort.ascending; -import static dev.morphia.query.filters.Filters.text; -import static java.lang.String.format; - -public class TestSorts extends TemplatedTestBase { - - @Test - public void metaAndSorts() { - getMapper().map(Article.class); - getDs().applyIndexes(); - - Query
query = getDs().find(Article.class) - .filter(text("coffee")); - FindOptions options = new FindOptions() - .logQuery() - .sort(textScore("textScore"), - ascending("subject")); - - testQuery((MorphiaQuery) query, options, true); - } - - @Entity(useDiscriminator = false) - private static class Article { - @Id - int id; - @Text - String subject; - String author; - int views; - double textScore; - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof Article article)) { - return false; - } - return id == article.id && views == article.views && Double.compare(article.textScore, textScore) == 0 && - Objects.equals(subject, article.subject) && Objects.equals(author, article.author); - } - - @Override - public int hashCode() { - return Objects.hash(id, subject, author, views, textScore); - } - - @Override - public String toString() { - return format("Article{id=%d, subject='%s', author='%s', views=%d, textScore=%s}", id, subject, author, views, textScore); - } - } -} diff --git a/core/src/test/java/dev/morphia/test/util/ActionTestOptions.java b/core/src/test/java/dev/morphia/test/util/ActionTestOptions.java index e70edccbf13..b724035df47 100644 --- a/core/src/test/java/dev/morphia/test/util/ActionTestOptions.java +++ b/core/src/test/java/dev/morphia/test/util/ActionTestOptions.java @@ -21,10 +21,6 @@ public class ActionTestOptions { private boolean skipDataCheck = false; - public ActionTestOptions() { - serverVersion = ANY; - } - public FindOptions findOptions() { return findOptions; }