Class DatasetEndToEnd

java.lang.Object
com.cyara.apisamples.DatasetEndToEnd

public class DatasetEndToEnd
extends java.lang.Object
A program to automate the creation and usage of a dataset. Once the dataset is created, it's attached to a test case, which is then used in creating a campaign. That campaign is then run.

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.2
Author:
Chris Ryan
  • Field Summary

    Fields 
    Modifier and Type Field Description
    (package private) static java.lang.String csvFilePath  
    (package private) static int testCaseId  
    (package private) static int velocityPlanId  
  • Constructor Summary

    Constructors 
    Constructor Description
    DatasetEndToEnd()  
  • Method Summary

    Modifier and Type Method Description
    private static javax.json.JsonObject campaignCreation​(ApiFunctionalities connInfo)
    Creates a new Velocity campaign that uses our dataset-driven test case.
    private static int checkForExistingDS​(ApiFunctionalities connInfo, java.lang.String localDSName)
    Loop through all existing datasets on the account.
    private static java.lang.String getLocalDSName()
    Takes the full path of our local csv file and parses out the path and file type.
    private static int getMostRecentRunId​(ApiFunctionalities connInfo, int campaignId)
    Grabs a campaign's run history, and pulls its most recent run, grabbing the runId.
    static void main​(java.lang.String[] argv)  
    private static void processCampaignRun​(ApiFunctionalities connInfo, int campaignId, int runId)
    Grabs the campaign run's test step results, getting every call, every step of every call, and every detail of every step of every call.
    private static int runCampaignAndCheckForCompletion​(ApiFunctionalities connInfo)
    Execute (run) the campaign and check every so often if it's finished running.
    private static int validateTestCaseAndGetResults​(ApiFunctionalities connInfo)
    Validate the test case and check for completion until it's finished.

    Methods inherited from class java.lang.Object

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

  • Constructor Details

  • Method Details

    • main

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

      private static void processCampaignRun​(ApiFunctionalities connInfo, int campaignId, int runId)
      Grabs the campaign run's test step results, getting every call, every step of every call, and every detail of every step of every call. The results of each step are then parsed and printed out.
      Parameters:
      connInfo - The controller to the API credentials and methods
      campaignId - The ID of the campaign whose history we want
      runId - The id for the campaign run's report
      Since:
      1.2
    • getMostRecentRunId

      private static int getMostRecentRunId​(ApiFunctionalities connInfo, int campaignId)
      Grabs a campaign's run history, and pulls its most recent run, grabbing the runId.
      Parameters:
      connInfo - The controller to the API credentials and methods
      campaignId - The ID of the campaign whose history we want
      Returns:
      The most recent runId for this campaign
      Since:
      1.2
    • runCampaignAndCheckForCompletion

      private static int runCampaignAndCheckForCompletion​(ApiFunctionalities connInfo)
      Execute (run) the campaign and check every so often if it's finished running.
      Parameters:
      connInfo - The controller to the API credentials and methods
      Returns:
      The newly-created campaign's ID
      Since:
      1.2
    • validateTestCaseAndGetResults

      private static int validateTestCaseAndGetResults​(ApiFunctionalities connInfo)
      Validate the test case and check for completion until it's finished. Once it is, grab the overall test result for the call.
      Parameters:
      connInfo - The controller to the API credentials and methods
      Returns:
      The test result. 0 for Success, -1 for other
      Since:
      1.2
    • getLocalDSName

      private static java.lang.String getLocalDSName()
      Takes the full path of our local csv file and parses out the path and file type. This leaves us with just the file name, which is what we'll eventually check for in our existing datasets.
      Returns:
      The file name without the file type and path
      Since:
      1.2
      See Also:
      checkForExistingDS(com.cyara.apisamples.ApiFunctionalities,java.lang.String)
    • checkForExistingDS

      private static int checkForExistingDS​(ApiFunctionalities connInfo, java.lang.String localDSName)
      Loop through all existing datasets on the account. Check if the name of the dataset matches our local file. If we find one that does, grab and return the ID.
      Parameters:
      connInfo - The controller to the API credentials and methods
      localDSName - The lowercase local csv file name
      Returns:
      The matching existing dataset ID, or -1
      Since:
      1.2
    • campaignCreation

      private static javax.json.JsonObject campaignCreation​(ApiFunctionalities connInfo)
      Creates a new Velocity campaign that uses our dataset-driven test case.
      Parameters:
      connInfo - The controller to the API credentials and methods
      Returns:
      The JsonObject for the newly-created campaign
      Since:
      1.2