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   * @since 0.25.1
16   */
17  final class PmdArrayIsStoredDirectlyTest {
18  
19      @Test
20      void allowsArrayIsStoredDirectlyWhenWrapped() throws Exception {
21          new PmdAssert(
22              "ArrayIsStoredDirectlyWrapped.java",
23              Matchers.any(Boolean.class),
24              Matchers.not(
25                  Matchers.containsString("(ArrayIsStoredDirectly)")
26              )
27          ).assertOk();
28      }
29  
30      @Test
31      void reportsArrayIsStoredDirectlyWhenPlain() throws Exception {
32          new PmdAssert(
33              "ArrayIsStoredDirectlyPlain.java",
34              Matchers.is(false),
35              Matchers.containsString("(ArrayIsStoredDirectly)")
36          ).assertOk();
37      }
38  }