use of org.sonar.db.measure.custom.CustomMeasureDto in project sonarqube by SonarSource.
the class DeleteActionTest method insertCustomMeasure.
private long insertCustomMeasure(ComponentDto component) {
CustomMeasureDto dto = newCustomMeasureDto().setComponentUuid(component.uuid());
dbClient.customMeasureDao().insert(dbSession, dto);
dbSession.commit();
return dto.getId();
}
use of org.sonar.db.measure.custom.CustomMeasureDto 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.measure.custom.CustomMeasureDto in project sonarqube by SonarSource.
the class SearchActionTest method insertCustomMeasure.
private CustomMeasureDto insertCustomMeasure(int id, MetricDto metric) {
CustomMeasureDto customMeasure = newCustomMeasure(id, metric);
dbClient.customMeasureDao().insert(dbSession, customMeasure);
dbSession.commit();
return customMeasure;
}
use of org.sonar.db.measure.custom.CustomMeasureDto in project sonarqube by SonarSource.
the class SearchActionTest method json_well_formatted.
@Test
public void json_well_formatted() throws Exception {
MetricDto metric1 = insertCustomMetric(1);
MetricDto metric2 = insertCustomMetric(2);
MetricDto metric3 = insertCustomMetric(3);
CustomMeasureDto customMeasure1 = insertCustomMeasure(1, metric1);
CustomMeasureDto customMeasure2 = insertCustomMeasure(2, metric2);
CustomMeasureDto customMeasure3 = insertCustomMeasure(3, metric3);
WsTester.Result response = newRequest().setParam(SearchAction.PARAM_PROJECT_ID, DEFAULT_PROJECT_UUID).execute();
response.assertJson(getClass(), "custom-measures.json");
String responseAsString = response.outputAsString();
assertThat(responseAsString).matches(nameStringValuePattern("id", metric1.getId().toString()));
assertThat(responseAsString).matches(nameStringValuePattern("id", metric2.getId().toString()));
assertThat(responseAsString).matches(nameStringValuePattern("id", metric3.getId().toString()));
assertThat(responseAsString).matches(nameStringValuePattern("id", String.valueOf(customMeasure1.getId())));
assertThat(responseAsString).matches(nameStringValuePattern("id", String.valueOf(customMeasure2.getId())));
assertThat(responseAsString).matches(nameStringValuePattern("id", String.valueOf(customMeasure3.getId())));
assertThat(responseAsString).contains("createdAt", "updatedAt");
}
use of org.sonar.db.measure.custom.CustomMeasureDto in project sonarqube by SonarSource.
the class CreateActionTest method response_with_object_and_id.
@Test
public void response_with_object_and_id() throws Exception {
insertProject(DEFAULT_PROJECT_UUID);
MetricDto metric = insertMetric(STRING);
WsTester.Result response = newRequest().setParam(CreateAction.PARAM_PROJECT_ID, DEFAULT_PROJECT_UUID).setParam(CreateAction.PARAM_METRIC_ID, metric.getId().toString()).setParam(CreateAction.PARAM_DESCRIPTION, "custom-measure-description").setParam(CreateAction.PARAM_VALUE, "custom-measure-free-text").execute();
CustomMeasureDto customMeasure = dbClient.customMeasureDao().selectByMetricId(dbSession, metric.getId()).get(0);
response.assertJson(getClass(), "custom-measure.json");
assertThat(response.outputAsString()).matches(String.format(".*\"id\"\\s*:\\s*\"%d\".*", customMeasure.getId()));
assertThat(response.outputAsString()).matches(String.format(".*\"id\"\\s*:\\s*\"%d\".*", metric.getId()));
}
Aggregations