Forum Discussion

akashreuben7's avatar
akashreuben7
New Contributor
6 years ago

String with two variables failing

I have two questions

1.

String asdf = ['B','S']
String qwer = ['B']
def result = getExpectedResult(asdf, qwer)
log.info result

 

Its failing

am expecting it takes something like getExpectedResult(['B','S'], ['B']). How to achieve

 

2.

am getting outputs from database like 

[A,B]

[A]

[B,S,L,N]

[E]

[P]

and so on ...

All these results are generated in a loop.

How to achieve as

['A',B']

['A']

['B','S','L','N']

['E']

['P']

 

 

  • JHunt's avatar
    JHunt
    Community Hero

    Hi,

     

    Your question isn't really a SoapUI one, and may be more suitable for a site like stackexchange.com that has a Groovy specific section.

     

    (I don't mind answering some Groovy questions here, but can only do so when they are well formulated.)

    • akashreuben7's avatar
      akashreuben7
      New Contributor

      def asdf = ["B","S"]
      def qwer = ["B"]
      log.info asdf
      String result = getExpectedResult(asdf,qwer)
      log.info result

       

      public String getExpectedResult(def dbList, def inputCom)
      {
      def masterSet = [A:'A',B:'BS',C:'CDE']
      def status= "true"
      for(e in inputCom){
      masterValOfCom = masterSet[e]
      log.info masterValOfCom
      dbList.each{
      if(!masterValOfCom.contains(it)){
      status="false"
      return status
      }
      }
      }
      return status
      }

       

      The above returns true which is good.

       

      Now I have list of values coming from the loop as for asdf as 

      [A,B]

      [A]

      [B]

      and so on.. 

      and values for qwer are [A],[B],[C]

      now hyow to insert these asdf and qwer in getExpectedResult

      because now I use the above code its throwing me error stating MissingPropertyException