Search in sources :

Example 6 with QProfileRef

use of org.sonar.server.qualityprofile.QProfileRef in project sonarqube by SonarSource.

the class QProfileRefTest method getLanguage_throws_ISE_if_key_ref.

@Test
public void getLanguage_throws_ISE_if_key_ref() {
    QProfileRef ref = QProfileRef.fromKey("foo");
    expectedException.expect(IllegalStateException.class);
    ref.getLanguage();
}
Also used : QProfileRef(org.sonar.server.qualityprofile.QProfileRef) Test(org.junit.Test)

Example 7 with QProfileRef

use of org.sonar.server.qualityprofile.QProfileRef in project sonarqube by SonarSource.

the class QProfileRefTest method test_equals_and_hashCode_of_name_ref.

@Test
public void test_equals_and_hashCode_of_name_ref() {
    QProfileRef name1 = QProfileRef.fromName("js", "one");
    QProfileRef name1bis = QProfileRef.fromName("js", "one");
    QProfileRef name2 = QProfileRef.fromName("js", "two");
    QProfileRef name1OtherLang = QProfileRef.fromName("java", "one");
    QProfileRef key = QProfileRef.fromKey("one");
    assertThat(name1.equals(name1)).isTrue();
    assertThat(name1.equals(name1bis)).isTrue();
    assertThat(name1.equals(name2)).isFalse();
    assertThat(name1.equals(name1OtherLang)).isFalse();
    assertThat(name1.equals(key)).isFalse();
    assertThat(name1.hashCode()).isEqualTo(name1.hashCode());
    assertThat(name1.hashCode()).isEqualTo(name1bis.hashCode());
}
Also used : QProfileRef(org.sonar.server.qualityprofile.QProfileRef) Test(org.junit.Test)

Example 8 with QProfileRef

use of org.sonar.server.qualityprofile.QProfileRef in project sonarqube by SonarSource.

the class QProfileRefTest method create_key_ref_from_ws_request.

@Test
public void create_key_ref_from_ws_request() {
    SimpleGetRequest req = new SimpleGetRequest();
    req.setParam("profileKey", "foo");
    QProfileRef ref = QProfileRef.from(req);
    assertThat(ref.getKey()).isEqualTo("foo");
}
Also used : SimpleGetRequest(org.sonar.api.server.ws.internal.SimpleGetRequest) QProfileRef(org.sonar.server.qualityprofile.QProfileRef) Test(org.junit.Test)

Example 9 with QProfileRef

use of org.sonar.server.qualityprofile.QProfileRef in project sonarqube by SonarSource.

the class QProfileRefTest method create_ref_by_name.

@Test
public void create_ref_by_name() {
    QProfileRef ref = QProfileRef.fromName("js", "Sonar way");
    assertThat(ref.hasKey()).isFalse();
    assertThat(ref.getLanguage()).isEqualTo("js");
    assertThat(ref.getName()).isEqualTo("Sonar way");
}
Also used : QProfileRef(org.sonar.server.qualityprofile.QProfileRef) Test(org.junit.Test)

Example 10 with QProfileRef

use of org.sonar.server.qualityprofile.QProfileRef in project sonarqube by SonarSource.

the class QProfileRefTest method getName_throws_ISE_if_key_ref.

@Test
public void getName_throws_ISE_if_key_ref() {
    QProfileRef ref = QProfileRef.fromKey("foo");
    expectedException.expect(IllegalStateException.class);
    ref.getName();
}
Also used : QProfileRef(org.sonar.server.qualityprofile.QProfileRef) Test(org.junit.Test)

Aggregations

QProfileRef (org.sonar.server.qualityprofile.QProfileRef)10 Test (org.junit.Test)9 SimpleGetRequest (org.sonar.api.server.ws.internal.SimpleGetRequest)2 DbSession (org.sonar.db.DbSession)1 QualityProfileDto (org.sonar.db.qualityprofile.QualityProfileDto)1