def visual_verifyActionSummary(verifyActionConf, defaultVerifyAction, verifyActionMap, strategy) {
if (strategy != 'verify') {
return null
}
String finalVerifyAction = defaultVerifyAction
if (verifyActionMap) {
Integer maxScore = 0
verifyActionMap.each { key, value ->
def actions = value as String
def actionGroups = actions.split("\\|")
Integer minGroupScore = actionGroups.collect { group ->
group.split("&").sum { action ->
verifyActionConf.get(action) as Integer
}
}.min() as Integer
if (minGroupScore > maxScore) {
maxScore = minGroupScore
finalVerifyAction = value
}
}
}
def formattedActions = finalVerifyAction.split("\\|").collect { group ->
"(" + group.replaceAll("&", " and ") + ")"
}
return formattedActions.join(" or ")
}
def verifyActionConf = ['phone':1,'2fa':3,'email':2]
def defaultVerifyAction =''
def inner_verifyActionMap = [:]
inner_verifyActionMap.put("node_e6933e0c.emptyNode","email&phone|phone&email")
def strategy='verify'
def ss=visual_verifyActionSummary(verifyActionConf,defaultVerifyAction,inner_verifyActionMap,strategy)
println(ss)