Forum Discussion

Gepir's avatar
Gepir
Occasional Contributor
8 years ago

Call Java class with variable in groovy

Hi all... I need to call java class and send variable in to. I know how to call class.   my code:     def oliNum="1234567890" Ticket newTicket = TicketTestUtil.generateTicket(); log.info newTic...
  • nmrao's avatar
    nmrao
    8 years ago

    Here are the changes needed in your java class:

     

    #1 from

     

    public static Ticket generateTicket() {

     

    To

    public static Ticket generateTicket(String oliNumber) {

     

    #2 from

    ticket.setOliNumber("4778077007");

    To

     ticket.setOliNumber(oliNumber);

     

     

     

    In the groovy script, you should be able to call

     

    Change from 

    Ticket newTicket = TicketTestUtil.generateTicket()

    To:

    Ticket newTicket = TicketTestUtil.generateTicket(oliNumber)