### Question:
CheckNonRoleTasksMemberRule extends BaseRule { @Override public RuleResult execute(Map<String, String> ruleParam, Map<String, String> resourceAttributes) { logger.debug("========CheckNonRoleTasksMemberRule started========="); Annotation annotation = null; String resourceId = null; String severity = ruleParam.get(PacmanRuleConstants.SEVERITY); String category = ruleParam.get(PacmanRuleConstants.CATEGORY); String adGroupEsURL = null; String formattedUrl = PacmanUtils.formatUrl(ruleParam,PacmanRuleConstants.ES_ADGROUP_URL); if(!StringUtils.isEmpty(formattedUrl)){ adGroupEsURL = formattedUrl; } MDC.put("executionId", ruleParam.get("executionId")); MDC.put("ruleId", ruleParam.get(PacmanSdkConstants.RULE_ID)); List<LinkedHashMap<String, Object>> issueList = new ArrayList<>(); LinkedHashMap<String, Object> issue = new LinkedHashMap<>(); if (!PacmanUtils.doesAllHaveValue(severity, category,adGroupEsURL)) { logger.info(PacmanRuleConstants.MISSING_CONFIGURATION); throw new InvalidInputException(PacmanRuleConstants.MISSING_CONFIGURATION); } if (resourceAttributes != null && "Task".equals(resourceAttributes.get("type"))) { resourceId = StringUtils.trim(resourceAttributes .get(PacmanSdkConstants.RESOURCE_ID)); if (resourceId.startsWith(PacmanRuleConstants.TASK)) { Boolean isNestedRole = false; try { isNestedRole = PacmanUtils.getNestedRoles(resourceId, adGroupEsURL, "nonRole"); } catch (Exception e) { logger.error("unable to determine" , e); throw new RuleExecutionFailedExeption("unable to determine" + e); } if (!isNestedRole) { annotation = Annotation.buildAnnotation(ruleParam, Annotation.Type.ISSUE); annotation.put(PacmanSdkConstants.DESCRIPTION, "Non-role task member found!!"); annotation.put(PacmanRuleConstants.SEVERITY, severity); annotation.put(PacmanRuleConstants.CATEGORY, category); issue.put(PacmanRuleConstants.VIOLATION_REASON, "Task is a member of non-role!!"); issueList.add(issue); annotation.put("issueDetails", issueList.toString()); logger.debug( "========CheckNonRoleTasksMemberRule ended with annotation : {}=========", annotation); return new RuleResult(PacmanSdkConstants.STATUS_FAILURE, PacmanRuleConstants.FAILURE_MESSAGE, annotation); } } } logger.debug("========CheckNonRoleTasksMemberRule ended========="); return new RuleResult(PacmanSdkConstants.STATUS_SUCCESS, PacmanRuleConstants.SUCCESS_MESSAGE); }  @Override RuleResult execute(Map<String, String> ruleParam,
            Map<String, String> resourceAttributes); @Override String getHelpText();  }### Answer:
@Test public void executeTest() throws Exception { mockStatic(PacmanUtils.class); when(PacmanUtils.doesAllHaveValue(anyString(), anyString(),anyString())).thenReturn( true); when(PacmanUtils.getNestedRoles(anyString(), anyString(),anyString())).thenReturn( false); when(PacmanUtils.formatUrl(anyObject(),anyString())).thenReturn("host"); assertThat(checkNonRoleTasksMemberRule.execute(CommonTestUtils.getMapString("t_123"),CommonTestUtils.getMapString("t_123")), is(notNullValue())); when(PacmanUtils.getNestedRoles(anyString(), anyString(),anyString())).thenReturn( true); assertThat(checkNonRoleTasksMemberRule.execute(CommonTestUtils.getMapString("r_123"),CommonTestUtils.getMapString("r_123")), is(notNullValue())); when(PacmanUtils.doesAllHaveValue(anyString(),anyString(),anyString())).thenReturn( false); assertThatThrownBy( () -> checkNonRoleTasksMemberRule.execute(CommonTestUtils.getMapString("r_123 "),CommonTestUtils.getMapString("r_123 "))).isInstanceOf(InvalidInputException.class); }