@Test public void buildAnnotation() throws Exception { Type annotationType = Type.INFO; Map<String, String> param = Maps.newHashMap(); param.put(PacmanSdkConstants.ACCOUNT_ID, "acc123"); param.put(PacmanSdkConstants.APPLICATION_TAG_KEY, "acc123"); param.put(PacmanSdkConstants.INVOCATION_ID, "acc123"); param.put(PacmanSdkConstants.RULE_SEVERITY, "acc123"); param.put(PacmanSdkConstants.REGION, "region123"); param.put(PacmanSdkConstants.RESOURCE_ID, "resou123"); param.put(PacmanSdkConstants.REGION, "region"); Map<String, String> response = RuleExecutionUtils.buildAnnotation(param, param, "executionId123",annotationType, getPacmanRule()); assertNotNull(response); }
public static Annotation buildAnnotation(Map<String, String> ruleParam, Map<String, String> resource, String executionId, Type annotationType, PacmanRule ruleAnnotation) { Annotation annotation = Annotation.buildAnnotation(ruleParam, annotationType); annotation.put(PacmanSdkConstants.EXECUTION_ID, executionId); if (null != ruleAnnotation) { annotation.put(PacmanSdkConstants.RULE_CATEGORY, ruleAnnotation.category()); annotation.put(PacmanSdkConstants.RULE_SEVERITY, ruleAnnotation.severity()); } if (null != ruleParam) { annotation.put(PacmanSdkConstants.DATA_SOURCE_KEY, ruleParam.get(PacmanSdkConstants.DATA_SOURCE_KEY)); annotation.put(PacmanSdkConstants.TARGET_TYPE, ruleParam.get(PacmanSdkConstants.TARGET_TYPE)); annotation.put(PacmanSdkConstants.RULE_ID, ruleParam.get(PacmanSdkConstants.RULE_ID)); if (ruleParam.containsKey(PacmanSdkConstants.INVOCATION_ID)) { annotation.put(PacmanSdkConstants.INVOCATION_ID, ruleParam.get(PacmanSdkConstants.INVOCATION_ID)); } if (ruleParam.containsKey(PacmanSdkConstants.RULE_SEVERITY)) { annotation.put(PacmanSdkConstants.RULE_SEVERITY, ruleParam.get(PacmanSdkConstants.RULE_SEVERITY)); } } if (null != resource) { annotation.put(PacmanSdkConstants.RESOURCE_ID, resource.get(PacmanSdkConstants.RESOURCE_ID)); annotation.put(PacmanSdkConstants.ACCOUNT_ID, resource.get(PacmanSdkConstants.ACCOUNT_ID)); annotation.put(PacmanSdkConstants.REGION, resource.get(PacmanSdkConstants.REGION)); annotation.put(PacmanSdkConstants.ACCOUNT_NAME, resource.get(PacmanSdkConstants.ACCOUNT_NAME)); annotation.put(PacmanSdkConstants.DOC_ID, resource.get(PacmanSdkConstants.DOC_ID)); if (resource.containsKey(PacmanSdkConstants.APPLICATION_TAG_KEY)) { annotation.put(PacmanSdkConstants.APPLICATION_TAG_KEY, resource.get(PacmanSdkConstants.APPLICATION_TAG_KEY)); } if (resource.containsKey(PacmanSdkConstants.ENV_TAG_KEY)) { annotation.put(PacmanSdkConstants.ENV_TAG_KEY, resource.get(PacmanSdkConstants.ENV_TAG_KEY)); } } return annotation; }
RuleExecutionUtils { public static Annotation buildAnnotation(Map<String, String> ruleParam, Map<String, String> resource, String executionId, Type annotationType, PacmanRule ruleAnnotation) { Annotation annotation = Annotation.buildAnnotation(ruleParam, annotationType); annotation.put(PacmanSdkConstants.EXECUTION_ID, executionId); if (null != ruleAnnotation) { annotation.put(PacmanSdkConstants.RULE_CATEGORY, ruleAnnotation.category()); annotation.put(PacmanSdkConstants.RULE_SEVERITY, ruleAnnotation.severity()); } if (null != ruleParam) { annotation.put(PacmanSdkConstants.DATA_SOURCE_KEY, ruleParam.get(PacmanSdkConstants.DATA_SOURCE_KEY)); annotation.put(PacmanSdkConstants.TARGET_TYPE, ruleParam.get(PacmanSdkConstants.TARGET_TYPE)); annotation.put(PacmanSdkConstants.RULE_ID, ruleParam.get(PacmanSdkConstants.RULE_ID)); if (ruleParam.containsKey(PacmanSdkConstants.INVOCATION_ID)) { annotation.put(PacmanSdkConstants.INVOCATION_ID, ruleParam.get(PacmanSdkConstants.INVOCATION_ID)); } if (ruleParam.containsKey(PacmanSdkConstants.RULE_SEVERITY)) { annotation.put(PacmanSdkConstants.RULE_SEVERITY, ruleParam.get(PacmanSdkConstants.RULE_SEVERITY)); } } if (null != resource) { annotation.put(PacmanSdkConstants.RESOURCE_ID, resource.get(PacmanSdkConstants.RESOURCE_ID)); annotation.put(PacmanSdkConstants.ACCOUNT_ID, resource.get(PacmanSdkConstants.ACCOUNT_ID)); annotation.put(PacmanSdkConstants.REGION, resource.get(PacmanSdkConstants.REGION)); annotation.put(PacmanSdkConstants.ACCOUNT_NAME, resource.get(PacmanSdkConstants.ACCOUNT_NAME)); annotation.put(PacmanSdkConstants.DOC_ID, resource.get(PacmanSdkConstants.DOC_ID)); if (resource.containsKey(PacmanSdkConstants.APPLICATION_TAG_KEY)) { annotation.put(PacmanSdkConstants.APPLICATION_TAG_KEY, resource.get(PacmanSdkConstants.APPLICATION_TAG_KEY)); } if (resource.containsKey(PacmanSdkConstants.ENV_TAG_KEY)) { annotation.put(PacmanSdkConstants.ENV_TAG_KEY, resource.get(PacmanSdkConstants.ENV_TAG_KEY)); } } return annotation; } }
RuleExecutionUtils { public static Annotation buildAnnotation(Map<String, String> ruleParam, Map<String, String> resource, String executionId, Type annotationType, PacmanRule ruleAnnotation) { Annotation annotation = Annotation.buildAnnotation(ruleParam, annotationType); annotation.put(PacmanSdkConstants.EXECUTION_ID, executionId); if (null != ruleAnnotation) { annotation.put(PacmanSdkConstants.RULE_CATEGORY, ruleAnnotation.category()); annotation.put(PacmanSdkConstants.RULE_SEVERITY, ruleAnnotation.severity()); } if (null != ruleParam) { annotation.put(PacmanSdkConstants.DATA_SOURCE_KEY, ruleParam.get(PacmanSdkConstants.DATA_SOURCE_KEY)); annotation.put(PacmanSdkConstants.TARGET_TYPE, ruleParam.get(PacmanSdkConstants.TARGET_TYPE)); annotation.put(PacmanSdkConstants.RULE_ID, ruleParam.get(PacmanSdkConstants.RULE_ID)); if (ruleParam.containsKey(PacmanSdkConstants.INVOCATION_ID)) { annotation.put(PacmanSdkConstants.INVOCATION_ID, ruleParam.get(PacmanSdkConstants.INVOCATION_ID)); } if (ruleParam.containsKey(PacmanSdkConstants.RULE_SEVERITY)) { annotation.put(PacmanSdkConstants.RULE_SEVERITY, ruleParam.get(PacmanSdkConstants.RULE_SEVERITY)); } } if (null != resource) { annotation.put(PacmanSdkConstants.RESOURCE_ID, resource.get(PacmanSdkConstants.RESOURCE_ID)); annotation.put(PacmanSdkConstants.ACCOUNT_ID, resource.get(PacmanSdkConstants.ACCOUNT_ID)); annotation.put(PacmanSdkConstants.REGION, resource.get(PacmanSdkConstants.REGION)); annotation.put(PacmanSdkConstants.ACCOUNT_NAME, resource.get(PacmanSdkConstants.ACCOUNT_NAME)); annotation.put(PacmanSdkConstants.DOC_ID, resource.get(PacmanSdkConstants.DOC_ID)); if (resource.containsKey(PacmanSdkConstants.APPLICATION_TAG_KEY)) { annotation.put(PacmanSdkConstants.APPLICATION_TAG_KEY, resource.get(PacmanSdkConstants.APPLICATION_TAG_KEY)); } if (resource.containsKey(PacmanSdkConstants.ENV_TAG_KEY)) { annotation.put(PacmanSdkConstants.ENV_TAG_KEY, resource.get(PacmanSdkConstants.ENV_TAG_KEY)); } } return annotation; }  }
RuleExecutionUtils { public static Annotation buildAnnotation(Map<String, String> ruleParam, Map<String, String> resource, String executionId, Type annotationType, PacmanRule ruleAnnotation) { Annotation annotation = Annotation.buildAnnotation(ruleParam, annotationType); annotation.put(PacmanSdkConstants.EXECUTION_ID, executionId); if (null != ruleAnnotation) { annotation.put(PacmanSdkConstants.RULE_CATEGORY, ruleAnnotation.category()); annotation.put(PacmanSdkConstants.RULE_SEVERITY, ruleAnnotation.severity()); } if (null != ruleParam) { annotation.put(PacmanSdkConstants.DATA_SOURCE_KEY, ruleParam.get(PacmanSdkConstants.DATA_SOURCE_KEY)); annotation.put(PacmanSdkConstants.TARGET_TYPE, ruleParam.get(PacmanSdkConstants.TARGET_TYPE)); annotation.put(PacmanSdkConstants.RULE_ID, ruleParam.get(PacmanSdkConstants.RULE_ID)); if (ruleParam.containsKey(PacmanSdkConstants.INVOCATION_ID)) { annotation.put(PacmanSdkConstants.INVOCATION_ID, ruleParam.get(PacmanSdkConstants.INVOCATION_ID)); } if (ruleParam.containsKey(PacmanSdkConstants.RULE_SEVERITY)) { annotation.put(PacmanSdkConstants.RULE_SEVERITY, ruleParam.get(PacmanSdkConstants.RULE_SEVERITY)); } } if (null != resource) { annotation.put(PacmanSdkConstants.RESOURCE_ID, resource.get(PacmanSdkConstants.RESOURCE_ID)); annotation.put(PacmanSdkConstants.ACCOUNT_ID, resource.get(PacmanSdkConstants.ACCOUNT_ID)); annotation.put(PacmanSdkConstants.REGION, resource.get(PacmanSdkConstants.REGION)); annotation.put(PacmanSdkConstants.ACCOUNT_NAME, resource.get(PacmanSdkConstants.ACCOUNT_NAME)); annotation.put(PacmanSdkConstants.DOC_ID, resource.get(PacmanSdkConstants.DOC_ID)); if (resource.containsKey(PacmanSdkConstants.APPLICATION_TAG_KEY)) { annotation.put(PacmanSdkConstants.APPLICATION_TAG_KEY, resource.get(PacmanSdkConstants.APPLICATION_TAG_KEY)); } if (resource.containsKey(PacmanSdkConstants.ENV_TAG_KEY)) { annotation.put(PacmanSdkConstants.ENV_TAG_KEY, resource.get(PacmanSdkConstants.ENV_TAG_KEY)); } } return annotation; }  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 Annotation buildAnnotation(Map<String, String> ruleParam, Map<String, String> resource, String executionId, Type annotationType, PacmanRule ruleAnnotation) { Annotation annotation = Annotation.buildAnnotation(ruleParam, annotationType); annotation.put(PacmanSdkConstants.EXECUTION_ID, executionId); if (null != ruleAnnotation) { annotation.put(PacmanSdkConstants.RULE_CATEGORY, ruleAnnotation.category()); annotation.put(PacmanSdkConstants.RULE_SEVERITY, ruleAnnotation.severity()); } if (null != ruleParam) { annotation.put(PacmanSdkConstants.DATA_SOURCE_KEY, ruleParam.get(PacmanSdkConstants.DATA_SOURCE_KEY)); annotation.put(PacmanSdkConstants.TARGET_TYPE, ruleParam.get(PacmanSdkConstants.TARGET_TYPE)); annotation.put(PacmanSdkConstants.RULE_ID, ruleParam.get(PacmanSdkConstants.RULE_ID)); if (ruleParam.containsKey(PacmanSdkConstants.INVOCATION_ID)) { annotation.put(PacmanSdkConstants.INVOCATION_ID, ruleParam.get(PacmanSdkConstants.INVOCATION_ID)); } if (ruleParam.containsKey(PacmanSdkConstants.RULE_SEVERITY)) { annotation.put(PacmanSdkConstants.RULE_SEVERITY, ruleParam.get(PacmanSdkConstants.RULE_SEVERITY)); } } if (null != resource) { annotation.put(PacmanSdkConstants.RESOURCE_ID, resource.get(PacmanSdkConstants.RESOURCE_ID)); annotation.put(PacmanSdkConstants.ACCOUNT_ID, resource.get(PacmanSdkConstants.ACCOUNT_ID)); annotation.put(PacmanSdkConstants.REGION, resource.get(PacmanSdkConstants.REGION)); annotation.put(PacmanSdkConstants.ACCOUNT_NAME, resource.get(PacmanSdkConstants.ACCOUNT_NAME)); annotation.put(PacmanSdkConstants.DOC_ID, resource.get(PacmanSdkConstants.DOC_ID)); if (resource.containsKey(PacmanSdkConstants.APPLICATION_TAG_KEY)) { annotation.put(PacmanSdkConstants.APPLICATION_TAG_KEY, resource.get(PacmanSdkConstants.APPLICATION_TAG_KEY)); } if (resource.containsKey(PacmanSdkConstants.ENV_TAG_KEY)) { annotation.put(PacmanSdkConstants.ENV_TAG_KEY, resource.get(PacmanSdkConstants.ENV_TAG_KEY)); } } return annotation; }  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);  }