use of org.apache.geode.management.internal.cli.result.TabularResultData in project geode by apache.
the class DataCommandFunctionWithPDXJUnitTest method testVerifyDataDoesNotShift.
@Test
public void testVerifyDataDoesNotShift() throws Exception {
TabularResultData rawTable = getTableFromQuery("select * from /" + PARTITIONED_REGION + " order by id");
// Verify any table built
assertThat(rawTable.getGfJsonObject()).isNotNull();
assertThat(rawTable.getGfJsonObject().getJSONObject("content")).isNotNull();
GfJsonObject tableJson = rawTable.getGfJsonObject().getJSONObject("content");
// Table only contains correct keys
assertThat(tableJson.getJSONArray("missingKey")).isNull();
// Table contains correct data
assertThatRowIsBuiltCorrectly(tableJson, 0, alice);
assertThatRowIsBuiltCorrectly(tableJson, 1, bob);
assertThatRowIsBuiltCorrectly(tableJson, 2, charlie);
assertThatRowIsBuiltCorrectly(tableJson, 3, dan);
}
use of org.apache.geode.management.internal.cli.result.TabularResultData in project geode by apache.
the class DataCommandFunctionWithPDXJUnitTest method testFilteredQueryWithoutPhone.
@Test
public void testFilteredQueryWithoutPhone() throws Exception {
TabularResultData rawTable = getTableFromQuery("select * from /" + PARTITIONED_REGION + " c where IS_UNDEFINED ( 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", "firstName", "lastName" }) {
assertThat(tableJson.getJSONArray(k).size()).isEqualTo(2);
}
assertThatRowIsBuiltCorrectly(tableJson, 0, alice);
assertThatRowIsBuiltCorrectly(tableJson, 1, bob);
}
use of org.apache.geode.management.internal.cli.result.TabularResultData in project geode by apache.
the class GemfireDataCommandsDUnitTest method validateJSONGetResult.
private void validateJSONGetResult(CommandResult cmdResult, String[] expectedCols) {
CompositeResultData rd = (CompositeResultData) cmdResult.getResultData();
SectionResultData section = rd.retrieveSectionByIndex(0);
TabularResultData table = section.retrieveTableByIndex(0);
GfJsonArray array = table.getHeaders();
assertEquals(expectedCols.length, array.size());
try {
for (String col : expectedCols) {
boolean found = false;
getLogWriter().info("Validating column " + col);
for (int i = 0; i < array.size(); i++) {
String header = (String) array.get(i);
if (col.equals(header))
found = true;
}
assertEquals(true, found);
}
} catch (GfJsonException e) {
fail("Error accessing table data", e);
}
}
use of org.apache.geode.management.internal.cli.result.TabularResultData in project geode by apache.
the class GemfireDataCommandsDUnitTest method validateJSONGetResultValues.
private void validateJSONGetResultValues(CommandResult cmdResult, String[] expectedCols) {
CompositeResultData rd = (CompositeResultData) cmdResult.getResultData();
SectionResultData section = rd.retrieveSectionByIndex(0);
TabularResultData table = section.retrieveTableByIndex(0);
GfJsonArray array = table.getHeaders();
assertEquals(expectedCols.length, array.size());
try {
for (String col : expectedCols) {
boolean found = false;
getLogWriter().info("Validating column " + col);
for (int i = 0; i < array.size(); i++) {
String header = (String) array.get(i);
if (col.equals(header))
found = true;
}
assertEquals(true, found);
List<String> values = table.retrieveAllValues(col);
for (String value : values) {
assertNotSame("null", value);
}
}
} catch (GfJsonException e) {
fail("Error accessing table data", e);
}
}
use of org.apache.geode.management.internal.cli.result.TabularResultData in project geode by apache.
the class WanCommandStatusDUnitTest method testGatewaySenderStatus_OnGroups.
@Test
public void testGatewaySenderStatus_OnGroups() {
Integer lnPort = (Integer) vm1.invoke(() -> createFirstLocatorWithDSId(1));
Properties props = getDistributedSystemProperties();
props.setProperty(MCAST_PORT, "0");
props.setProperty(LOCATORS, "localhost[" + lnPort + "]");
setUpJmxManagerOnVm0ThenConnect(props);
Integer nyPort = (Integer) vm2.invoke(() -> createFirstRemoteLocator(2, lnPort));
vm7.invoke(() -> createAndStartReceiver(nyPort));
vm3.invoke(() -> createCacheWithGroups(lnPort, "Serial_Sender, Parallel_Sender"));
vm3.invoke(() -> createSender("ln_Serial", 2, false, 100, 400, false, false, null, true));
vm3.invoke(() -> createSender("ln_Parallel", 2, true, 100, 400, false, false, null, true));
vm4.invoke(() -> createCacheWithGroups(lnPort, "Serial_Sender, Parallel_Sender"));
vm4.invoke(() -> createSender("ln_Serial", 2, false, 100, 400, false, false, null, true));
vm4.invoke(() -> createSender("ln_Parallel", 2, true, 100, 400, false, false, null, true));
vm5.invoke(() -> createCacheWithGroups(lnPort, "Parallel_Sender"));
vm5.invoke(() -> createSender("ln_Serial", 2, false, 100, 400, false, false, null, true));
vm5.invoke(() -> createSender("ln_Parallel", 2, true, 100, 400, false, false, null, true));
vm6.invoke(() -> createCacheWithGroups(lnPort, "Serial_Sender"));
final DistributedMember vm1Member = (DistributedMember) vm3.invoke(() -> getMember());
pause(10000);
String command = CliStrings.STATUS_GATEWAYSENDER + " --" + CliStrings.STATUS_GATEWAYSENDER__ID + "=ln_Serial --" + CliStrings.STATUS_GATEWAYSENDER__GROUP + "=Serial_Sender";
CommandResult cmdResult = executeCommand(command);
if (cmdResult != null) {
TabularResultData tableResultData = ((CompositeResultData) cmdResult.getResultData()).retrieveSection(CliStrings.SECTION_GATEWAY_SENDER_AVAILABLE).retrieveTable(CliStrings.TABLE_GATEWAY_SENDER);
List<String> result_Status = tableResultData.retrieveAllValues(CliStrings.RESULT_STATUS);
assertEquals(2, result_Status.size());
assertFalse(result_Status.contains(CliStrings.GATEWAY_RUNNING));
tableResultData = ((CompositeResultData) cmdResult.getResultData()).retrieveSection(CliStrings.SECTION_GATEWAY_SENDER_NOT_AVAILABLE).retrieveTable(CliStrings.TABLE_GATEWAY_SENDER);
List<String> result_hosts = tableResultData.retrieveAllValues(CliStrings.RESULT_HOST_MEMBER);
assertEquals(1, result_hosts.size());
String strCmdResult = commandResultToString(cmdResult);
getLogWriter().info("testGatewaySenderStatus_OnGroups : " + strCmdResult + ">>>>> ");
assertEquals(Result.Status.OK, cmdResult.getStatus());
} else {
fail("testListGatewaySender failed as did not get CommandResult");
}
vm3.invoke(() -> startSender("ln_Serial"));
vm3.invoke(() -> startSender("ln_Parallel"));
vm4.invoke(() -> startSender("ln_Serial"));
vm4.invoke(() -> startSender("ln_Parallel"));
pause(10000);
command = CliStrings.STATUS_GATEWAYSENDER + " --" + CliStrings.STATUS_GATEWAYSENDER__ID + "=ln_Serial --" + CliStrings.STATUS_GATEWAYSENDER__GROUP + "=Serial_Sender";
cmdResult = executeCommand(command);
if (cmdResult != null) {
TabularResultData tableResultData = ((CompositeResultData) cmdResult.getResultData()).retrieveSection(CliStrings.SECTION_GATEWAY_SENDER_AVAILABLE).retrieveTable(CliStrings.TABLE_GATEWAY_SENDER);
List<String> result_Status = tableResultData.retrieveAllValues(CliStrings.RESULT_STATUS);
assertEquals(2, result_Status.size());
assertFalse(result_Status.contains(CliStrings.GATEWAY_NOT_RUNNING));
tableResultData = ((CompositeResultData) cmdResult.getResultData()).retrieveSection(CliStrings.SECTION_GATEWAY_SENDER_NOT_AVAILABLE).retrieveTable(CliStrings.TABLE_GATEWAY_SENDER);
List<String> result_hosts = tableResultData.retrieveAllValues(CliStrings.RESULT_HOST_MEMBER);
assertEquals(1, result_hosts.size());
String strCmdResult = commandResultToString(cmdResult);
getLogWriter().info("testGatewaySenderStatus_OnGroups : " + strCmdResult + ">>>>> ");
assertEquals(Result.Status.OK, cmdResult.getStatus());
} else {
fail("testListGatewaySender failed as did not get CommandResult");
}
}
Aggregations