use of edu.umass.cs.gnsclient.client.util.GuidEntry in project GNS by MobilityFirst.
the class HttpClientTest method test_999_Cleanup.
/**
*
*/
@Test
public void test_999_Cleanup() {
try {
httpClient.guidRemove(masterGuid, httpOneEntry.getGuid());
httpClient.guidRemove(masterGuid, httpTwoEntry.getGuid());
httpClient.guidRemove(masterGuid, mygroupEntry.getGuid());
for (GuidEntry guid : createdGuids) {
httpClient.guidRemove(masterGuid, guid.getGuid());
}
createdGuids.clear();
} catch (ClientException | IOException e) {
Utils.failWithStackTrace("Exception while removing guids: " + e);
}
}
use of edu.umass.cs.gnsclient.client.util.GuidEntry in project GNS by MobilityFirst.
the class SelectAutoGroupTest method test_552_QuerySetupGuids.
/**
*
*/
@Test
public void test_552_QuerySetupGuids() {
try {
for (int cnt = 0; cnt < 5; cnt++) {
GuidEntry testEntry = clientCommands.guidCreate(masterGuid, "queryTest-" + RandomString.randomString(12));
createdGuids.add(testEntry);
JSONArray array = new JSONArray(Arrays.asList(Integer.parseInt(TEST_HIGH_VALUE)));
clientCommands.fieldReplaceOrCreateList(testEntry, groupTestFieldName, array);
}
for (int cnt = 0; cnt < 5; cnt++) {
GuidEntry testEntry = clientCommands.guidCreate(masterGuid, "queryTest-" + RandomString.randomString(12));
createdGuids.add(testEntry);
JSONArray array = new JSONArray(Arrays.asList(Integer.parseInt(TEST_LOW_VALUE)));
clientCommands.fieldReplaceOrCreateList(testEntry, groupTestFieldName, array);
}
} catch (ClientException | IOException | NumberFormatException e) {
Utils.failWithStackTrace("Exception while trying to create the guids: " + e);
}
try {
// the HRN is a hash of the query
String groupOneGuidName = Base64.encodeToString(SHA1HashFunction.getInstance().hash(queryOne), false);
groupOneGuid = clientCommands.guidCreate(masterGuid, groupOneGuidName);
} catch (ClientException | IOException e) {
Utils.failWithStackTrace("Exception while trying to create the guids: " + e);
}
try {
// the HRN is a hash of the query
String groupTwoGuidName = Base64.encodeToString(SHA1HashFunction.getInstance().hash(queryTwo), false);
groupTwoGuid = clientCommands.guidCreate(masterGuid, groupTwoGuidName);
} catch (ClientException | IOException e) {
Utils.failWithStackTrace("Exception while trying to create the guids: " + e);
}
}
use of edu.umass.cs.gnsclient.client.util.GuidEntry in project GNS by MobilityFirst.
the class SelectAutoGroupTest method test_561_QueryLookupSecondGroup.
/**
*
*/
@Test
public // Check to see if the second group has members now... it should.
void test_561_QueryLookupSecondGroup() {
try {
JSONArray result = clientCommands.selectLookupGroupQuery(groupTwoGuid.getGuid());
// should be 4 now
Assert.assertThat(result.length(), Matchers.equalTo(4));
// 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("0", value);
}
} catch (ClientException | IOException | JSONException e) {
Utils.failWithStackTrace("Exception executing selectLookupGroupQuery: " + e);
}
}
use of edu.umass.cs.gnsclient.client.util.GuidEntry in project GNS by MobilityFirst.
the class SelectAutoGroupTest method test_562_QueryLookupSelectCleanup.
/**
*
*/
@Test
public void test_562_QueryLookupSelectCleanup() {
try {
clientCommands.guidRemove(masterGuid, groupOneGuid.getGuid());
clientCommands.guidRemove(masterGuid, groupTwoGuid.getGuid());
for (GuidEntry guid : createdGuids) {
clientCommands.guidRemove(masterGuid, guid.getGuid());
}
createdGuids.clear();
} catch (ClientException | IOException e) {
Utils.failWithStackTrace("Exception during cleanup: " + e);
}
}
use of edu.umass.cs.gnsclient.client.util.GuidEntry in project GNS by MobilityFirst.
the class SelectAutoGroupTest method checkSelectTheReturnValues.
private void checkSelectTheReturnValues(JSONArray result) throws Exception {
// should be 5
Assert.assertThat(result.length(), Matchers.equalTo(5));
// 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);
}
}
Aggregations