View Javadoc
1   /*
2    * SPDX-FileCopyrightText: Copyright (c) 2011-2026 Yegor Bugayenko
3    * SPDX-License-Identifier: MIT
4    */
5   package com.qulice.pmd;
6   
7   import org.hamcrest.core.IsEqual;
8   import org.hamcrest.core.StringContains;
9   import org.junit.jupiter.api.Assertions;
10  import org.junit.jupiter.api.Test;
11  
12  /**
13   * Regression test for {@link UseStringIsEmptyRule}: the rule
14   * must not throw a {@code NullPointerException} when it
15   * encounters a pattern-matching expression.
16   *
17   * @since 0.25.1
18   */
19  final class PmdUseStringIsEmptyNpeTest {
20  
21      @Test
22      void doesNotThrowNullPointerOnPatternMatching() {
23          Assertions.assertDoesNotThrow(
24              () -> new PmdAssert(
25                  "UseStringIsEmptyRuleFailsOnPatternMatching.java",
26                  new IsEqual<>(false),
27                  new StringContains("UnusedLocalVariable")
28              ).assertOk()
29          );
30      }
31  }