use of edu.umass.cs.gnsclient.client.util.BasicGuidEntry in project GNS by MobilityFirst.
the class SelectAutoGroupTest method test_559_QueryAlterGroup.
/**
*
*/
@Test
public // Change all the testQuery fields except 1 to be equal to zero
void test_559_QueryAlterGroup() {
try {
JSONArray result = clientCommands.selectLookupGroupQuery(groupOneGuid.getGuid());
// change ALL BUT ONE to be ZERO
for (int i = 0; i < result.length() - 1; i++) {
BasicGuidEntry guidInfo = new BasicGuidEntry(clientCommands.lookupGuidRecord(result.getString(i)));
GuidEntry entry = GuidUtils.lookupGuidEntryFromDatabase(clientCommands, guidInfo.getEntityName());
JSONArray array = new JSONArray(Arrays.asList(0));
clientCommands.fieldReplaceOrCreateList(entry, groupTestFieldName, array);
}
} catch (ClientException | IOException | JSONException e) {
Utils.failWithStackTrace("Exception while trying to alter the fields: " + e);
}
}
use of edu.umass.cs.gnsclient.client.util.BasicGuidEntry in project GNS by MobilityFirst.
the class SelectAutoGroupTest method test_560_QueryLookupGroupAfterAlterations.
/**
*
*/
@Test
public void test_560_QueryLookupGroupAfterAlterations() {
try {
JSONArray result = clientCommands.selectLookupGroupQuery(groupOneGuid.getGuid());
// should only be one
Assert.assertThat(result.length(), Matchers.equalTo(1));
// look up the individual values
for (int i = 0; i < result.length(); i++) {
BasicGuidEntry guidInfo = new BasicGuidEntry(clientCommands.lookupGuidRecord(result.getString(i)));
GuidEntry entry = GuidUtils.lookupGuidEntryFromDatabase(clientCommands, guidInfo.getEntityName());
String value = clientCommands.fieldReadArrayFirstElement(entry, groupTestFieldName);
Assert.assertEquals(TEST_HIGH_VALUE, value);
}
} catch (ClientException | IOException | JSONException e) {
Utils.failWithStackTrace("Exception executing selectLookupGroupQuery: " + e);
}
}
use of edu.umass.cs.gnsclient.client.util.BasicGuidEntry in project GNS by MobilityFirst.
the class SelectAutoGroupTest method test_551_QueryRemovePreviousTestFields.
/**
*
*/
@Test
public void test_551_QueryRemovePreviousTestFields() {
// find all the guids that have our field and remove it from them
try {
String query = "~" + groupTestFieldName + " : {$exists: true}";
JSONArray result = clientCommands.selectQuery(query);
for (int i = 0; i < result.length(); i++) {
BasicGuidEntry guidInfo = new BasicGuidEntry(clientCommands.lookupGuidRecord(result.getString(i)));
GuidEntry guidEntry = GuidUtils.lookupGuidEntryFromDatabase(clientCommands, guidInfo.getEntityName());
System.out.println("Removing from " + guidEntry.getEntityName());
clientCommands.fieldRemove(guidEntry, groupTestFieldName);
}
} catch (ClientException | IOException | JSONException e) {
Utils.failWithStackTrace("Trying to remove previous test's fields: " + e);
}
}
Aggregations