private void findMatchesInContexts(List<NumberContext> contexts,boolean isValid,boolean isPossible,String region,String number){
  if (isValid) {
    doTestInContext(number,region,contexts,Leniency.VALID);
  }
 else {
    for (    NumberContext context : contexts) {
      String text=context.leadingText + number + context.trailingText;
      assertTrue("Should not have found a number in " + text,hasNoMatches(phoneUtil.findNumbers(text,region)));
    }
  }
  if (isPossible) {
    doTestInContext(number,region,contexts,Leniency.POSSIBLE);
  }
 else {
    for (    NumberContext context : contexts) {
      String text=context.leadingText + number + context.trailingText;
      assertTrue("Should not have found a number in " + text,hasNoMatches(phoneUtil.findNumbers(text,region,Leniency.POSSIBLE,Long.MAX_VALUE)));
    }
  }
}

private void findMatchesInContexts ( List < NumberContext > contexts , boolean isValid , boolean isPossible , String region , String number ) { if ( isValid ) { doTestInContext ( number , region , contexts , Leniency . VALID ) ; } else { for ( NumberContext context : contexts ) { String text = context . leadingText + number + context . trailingText ; assertTrue ( "Should not have found a number in " + text , hasNoMatches ( phoneUtil . findNumbers ( text , region ) ) ) ; } } if ( isPossible ) { doTestInContext ( number , region , contexts , Leniency . POSSIBLE ) ; } else { for ( NumberContext context : contexts ) { String text = context . leadingText + number + context . trailingText ; assertTrue ( "Should not have found a number in " + text , hasNoMatches ( phoneUtil . findNumbers ( text , region , Leniency . POSSIBLE , Long . MAX_VALUE ) ) ) ; } } }
helper method which tests the contexts provided and ensures that : - - if isvalid is true , they all find a test number inserted in the middle when leniency of matching is set to valid ; else no test number should be extracted at that leniency level - - if ispossible is true , they all find a test number inserted in the middle when leniency of matching is set to possible ; else no test number should be extracted at that leniency level
