Search in sources :

Example 16 with GfJsonArray

use of org.apache.geode.management.internal.cli.json.GfJsonArray 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);
    }
}
Also used : GfJsonArray(org.apache.geode.management.internal.cli.json.GfJsonArray) CompositeResultData(org.apache.geode.management.internal.cli.result.CompositeResultData) TabularResultData(org.apache.geode.management.internal.cli.result.TabularResultData) GfJsonException(org.apache.geode.management.internal.cli.json.GfJsonException) SectionResultData(org.apache.geode.management.internal.cli.result.CompositeResultData.SectionResultData)

Example 17 with GfJsonArray

use of org.apache.geode.management.internal.cli.json.GfJsonArray 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);
    }
}
Also used : GfJsonArray(org.apache.geode.management.internal.cli.json.GfJsonArray) CompositeResultData(org.apache.geode.management.internal.cli.result.CompositeResultData) TabularResultData(org.apache.geode.management.internal.cli.result.TabularResultData) GfJsonException(org.apache.geode.management.internal.cli.json.GfJsonException) SectionResultData(org.apache.geode.management.internal.cli.result.CompositeResultData.SectionResultData)

Aggregations

GfJsonArray (org.apache.geode.management.internal.cli.json.GfJsonArray)17 GfJsonException (org.apache.geode.management.internal.cli.json.GfJsonException)14 GfJsonObject (org.apache.geode.management.internal.cli.json.GfJsonObject)10 ResultDataException (org.apache.geode.management.internal.cli.result.ResultDataException)4 TabularResultData (org.apache.geode.management.internal.cli.result.TabularResultData)4 ArrayList (java.util.ArrayList)3 CompositeResultData (org.apache.geode.management.internal.cli.result.CompositeResultData)3 SectionResultData (org.apache.geode.management.internal.cli.result.CompositeResultData.SectionResultData)3 CliJsonSerializable (org.apache.geode.management.internal.cli.result.CliJsonSerializable)2 Row (org.apache.geode.management.internal.cli.result.TableBuilder.Row)2 BufferedWriter (java.io.BufferedWriter)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 FileWriter (java.io.FileWriter)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 List (java.util.List)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 DataFormatException (java.util.zip.DataFormatException)1 DeflaterInflaterData (org.apache.geode.management.internal.cli.CliUtil.DeflaterInflaterData)1