From d8ebc8fbb62dad04ed4f665379bd80c4d7d88dc2 Mon Sep 17 00:00:00 2001 From: Eric Giffon Date: Tue, 27 Aug 2024 13:40:14 +0200 Subject: SONAR-22874 Rename Measure classes to ProjectMeasure --- .../java/org/sonar/db/measure/MeasureDtoTest.java | 49 ------------------- .../org/sonar/db/measure/PastMeasureDtoTest.java | 57 ---------------------- .../sonar/db/measure/ProjectMeasureDtoTest.java | 49 +++++++++++++++++++ 3 files changed, 49 insertions(+), 106 deletions(-) delete mode 100644 server/sonar-db-dao/src/test/java/org/sonar/db/measure/MeasureDtoTest.java delete mode 100644 server/sonar-db-dao/src/test/java/org/sonar/db/measure/PastMeasureDtoTest.java create mode 100644 server/sonar-db-dao/src/test/java/org/sonar/db/measure/ProjectMeasureDtoTest.java (limited to 'server/sonar-db-dao/src/test') diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/measure/MeasureDtoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/measure/MeasureDtoTest.java deleted file mode 100644 index ef88cb24f84..00000000000 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/measure/MeasureDtoTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2024 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.db.measure; - -import com.google.common.base.Strings; -import org.junit.jupiter.api.Test; - -import static org.assertj.core.api.Assertions.assertThat; - -class MeasureDtoTest { - - MeasureDto underTest = new MeasureDto(); - - @Test - void test_getter_and_setter() { - underTest - .setValue(2d) - .setData("text value"); - assertThat(underTest.getValue()).isEqualTo(2d); - assertThat(underTest.getData()).isNotNull(); - } - - @Test - void value_with_text_over_4000_characters() { - assertThat(underTest.setData(Strings.repeat("1", 4001)).getData()).isNotNull(); - } - - @Test - void text_value_under_4000_characters() { - assertThat(underTest.setData("text value").getData()).isEqualTo("text value"); - } -} diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/measure/PastMeasureDtoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/measure/PastMeasureDtoTest.java deleted file mode 100644 index 99d153add58..00000000000 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/measure/PastMeasureDtoTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2024 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.db.measure; - -import org.junit.jupiter.api.Test; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -class PastMeasureDtoTest { - - @Test - void test_getter_and_setter() { - PastMeasureDto dto = new PastMeasureDto() - .setValue(1d) - .setMetricUuid("2"); - - assertThat(dto.hasValue()).isTrue(); - assertThat(dto.getValue()).isEqualTo(1d); - assertThat(dto.getMetricUuid()).isEqualTo("2"); - } - - @Test - void test_has_value() { - PastMeasureDto measureWithValue = new PastMeasureDto() - .setValue(1d) - .setMetricUuid("2"); - assertThat(measureWithValue.hasValue()).isTrue(); - - PastMeasureDto measureWithoutValue = new PastMeasureDto() - .setMetricUuid("2"); - assertThat(measureWithoutValue.hasValue()).isFalse(); - } - - @Test - void get_value_throw_a_NPE_if_value_is_null() { - assertThatThrownBy(() -> new PastMeasureDto().getValue()) - .isInstanceOf(NullPointerException.class); - } -} diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/measure/ProjectMeasureDtoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/measure/ProjectMeasureDtoTest.java new file mode 100644 index 00000000000..8c28c8c9d8e --- /dev/null +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/measure/ProjectMeasureDtoTest.java @@ -0,0 +1,49 @@ +/* + * SonarQube + * Copyright (C) 2009-2024 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.db.measure; + +import com.google.common.base.Strings; +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +class ProjectMeasureDtoTest { + + ProjectMeasureDto underTest = new ProjectMeasureDto(); + + @Test + void test_getter_and_setter() { + underTest + .setValue(2d) + .setData("text value"); + assertThat(underTest.getValue()).isEqualTo(2d); + assertThat(underTest.getData()).isNotNull(); + } + + @Test + void value_with_text_over_4000_characters() { + assertThat(underTest.setData(Strings.repeat("1", 4001)).getData()).isNotNull(); + } + + @Test + void text_value_under_4000_characters() { + assertThat(underTest.setData("text value").getData()).isEqualTo("text value"); + } +} -- cgit v1.2.3