public static Map<String,Object> testRandomAuthorize(DispatchContext dctx,Map<String,? extends Object> context){
  Locale locale=(Locale)context.get("locale");
  Map<String,Object> result=ServiceUtil.returnSuccess();
  String refNum=UtilDateTime.nowAsString();
  Random r=new Random();
  int i=r.nextInt(9);
  if (i < 5 || i % 2 == 0) {
    result.put("authResult",Boolean.TRUE);
    result.put("authFlag","A");
  }
 else {
    result.put("authResult",Boolean.FALSE);
    result.put("authFlag","D");
  }
  result.put("processAmount",context.get("processAmount"));
  result.put("authRefNum",refNum);
  result.put("authAltRefNum",refNum);
  result.put("authCode","100");
  result.put("authMessage",UtilProperties.getMessage(resource,"AccountingPaymentTestCapture",locale));
  return result;
}

public static Map < String , Object > testRandomAuthorize ( DispatchContext dctx , Map < String , ? extends Object > context ) { Locale locale = ( Locale ) context . get ( "locale" ) ; Map < String , Object > result = ServiceUtil . returnSuccess ( ) ; String refNum = UtilDateTime . nowAsString ( ) ; Random r = new Random ( ) ; int i = r . nextInt ( 9 ) ; if ( i < 5 || i % 2 == 0 ) { result . put ( "authResult" , Boolean . TRUE ) ; result . put ( "authFlag" , "A" ) ; } else { result . put ( "authResult" , Boolean . FALSE ) ; result . put ( "authFlag" , "D" ) ; } result . put ( "processAmount" , context . get ( "processAmount" ) ) ; result . put ( "authRefNum" , refNum ) ; result . put ( "authAltRefNum" , refNum ) ; result . put ( "authCode" , "100" ) ; result . put ( "authMessage" , UtilProperties . getMessage ( resource , "AccountingPaymentTestCapture" , locale ) ) ; return result ; }
test authorize - does random declines
