Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ public Map<String, Object> DataObjectRemoteDataMap_get(String _oid) {
**/
public void DataObjectRemoteDataMap_update(String _oid, Map<String, Object> fullMap,
Set<String> updateKeys) {


// Configure this to be an "upsert" query
FindOneAndUpdateOptions opt = new FindOneAndUpdateOptions();
Expand All @@ -236,7 +237,9 @@ public void DataObjectRemoteDataMap_update(String _oid, Map<String, Object> full
Document unset_doc = new Document();

// Lets iterate the keys, and decide accordingly
Set<String> fullKeys = fullMap.keySet();
Set<String> fullKeys = new HashSet<String>(fullMap.keySet());
fullKeys.addAll(updateKeys);

for (String key : fullKeys) {
// Get the value
Object value = fullMap.get(key);
Expand Down Expand Up @@ -268,8 +271,10 @@ public void DataObjectRemoteDataMap_update(String _oid, Map<String, Object> full
if (updateKeys.contains(key)) {
// Handle NULL values unset
if (value == null || value == ObjectToken.NULL) {

unset_doc.append(key, "");
continue;

}

// Handle values update
Expand All @@ -285,6 +290,7 @@ public void DataObjectRemoteDataMap_update(String _oid, Map<String, Object> full
setOnInsert_doc.append(key, value);
}
}


// Generate the "update" doc
Document updateDoc = new Document();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ public void constructorTest() {
// Subset assertion
//-----------------------------------------------

/// Utility function, to ensure the expected values exists in map
/// while allowing future test cases not to break when additional values
/// like create timestamp is added.
// Utility function, to ensure the expected values exists in map
// while allowing future test cases not to break when additional values
// like create timestamp is added.
public void assetSubset(Map<String, Object> expected, Map<String, Object> result) {
for (Map.Entry<String, Object> entry : expected.entrySet()) {
assertEquals(entry.getValue(), result.get(entry.getKey()));
Expand All @@ -86,10 +86,9 @@ protected HashMap<String, Object> randomObjMap() {
}

// @Test
// public void invalidSetup() { //Numeric as table prefix tend to cuase
// problems
// public void invalidSetup() {
// //Numeric as table prefix tend to cause problems
// DataObjectMap m;
//
// try {
// m = new DataObjectMap(JStackObj, "1" + TestConfig.randomTablePrefix());
// fail(); // if we got here, no exception was thrown, which is bad
Expand Down Expand Up @@ -139,7 +138,7 @@ public void basicTest() {
assetSubset(objMap, mtObj.get(guid));
}

/// Checks if a blank object gets saved
// Checks if a blank object gets saved
@Test
public void blankObjectSave() {
String guid = null;
Expand Down Expand Up @@ -607,9 +606,65 @@ public void getKeyNamesTest() {
// }

// remove meta object support
//-----------------------------------------------
// -----------------------------------------------
@Test
public void removePropertyViaDataObject_saveDelta() {

// Lets just rescycle old test for some dummy data
basicTest();

// Lets get DataObject list
DataObject[] oRes = null;
assertNotNull(oRes = mtObj.query(null, null));
assertTrue(oRes.length > 0);

// Lets get the first object
DataObject testObject = oRes[0];
String oid = testObject._oid();

testObject.remove("num");
testObject.remove("str_val");
testObject.saveDelta();

// Get the object again
DataObject changedObject = mtObj.get(oid);
assertNotNull( changedObject );

// Check the respective value is null
assertNull( changedObject.get("num") );
assertNull( changedObject.get("str_val") );
}

@Test
public void removePropertyViaDataObject_saveAll() {

// Lets just rescycle old test for some dummy data
basicTest();

// Lets get DataObject list
DataObject[] oRes = null;
assertNotNull(oRes = mtObj.query(null, null));
assertTrue(oRes.length > 0);

// Lets get the first object
DataObject testObject = oRes[0];
String oid = testObject._oid();

testObject.remove("num");
testObject.remove("str_val");
testObject.saveAll();

// Get the object again
DataObject changedObject = mtObj.get(oid);
assertNotNull( changedObject );

// Check the respective value is null
assertNull( changedObject.get("num") );
assertNull( changedObject.get("str_val") );
}

@Test
public void removeViaDataObject() {
public void removeViaMetaOID() {

// Lets just rescycle old test for some dummy data
basicTest();
Expand All @@ -620,7 +675,7 @@ public void removeViaDataObject() {
assertTrue(oRes.length > 0);

// Lets remove one object
mtObj.remove(oRes[0]);
mtObj.remove(oRes[0]._oid());

// Lets query to make sure its removed
DataObject[] qRes = null;
Expand All @@ -629,7 +684,7 @@ public void removeViaDataObject() {
}

@Test
public void removeViaMetaOID() {
public void removePropertyForMetaObject() {

// Lets just rescycle old test for some dummy data
basicTest();
Expand All @@ -640,7 +695,7 @@ public void removeViaMetaOID() {
assertTrue(oRes.length > 0);

// Lets remove one object
mtObj.remove(oRes[0]._oid());
mtObj.remove(oRes[0]);

// Lets query to make sure its removed
DataObject[] qRes = null;
Expand Down