@Test public void getRuleAttribute() throws Exception { Map<String, String> param = Maps.newHashMap(); param.put(PacmanSdkConstants.ACCOUNT_ID, "acc123"); param.put(PacmanSdkConstants.REGION, "region123"); param.put(PacmanSdkConstants.RESOURCE_ID, "resou123"); param.put(PacmanSdkConstants.REGION, "region"); Annotation annotation = new Annotation(); annotation.put(PacmanSdkConstants.RULE_ID, "ruleId123"); annotation.put(PacmanSdkConstants.DOC_ID, "docId123"); annotation.put(PacmanSdkConstants.DATA_SOURCE_KEY, "sKey123"); annotation.put(PacmanSdkConstants.TARGET_TYPE, "target123"); RuleResult result = new RuleResult(); result.setAnnotation(annotation); result.setDesc("desc"); result.setResource(param); result.setStatus("status"); PacmanRule ruleAnnotation = getPacmanRule(); String response = RuleExecutionUtils.getRuleAttribute(result, param, ruleAnnotation, "attribute"); assertNotNull(response); response = RuleExecutionUtils.getRuleAttribute(result, null, null, "attribute"); assertNull(response); }
public static String getRuleAttribute(RuleResult result, Map<String, String> ruleParam, PacmanRule ruleAnnotation, String attribute) { if (ruleParam != null && ruleParam.containsKey(attribute)) { return ruleParam.get(attribute); } if (ruleAnnotation != null) { return ruleAnnotation.category(); } return getValueFromResult(result, attribute); }
RuleExecutionUtils { public static String getRuleAttribute(RuleResult result, Map<String, String> ruleParam, PacmanRule ruleAnnotation, String attribute) { if (ruleParam != null && ruleParam.containsKey(attribute)) { return ruleParam.get(attribute); } if (ruleAnnotation != null) { return ruleAnnotation.category(); } return getValueFromResult(result, attribute); } }
RuleExecutionUtils { public static String getRuleAttribute(RuleResult result, Map<String, String> ruleParam, PacmanRule ruleAnnotation, String attribute) { if (ruleParam != null && ruleParam.containsKey(attribute)) { return ruleParam.get(attribute); } if (ruleAnnotation != null) { return ruleAnnotation.category(); } return getValueFromResult(result, attribute); }  }
RuleExecutionUtils { public static String getRuleAttribute(RuleResult result, Map<String, String> ruleParam, PacmanRule ruleAnnotation, String attribute) { if (ruleParam != null && ruleParam.containsKey(attribute)) { return ruleParam.get(attribute); } if (ruleAnnotation != null) { return ruleAnnotation.category(); } return getValueFromResult(result, attribute); }  static boolean ifFilterMatchesTheCurrentResource(Map<String, String> ruleParam,
            Map<String, String> resource); static Map<String, String> getLocalRuleParam(Map<String, String> ruleParam, Map<String, String> resource); static String getRuleAttribute(RuleResult result, Map<String, String> ruleParam, PacmanRule ruleAnnotation,
            String attribute); static Annotation buildAnnotation(Map<String, String> ruleParam, Map<String, String> resource,
            String executionId, Type annotationType, PacmanRule ruleAnnotation); }
RuleExecutionUtils { public static String getRuleAttribute(RuleResult result, Map<String, String> ruleParam, PacmanRule ruleAnnotation, String attribute) { if (ruleParam != null && ruleParam.containsKey(attribute)) { return ruleParam.get(attribute); } if (ruleAnnotation != null) { return ruleAnnotation.category(); } return getValueFromResult(result, attribute); }  static boolean ifFilterMatchesTheCurrentResource(Map<String, String> ruleParam,
            Map<String, String> resource); static Map<String, String> getLocalRuleParam(Map<String, String> ruleParam, Map<String, String> resource); static String getRuleAttribute(RuleResult result, Map<String, String> ruleParam, PacmanRule ruleAnnotation,
            String attribute); static Annotation buildAnnotation(Map<String, String> ruleParam, Map<String, String> resource,
            String executionId, Type annotationType, PacmanRule ruleAnnotation);  }