Search in sources :

Example 11 with MessageException

use of org.sonar.api.utils.MessageException in project sonarqube by SonarSource.

the class LanguageDetectionTest method fail_if_conflicting_language_suffix.

@Test
public void fail_if_conflicting_language_suffix() {
    LanguagesRepository languages = new DefaultLanguagesRepository(new Languages(new MockLanguage("xml", "xhtml"), new MockLanguage("web", "xhtml")));
    LanguageDetection detection = new LanguageDetection(settings.asConfig(), languages);
    try {
        detectLanguageKey(detection, "abc.xhtml");
        fail();
    } catch (MessageException e) {
        assertThat(e.getMessage()).contains("Language of file 'abc.xhtml' can not be decided as the file matches patterns of both ").contains("sonar.lang.patterns.web : **/*.xhtml").contains("sonar.lang.patterns.xml : **/*.xhtml");
    }
}
Also used : MessageException(org.sonar.api.utils.MessageException) LanguagesRepository(org.sonar.scanner.repository.language.LanguagesRepository) DefaultLanguagesRepository(org.sonar.scanner.repository.language.DefaultLanguagesRepository) Languages(org.sonar.api.resources.Languages) DefaultLanguagesRepository(org.sonar.scanner.repository.language.DefaultLanguagesRepository) Test(org.junit.Test)

Example 12 with MessageException

use of org.sonar.api.utils.MessageException in project sonarqube by SonarSource.

the class DefaultProjectRepositoriesLoaderTest method failFastHttpErrorMessageException.

@Test
public void failFastHttpErrorMessageException() {
    HttpException http = new HttpException("uri", 403, null);
    MessageException e = MessageException.of("http error", http);
    WsTestUtil.mockException(wsClient, e);
    assertThatThrownBy(() -> loader.load(PROJECT_KEY, null)).isInstanceOf(MessageException.class).hasMessage("http error");
}
Also used : MessageException(org.sonar.api.utils.MessageException) HttpException(org.sonarqube.ws.client.HttpException) Test(org.junit.Test)

Aggregations

MessageException (org.sonar.api.utils.MessageException)12 Test (org.junit.Test)11 Languages (org.sonar.api.resources.Languages)3 TestComputationStepContext (org.sonar.ce.task.step.TestComputationStepContext)3 DatabaseMetaData (java.sql.DatabaseMetaData)2 ComponentDto (org.sonar.db.component.ComponentDto)2 Oracle (org.sonar.db.dialect.Oracle)2 DefaultLanguagesRepository (org.sonar.scanner.repository.language.DefaultLanguagesRepository)2 LanguagesRepository (org.sonar.scanner.repository.language.LanguagesRepository)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1 LogAndArguments (org.sonar.api.utils.log.LogAndArguments)1 CeTask (org.sonar.ce.task.CeTask)1 HttpException (org.sonarqube.ws.client.HttpException)1