use of org.sonar.db.metric.MetricDto in project sonarqube by SonarSource.
the class UpdateActionTest method insertNewMetric.
private MetricDto insertNewMetric(ValueType metricType) {
MetricDto metric = MetricTesting.newMetricDto().setEnabled(true).setValueType(metricType.name());
dbClient.metricDao().insert(dbSession, metric);
return metric;
}
use of org.sonar.db.metric.MetricDto in project sonarqube by SonarSource.
the class UpdateActionTest method update_value_only.
@Test
public void update_value_only() throws Exception {
MetricDto metric = insertNewMetric(ValueType.STRING);
ComponentDto component = db.components().insertProject(db.getDefaultOrganization(), "project-uuid");
CustomMeasureDto customMeasure = newCustomMeasure(component, metric).setDescription("custom-measure-description").setTextValue("text-measure-value");
dbClient.customMeasureDao().insert(dbSession, customMeasure);
dbSession.commit();
when(system.now()).thenReturn(123_456_789L);
logInAsProjectAdministrator(component);
ws.newPostRequest(CustomMeasuresWs.ENDPOINT, UpdateAction.ACTION).setParam(PARAM_ID, String.valueOf(customMeasure.getId())).setParam(PARAM_DESCRIPTION, "new-custom-measure-description").execute();
logInAsProjectAdministrator(component);
CustomMeasureDto updatedCustomMeasure = dbClient.customMeasureDao().selectOrFail(dbSession, customMeasure.getId());
assertThat(updatedCustomMeasure.getTextValue()).isEqualTo("text-measure-value");
assertThat(updatedCustomMeasure.getDescription()).isEqualTo("new-custom-measure-description");
assertThat(updatedCustomMeasure.getUpdatedAt()).isEqualTo(123_456_789L);
assertThat(customMeasure.getCreatedAt()).isEqualTo(updatedCustomMeasure.getCreatedAt());
}
use of org.sonar.db.metric.MetricDto in project sonarqube by SonarSource.
the class MetricsActionTest method list_metrics_based_on_project_key.
@Test
public void list_metrics_based_on_project_key() throws Exception {
MetricDto metric = insertCustomMetric("metric-key-1");
insertCustomMetric("metric-key-2");
insertProject("project-uuid-2", "project-key-2");
CustomMeasureDto customMeasure = newCustomMeasureDto().setComponentUuid(defaultProject.uuid()).setMetricId(metric.getId());
dbClient.customMeasureDao().insert(dbSession, customMeasure);
dbSession.commit();
String response = ws.newGetRequest(ENDPOINT, ACTION).setParam(MetricsAction.PARAM_PROJECT_KEY, DEFAULT_PROJECT_KEY).execute().outputAsString();
assertThat(response).contains("metric-key-2").doesNotContain("metric-key-1");
}
use of org.sonar.db.metric.MetricDto in project sonarqube by SonarSource.
the class MetricsActionTest method insertCustomMetric.
private MetricDto insertCustomMetric(String metricKey) {
MetricDto metric = newCustomMetric(metricKey);
dbClient.metricDao().insert(dbSession, metric);
dbSession.commit();
return metric;
}
use of org.sonar.db.metric.MetricDto in project sonarqube by SonarSource.
the class SearchActionTest method search_by_project_uuid.
@Test
public void search_by_project_uuid() throws Exception {
MetricDto metric1 = insertCustomMetric(1);
MetricDto metric2 = insertCustomMetric(2);
MetricDto metric3 = insertCustomMetric(3);
insertCustomMeasure(1, metric1);
insertCustomMeasure(2, metric2);
insertCustomMeasure(3, metric3);
String response = newRequest().setParam(SearchAction.PARAM_PROJECT_ID, DEFAULT_PROJECT_UUID).execute().outputAsString();
assertThat(response).contains("text-value-1", "text-value-2", "text-value-3");
}
Aggregations