### Question:
RuleTypeEvaluator { public IrodsRuleInvocationTypeEnum detectTypeFromExtension(final String fileName) { log.info("detectTypeFromExtension()"); if (fileName == null || fileName.isEmpty()) { throw new IllegalArgumentException("null or empty fileName"); } log.info("fileName:{}", fileName); String extension = LocalFileUtils.getFileExtension(fileName); log.debug("extension is:{}", extension); IrodsRuleInvocationTypeEnum enumVal; if (extension.trim().equals(".r")) { enumVal = IrodsRuleInvocationTypeEnum.IRODS; } else if (extension.trim().equals(".py")) { enumVal = IrodsRuleInvocationTypeEnum.PYTHON; } else { enumVal = IrodsRuleInvocationTypeEnum.OTHER; } return enumVal; } RuleTypeEvaluator(); IrodsRuleInvocationTypeEnum guessRuleLanguageType(final String ruleText); IrodsRuleInvocationTypeEnum detectTypeFromExtension(final String fileName); IrodsRuleInvocationTypeEnum detectTypeFromRuleTextAnnotation(final String ruleText); static final String RULE_ENGINE_ANNOTATION; }### Answer:
@Test public void testDetectTypeFromExtensionIrods() { String testFileName = "/a/path/to/core.r"; RuleTypeEvaluator detector = new RuleTypeEvaluator(); IrodsRuleInvocationTypeEnum actual = detector.detectTypeFromExtension(testFileName); Assert.assertEquals(IrodsRuleInvocationTypeEnum.IRODS, actual); }
@Test public void testDetectTypeFromExtensionPython() { String testFileName = "/a/path/to/core.py"; RuleTypeEvaluator detector = new RuleTypeEvaluator(); IrodsRuleInvocationTypeEnum actual = detector.detectTypeFromExtension(testFileName); Assert.assertEquals(IrodsRuleInvocationTypeEnum.PYTHON, actual); }
@Test public void testDetectTypeFromExtensionUnknown() { String testFileName = "/a/path/to/core.wtf"; RuleTypeEvaluator detector = new RuleTypeEvaluator(); IrodsRuleInvocationTypeEnum actual = detector.detectTypeFromExtension(testFileName); Assert.assertEquals(IrodsRuleInvocationTypeEnum.OTHER, actual); }
@Test(expected = IllegalArgumentException.class) public void testDetectTypeFromExtensionNull() { RuleTypeEvaluator detector = new RuleTypeEvaluator(); detector.detectTypeFromExtension(null); }