Giter Site home page Giter Site logo

mongounit / mongounit Goto Github PK

View Code? Open in Web Editor NEW
24.0 24.0 6.0 23.06 MB

MongoUnit is a data driven integration testing framework for Spring Boot based applications that use MongoDB for persistence. The framework enables the developer to test the data access logic with relative ease.

Home Page: https://mongoUnit.org

License: Apache License 2.0

Java 100.00%
integration integration-testing mongodb spring spring-boot testing

mongounit's Introduction

mongoUnit logo

What is this framework?

mongoUnit is a data driven Integration testing framework for Spring Boot based applications that use MongoDB for persistence. The framework enables the developer to test the data access logic with relative ease.

You can see the complete documentation on how to use this framework at mongoUnit.org

Issues?

If you find a bug or think that a feature might be really useful to your team, please look through current issues, and if you don't find yours, create a new one.

mongounit's People

Contributors

ychaikin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

mongounit's Issues

mongounit generates wrong mongo uri when run inside jenkins docker agent

when integration tests are run inside docker agent in jenkins following exception is thrown:

Caused by: java.lang.IllegalArgumentException: The connection string contains an invalid option '_2022_05_10_10_04_19_234526705'. '_2022_05_10_10_04_19_234526705' is missing the value delimiter eg '_2022_05_10_10_04_19_234526705=value'
	at com.mongodb.ConnectionString.parseOptions(ConnectionString.java:889) ~[mongodb-driver-core-4.4.2.jar:na]

The exception is caused by incorrect uri generated:

o.m.config.MongoUnitConfigurationUtil    : Using test database with URI: 'mongodb://172.17.0.1:49854/test_?_2022_05_10_10_04_19_234526705'

The issue here is that System.getProperty("user.name") produces ? when username is not specified in OS. The offending line is at

String newDbName = baseUriDbName + "_" + System.getProperty("user.name") + "_" + dateTimePad

How this happens:

  • when tests are executed inside docker container spawned by jenkins, jenkins passes --user parameter with user id and group id of jenkins user in host. The user id of course does not exist in /etc/passwd file in the container, that's why there is no username associated with passed user id

How to reproduce it:

  • docker run --rm --user 2345 alpine:3.15.4 id
  • docker run --rm alpine:3.15.4 id
  • run System.getProperty("user.name") inside jshell
    • docker run -it --rm openjdk:11.0.14.1-jdk-slim-bullseye
    • docker run -it --rm --user 2345 openjdk:11.0.14.1-jdk-slim-bullseye

$$DATE_TIME using local timezone instead of UTC

I have a json seed with a datetime field "$$DATE_TIME": "2021-08-03T03:25:27.138Z", And my local timezone is UTC+8. After the json had been inserted to Mongo, The datetime turned to be 2021-08-02T19:25:27.138+00:00.

From the code snippet I found that mongounit doesn't set the timezone for SimpleDateFormatter and the formatter doesn't respect the Z suffix. It uses my local timezone to parse the date string:

SimpleDateFormat format = new SimpleDateFormat(DATE_STRING_FORMAT);

The debug screenshort with value evaluation is listed below(CST stands for UTC+8):

image

Provide toggle to ignore collections in assertion

I have a integration test which would manipulate 2 collections: A and B, but in order to run the test, I need to prepare collection C and D as fixture. But once the test is completed, I only need to verify collection A and B which I could write a json for asserting like :

[
  {
    "collectionName": "A",
    "documents": [...]
  },
  {
    "collectionName": "B",
    "documents": [...]
  }
]

But MongoUnit compares actual collections and expected collections and fail the test:

 Expected 2 collections, but found 4

Could MongoUnit provide some configuraitons to ignore additional collections and only match the collections which i have put in the test

Error comparing "null" values.

Hi!

When the attribute of a document is null the comparison fails with the message "Expected field name 'nameOfTheField' to be present".
The expected data is defined like this:

"nameOfTheField": { "$$NULL": "null" },

It has been checked that the mongoDb collection contains the document with:
nameOfTheField: null

Regards

Error saving a Date before 1970.

Hi!

Saving a data set with dates before 1970, the dates are not saved correctly.
With the dataset:

{
...
...
    "fieldDatePrev1970" : {
      "$$DATE_TIME" : "1900-04-06T04:25:65.000Z"
    },
...
...
}

The stored value is
fieldDatePrev1970: 1900-04-06T04:40:49.000+00:00

As you can see the time is not the same 04:25:65.000 <> 04:40:49.000.

Testing with a new data set with dates before 1970 but with a time 00:00:00, the dates are stored correctly:

{
...
...
    "fieldDatePrev1970" : {
      "$$DATE_TIME" : "1900-04-06T00:00:00.000Z"
    },
...
...
}

The stored value is
fieldDatePrev1970: 1900-04-06T00:00:00.000+00:00

Bye!!

MongoUnit Doesn't recreate index after drop all database before each test

I have annotate some of my Mongo entites with @Index(unique=true) and I write some tests to verify the confliction when insert multiple documents with same field that has unique index.

But seems that mongo unit has dropped all collections with index definitions and the collections created later doesn't have any index exception _id field. The source reference:

MongoUnitUtil.dropAllCollectionsInDatabase(mongoDatabase);

Unique index of collection is part of my business logics, It's nice to support index after collection recreation

error if system.profile has to be dropped

Hello,

if we are using mongounit to unit test our code on our deployed mongodb-cluster and mongounit is dropping collections before each test there occures an error while dropping system.profile collection.

In our case profiling is enabled.

Is there any config availabe to ignore dropping system.profile collection in created database? This would be helpful in our case because we are only able to activate profiling for all servers or directly on mongod instance and there isnt any possibility to activate or deactivate profiling for temporary created database(while mongounit runs).

Thank you very much,

Greetings
Philipp Allstadt

Wrong date offset from "expected" file

Hi,
I made an Integration Test with mongounit. In my "expected" file I have date field start with date value "$$DATE_TIME": "2021-02-15T10:00:00.000Z".
When I run this test on my local environment there is an error Field name 'start': Expected '1613379600000' but got '1613383200000'.

1613383200000 is 2021-02-15T10:00:00.000Z which is what I expect. It seems like mongounit converts date from expected file to my local timezone.

Is there a way to configure this? I have added property mongounit.local-time-zone-id=UTC but it changes nothing.

Thanks

Any plans to support JDK 8?

I get the following error when trying to compile this with JDK 8:

class file has wrong version 55.0, should be 52.0

Some quick research seems to indicate that this means mongounit was compiled with JDK 11

Error comparing DB_POINTER attributes

Hi!

When the expected value is a DB_POINTER, MongoUnit fails loading the dataset.

Expected data:
"fieldDbPointer": { "$$DB_POINTER": { "namespace": "categories", "objectId": "5db7545b7b615c739732c773" }}

Error:
org.bson.BsonInvalidOperationException: Value expected to be of type OBJECT_ID is of unexpected type DB_POINTER

at org.bson.BsonValue.throwIfInvalidType(BsonValue.java:419)
at org.bson.BsonValue.asObjectId(BsonValue.java:150)
at org.mongounit.MongoUnitUtil.getFieldValue(MongoUnitUtil.java:493)
at org.mongounit.MongoUnitUtil.getDocument(MongoUnitUtil.java:331)

Bye!!

Spring boot >= 2.3.0 - MongoDbFactory deprecated

I'm in the process of migrating from lordofthejars/nosqlunit to this library (thank you, btw!) and I'm having issues updating to the latest Spring Boot version.

The interface MongoDbFactory is now deprecated in replace of its superclass MongoDatabaseFactory.
This change was made in org.springframework.data:spring-data-mongodb:3.0.

The error stack trace is -
No qualifying bean of type 'org.springframework.data.mongodb.MongoDbFactory' available org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.data.mongodb.MongoDbFactory' available at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:351) at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:342) at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1127) at org.mongounit.MongoUnitExtension.beforeAll(MongoUnitExtension.java:94) at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeBeforeAllCallbacks$7(ClassBasedTestDescriptor.java:359) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.invokeBeforeAllCallbacks(ClassBasedTestDescriptor.java:359) at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.before(ClassBasedTestDescriptor.java:189) at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.before(ClassBasedTestDescriptor.java:78) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:132) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80) at java.base/java.util.ArrayList.forEach(ArrayList.java:1541) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32) at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57) at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:248) at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$5(DefaultLauncher.java:211) at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:226) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:199) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:132) at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.processAllTestClasses(JUnitPlatformTestClassProcessor.java:99) at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.access$000(JUnitPlatformTestClassProcessor.java:79) at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor.stop(JUnitPlatformTestClassProcessor.java:75) at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.stop(SuiteTestClassProcessor.java:61) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33) at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94) at com.sun.proxy.$Proxy5.stop(Unknown Source) at org.gradle.api.internal.tasks.testing.worker.TestWorker.stop(TestWorker.java:133) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:182) at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:164) at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:414) at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64) at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56) at java.base/java.lang.Thread.run(Thread.java:834)

Nested and multiple @SeedWithDataset doesnt clear dataSets correctly

Hi, I have a problem when I uses multiple @SeedWithDataset. On the class and methods.
Different @SeedWithDataset adding data to the same collection. Inserting data to database is ok, but I think it's a bug with deleting data based on seed annotations.

Reproduce:

  1. Add common users data @SeedWithDataset annotation on the class.
  2. Add extra users data @SeedWithDataset on the method add extra data to the same collection
  3. Add the same extra data in another method. Error occured. Id with this record exists!

All of data seed must have identification!

Enable package location type as the default for dataset locations in annotations

Consider @MongoUnitTest annotation to be used to rename the deepest directory which is the name of the class (by default) to something more meaningful to the user.

Only use mongounit directory search for dataset files with classpath root location type.

This includes processing annotations and manual MongoUnit methods.

Provide ability to output snapshot dataset by placing annotation on test method

Not sure what to call that annotation yet, but something like @SnapshotAfterExecution would probably do.

It should output a snapshot of what's in the database and place it into the default location of where dataset snapshots go for that test method. If one already exists there, it should append -1, -2, etc. to the file name.

Probably same thing needs to be done for @SnapshotBeforeExecution to have a dataset file that puts all of the composable @SeedWithDataset annotations into 1 file for developer inspection.

Both snapshot annotations should have options similar to @SeedWithDataset so output snapshot files can be placed where @SeedWithDataset is allowed to look for them.

The snapshot functionality should also be made available through manual execution (instead of annotation) through the MongoUnit class.

Text Indexes are not created

Hi,
I have noticed that collections created by mongounit don't have text indexes.
Is there a way to force mongounit to create text indexes on collections for fields annotated with @TextIndex?

Thanks :)

Errors when using '$$INT64' Bson type in Seeding or Assertion.

An error occurs whenever '$$INT64' is used as a BSON type, when seeding or using AssertMatches in database. It seems to be that it is treating every number as an integer, when it should be a long.

I am assuming I am using the correct syntax in the json file:
"playerId": { "$$INT64": 17745 }

Full error message received when seeding is posted below.

Failed to treat value '987597' of type 'java.lang.Integer' as the provided bsonType 'INT64'. at org.mongounit.MongoUnitUtil.toDatabase(MongoUnitUtil.java:162) at org.mongounit.MongoUnitExtension.beforeEach(MongoUnitExtension.java:154) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeBeforeEachCallbacks$1(TestMethodTestDescriptor.java:151) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeBeforeMethodsOrCallbacksUntilExceptionOccurs$5(TestMethodTestDescriptor.java:187) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeBeforeMethodsOrCallbacksUntilExceptionOccurs(TestMethodTestDescriptor.java:187) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeBeforeEachCallbacks(TestMethodTestDescriptor.java:150) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:129) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:69) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:135) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80) at java.base/java.util.ArrayList.forEach(ArrayList.java:1541) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80) at java.base/java.util.ArrayList.forEach(ArrayList.java:1541) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32) at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57) at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:248) at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$5(DefaultLauncher.java:211) at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:226) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:199) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:132) at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.processAllTestClasses(JUnitPlatformTestClassProcessor.java:99) at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.access$000(JUnitPlatformTestClassProcessor.java:79) at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor.stop(JUnitPlatformTestClassProcessor.java:75) at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.stop(SuiteTestClassProcessor.java:61) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33) at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94) at com.sun.proxy.$Proxy5.stop(Unknown Source) at org.gradle.api.internal.tasks.testing.worker.TestWorker.stop(TestWorker.java:133) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:182) at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:164) at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:414) at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64) at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56) at java.base/java.lang.Thread.run(Thread.java:834)

Allow deprecated `ZoneId` short IDs to be used

The SHORT_IDS are deprecated. So, when specifying mongounit.local-time-zone-id=ZONE_ID, the short IDs can't be used.

This is important when taking the user-specified ZoneID and converting it to Java. This happens in MongoUnitConfigurationUtil.generateNewMongoClientURI method.

Instead of ZoneId.of(string) method, use ZoneId.of(string, map) method. That would allow support for short IDs like EST, PST, etc.

support for mongodb test containers

please consider adding support for mongodb test containers (https://www.testcontainers.org/modules/databases/mongodb/).
At the moment mongounit expects mongounit.base-uri to be provided upfront, which is only to be known at runtime in case of test containers.
Please take a look at examples how spring.data.mongodb.uri is configured at runtime for spring boot

I briefly looked through the source code, and I think this could be achieved by not substituting MongoDatabaseFactory in MongoDatabaseGuardConfiguration and use spring.data.mongodb.uri as is

Dataset Generator Utility: Error exporting double "Infinity"

Hi!

An infinite double value is not exported correctly:

Executing the command:
java -jar mongounit-2.0.0-jar-with-dependencies.jar -dbUri=mongodb://mongoroot:s3cretp4ss@localhost:27017/items?authSource=admin -output=db_expec.json

In file db_expect.json is generate a value like this:

{
  ...
  ...
 "fieldInfinity" : "Infinity",
  ...
  ...
}

So, when the file is used to assert the database, the attribute will be treated like a String, not a Double.

The export process must generate a value like this one:

{
  ...
  ...
  "fieldInfinity" : {"$$DOUBLE": "Infinity" },
  ...
  ...
}

Bye!!

Dataset Generator Utility: Error exporting long

Hi!

An long value that is assignable to an integer is not exported correctly:

Executing the command:
java -jar mongounit-2.0.0-jar-with-dependencies.jar -dbUri=mongodb://mongoroot:s3cretp4ss@localhost:27017/items?authSource=admin -output=db_expec.json

In file db_expect.json is generate a value like this:

{
  ...
  ...
 "fieldShortLong" : 87236,
  ...
  ...
}

So, when the file is used to assert the database, the attribute will be treated like an Integer, not a Long.

The export process must generate a value like this one:

{
  ...
  ...
  "fieldShortLong": { "$$INT64": "87236" },
  ...
  ...
}

Bye!!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.