use of org.sonar.server.qualityprofile.QProfileRef in project sonarqube by SonarSource.
the class QProfileRefTest method create_name_ref_from_ws_request.
@Test
public void create_name_ref_from_ws_request() {
SimpleGetRequest req = new SimpleGetRequest();
req.setParam("language", "js");
req.setParam("profileName", "Sonar way");
QProfileRef ref = QProfileRef.from(req);
assertThat(ref.getLanguage()).isEqualTo("js");
assertThat(ref.getName()).isEqualTo("Sonar way");
}
use of org.sonar.server.qualityprofile.QProfileRef in project sonarqube by SonarSource.
the class QProfileRefTest method test_equals_and_hashCode_of_key_ref.
@Test
public void test_equals_and_hashCode_of_key_ref() {
QProfileRef key1 = QProfileRef.fromKey("one");
QProfileRef key1bis = QProfileRef.fromKey("one");
QProfileRef key2 = QProfileRef.fromKey("two");
QProfileRef name = QProfileRef.fromName("js", "one");
assertThat(key1.equals(key1)).isTrue();
assertThat(key1.equals(key1bis)).isTrue();
assertThat(key1.equals(key2)).isFalse();
assertThat(key1.equals(name)).isFalse();
assertThat(key1.hashCode()).isEqualTo(key1.hashCode());
assertThat(key1.hashCode()).isEqualTo(key1bis.hashCode());
}
use of org.sonar.server.qualityprofile.QProfileRef in project sonarqube by SonarSource.
the class QProfileRefTest method create_ref_by_key.
@Test
public void create_ref_by_key() {
QProfileRef ref = QProfileRef.fromKey("foo");
assertThat(ref.hasKey()).isTrue();
assertThat(ref.getKey()).isEqualTo("foo");
}
use of org.sonar.server.qualityprofile.QProfileRef in project sonarqube by SonarSource.
the class QProfileRefTest method getKey_throws_ISE_if_name_ref.
@Test
public void getKey_throws_ISE_if_name_ref() {
QProfileRef ref = QProfileRef.fromName("js", "Sonar way");
expectedException.expect(IllegalStateException.class);
ref.getKey();
}
use of org.sonar.server.qualityprofile.QProfileRef in project sonarqube by SonarSource.
the class ChangeParentAction method handle.
@Override
public void handle(Request request, Response response) throws Exception {
qProfileWsSupport.checkQProfileAdminPermission();
try (DbSession dbSession = dbClient.openSession(false)) {
QualityProfileDto profile = profileFactory.find(dbSession, QProfileRef.from(request));
String parentKey = request.param(PARAM_PARENT_KEY);
String parentName = request.param(PARAM_PARENT_NAME);
if (isEmpty(parentKey) && isEmpty(parentName)) {
ruleActivator.setParent(dbSession, profile.getKey(), null);
} else {
QProfileRef parentRef = QProfileRef.from(parentKey, request.param(QProfileRef.PARAM_LANGUAGE), parentName);
QualityProfileDto parent = profileFactory.find(dbSession, parentRef);
ruleActivator.setParent(dbSession, profile.getKey(), parent.getKey());
}
response.noContent();
}
}
Aggregations