use of edu.umass.cs.gnscommon.exceptions.client.ClientException 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.gnscommon.exceptions.client.ClientException in project GNS by MobilityFirst.
the class HttpClientTest method test_935_ReadMid.
/**
*
*/
@Test
public void test_935_ReadMid() {
try {
String actual = httpClient.fieldRead(httpOneEntry.getGuid(), "flapjack.sally", httpOneEntry);
String expected = "{ \"left\" : \"eight\" , \"right\" : \"seven\"}";
//System.out.println("expected:" + expected);
//System.out.println("actual:" + actual);
JSONAssert.assertEquals(expected, actual, JSONCompareMode.NON_EXTENSIBLE);
} catch (IOException | ClientException | JSONException e) {
Utils.failWithStackTrace("Exception while reading \"flapjack.sally\": ", e);
}
}
use of edu.umass.cs.gnscommon.exceptions.client.ClientException in project GNS by MobilityFirst.
the class HttpClientTest method test_933_ReadAll.
/**
*
*/
@Test
public void test_933_ReadAll() {
try {
JSONObject expected = new JSONObject();
JSONObject subJson = new JSONObject();
subJson.put("sammy", "green");
JSONObject subsubJson = new JSONObject();
subsubJson.put("right", "seven");
subsubJson.put("left", "eight");
subJson.put("sally", subsubJson);
expected.put("flapjack", subJson);
expected.put("environment", "work");
expected.put("ssn", "000-00-0000");
expected.put("password", "666flapJack");
expected.put("address", "100 Hinkledinkle Drive");
JSONObject actual = httpClient.read(httpOneEntry);
JSONAssert.assertEquals(expected, actual, JSONCompareMode.NON_EXTENSIBLE);
//System.out.println(actual);
} catch (JSONException | IOException | ClientException e) {
Utils.failWithStackTrace("Exception while reading JSON: ", e);
}
}
use of edu.umass.cs.gnscommon.exceptions.client.ClientException 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.gnscommon.exceptions.client.ClientException 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);
}
}
Aggregations