package com.xtuple;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import java.io.*;
import org.json.*;
import java.util.*;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
//import java.*;
/**
 * Unit test for simple App.
 */
public class XtupleRestClientTest
    extends TestCase
{
    /**
     * Create the test case
     *
     * @param testName name of the test case
     */
    public XtupleRestClientTest( String testName )
    {
        super( testName );
    }

    public void testreadFile(){
        XtupleRestClient client = new XtupleRestClient();
        String result = client.readFile("data/IssueToShipping.json");
    }
    public void testParseIssueToShipping(){
        XtupleRestClient client = new XtupleRestClient();
        String result = client.readFile("data/IssueToShipping.json");
        //System.out.println(result);
        try{
            String output = client.ParseIssueToShipping(result);
            System.out.println(output);
        }
        catch (Exception e){
             e.printStackTrace();
         }
    }

    public void testActivitySalesOrderWorkflow(){
        XtupleRestClient client = new XtupleRestClient();
        //https://192.168.33.10:8443/inventory/api/v1alpha1/ActivityListItem?attributes[activityType][EQUALS]=SalesOrderWorkflow
        String result = client.readFile("data/activityTypeSalesOrderWorkflow.json");
        try{
            String output = client.ParseSalesOrderWorkflow(result);
            System.out.println(output);
        }
        catch (Exception e){
             e.printStackTrace();
         }
    }

    public void testActivitySalesOrderWorkflowI(){
        XtupleRestClient client = new XtupleRestClient();
        //https://192.168.33.10:8443/inventory/api/v1alpha1/activity-list-item?attributes[activityType][EQUALS]=SalesOrderWorkflow&attributes[status][EQUALS]=I
        String result = client.readFile("data/activityTypeSalesOrderWorkflowI.json");
        try{
            String output = client.ParseSalesOrderWorkflow(result);
            System.out.println(output);
        }
        catch (Exception e){
             e.printStackTrace();
         }
    }
    public void testActivitySalesOrderWorkflowP(){
        XtupleRestClient client = new XtupleRestClient();
        //https://192.168.33.10:8443/inventory/api/v1alpha1/activity-list-item?attributes[activityType][EQUALS]=SalesOrderWorkflow&attributes[status][EQUALS]=I
        String result = client.readFile("data/activityTypeSalesOrderWorkflowP.json");
        try{
            String output = client.ParseSalesOrderWorkflow(result);
            System.out.println(output);
        }
        catch (Exception e){
             e.printStackTrace();
         }
    }
    public void testSplitCommaString(){
        XtupleRestClient client = new XtupleRestClient();
        //https://192.168.33.10:8443/inventory/api/v1alpha1/activity-list-item?attributes[activityType][EQUALS]=SalesOrderWorkflow&attributes[status][EQUALS]=I
        String result = client.readFile("data/activityTypeSalesOrderWorkflowP.json");
        try{
            String output = client.ParseSalesOrderWorkflow(result);
            System.out.println(output);
            XtupleRestClient.SplitCommaString(result);
        }
        catch (Exception e){
             e.printStackTrace();
        }
    }
    /**
     * Rigourous Test :-)
     */
    // public void testApp()
    // {
    //     assertTrue( true );
    // }
}

@@ -3253,24 +3253,45 @@
 %0A           
+ List%3CString%3E items =
  XtupleRestC
@@ -3309,32 +3309,171 @@
 CommaString(
-result);
+output);%0A            //DEBUG, Returns the UUID items in list%0A            for(String s: items)%7B%0A                System.out.println(s);%0A            %7D
 %0A        %7D%0A 

prints the UUIDs