|
1 | | -/* |
2 | | - * SonarQube Java |
3 | | - * Copyright (C) 2012-2025 SonarSource SA |
4 | | - * mailto:info AT sonarsource DOT com |
5 | | - * |
6 | | - * This program is free software; you can redistribute it and/or |
7 | | - * modify it under the terms of the Sonar Source-Available License Version 1, as published by SonarSource SA. |
8 | | - * |
9 | | - * This program is distributed in the hope that it will be useful, |
10 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
12 | | - * See the Sonar Source-Available License for more details. |
13 | | - * |
14 | | - * You should have received a copy of the Sonar Source-Available License |
15 | | - * along with this program; if not, see https://sonarsource.com/license/ssal/ |
16 | | - */ |
17 | | -package org.sonar.java.utils; |
18 | | - |
19 | | -import org.junit.jupiter.api.Test; |
20 | | - |
21 | | -import static org.assertj.core.api.Assertions.assertThat; |
22 | | -import static org.junit.jupiter.api.Assertions.assertNull; |
23 | | -import static org.junit.jupiter.api.Assertions.assertSame; |
24 | | -import static org.sonar.java.TestUtils.mockProjectDefinition; |
25 | | - |
26 | | -class ModuleMetadataUtilsTest { |
27 | | - |
28 | | - @Test |
29 | | - void getModuleKey() { |
30 | | - var projectDefinition = mockProjectDefinition(); |
31 | | - assertThat(ModuleMetadataUtils.getModuleKey(projectDefinition)).isEqualTo("pmodule/cmodule"); |
32 | | - assertThat(ModuleMetadataUtils.getModuleKey(null)).isEmpty(); |
33 | | - } |
34 | | - |
35 | | - @Test |
36 | | - void getRootProject() { |
37 | | - var projectDefinition = mockProjectDefinition(); |
38 | | - assertSame(ModuleMetadataUtils.getRootProject(projectDefinition), ModuleMetadataUtils.getRootProject(projectDefinition.getParent())); |
39 | | - assertNull(ModuleMetadataUtils.getRootProject(null)); |
40 | | - } |
41 | | -} |
| 1 | +/* |
| 2 | + * SonarQube Java |
| 3 | + * Copyright (C) 2012-2025 SonarSource Sàrl |
| 4 | + * mailto:info AT sonarsource DOT com |
| 5 | + * |
| 6 | + * This program is free software; you can redistribute it and/or |
| 7 | + * modify it under the terms of the Sonar Source-Available License Version 1, as published by SonarSource SA. |
| 8 | + * |
| 9 | + * This program is distributed in the hope that it will be useful, |
| 10 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 12 | + * See the Sonar Source-Available License for more details. |
| 13 | + * |
| 14 | + * You should have received a copy of the Sonar Source-Available License |
| 15 | + * along with this program; if not, see https://sonarsource.com/license/ssal/ |
| 16 | + */ |
| 17 | +package org.sonar.java.utils; |
| 18 | + |
| 19 | +import org.junit.jupiter.api.Test; |
| 20 | + |
| 21 | +import static org.assertj.core.api.Assertions.assertThat; |
| 22 | +import static org.junit.jupiter.api.Assertions.assertNull; |
| 23 | +import static org.junit.jupiter.api.Assertions.assertSame; |
| 24 | +import static org.sonar.java.TestUtils.mockProjectDefinition; |
| 25 | + |
| 26 | +class ModuleMetadataUtilsTest { |
| 27 | + |
| 28 | + @Test |
| 29 | + void getModuleKey() { |
| 30 | + var projectDefinition = mockProjectDefinition(); |
| 31 | + assertThat(ModuleMetadataUtils.getModuleKey(projectDefinition)).isEqualTo("pmodule/cmodule"); |
| 32 | + assertThat(ModuleMetadataUtils.getModuleKey(null)).isEmpty(); |
| 33 | + } |
| 34 | + |
| 35 | + @Test |
| 36 | + void getRootProject() { |
| 37 | + var projectDefinition = mockProjectDefinition(); |
| 38 | + assertSame(ModuleMetadataUtils.getRootProject(projectDefinition), ModuleMetadataUtils.getRootProject(projectDefinition.getParent())); |
| 39 | + assertNull(ModuleMetadataUtils.getRootProject(null)); |
| 40 | + } |
| 41 | +} |
0 commit comments