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   * @since 0.25.1
17   */
18  final class PmdUseStringIsEmptyNpeTest {
19  
20      @Test
21      void doesNotThrowNullPointerOnPatternMatching() {
22          Assertions.assertDoesNotThrow(
23              () -> new PmdAssert(
24                  "UseStringIsEmptyRuleFailsOnPatternMatching.java",
25                  new IsEqual<>(false),
26                  new StringContains("UnusedLocalVariable")
27              ).assertOk()
28          );
29      }
30  }