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.Matchers;
8   import org.junit.jupiter.api.Test;
9   
10  /**
11   * Test case for {@link PmdValidator}'s handling of the
12   * {@code ArrayIsStoredDirectly} rule, including the suppression
13   * when a varargs/array parameter is wrapped in a method call or
14   * constructor before assignment (issue #1053).
15   *
16   * @since 0.25.1
17   */
18  final class PmdArrayIsStoredDirectlyTest {
19  
20      @Test
21      void allowsArrayIsStoredDirectlyWhenWrapped() throws Exception {
22          new PmdAssert(
23              "ArrayIsStoredDirectlyWrapped.java",
24              Matchers.any(Boolean.class),
25              Matchers.not(
26                  Matchers.containsString("(ArrayIsStoredDirectly)")
27              )
28          ).assertOk();
29      }
30  
31      @Test
32      void reportsArrayIsStoredDirectlyWhenPlain() throws Exception {
33          new PmdAssert(
34              "ArrayIsStoredDirectlyPlain.java",
35              Matchers.is(false),
36              Matchers.containsString("(ArrayIsStoredDirectly)")
37          ).assertOk();
38      }
39  }