org.sonar.api.Property Java Examples

The following examples show how to use org.sonar.api.Property. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TypeScriptPluginTest.java    From SonarTsPlugin with MIT License 6 votes vote down vote up
@Test
public void ruleConfigsSetting_definedAppropriately() {
    Property property = findPropertyByName(TypeScriptPlugin.SETTING_TS_RULE_CONFIGS);

    assertEquals(PropertyType.STRING, property.type());
    assertEquals("", property.defaultValue());
    assertEquals(false, property.project());
    assertEquals(true, property.global());
    assertEquals(2, property.fields().length);

    // name
    assertEquals("name", property.fields()[0].key());
    assertEquals(PropertyType.STRING, property.fields()[0].type());

    // config
    assertEquals("config", property.fields()[1].key());
    assertEquals(PropertyType.TEXT, property.fields()[1].type());
    assertEquals(120, property.fields()[1].indicativeSize());
}
 
Example #2
Source File: TypeScriptPluginTest.java    From SonarTsPlugin with MIT License 5 votes vote down vote up
@Test
public void definesExpectedProperties() {
    Annotation annotation = plugin.getClass().getAnnotations()[0];
    Properties propertiesAnnotation = (Properties) annotation;

    assertEquals(13, propertiesAnnotation.value().length);

    Property[] properties = propertiesAnnotation.value();
    assertNotNull(findPropertyByName(properties,
            TypeScriptPlugin.SETTING_EXCLUDE_TYPE_DEFINITION_FILES));
    assertNotNull(findPropertyByName(properties,
            TypeScriptPlugin.SETTING_FORCE_ZERO_COVERAGE));
    assertNotNull(findPropertyByName(properties,
            TypeScriptPlugin.SETTING_LCOV_REPORT_PATH));
    assertNotNull(findPropertyByName(properties,
        TypeScriptPlugin.SETTING_TS_LINT_ENABLED));
    assertNotNull(findPropertyByName(properties,
            TypeScriptPlugin.SETTING_TS_LINT_PATH));
    assertNotNull(findPropertyByName(properties,
            TypeScriptPlugin.SETTING_TS_LINT_CONFIG_PATH));
    assertNotNull(findPropertyByName(properties,
            TypeScriptPlugin.SETTING_TS_LINT_TIMEOUT));
    assertNotNull(findPropertyByName(properties,
            TypeScriptPlugin.SETTING_TS_LINT_RULES_DIR));
    assertNotNull(findPropertyByName(properties,
            TypeScriptPlugin.SETTING_TS_RULE_CONFIGS));
    assertNotNull(findPropertyByName(properties,
        TypeScriptPlugin.SETTING_TS_LINT_TYPECHECK));
    assertNotNull(findPropertyByName(properties,
        TypeScriptPlugin.SETTING_TS_LINT_PROJECT_PATH));
    assertNotNull(findPropertyByName(properties,
        TypeScriptPlugin.SETTING_TS_LINT_OUTPUT_PATH));
    assertNotNull(findPropertyByName(properties,
        TypeScriptPlugin.SETTING_TS_LINT_DISALLOW_CUSTOM_RULES));
}
 
Example #3
Source File: TypeScriptPluginTest.java    From SonarTsPlugin with MIT License 5 votes vote down vote up
@Test
public void tsLintPathSetting_definedAppropriately() {
    Property property = findPropertyByName(TypeScriptPlugin.SETTING_TS_LINT_PATH);

    assertEquals(PropertyType.STRING, property.type());
    assertEquals("", property.defaultValue());
    assertEquals(true, property.project());
    assertEquals(true, property.global());
}
 
Example #4
Source File: TypeScriptPluginTest.java    From SonarTsPlugin with MIT License 5 votes vote down vote up
@Test
public void excludeTypeDefinitionFilesSetting_definedAppropriately() {
    Property property = findPropertyByName(TypeScriptPlugin.SETTING_EXCLUDE_TYPE_DEFINITION_FILES);

    assertEquals(PropertyType.BOOLEAN, property.type());
    assertEquals("true", property.defaultValue());
    assertEquals(true, property.project());
    assertEquals(false, property.global());
}
 
Example #5
Source File: TypeScriptPluginTest.java    From SonarTsPlugin with MIT License 5 votes vote down vote up
@Test
public void lcovReportPathSetting_definedAppropriately() {
    Property property = findPropertyByName(TypeScriptPlugin.SETTING_LCOV_REPORT_PATH);

    assertEquals(PropertyType.STRING, property.type());
    assertEquals("", property.defaultValue());
    assertEquals(true, property.project());
    assertEquals(false, property.global());
}
 
Example #6
Source File: TypeScriptPluginTest.java    From SonarTsPlugin with MIT License 5 votes vote down vote up
@Test
public void forceZeroCoverageSetting_definedAppropriately() {
    Property property = findPropertyByName(TypeScriptPlugin.SETTING_FORCE_ZERO_COVERAGE);

    assertEquals(PropertyType.BOOLEAN, property.type());
    assertEquals("false", property.defaultValue());
    assertEquals(true, property.project());
    assertEquals(false, property.global());
}
 
Example #7
Source File: TypeScriptPluginTest.java    From SonarTsPlugin with MIT License 5 votes vote down vote up
@Test
public void tsLintTimeoutSettings_definedAppropriately() {
    Property property = findPropertyByName(TypeScriptPlugin.SETTING_TS_LINT_TIMEOUT);

    assertEquals(PropertyType.INTEGER, property.type());
    assertEquals("60000", property.defaultValue());
    assertEquals(true, property.project());
    assertEquals(false, property.global());
}
 
Example #8
Source File: TypeScriptPluginTest.java    From SonarTsPlugin with MIT License 5 votes vote down vote up
@Test
public void rulesDirSetting_definedAppropriately() {
    Property property = findPropertyByName(TypeScriptPlugin.SETTING_TS_LINT_RULES_DIR);

    assertEquals(PropertyType.STRING, property.type());
    assertEquals("", property.defaultValue());
    assertEquals(true, property.project());
    assertEquals(false, property.global());
}
 
Example #9
Source File: TypeScriptPluginTest.java    From SonarTsPlugin with MIT License 5 votes vote down vote up
private static Property findPropertyByName(Property[] properties,
        final String name) {
    return (Property) CollectionUtils.find(Arrays.asList(properties),
            new Predicate() {
                @Override
                public boolean evaluate(Object arg0) {
                    return ((Property) arg0).key().equals(name);
                }
            });
}
 
Example #10
Source File: TypeScriptPluginTest.java    From SonarTsPlugin with MIT License 4 votes vote down vote up
private Property findPropertyByName(String property) {
    return findPropertyByName(((Properties) plugin.getClass()
            .getAnnotations()[0]).value(), property);
}