|
| 1 | +/* |
| 2 | + * SonarQube Flex Plugin |
| 3 | + * Copyright (C) 2010-2024 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 GNU Lesser General Public |
| 8 | + * License as published by the Free Software Foundation; either |
| 9 | + * version 3 of the License, or (at your option) any later version. |
| 10 | + * |
| 11 | + * This program is distributed in the hope that it will be useful, |
| 12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | + * Lesser General Public License for more details. |
| 15 | + * |
| 16 | + * You should have received a copy of the GNU Lesser General Public License |
| 17 | + * along with this program; if not, write to the Free Software Foundation, |
| 18 | + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 19 | + */ |
| 20 | +package org.sonar.plugins.flex; |
| 21 | + |
| 22 | +import static org.assertj.core.api.Assertions.assertThat; |
| 23 | +import static org.assertj.core.api.Assertions.fail; |
| 24 | + |
| 25 | +import java.util.ArrayList; |
| 26 | +import java.util.List; |
| 27 | +import org.junit.jupiter.api.Test; |
| 28 | + |
| 29 | +class AnalysisWarningsWrapperTest { |
| 30 | + |
| 31 | + @Test |
| 32 | + void test() { |
| 33 | + List<String> warnings = new ArrayList<>(); |
| 34 | + AnalysisWarningsWrapper wrapper = new AnalysisWarningsWrapper(warnings::add); |
| 35 | + wrapper.addUnique("test"); |
| 36 | + assertThat(warnings).containsExactly("test"); |
| 37 | + } |
| 38 | + |
| 39 | + @Test |
| 40 | + void test_null() { |
| 41 | + try { |
| 42 | + AnalysisWarningsWrapper wrapper = new AnalysisWarningsWrapper(null); |
| 43 | + wrapper.addUnique("test"); |
| 44 | + } catch (Exception e) { |
| 45 | + fail("No exception should be thrown"); |
| 46 | + } |
| 47 | + } |
| 48 | +} |
0 commit comments