use of org.sonar.db.measure.custom.CustomMeasureDto in project sonarqube by SonarSource.
the class CustomMeasuresCopyStepTest method test_boolean_value_type.
@Test
public void test_boolean_value_type() throws Exception {
MetricImpl booleanMetric = new MetricImpl(1, "m", "M", Metric.MetricType.BOOL);
CustomMeasureDto dto = new CustomMeasureDto();
assertThat(dtoToMeasure(dto.setValue(1.0), booleanMetric).getBooleanValue()).isTrue();
assertThat(dtoToMeasure(dto.setValue(0.0), booleanMetric).getBooleanValue()).isFalse();
}
use of org.sonar.db.measure.custom.CustomMeasureDto in project sonarqube by SonarSource.
the class CustomMeasuresCopyStepTest method test_float_value_type.
@Test
public void test_float_value_type() throws Exception {
CustomMeasureDto dto = new CustomMeasureDto();
dto.setValue(10.0);
assertThat(dtoToMeasure(dto, new MetricImpl(1, "m", "M", Metric.MetricType.FLOAT)).getDoubleValue()).isEqualTo(10.0);
}
use of org.sonar.db.measure.custom.CustomMeasureDto in project sonarqube by SonarSource.
the class CustomMeasuresCopyStepTest method test_percent_value_type.
@Test
public void test_percent_value_type() throws Exception {
CustomMeasureDto dto = new CustomMeasureDto();
dto.setValue(10.0);
assertThat(dtoToMeasure(dto, new MetricImpl(1, "m", "M", Metric.MetricType.PERCENT)).getDoubleValue()).isEqualTo(10);
}
use of org.sonar.db.measure.custom.CustomMeasureDto in project sonarqube by SonarSource.
the class CustomMeasuresCopyStepTest method test_string_value_type.
@Test
public void test_string_value_type() throws Exception {
CustomMeasureDto dto = new CustomMeasureDto();
dto.setTextValue("foo");
assertThat(dtoToMeasure(dto, new MetricImpl(1, "m", "M", Metric.MetricType.STRING)).getStringValue()).isEqualTo("foo");
}
use of org.sonar.db.measure.custom.CustomMeasureDto in project sonarqube by SonarSource.
the class UpdateActionTest method update_description_only.
@Test
public void update_description_only() throws Exception {
MetricDto metric = insertNewMetric(ValueType.STRING);
OrganizationDto organizationDto = db.organizations().insert();
ComponentDto component = db.components().insertProject(organizationDto, "project-uuid");
CustomMeasureDto customMeasure = newCustomMeasure(component, metric).setMetricId(metric.getId()).setComponentUuid(component.uuid()).setCreatedAt(system.now()).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_VALUE, "new-text-measure-value").execute();
CustomMeasureDto updatedCustomMeasure = dbClient.customMeasureDao().selectOrFail(dbSession, customMeasure.getId());
assertThat(updatedCustomMeasure.getTextValue()).isEqualTo("new-text-measure-value");
assertThat(updatedCustomMeasure.getDescription()).isEqualTo("custom-measure-description");
assertThat(updatedCustomMeasure.getUpdatedAt()).isEqualTo(123_456_789L);
assertThat(customMeasure.getCreatedAt()).isEqualTo(updatedCustomMeasure.getCreatedAt());
}
Aggregations