use of org.sonar.db.measure.custom.CustomMeasureDto in project sonarqube by SonarSource.
the class CreateActionTest method create_text_custom_measure_as_project_admin.
@Test
public void create_text_custom_measure_as_project_admin() throws Exception {
insertProject(DEFAULT_PROJECT_UUID);
MetricDto metric = insertMetric(STRING);
userSession.logIn("login").addProjectUuidPermissions(UserRole.ADMIN, DEFAULT_PROJECT_UUID);
newRequest().setParam(CreateAction.PARAM_PROJECT_ID, DEFAULT_PROJECT_UUID).setParam(CreateAction.PARAM_METRIC_ID, metric.getId().toString()).setParam(CreateAction.PARAM_VALUE, "custom-measure-free-text").execute();
CustomMeasureDto customMeasure = dbClient.customMeasureDao().selectByMetricId(dbSession, metric.getId()).get(0);
assertThat(customMeasure).isNotNull();
}
use of org.sonar.db.measure.custom.CustomMeasureDto in project sonarqube by SonarSource.
the class CreateActionTest method create_int_custom_measure_in_db.
@Test
public void create_int_custom_measure_in_db() throws Exception {
insertProject(DEFAULT_PROJECT_UUID);
MetricDto metric = insertMetric(INT);
newRequest().setParam(CreateAction.PARAM_PROJECT_ID, DEFAULT_PROJECT_UUID).setParam(CreateAction.PARAM_METRIC_ID, metric.getId().toString()).setParam(CreateAction.PARAM_VALUE, "42").execute();
CustomMeasureDto customMeasure = dbClient.customMeasureDao().selectByMetricId(dbSession, metric.getId()).get(0);
assertThat(customMeasure.getTextValue()).isNullOrEmpty();
assertThat(customMeasure.getValue()).isCloseTo(42.0d, offset(0.01d));
}
use of org.sonar.db.measure.custom.CustomMeasureDto in project sonarqube by SonarSource.
the class CreateActionTest method create_text_custom_measure_with_project_key.
@Test
public void create_text_custom_measure_with_project_key() throws Exception {
insertProject(DEFAULT_PROJECT_UUID);
MetricDto metric = insertMetric(STRING);
newRequest().setParam(CreateAction.PARAM_PROJECT_KEY, DEFAULT_PROJECT_KEY).setParam(CreateAction.PARAM_METRIC_ID, metric.getId().toString()).setParam(CreateAction.PARAM_VALUE, "whatever-value").execute();
CustomMeasureDto customMeasure = dbClient.customMeasureDao().selectByMetricId(dbSession, metric.getId()).get(0);
assertThat(customMeasure).isNotNull();
}
use of org.sonar.db.measure.custom.CustomMeasureDto in project sonarqube by SonarSource.
the class CreateActionTest method create_work_duration_custom_measure_in_db.
@Test
public void create_work_duration_custom_measure_in_db() throws Exception {
insertProject(DEFAULT_PROJECT_UUID);
MetricDto metric = insertMetric(WORK_DUR);
newRequest().setParam(CreateAction.PARAM_PROJECT_ID, DEFAULT_PROJECT_UUID).setParam(CreateAction.PARAM_METRIC_ID, metric.getId().toString()).setParam(CreateAction.PARAM_VALUE, "253").execute();
CustomMeasureDto customMeasure = dbClient.customMeasureDao().selectByMetricId(dbSession, metric.getId()).get(0);
assertThat(customMeasure.getTextValue()).isNullOrEmpty();
assertThat(customMeasure.getValue()).isCloseTo(253, offset(0.01d));
}
use of org.sonar.db.measure.custom.CustomMeasureDto in project sonarqube by SonarSource.
the class CreateActionTest method create_custom_measure_on_a_view.
@Test
public void create_custom_measure_on_a_view() throws Exception {
String viewUuid = "VIEW_UUID";
dbClient.componentDao().insert(dbSession, ComponentTesting.newView(db.organizations().insert(), viewUuid));
dbSession.commit();
MetricDto metric = insertMetric(BOOL);
userSession.logIn("login").addProjectUuidPermissions(UserRole.ADMIN, viewUuid);
newRequest().setParam(CreateAction.PARAM_PROJECT_ID, viewUuid).setParam(CreateAction.PARAM_METRIC_ID, metric.getId().toString()).setParam(CreateAction.PARAM_DESCRIPTION, "custom-measure-description").setParam(CreateAction.PARAM_VALUE, "true").execute();
List<CustomMeasureDto> customMeasures = dbClient.customMeasureDao().selectByMetricId(dbSession, metric.getId());
CustomMeasureDto customMeasure = customMeasures.get(0);
assertThat(customMeasures).hasSize(1);
assertThat(customMeasure.getComponentUuid()).isEqualTo(viewUuid);
}
Aggregations