### Question:
CheckInactiveIamUsersRule extends BaseRule { public RuleResult execute(final Map<String, String> ruleParam,Map<String, String> resourceAttributes) { logger.debug("========CheckInactiveIamUsersRule started========="); Annotation annotation = null; String passwordlastused = null; long inActiveDuration; long pwdInactiveDuration; String pwdInactiveDurationInString = ruleParam.get(PacmanRuleConstants.PD_INACTIVE_DURATION); String severity = ruleParam.get(PacmanRuleConstants.SEVERITY); String category = ruleParam.get(PacmanRuleConstants.CATEGORY); 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(pwdInactiveDurationInString,severity,category)) { logger.info(PacmanRuleConstants.MISSING_CONFIGURATION); throw new InvalidInputException(PacmanRuleConstants.MISSING_CONFIGURATION); } if (resourceAttributes != null) { passwordlastused = resourceAttributes.get(PacmanRuleConstants.PD_LAST_USED); if(!StringUtils.isEmpty(passwordlastused)){ inActiveDuration = calculateInactiveDuration(passwordlastused); pwdInactiveDuration = Long.parseLong(pwdInactiveDurationInString); if (inActiveDuration > 0) { if (inActiveDuration >= pwdInactiveDuration) { annotation = Annotation.buildAnnotation(ruleParam,Annotation.Type.ISSUE); annotation.put(PacmanSdkConstants.DESCRIPTION,"Iam user is inactive since "+ inActiveDuration+ " days!!"); annotation.put(PacmanRuleConstants.SEVERITY, severity); annotation.put(PacmanRuleConstants.CATEGORY, category); issue.put(PacmanRuleConstants.VIOLATION_REASON, "Iam user is inactive since "+ inActiveDuration+ " days!!"); issue.put(passwordlastused, passwordlastused); issueList.add(issue); annotation.put("issueDetails",issueList.toString()); logger.debug("========CheckInactiveIamUsersRule ended with annotation {} :=========",annotation); return new RuleResult(PacmanSdkConstants.STATUS_FAILURE,PacmanRuleConstants.FAILURE_MESSAGE, annotation); } } else { logger.info("Iam user is active"); } } } logger.debug("========CheckInactiveIamUsersRule ended========="); return new RuleResult(PacmanSdkConstants.STATUS_SUCCESS,PacmanRuleConstants.SUCCESS_MESSAGE); }  RuleResult execute(final Map<String, String> ruleParam,Map<String, String> resourceAttributes); String getHelpText();  }### Answer:
@Test public void executeTest() throws Exception { mockStatic(PacmanUtils.class); when(PacmanUtils.doesAllHaveValue(anyString(),anyString(),anyString())).thenReturn( true); assertThat(checkInactiveIamUsersRule.execute(CommonTestUtils.getMapString("r_123 "),CommonTestUtils.getMapString("r_123 ")), is(notNullValue())); assertThat(checkInactiveIamUsersRule.execute(CommonTestUtils.getMapString("r_123 "),null), is(notNullValue())); assertThatThrownBy( () -> checkInactiveIamUsersRule.execute(CommonTestUtils.getMapString("r_123 "),CommonTestUtils.getOneMoreMapString("r_123 "))).isInstanceOf(RuleExecutionFailedExeption.class); when(PacmanUtils.doesAllHaveValue(anyString(),anyString(),anyString())).thenReturn( false); assertThatThrownBy( () -> checkInactiveIamUsersRule.execute(CommonTestUtils.getMapString("r_123 "),CommonTestUtils.getMapString("r_123 "))).isInstanceOf(InvalidInputException.class); }