Search in sources :

Example 46 with LiveMeasureDto

use of org.sonar.db.measure.LiveMeasureDto in project sonarqube by SonarSource.

the class MeasureMatrixTest method setValue_String_does_nothing_if_value_is_not_changed.

@Test
public void setValue_String_does_nothing_if_value_is_not_changed() {
    LiveMeasureDto measure = newMeasure(METRIC_1, PROJECT).setData("foo");
    MeasureMatrix underTest = new MeasureMatrix(asList(PROJECT, FILE), asList(METRIC_1), asList(measure));
    underTest.setValue(PROJECT, METRIC_1.getKey(), "foo");
    assertThat(underTest.getMeasure(PROJECT, METRIC_1.getKey()).get().getDataAsString()).isEqualTo("foo");
    assertThat(underTest.getChanged()).isEmpty();
}
Also used : LiveMeasureDto(org.sonar.db.measure.LiveMeasureDto) Test(org.junit.Test)

Example 47 with LiveMeasureDto

use of org.sonar.db.measure.LiveMeasureDto in project sonarqube by SonarSource.

the class MeasureMatrixTest method getValue_returns_empty_if_measure_is_absent.

@Test
public void getValue_returns_empty_if_measure_is_absent() {
    MetricDto metric = newMetricDto();
    LiveMeasureDto measure = newMeasure(metric, PROJECT).setValue(null);
    MeasureMatrix underTest = new MeasureMatrix(asList(PROJECT), asList(metric), asList(measure));
    assertThat(underTest.getMeasure(FILE, metric.getKey())).isEmpty();
}
Also used : MetricTesting.newMetricDto(org.sonar.db.metric.MetricTesting.newMetricDto) MetricDto(org.sonar.db.metric.MetricDto) LiveMeasureDto(org.sonar.db.measure.LiveMeasureDto) Test(org.junit.Test)

Example 48 with LiveMeasureDto

use of org.sonar.db.measure.LiveMeasureDto in project sonarqube by SonarSource.

the class MeasureMatrixTest method setValue_String_updates_value.

@Test
public void setValue_String_updates_value() {
    LiveMeasureDto measure = newMeasure(METRIC_1, PROJECT).setData("foo");
    MeasureMatrix underTest = new MeasureMatrix(asList(PROJECT, FILE), asList(METRIC_1), asList(measure));
    underTest.setValue(PROJECT, METRIC_1.getKey(), "bar");
    assertThat(underTest.getMeasure(PROJECT, METRIC_1.getKey()).get().getDataAsString()).isEqualTo("bar");
    assertThat(underTest.getChanged()).extracting(LiveMeasureDto::getDataAsString).containsExactly("bar");
}
Also used : LiveMeasureDto(org.sonar.db.measure.LiveMeasureDto) Test(org.junit.Test)

Aggregations

LiveMeasureDto (org.sonar.db.measure.LiveMeasureDto)48 Test (org.junit.Test)29 MetricDto (org.sonar.db.metric.MetricDto)26 ComponentDto (org.sonar.db.component.ComponentDto)15 SnapshotDto (org.sonar.db.component.SnapshotDto)10 MetricTesting.newMetricDto (org.sonar.db.metric.MetricTesting.newMetricDto)9 UserRole (org.sonar.api.web.UserRole)8 DbSession (org.sonar.db.DbSession)8 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)7 Assertions.tuple (org.assertj.core.api.Assertions.tuple)7 ForbiddenException (org.sonar.server.exceptions.ForbiddenException)7 NotFoundException (org.sonar.server.exceptions.NotFoundException)7 Common (org.sonarqube.ws.Common)7 Double.parseDouble (java.lang.Double.parseDouble)6 String.format (java.lang.String.format)6 Map (java.util.Map)6 Assertions.assertThatThrownBy (org.assertj.core.api.Assertions.assertThatThrownBy)6 Rule (org.junit.Rule)6 Param (org.sonar.api.server.ws.WebService.Param)6 DbClient (org.sonar.db.DbClient)6