use of org.apache.geode.management.internal.cli.json.GfJsonObject in project geode by apache.
the class TypedJsonJUnitTest method checkResult.
public void checkResult(TypedJson tjson) {
GfJsonObject gfJsonObj;
try {
gfJsonObj = new GfJsonObject(tjson.toString());
System.out.println(gfJsonObj);
assertNotNull(gfJsonObj.get(RESULT));
} catch (GfJsonException e) {
fail("Result could not be found");
}
}
use of org.apache.geode.management.internal.cli.json.GfJsonObject in project geode by apache.
the class DataCommandFunctionWithPDXJUnitTest method testTableIsRectangular.
// GEODE-2662: building a table where early values are missing keys causes the data to shift
// upward during reporting.
@Test
public void testTableIsRectangular() throws GfJsonException {
TabularResultData rawTable = getTableFromQuery("select * from /" + PARTITIONED_REGION);
// Verify any table built
assertThat(rawTable.getGfJsonObject()).isNotNull();
assertThat(rawTable.getGfJsonObject().getJSONObject("content")).isNotNull();
GfJsonObject tableJson = rawTable.getGfJsonObject().getJSONObject("content");
// Verify table is rectangular
SoftAssertions softly = new SoftAssertions();
for (String k : new String[] { "id", "phone", "firstName", "lastName" }) {
softly.assertThat(tableJson.getJSONArray(k).size()).isEqualTo(4);
}
softly.assertAll();
}
use of org.apache.geode.management.internal.cli.json.GfJsonObject in project geode by apache.
the class DataCommandFunctionWithPDXJUnitTest method testFilteredQueryWithPhone.
@Test
public void testFilteredQueryWithPhone() throws Exception {
TabularResultData rawTable = getTableFromQuery("select * from /" + PARTITIONED_REGION + " c where IS_DEFINED ( c.phone ) order by id");
assertThat(rawTable.getGfJsonObject()).isNotNull();
assertThat(rawTable.getGfJsonObject().getJSONObject("content")).isNotNull();
GfJsonObject tableJson = rawTable.getGfJsonObject().getJSONObject("content");
for (String k : new String[] { "id", "phone", "firstName", "lastName" }) {
assertThat(tableJson.getJSONArray(k).size()).isEqualTo(2);
}
assertThatRowIsBuiltCorrectly(tableJson, 0, charlie);
assertThatRowIsBuiltCorrectly(tableJson, 1, dan);
}
use of org.apache.geode.management.internal.cli.json.GfJsonObject in project geode by apache.
the class LocatorStateTest method createStatusJson.
private String createStatusJson() {
final Map<String, Object> map = new HashMap<String, Object>();
map.put(ServiceState.JSON_CLASSPATH, getClasspath());
map.put(ServiceState.JSON_GEMFIREVERSION, getGemFireVersion());
map.put(ServiceState.JSON_HOST, getHost());
map.put(ServiceState.JSON_JAVAVERSION, getJavaVersion());
map.put(ServiceState.JSON_JVMARGUMENTS, getJvmArguments());
map.put(ServiceState.JSON_LOCATION, getServiceLocation());
map.put(ServiceState.JSON_LOGFILE, getLogFile());
map.put(ServiceState.JSON_MEMBERNAME, getMemberName());
map.put(ServiceState.JSON_PID, getPid());
map.put(ServiceState.JSON_PORT, getPort());
map.put(ServiceState.JSON_STATUS, getStatusDescription());
map.put(ServiceState.JSON_STATUSMESSAGE, getStatusMessage());
map.put(ServiceState.JSON_TIMESTAMP, getTimestampTime());
map.put(ServiceState.JSON_UPTIME, getUptime());
map.put(ServiceState.JSON_WORKINGDIRECTORY, getWorkingDirectory());
return new GfJsonObject(map).toString();
}
use of org.apache.geode.management.internal.cli.json.GfJsonObject in project geode by apache.
the class DataCommandResult method addJSONObjectToTable.
private void addJSONObjectToTable(TabularResultData table, GfJsonObject object) {
Iterator<String> keys;
keys = object.keys();
while (keys.hasNext()) {
String k = keys.next();
// filter out meta-field type-class used to identify java class of json object
if (!"type-class".equals(k)) {
Object value = object.get(k);
if (value != null) {
table.accumulate(k, getDomainValue(value));
}
}
}
}
Aggregations