-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to insert ISODate in MongoDB #50
Comments
Hello, well there is a problem with this kind of data, but is not related to NoSQLUnit but java mongodb driver, if you look next issue JIRA it talks about similar problem but in queries. I think that should work with insertion too. Moreover in stackoverflow it is explained that ISODate is simply a helper class that wraps a Javascript date object. I will write a unit test about this to validate all this information I have provided, and depending on results I will close the issue or fix the problem. But as you noted in description it seems more a problem with json file than NoSQLUnit. Thank you very much for using NoSQLUnit, for any question , problem, ... do not hesitate to contact me. |
Thanks for your post. Actually, using explanation provided in JIRA issue, I succeed to insert date. The final file is: It seems to me you can close this issue without trouble but I prefer to let you do so. |
Good, thank you very much, I will update documentation by providing an example for ISODates. |
I have a simple structure with a date as field. Naively, I thought I can do something like this:
{
"todo":[
{
"_class":"experiments.entity.Todo",
"_id":1,
"completed":false,
"content":"test",
"order":1,
"title":"title",
"username":"username",
"lastUpdate":ISODate("2013-02-07T01:15:01.090Z")
}
]
}
But I get an exception when parsing:
Caused by: com.mongodb.util.JSONParseException:
{ "todo":[ { "_class":"experiments.entity.Todo", "_id":1, "completed":false, "content":"test", "order":1, "title":"title", "username":"username", "lastUpdate":ISODate("2013-02-07T01:15:01.090Z") } ]}
at com.mongodb.util.JSONParser.parse(JSON.java:198)
at com.mongodb.util.JSONParser.parseObject(JSON.java:231)
at com.mongodb.util.JSONParser.parse(JSON.java:195)
at com.mongodb.util.JSONParser.parseArray(JSON.java:539)
at com.mongodb.util.JSONParser.parse(JSON.java:191)
at com.mongodb.util.JSONParser.parseObject(JSON.java:231)
at com.mongodb.util.JSONParser.parse(JSON.java:195)
at com.mongodb.util.JSONParser.parse(JSON.java:145)
at com.mongodb.util.JSON.parse(JSON.java:81)
at com.mongodb.util.JSON.parse(JSON.java:66)
at com.lordofthejars.nosqlunit.mongodb.DefaultInsertionStrategy.parseData(DefaultInsertionStrategy.java:34)
I guess it's because my file is not compliant with json format. So, my question is how to insert date in unit test using nosql-unit?
The text was updated successfully, but these errors were encountered: