### Question:
S3HostsWebsiteRule extends BaseRule { @Override public RuleResult execute(Map<String, String> ruleParam, Map<String, String> resourceAttributes) { logger.debug("========S3HostsWebsiteRule started========="); String s3BucketName = resourceAttributes.get(PacmanSdkConstants.RESOURCE_ID); String websiteConfiguration = resourceAttributes.get(PacmanRuleConstants.WEB_SITE_CONFIGURATION); String description = "S3 bucket " + s3BucketName+ " has website configuration for hosting website or redirecting requests from S3"; MDC.put("executionId", ruleParam.get("executionId")); MDC.put("ruleId", ruleParam.get(PacmanSdkConstants.RULE_ID)); if(!StringUtils.isEmpty(websiteConfiguration)){ if ("true".equalsIgnoreCase(websiteConfiguration)) { logger.info("Found S3 Bucket With Resource Id: [{}] Which Hosts Website",resourceAttributes.get(PacmanRuleConstants.RESOURCE_ID)); return new RuleResult(PacmanSdkConstants.STATUS_FAILURE, PacmanRuleConstants.FAILURE_MESSAGE, PacmanUtils.createS3Annotation(ruleParam, description)); } else { logger.info(s3BucketName, "This Bucket Doesn't Host Website."); return new RuleResult(PacmanSdkConstants.STATUS_SUCCESS, PacmanRuleConstants.SUCCESS_MESSAGE); } }else{ logger.error("website configuration attribute is not available for {}", s3BucketName); throw new RuleExecutionFailedExeption("website configuration attribute is not available for "+ s3BucketName); } }  @Override RuleResult execute(Map<String, String> ruleParam, Map<String, String> resourceAttributes); @Override String getHelpText();  }### Answer:
@Test public void testExecute() { Map<String, String> ruleParam = new HashMap<>(); Map<String, String> resourceAttributes = new HashMap<>(); S3HostsWebsiteRule s3HostsWebsiteRule = new S3HostsWebsiteRule(); resourceAttributes.put(PacmanSdkConstants.RESOURCE_ID, "test-resource-id"); resourceAttributes.put(PacmanRuleConstants.WEB_SITE_CONFIGURATION, "true"); ruleParam.put("executionId", "test"); ruleParam.put(PacmanSdkConstants.RULE_ID, "rule-id"); RuleResult ruleResult = s3HostsWebsiteRule.execute(ruleParam, resourceAttributes); assertTrue(ruleResult.getStatus().equals(PacmanSdkConstants.STATUS_FAILURE)); }
@Test public void testExecuteNoWebsiteConfiguration() { Map<String, String> ruleParam = new HashMap<>(); Map<String, String> resourceAttributes = new HashMap<>(); S3HostsWebsiteRule s3HostsWebsiteRule = new S3HostsWebsiteRule(); resourceAttributes.put(PacmanSdkConstants.RESOURCE_ID, "test-resource-id"); resourceAttributes.put(PacmanRuleConstants.WEB_SITE_CONFIGURATION, "false"); ruleParam.put("executionId", "test"); ruleParam.put(PacmanSdkConstants.RULE_ID, "rule-id"); RuleResult ruleResult = s3HostsWebsiteRule.execute(ruleParam, resourceAttributes); assertTrue(ruleResult.getStatus().equals(PacmanSdkConstants.STATUS_SUCCESS)); }