Search in sources :

Example 1 with Table

use of org.apache.geode.management.internal.cli.result.TableBuilder.Table in project geode by apache.

the class TableBuilderJUnitTest method createTableStructure.

private Table createTableStructure(int cols, String separator, String... colNames) {
    Table resultTable = TableBuilder.newTable();
    resultTable.setTabularResult(true);
    resultTable.setColumnSeparator(separator);
    resultTable.newBlankRow();
    RowGroup rowGroup = resultTable.newRowGroup();
    Row row = rowGroup.newRow();
    for (int colIndex = 0; colIndex < cols; colIndex++) {
        row.newCenterCol(colNames[colIndex] + colIndex);
    }
    rowGroup.newRowSeparator('-', false);
    return resultTable;
}
Also used : Table(org.apache.geode.management.internal.cli.result.TableBuilder.Table) RowGroup(org.apache.geode.management.internal.cli.result.TableBuilder.RowGroup) Row(org.apache.geode.management.internal.cli.result.TableBuilder.Row)

Example 2 with Table

use of org.apache.geode.management.internal.cli.result.TableBuilder.Table in project geode by apache.

the class TableBuilderJUnitTest method testManyColumns.

/**
   * multiple columns upto 8 : done
   */
@Test
public void testManyColumns() throws Exception {
    assertTrue(TableBuilderHelper.shouldTrimColumns());
    Table table = createTableStructure(8, "|");
    RowGroup rowGroup = table.getLastRowGroup();
    Row row1 = rowGroup.newRow();
    row1.newLeftCol("123456789-").newLeftCol("123456789-").newLeftCol("123456789-").newLeftCol("123456789-").newLeftCol("123456789-").newLeftCol("123456789-").newLeftCol("123456789-").newLeftCol("123456789-");
    List<String> result = validateTable(table, true);
    // Check the last line
    assertEquals("123456789-|123456789-|..|..|..|..|..|..", result.get(3));
}
Also used : Table(org.apache.geode.management.internal.cli.result.TableBuilder.Table) RowGroup(org.apache.geode.management.internal.cli.result.TableBuilder.RowGroup) Row(org.apache.geode.management.internal.cli.result.TableBuilder.Row) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 3 with Table

use of org.apache.geode.management.internal.cli.result.TableBuilder.Table in project geode by apache.

the class TableBuilderJUnitTest method testSanity.

/**
   * Test Variations table-wide separator true false
   */
@Test
public void testSanity() throws Exception {
    assertTrue(TableBuilderHelper.shouldTrimColumns());
    Table table = createTableStructure(3, "|");
    RowGroup rowGroup = table.getLastRowGroup();
    Row row1 = rowGroup.newRow();
    row1.newLeftCol("1").newLeftCol("1").newLeftCol("1");
    List<String> result = validateTable(table, true);
    // Check the last line
    assertEquals("1     |1     |1", result.get(3));
}
Also used : Table(org.apache.geode.management.internal.cli.result.TableBuilder.Table) RowGroup(org.apache.geode.management.internal.cli.result.TableBuilder.RowGroup) Row(org.apache.geode.management.internal.cli.result.TableBuilder.Row) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 4 with Table

use of org.apache.geode.management.internal.cli.result.TableBuilder.Table in project geode by apache.

the class TableBuilderJUnitTest method testColumnsWithShortNames.

@Test
public void testColumnsWithShortNames() throws Exception {
    when(TableBuilderHelper.class, "getScreenWidth").thenReturn(9);
    assertTrue(TableBuilderHelper.shouldTrimColumns());
    Table table = createTableStructure(3, "|", "A", "A", "A");
    RowGroup rowGroup = table.getLastRowGroup();
    Row row1 = rowGroup.newRow();
    row1.newLeftCol("123").newLeftCol("123").newLeftCol("123");
    List<String> result = validateTable(table, true);
    // Check the last line
    assertEquals("..|..|..", result.get(3));
}
Also used : Table(org.apache.geode.management.internal.cli.result.TableBuilder.Table) TableBuilderHelper(org.apache.geode.management.internal.cli.result.TableBuilderHelper) RowGroup(org.apache.geode.management.internal.cli.result.TableBuilder.RowGroup) Row(org.apache.geode.management.internal.cli.result.TableBuilder.Row) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 5 with Table

use of org.apache.geode.management.internal.cli.result.TableBuilder.Table in project geode by apache.

the class TableBuilderJUnitTest method testLastColumnTruncated.

@Test
public void testLastColumnTruncated() throws Exception {
    assertTrue(TableBuilderHelper.shouldTrimColumns());
    Table table = createTableStructure(4, "|");
    RowGroup rowGroup = table.getLastRowGroup();
    Row row1 = rowGroup.newRow();
    row1.newLeftCol("1").newLeftCol("123456789-").newLeftCol("123456789-").newLeftCol("123456789-123456789-12345");
    List<String> result = validateTable(table, true);
    // Check the last line
    assertEquals("1     |123456789-|123456789-|123456789..", result.get(3));
}
Also used : Table(org.apache.geode.management.internal.cli.result.TableBuilder.Table) RowGroup(org.apache.geode.management.internal.cli.result.TableBuilder.RowGroup) Row(org.apache.geode.management.internal.cli.result.TableBuilder.Row) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Aggregations

Table (org.apache.geode.management.internal.cli.result.TableBuilder.Table)14 Row (org.apache.geode.management.internal.cli.result.TableBuilder.Row)12 RowGroup (org.apache.geode.management.internal.cli.result.TableBuilder.RowGroup)12 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)11 Test (org.junit.Test)11 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)11 TableBuilderHelper (org.apache.geode.management.internal.cli.result.TableBuilderHelper)3 GfJsonException (org.apache.geode.management.internal.cli.json.GfJsonException)2 GfJsonObject (org.apache.geode.management.internal.cli.json.GfJsonObject)2 GfJsonArray (org.apache.geode.management.internal.cli.json.GfJsonArray)1