Class PrettyPrintTestCase

java.lang.Object
com.cyara.apisamples.PrettyPrintTestCase

public class PrettyPrintTestCase
extends java.lang.Object
Takes in a test case ID and generates a cleaner, simpler table of a test case with all the expect to hears and replies. The table is HTML with inline CSS and is printed out to the console.

This is not an official Cyara product and is not officially supported. It is used for demonstration and training purposes. For assistance, contact chris.ryan@cyara.com

Version:
1.1
Author:
Chris Ryan
  • Constructor Summary

    Constructors 
    Constructor Description
    PrettyPrintTestCase()  
  • Method Summary

    Modifier and Type Method Description
    static int[] calcColWidths​(int[] predeterminedHeaderWidths, java.lang.String[] headers)
    Calculates the correct column widths for the supplied values.
    private static java.lang.String generatePrettyPrint​(ApiFunctionalities connInfo, int testCaseId)
    The central method that launches the various HTML builders and compiles and constructs the final table.
    static java.lang.String generateTableFoot​(java.lang.String tableLabel, int columnCount)
    Generates the HTML for the table's footer where we display the table's label.
    static java.lang.String generateTableHead​(int[] colWidths, java.lang.String[] headers)
    Generates the HTML for the header columns, including their color.
    static java.lang.String generateTableRow​(int[] colWidths, java.lang.String[] rowCells, int rowNumber)
    Generates the HTML for the specified step row, including their color.
    static void main​(java.lang.String[] argv)  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • main

      public static void main​(java.lang.String[] argv)
    • generatePrettyPrint

      private static java.lang.String generatePrettyPrint​(ApiFunctionalities connInfo, int testCaseId)
      The central method that launches the various HTML builders and compiles and constructs the final table.
      Parameters:
      connInfo - The controller to the API credentials and methods
      testCaseId - The id we're generating the table for
      Returns:
      The final HTML String of the table
      Since:
      1.0
    • generateTableHead

      public static java.lang.String generateTableHead​(int[] colWidths, java.lang.String[] headers)
      Generates the HTML for the header columns, including their color. Uses the passed in widths, and content.
      Parameters:
      colWidths - The pixel width for each header column
      headers - The id we're generating the table for
      Returns:
      The HTML for the table's header
      Since:
      1.0
    • generateTableRow

      public static java.lang.String generateTableRow​(int[] colWidths, java.lang.String[] rowCells, int rowNumber)
      Generates the HTML for the specified step row, including their color. Uses the passed in widths, and content.
      Parameters:
      colWidths - The pixel width for each column
      rowCells - The string content for each cell of the row
      rowNumber - The index of which row we're processing. Used for background shading
      Returns:
      The HTML for the row
      Since:
      1.0
    • generateTableFoot

      public static java.lang.String generateTableFoot​(java.lang.String tableLabel, int columnCount)
      Generates the HTML for the table's footer where we display the table's label.
      Parameters:
      tableLabel - The unique label shown underneath the table for what this table contains
      columnCount - The number of columns this table has. Used to give the correct width
      Returns:
      The HTML for the table's footer
      Since:
      1.0
    • calcColWidths

      public static int[] calcColWidths​(int[] predeterminedHeaderWidths, java.lang.String[] headers)
      Calculates the correct column widths for the supplied values. Uses the number of headers being passed, and any desired column widths to calculate the equal number of column widths to be used for the remaining columns.
      Parameters:
      predeterminedHeaderWidths - The passed header widths. Any specified, predetermined header widths have a value other than -1. The -1 widths will get assigned the equally divided remaining width.
      headers - The headers this table contains, only used for their count
      Returns:
      The array of all the column widths
      Since:
      1.0