getRosieRulesForLanguage(LanguageEnumeration language) {
- var cachedRules = cache.get(language);
+ var cachedRules = cache.get(getCachedLanguageTypeOf(language));
return cachedRules != null ? cachedRules.getRosieRules() : List.of();
}
+ /**
+ * Since, besides JavaScript files, rules for TypeScript files are also handled under the same JavaScript Rosie language
+ * type, we have to return JavaScript rules for TypeScript files as well.
+ *
+ * @param fileLanguage the file language to map
+ */
+ private LanguageEnumeration getCachedLanguageTypeOf(LanguageEnumeration fileLanguage) {
+ return fileLanguage == LanguageEnumeration.TYPESCRIPT ? LanguageEnumeration.JAVASCRIPT : fileLanguage;
+ }
+
/**
* Returns the cached rules for the provided language and rule id.
*
@@ -179,7 +189,7 @@ public List getRosieRulesForLanguage(LanguageEnumeration language) {
* cached here.
*/
public RuleWithNames getRuleWithNamesFor(LanguageEnumeration language, String ruleId) {
- return cache.get(language).getRules().get(ruleId);
+ return cache.get(getCachedLanguageTypeOf(language)).getRules().get(ruleId);
}
/**
diff --git a/src/main/java/io/codiga/plugins/jetbrains/model/rosie/RosieRequest.java b/src/main/java/io/codiga/plugins/jetbrains/model/rosie/RosieRequest.java
index 5afb7b41..e5327930 100644
--- a/src/main/java/io/codiga/plugins/jetbrains/model/rosie/RosieRequest.java
+++ b/src/main/java/io/codiga/plugins/jetbrains/model/rosie/RosieRequest.java
@@ -1,6 +1,6 @@
package io.codiga.plugins.jetbrains.model.rosie;
-import io.codiga.plugins.jetbrains.rosie.RosieApiImpl;
+import io.codiga.plugins.jetbrains.utils.RosieLanguageSupport;
import lombok.AllArgsConstructor;
import java.util.List;
@@ -14,8 +14,7 @@ public class RosieRequest {
/**
* The Rosie language string.
*
- * See {@link io.codiga.plugins.jetbrains.utils.RosieUtils#getRosieLanguage(io.codiga.api.type.LanguageEnumeration)}
- * and {@link RosieApiImpl#SUPPORTED_LANGUAGES}.
+ * @see RosieLanguageSupport
*/
public String language;
public String fileEncoding;
diff --git a/src/main/java/io/codiga/plugins/jetbrains/model/rosie/RosieRule.java b/src/main/java/io/codiga/plugins/jetbrains/model/rosie/RosieRule.java
index a960e122..2cd06432 100644
--- a/src/main/java/io/codiga/plugins/jetbrains/model/rosie/RosieRule.java
+++ b/src/main/java/io/codiga/plugins/jetbrains/model/rosie/RosieRule.java
@@ -1,7 +1,6 @@
package io.codiga.plugins.jetbrains.model.rosie;
import io.codiga.api.GetRulesetsForClientQuery;
-import io.codiga.api.type.ElementCheckedEnumeration;
import lombok.ToString;
/**
@@ -16,44 +15,12 @@ public class RosieRule {
public String entityChecked;
public String pattern;
- public final static String ENTITY_CHECKED_FUNCTION_CALL = "functioncall";
- public final static String ENTITY_CHECKED_IF_CONDITION = "ifcondition";
- public final static String ENTITY_CHECKED_IMPORT = "import";
- public final static String ENTITY_CHECKED_ASSIGNMENT = "assign";
- public final static String ENTITY_CHECKED_FOR_LOOP = "forloop";
- public final static String ENTITY_CHECKED_FUNCTION_DEFINITION = "functiondefinition";
- public final static String ENTITY_CHECKED_TRY_BLOCK = "tryblock";
-
- private String elementCheckedToRosieEntityChecked(ElementCheckedEnumeration elementChecked) {
- if (elementChecked == null) {
- return null;
- }
- switch (elementChecked) {
- case FORLOOP:
- return ENTITY_CHECKED_FOR_LOOP;
- case ASSIGNMENT:
- return ENTITY_CHECKED_ASSIGNMENT;
- case FUNCTIONDEFINITION:
- return ENTITY_CHECKED_FUNCTION_DEFINITION;
- case TRYBLOCK:
- return ENTITY_CHECKED_TRY_BLOCK;
- case IMPORT:
- return ENTITY_CHECKED_IMPORT;
- case IFCONDITION:
- return ENTITY_CHECKED_IF_CONDITION;
- case FUNCTIONCALL:
- return ENTITY_CHECKED_FUNCTION_CALL;
- default:
- return null;
- }
- }
-
public RosieRule(String rulesetName, GetRulesetsForClientQuery.Rule rule) {
this.id = rulesetName + "/" + rule.name();
this.contentBase64 = rule.content();
this.language = rule.language().rawValue();
this.type = rule.ruleType().rawValue();
- this.entityChecked = elementCheckedToRosieEntityChecked(rule.elementChecked());
+ this.entityChecked = RosieRuleAstTypes.elementCheckedToRosieEntityChecked(rule.elementChecked());
this.pattern = rule.pattern();
}
}
diff --git a/src/main/java/io/codiga/plugins/jetbrains/model/rosie/RosieRuleAstTypes.java b/src/main/java/io/codiga/plugins/jetbrains/model/rosie/RosieRuleAstTypes.java
new file mode 100644
index 00000000..0d055e29
--- /dev/null
+++ b/src/main/java/io/codiga/plugins/jetbrains/model/rosie/RosieRuleAstTypes.java
@@ -0,0 +1,62 @@
+package io.codiga.plugins.jetbrains.model.rosie;
+
+import io.codiga.api.type.ElementCheckedEnumeration;
+
+/**
+ * Provides values and mapping logic for rule AST types.
+ */
+final class RosieRuleAstTypes {
+ private final static String ENTITY_CHECKED_FUNCTION_CALL = "functioncall";
+ private final static String ENTITY_CHECKED_IF_CONDITION = "ifcondition";
+ private final static String ENTITY_CHECKED_IMPORT = "import";
+ private final static String ENTITY_CHECKED_ASSIGNMENT = "assign";
+ private final static String ENTITY_CHECKED_FOR_LOOP = "forloop";
+ private final static String ENTITY_CHECKED_FUNCTION_DEFINITION = "functiondefinition";
+ private final static String ENTITY_CHECKED_TRY_BLOCK = "tryblock";
+ private final static String ENTITY_CHECKED_TYPE = "type";
+ private final static String ENTITY_CHECKED_INTERFACE = "interface";
+ private final static String ENTITY_CHECKED_HTML_ELEMENT = "htmlelement";
+ private final static String ENTITY_CHECKED_CLASS_DEFINITION = "classdefinition";
+ private final static String ENTITY_CHECKED_FUNCTION_EXPRESSION = "functionexpression";
+
+ /**
+ * Maps the argument element checked to its Rosie counterpart value.
+ */
+ static String elementCheckedToRosieEntityChecked(ElementCheckedEnumeration elementChecked) {
+ if (elementChecked == null) {
+ return null;
+ }
+ switch (elementChecked) {
+ case FORLOOP:
+ return ENTITY_CHECKED_FOR_LOOP;
+ case ASSIGNMENT:
+ return ENTITY_CHECKED_ASSIGNMENT;
+ case FUNCTIONDEFINITION:
+ return ENTITY_CHECKED_FUNCTION_DEFINITION;
+ case TRYBLOCK:
+ return ENTITY_CHECKED_TRY_BLOCK;
+ case IMPORT:
+ return ENTITY_CHECKED_IMPORT;
+ case IFCONDITION:
+ return ENTITY_CHECKED_IF_CONDITION;
+ case FUNCTIONCALL:
+ return ENTITY_CHECKED_FUNCTION_CALL;
+ case TYPE:
+ return ENTITY_CHECKED_TYPE;
+ case INTERFACE:
+ return ENTITY_CHECKED_INTERFACE;
+ case HTMLELEMENT:
+ return ENTITY_CHECKED_HTML_ELEMENT;
+ case CLASSDEFINITION:
+ return ENTITY_CHECKED_CLASS_DEFINITION;
+ case FUNCTIONEXPRESSION:
+ return ENTITY_CHECKED_FUNCTION_EXPRESSION;
+ default:
+ return null;
+ }
+ }
+
+ private RosieRuleAstTypes() {
+ //Utility class
+ }
+}
diff --git a/src/main/java/io/codiga/plugins/jetbrains/rosie/CodigaRulesetConfigs.java b/src/main/java/io/codiga/plugins/jetbrains/rosie/CodigaRulesetConfigs.java
index d1923a9b..bb654241 100644
--- a/src/main/java/io/codiga/plugins/jetbrains/rosie/CodigaRulesetConfigs.java
+++ b/src/main/java/io/codiga/plugins/jetbrains/rosie/CodigaRulesetConfigs.java
@@ -1,11 +1,9 @@
package io.codiga.plugins.jetbrains.rosie;
-import com.intellij.openapi.project.Project;
-
/**
* Provides default ruleset configurations for the Codiga config file.
*
- * @see io.codiga.plugins.jetbrains.starter.RosieStartupActivity#showConfigureDefaultConfigFileNotification(Project)
+ * @see io.codiga.plugins.jetbrains.starter.RosieStartupActivity#showConfigureDefaultConfigFileNotification(com.intellij.openapi.project.Project)
*/
public final class CodigaRulesetConfigs {
diff --git a/src/main/java/io/codiga/plugins/jetbrains/rosie/RosieApiImpl.java b/src/main/java/io/codiga/plugins/jetbrains/rosie/RosieApiImpl.java
index bf41b290..8b9bc306 100644
--- a/src/main/java/io/codiga/plugins/jetbrains/rosie/RosieApiImpl.java
+++ b/src/main/java/io/codiga/plugins/jetbrains/rosie/RosieApiImpl.java
@@ -28,7 +28,8 @@
import java.util.List;
import static io.codiga.plugins.jetbrains.Constants.LOGGER_NAME;
-import static io.codiga.plugins.jetbrains.utils.RosieUtils.getRosieLanguage;
+import static io.codiga.plugins.jetbrains.utils.RosieLanguageSupport.getRosieLanguage;
+import static io.codiga.plugins.jetbrains.utils.RosieLanguageSupport.isLanguageSupported;
import static io.codiga.plugins.jetbrains.utils.UserAgentUtils.getUserAgent;
import static java.util.stream.Collectors.toList;
@@ -40,13 +41,6 @@ public class RosieApiImpl implements RosieApi {
private static final String ROSIE_POST_URL = "https://analysis.codiga.io/analyze";
private static final Gson GSON = new Gson();
- /**
- * Current supported languages by Rosie.
- *
- * See also {@link io.codiga.plugins.jetbrains.utils.RosieUtils#getRosieLanguage(LanguageEnumeration)}.
- */
- private static final List SUPPORTED_LANGUAGES = List.of(LanguageEnumeration.PYTHON);
-
public RosieApiImpl() {
// no constructor instructions
}
@@ -58,11 +52,11 @@ public List getAnnotations(@NotNull PsiFile psiFile, @NotNull P
return List.of();
}
- LanguageEnumeration language = LanguageUtils.getLanguageFromFilename(psiFile.getVirtualFile().getCanonicalPath());
+ LanguageEnumeration fileLanguage = LanguageUtils.getLanguageFromFilename(psiFile.getVirtualFile().getCanonicalPath());
// not supported, we exit right away
- if (!SUPPORTED_LANGUAGES.contains(language)) {
- LOGGER.info(String.format("language not supported %s", language));
+ if (!isLanguageSupported(fileLanguage)) {
+ LOGGER.info(String.format("language not supported %s", fileLanguage));
return List.of();
}
@@ -71,13 +65,13 @@ public List getAnnotations(@NotNull PsiFile psiFile, @NotNull P
String codeBase64 = Base64.getEncoder().encodeToString(fileText);
// Prepare the request
- var rosieRules = RosieRulesCache.getInstance(project).getRosieRulesForLanguage(language);
+ var rosieRules = RosieRulesCache.getInstance(project).getRosieRulesForLanguage(fileLanguage);
//If there is no rule for the target language, then Rosie is not called, and no annotation is performed
if (rosieRules.isEmpty()) {
return List.of();
}
- RosieRequest request = new RosieRequest(psiFile.getName(), getRosieLanguage(language), "utf8", codeBase64, rosieRules, true);
+ RosieRequest request = new RosieRequest(psiFile.getName(), getRosieLanguage(fileLanguage), "utf8", codeBase64, rosieRules, true);
String requestString = GSON.toJson(request);
StringEntity postingString = new StringEntity(requestString); //gson.toJson() converts your pojo to json
HttpPost httpPost = new HttpPost(ROSIE_POST_URL);
@@ -91,21 +85,23 @@ public List getAnnotations(@NotNull PsiFile psiFile, @NotNull P
LOGGER.debug("Rules sent in request " + requestTimestamp + ": " + rosieRules.stream().map(RosieRule::toString).collect(toList()));
List annotations = List.of();
if (response.getEntity() != null) {
-
String result = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
LOGGER.debug("Response received from request " + requestTimestamp + ": " + result);
RosieResponse rosieResponse = GSON.fromJson(result, RosieResponse.class);
- annotations = rosieResponse.ruleResponses.stream()
- .flatMap(res -> res.violations.stream()
- //distinct()' makes sure that if multiple, completely identical, violations are returned
- // for the same problem from Rosie, only one instance is shown by RosieAnnotator.
- .distinct()
- .map(violation -> {
- var rule = RosieRulesCache.getInstance(project).getRuleWithNamesFor(language, res.identifier);
- return new RosieAnnotation(rule.ruleName, rule.rulesetName, violation);
- }))
- .collect(toList());
+ //If there is no error returned, collect the violations
+ if (rosieResponse.errors == null || rosieResponse.errors.isEmpty()) {
+ annotations = rosieResponse.ruleResponses.stream()
+ .flatMap(res -> res.violations.stream()
+ //distinct()' makes sure that if multiple, completely identical, violations are returned
+ // for the same problem from Rosie, only one instance is shown by RosieAnnotator.
+ .distinct()
+ .map(violation -> {
+ var rule = RosieRulesCache.getInstance(project).getRuleWithNamesFor(fileLanguage, res.identifier);
+ return new RosieAnnotation(rule.ruleName, rule.rulesetName, violation);
+ }))
+ .collect(toList());
+ }
}
client.close();
return annotations;
diff --git a/src/main/java/io/codiga/plugins/jetbrains/utils/RosieLanguageSupport.java b/src/main/java/io/codiga/plugins/jetbrains/utils/RosieLanguageSupport.java
new file mode 100644
index 00000000..98f2acaf
--- /dev/null
+++ b/src/main/java/io/codiga/plugins/jetbrains/utils/RosieLanguageSupport.java
@@ -0,0 +1,50 @@
+package io.codiga.plugins.jetbrains.utils;
+
+import io.codiga.api.type.LanguageEnumeration;
+
+import java.util.Set;
+
+/**
+ * Utility for the Rosie integration.
+ */
+public final class RosieLanguageSupport {
+
+ /**
+ * Currently supported languages by Rosie.
+ */
+ private static final Set SUPPORTED_LANGUAGES = Set.of(
+ LanguageEnumeration.PYTHON,
+ LanguageEnumeration.JAVASCRIPT,
+ LanguageEnumeration.TYPESCRIPT);
+
+ /**
+ * Returns whether the argument language is supported by Rosie.
+ *
+ * @param fileLanguage the language to check
+ */
+ public static boolean isLanguageSupported(LanguageEnumeration fileLanguage) {
+ return SUPPORTED_LANGUAGES.contains(fileLanguage);
+ }
+
+ /**
+ * Returns the Rosie language string of the argument Codiga language.
+ *
+ * @param language the Codiga language to map to Rosie language
+ */
+ public static String getRosieLanguage(LanguageEnumeration language) {
+ switch (language) {
+ case PYTHON:
+ return "python";
+ case JAVASCRIPT:
+ return "javascript";
+ case TYPESCRIPT:
+ return "typescript";
+ default:
+ return "unknown";
+ }
+ }
+
+ private RosieLanguageSupport() {
+ //Utility class
+ }
+}
diff --git a/src/main/java/io/codiga/plugins/jetbrains/utils/RosieUtils.java b/src/main/java/io/codiga/plugins/jetbrains/utils/RosieUtils.java
deleted file mode 100644
index 8c51e970..00000000
--- a/src/main/java/io/codiga/plugins/jetbrains/utils/RosieUtils.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package io.codiga.plugins.jetbrains.utils;
-
-import io.codiga.api.type.LanguageEnumeration;
-
-/**
- * Utility for the Rosie integration.
- */
-public final class RosieUtils {
-
- /**
- * Returns the Rosie language version String of the argument Codiga language.
- *
- * @param language the Codiga language to map to Rosie language
- */
- public static String getRosieLanguage(LanguageEnumeration language) {
- switch (language) {
- case PYTHON:
- return "python";
- default:
- return "unknown";
- }
- }
-
- private RosieUtils() {
- //Utility class
- }
-}
diff --git a/src/test/java/io/codiga/plugins/jetbrains/annotators/RosieRulesCacheTest.java b/src/test/java/io/codiga/plugins/jetbrains/annotators/RosieRulesCacheTest.java
index 67fccfce..8fdfbef6 100644
--- a/src/test/java/io/codiga/plugins/jetbrains/annotators/RosieRulesCacheTest.java
+++ b/src/test/java/io/codiga/plugins/jetbrains/annotators/RosieRulesCacheTest.java
@@ -120,6 +120,17 @@ public void testReturnsRulesForLanguage() {
assertTrue(javaRules.stream().allMatch(rule -> LanguageEnumeration.JAVA.rawValue().equals(rule.language)));
}
+ public void testReturnsJavaScriptRulesForTypeScript() {
+ var cache = RosieRulesCache.getInstance(getProject());
+ var rulesetNames = List.of("javascriptRuleset");
+ var rulesets = CodigaApi.getInstance().getRulesetsForClient(rulesetNames);
+
+ cache.updateCacheFrom(rulesets.get());
+
+ var jsRules = cache.getRosieRulesForLanguage(LanguageEnumeration.TYPESCRIPT);
+ assertTrue(jsRules.stream().allMatch(rule -> LanguageEnumeration.JAVASCRIPT.rawValue().equals(rule.language)));
+ }
+
//Helpers
private void validateRuleCountAndRuleIds(List rules, int count, String... ruleIds) {
diff --git a/src/test/java/io/codiga/plugins/jetbrains/graphql/RulesetsForClientTestSupport.java b/src/test/java/io/codiga/plugins/jetbrains/graphql/RulesetsForClientTestSupport.java
index 43791b07..052649d5 100644
--- a/src/test/java/io/codiga/plugins/jetbrains/graphql/RulesetsForClientTestSupport.java
+++ b/src/test/java/io/codiga/plugins/jetbrains/graphql/RulesetsForClientTestSupport.java
@@ -13,6 +13,8 @@
*/
public final class RulesetsForClientTestSupport {
+ // Python rules
+
private static final GetRulesetsForClientQuery.Rule PYTHON_RULE_1 = createAstRule("typename_1",
"10",
"python_rule_1",
@@ -38,12 +40,33 @@ public final class RulesetsForClientTestSupport {
"python_rule_5",
"ZnVuY3Rpb24gdmlzaXQocGF0dGVybiwgZmlsZW5hbWUsIGNvZGUpIHsKICAgIGNvbnN0IGVycm9yID0gYnVpbGRFcnJvcihtb2RlLnN0YXJ0LmxpbmUsIG1vZGUuc3RhcnQuY29sLCBtb2RlLmVuZC5saW5lLCBtb2RlLmVuZC5jb2wsICJlcnJvciBtZXNzYWdlIiwgIkNSSVRJQ0FMIiwgInNlY3VyaXR5Iik7CiAgICBhZGRFcnJvcihlcnJvcik7CiAgfQp9",
LanguageEnumeration.PYTHON);
+
+ // Java rules
+
private static final GetRulesetsForClientQuery.Rule JAVA_RULE_1 = createAstRule("typename_2",
"20",
"java_rule_1",
"ZnVuY3Rpb24gdmlzaXQocGF0dGVybiwgZmlsZW5hbWUsIGNvZGUpIHsKICAgIGFkZEVycm9yKGJ1aWxkRXJyb3IobW9kZS5zdGFydC5saW5lLCBtb2RlLnN0YXJ0LmNvbCwgbW9kZS5lbmQubGluZSwgbW9kZS5lbmQuY29sLCAiZXJyb3IgbWVzc2FnZSIsICJDUklUSUNBTCIsICJzZWN1cml0eSIpKTsKICB9Cn0=",
LanguageEnumeration.JAVA);
+ // JavaScript rules
+
+ private static final GetRulesetsForClientQuery.Rule JAVASCRIPT_RULE_1 = createAstRule("typename_1",
+ "10",
+ "javascript_rule_1",
+ "ZnVuY3Rpb24gdmlzaXQocGF0dGVybiwgZmlsZW5hbWUsIGNvZGUpIHsKfQ==",
+ LanguageEnumeration.JAVASCRIPT);
+ private static final GetRulesetsForClientQuery.Rule JAVASCRIPT_RULE_2 = createAstRule("typename_1",
+ "11",
+ "javascript_rule_2",
+ "ZnVuY3Rpb24gdmlzaXQocGF0dGVybiwgZmlsZW5hbWUsIGNvZGUpIHsKICAgIGFkZEVycm9yKGJ1aWxkRXJyb3IobW9kZS5zdGFydC5saW5lLCBtb2RlLnN0YXJ0LmNvbCwgbW9kZS5lbmQubGluZSwgbW9kZS5lbmQuY29sLCAiZXJyb3IgbWVzc2FnZSIsICJDUklUSUNBTCIsICJzZWN1cml0eSIpKTsKICB9Cn0=",
+ LanguageEnumeration.JAVASCRIPT);
+ private static final GetRulesetsForClientQuery.Rule JAVASCRIPT_RULE_3 = createAstRule("typename_1",
+ "12",
+ "javascript_rule_3",
+ "ZnVuY3Rpb24gdmlzaXQocGF0dGVybiwgZmlsZW5hbWUsIGNvZGUpIHsKICAgIGNvbnN0IGVycm9yID0gYnVpbGRFcnJvcihtb2RlLnN0YXJ0LmxpbmUsIG1vZGUuc3RhcnQuY29sLCBtb2RlLmVuZC5saW5lLCBtb2RlLmVuZC5jb2wsICJlcnJvciBtZXNzYWdlIiwgIkNSSVRJQ0FMIiwgInNlY3VyaXR5Iik7CiAgICBhZGRFcnJvcihlcnJvcik7CiAgfQp9",
+ LanguageEnumeration.JAVASCRIPT);
+
/**
* Returns test rulesets based on the argument ruleset names. Currently, rulesets are returned based on the first
* value in the provided list.
@@ -70,6 +93,9 @@ public static Optional> getRul
case "erroredRuleset":
rulesets = null;
break;
+ case "javascriptRuleset":
+ rulesets = javascriptRulesets();
+ break;
default:
rulesets = List.of();
}
@@ -88,6 +114,8 @@ public static Optional getRulesetsLastTimestamp(List rulesetNames)
return Optional.of(103L);
case "multipleRulesetsMultipleLanguages":
return Optional.of(104L);
+ case "javascriptRuleset":
+ return Optional.of(105L);
default:
return Optional.empty();
}
@@ -141,6 +169,17 @@ private static List multipleRuleset
return List.of(ruleset, ruleset2);
}
+ /**
+ * Returns a single ruleset with JavaScript rules.
+ */
+ private static List javascriptRulesets() {
+ var rules = List.of(JAVASCRIPT_RULE_1, JAVASCRIPT_RULE_2, JAVASCRIPT_RULE_3);
+
+ var ruleset = new GetRulesetsForClientQuery.RuleSetsForClient("typename", 1234, "javascriptRuleset", rules);
+
+ return List.of(ruleset);
+ }
+
private static GetRulesetsForClientQuery.Rule createAstRule(@NotNull String __typename,
@NotNull Object id,
@NotNull String name,
diff --git a/src/test/java/io/codiga/plugins/jetbrains/utils/RosieLanguageSupportTest.java b/src/test/java/io/codiga/plugins/jetbrains/utils/RosieLanguageSupportTest.java
new file mode 100644
index 00000000..b407ca9c
--- /dev/null
+++ b/src/test/java/io/codiga/plugins/jetbrains/utils/RosieLanguageSupportTest.java
@@ -0,0 +1,34 @@
+package io.codiga.plugins.jetbrains.utils;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import io.codiga.api.type.LanguageEnumeration;
+import org.junit.Test;
+
+/**
+ * Unit test for {@link RosieLanguageSupport}.
+ */
+public class RosieLanguageSupportTest {
+
+ @Test
+ public void shouldSupportLanguage() {
+ assertTrue(RosieLanguageSupport.isLanguageSupported(LanguageEnumeration.PYTHON));
+ }
+
+ @Test
+ public void shouldNotSupportLanguage() {
+ assertFalse(RosieLanguageSupport.isLanguageSupported(LanguageEnumeration.CSS));
+ }
+
+ @Test
+ public void shouldReturnRosieLanguageForPython() {
+ assertEquals("python", RosieLanguageSupport.getRosieLanguage(LanguageEnumeration.PYTHON));
+ }
+
+ @Test
+ public void shouldReturnUnknownRosieLanguageForNotSupportedLanguage() {
+ assertEquals("unknown", RosieLanguageSupport.getRosieLanguage(LanguageEnumeration.CSS));
+ }
+}