use of edu.umass.cs.gnsserver.utils.ValuesMap in project GNS by MobilityFirst.
the class NoSQLTest method test_01_Insert.
/**
*
*/
@Test
public void test_01_Insert() {
JSONObject json = new JSONObject();
try {
json.put(field, "some value");
} catch (JSONException e) {
fail("Problem creating json " + e);
}
ValuesMap valuesMap = new ValuesMap(json);
NameRecord nameRecord = new NameRecord(recordMap, guid, valuesMap);
try {
instance.insert(collection, guid, nameRecord.toJSONObject());
} catch (FailedDBOperationException | JSONException | RecordExistsException e) {
fail("Problem during insert " + e);
}
}
use of edu.umass.cs.gnsserver.utils.ValuesMap in project GNS by MobilityFirst.
the class NoSQLTest method test_04_LookupSomeFields.
/**
*
*/
@Test
public void test_04_LookupSomeFields() {
Map<ColumnField, Object> expected = new HashMap<>();
expected.put(NameRecord.NAME, guid);
JSONObject json = new JSONObject();
try {
json.put(field, "some value");
} catch (JSONException e) {
fail("Problem creating json: " + e);
}
expected.put(NameRecord.VALUES_MAP, new ValuesMap(json));
try {
Map<ColumnField, Object> actual = instance.lookupSomeFields(collection, guid, NameRecord.NAME, NameRecord.VALUES_MAP, new ArrayList<>(Arrays.asList(new ColumnField(field, ColumnFieldType.USER_JSON))));
assertEquals(expected.get(NameRecord.NAME), actual.get(NameRecord.NAME));
JSONAssert.assertEquals(((JSONObject) expected.get(NameRecord.VALUES_MAP)), ((JSONObject) actual.get(NameRecord.VALUES_MAP)), JSONCompareMode.STRICT);
} catch (RecordNotFoundException | FailedDBOperationException | JSONException e) {
fail("Problem during LookupSomeFields: " + e);
}
}
use of edu.umass.cs.gnsserver.utils.ValuesMap in project GNS by MobilityFirst.
the class NoSQLTest method test_22_LookupEntireRecordGuid2.
/**
*
*/
@Test
public void test_22_LookupEntireRecordGuid2() {
JSONObject json = new JSONObject();
try {
JSONObject innerJson = new JSONObject();
innerJson.put("key", "value");
json.put("map", innerJson);
} catch (JSONException e) {
fail("Problem creating json " + e);
}
ValuesMap valuesMap = new ValuesMap(json);
JSONObject expected = new JSONObject();
try {
expected.put(NameRecord.NAME.getName(), guid2);
expected.put(NameRecord.VALUES_MAP.getName(), valuesMap);
} catch (JSONException e) {
fail("Problem creating json expected value: " + e);
}
try {
JSONAssert.assertEquals(expected, instance.lookupEntireRecord(collection, guid2), JSONCompareMode.STRICT);
} catch (RecordNotFoundException | FailedDBOperationException | JSONException e) {
fail("Problem during LookupEntireRecord: " + e);
}
}
use of edu.umass.cs.gnsserver.utils.ValuesMap in project GNS by MobilityFirst.
the class NoSQLTest method test_20_InsertRecord.
/**
*
*/
@Test
public void test_20_InsertRecord() {
JSONObject json = new JSONObject();
try {
json.put(field, "some value");
} catch (JSONException e) {
fail("Problem creating json " + e);
}
ValuesMap valuesMap = new ValuesMap(json);
NameRecord nameRecord = new NameRecord(recordMap, guid2, valuesMap);
try {
instance.insert(collection, guid2, nameRecord.toJSONObject());
} catch (FailedDBOperationException | JSONException | RecordExistsException e) {
fail("Problem during insert " + e);
}
}
use of edu.umass.cs.gnsserver.utils.ValuesMap in project GNS by MobilityFirst.
the class NoSQLTest method test_24_LookupEntireRecordGuid2Again.
/**
*
*/
@Test
public void test_24_LookupEntireRecordGuid2Again() {
JSONObject json = new JSONObject();
try {
JSONObject innerJson = new JSONObject();
innerJson.put("key", "value");
json.put("map", innerJson);
json.put("new", "newValue");
} catch (JSONException e) {
fail("Problem creating json " + e);
}
ValuesMap valuesMap = new ValuesMap(json);
JSONObject expected = new JSONObject();
try {
expected.put(NameRecord.NAME.getName(), guid2);
expected.put(NameRecord.VALUES_MAP.getName(), valuesMap);
} catch (JSONException e) {
fail("Problem creating json expected value: " + e);
}
try {
JSONAssert.assertEquals(expected, instance.lookupEntireRecord(collection, guid2), JSONCompareMode.STRICT);
} catch (RecordNotFoundException | FailedDBOperationException | JSONException e) {
fail("Problem during LookupEntireRecord: " + e);
}
}
Aggregations