Service Virtualization

  • 1.  how to use java execution in VSM?

    Posted Dec 04, 2017 01:27 AM

    I am trying to use java code in my VSM which creates dynamic JSON payload 

     

    The code is as below:

     

    public class json {
    public static void main(String[] args) throws Exception {
    String FNNOrg = "123,456";
    String[] FNN = FNNOrg.split(",");
    int counter = FNN.length;
    System.out.println("No of FNNs:"+counter);
    int endcounter = counter - 1;
    String json = "{" +
    "\"status\": 200," +
    "\"data\": {" +
    "\"numberDetails\": [";

    for (int i = 0; i < counter; i++) {
    System.out.println("FNN values:"+FNN[i]);
    json += "{ \"fullNationalNumber\": \""+FNN[i]+"\", \"fnnServiceabilityIndicator\": \"2\", \"reason\": \"3\", \"code\": \"4\" }";
    if(i != endcounter) json += ",";
    }

    json += "]}}";

    System.out.println("JSON = " + json);
    }


    }

     

     

    I want to dynamically create JSON responses.



  • 2.  Re: how to use java execution in VSM?
    Best Answer

    Posted Dec 04, 2017 12:32 PM

    Hi,

        Create a runnable jar  and use the  dynamic java execution  step.

    Dynamic Java Execution - DevTest Solutions - 8.1 - CA Technologies Documentation 

    Thanks,

    Vish