-1

I have a scenario where I have arrays like Names(Mike, Harry, Jones, Jack, Jimmy) Rank(4,2,1,3,5) and Rollno(S12,S76,S89,S87,S99). I need to capture lowest rank and associated name and roll no in beanshell.

I'm expecting to capture lowest rank and to get their names and roll no.

Mikey8997
  • 7
  • 2
  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. – Community Dec 19 '22 at 09:26

1 Answers1

0

Since JMeter 3.1 you're supposed to be using JSR223 Test Elements and Groovy language for scripting so I will provide solution in Groovy:

import java.util.stream.IntStream

def Names = ['Mike', 'Harry', 'Jones', 'Jack', 'Jimmy']
def Rank = [4, 2, 1, 3, 5]
def Rollno = ['S12', 'S76', 'S89', 'S87', 'S99']

def lowestRankIndex = IntStream
        .range(0, Rank.size())
        .reduce((i, j) -> Rank.get(i) > Rank.get(j) ? j : i)
        .getAsInt()

def lowestRankName = Names.get(lowestRankIndex)

def lowestRankRollno = Rollno.get(lowestRankIndex)

log.info('Lowest rank name: ' + lowestRankName + ' rollno: ' + lowestRankRollno)

Demo:

enter image description here

Dmitri T
  • 159,985
  • 5
  • 83
  • 133