Class MongoFlexibleComparisonStrategy
- java.lang.Object
-
- com.lordofthejars.nosqlunit.mongodb.MongoFlexibleComparisonStrategy
-
- All Implemented Interfaces:
com.lordofthejars.nosqlunit.core.ComparisonStrategy<MongoDbConnectionCallback>
,MongoComparisonStrategy
public class MongoFlexibleComparisonStrategy extends java.lang.Object implements MongoComparisonStrategy
Comparison strategy that checks that all the expected data exists in the Mongo database. It doesn't compare that all the data stored in the database is included in the expected file, so other data not defined in the expected resource could exist in Mongo. It just assure that the expected data exists.Checks the following assertions:
-
Checks that all the expected collections are present in Mongo DB, but accepts
other collections stored in the database that are not defined in the expected
file.
-
Checks that all the expected objects are present in Mongo DB, but accepts
other objects stored in the same collections that are not defined as expected.
-
For each object checks that all properties set to be ignored its value
exist in the object stored in the database, but it accepts any saved value.
-
collection.property : When are defined both collection and property name
the exclusion will only affect to the indicated collection.
e.g: With @IgnorePropertyValue(properties = {"book.date"}), the property date
will be ignored in each object of the 'book' collection. If other objects in
different collections have the property 'date' it won't be ignored.
-
property : When only is defined the property name it will be excluded
from all objects in any expected collection.
e.g: With @IgnorePropertyValue(properties = {"date"}), the property 'date'
will be ignored in each object, no matter the collection.
- Author:
- Víctor Hernández
-
-
Constructor Summary
Constructors Constructor Description MongoFlexibleComparisonStrategy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
compare(MongoDbConnectionCallback connection, java.io.InputStream dataset)
void
setIgnoreProperties(java.lang.String[] ignorePropertyValues)
-
-
-
Method Detail
-
compare
public boolean compare(MongoDbConnectionCallback connection, java.io.InputStream dataset) throws java.io.IOException
- Specified by:
compare
in interfacecom.lordofthejars.nosqlunit.core.ComparisonStrategy<MongoDbConnectionCallback>
- Throws:
java.io.IOException
-
setIgnoreProperties
public void setIgnoreProperties(java.lang.String[] ignorePropertyValues)
- Specified by:
setIgnoreProperties
in interfacecom.lordofthejars.nosqlunit.core.ComparisonStrategy<MongoDbConnectionCallback>
-
-