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 ReturnEmptyCollectionRatherThanNull.
12   *
13   * @since 0.19
14   */
15  final class EmptyCollectionRuleTest {
16  
17      /**
18       * Makes sure that empty collections not returned as null.
19       *
20       * @throws Exception when something goes wrong
21       */
22      @Test
23      void failsForNullCollection() throws Exception {
24          new PmdAssert(
25              "NullCollection.java",
26              Matchers.is(false),
27              Matchers.containsString(
28                  "Return an empty collection rather than null. (ReturnEmptyCollectionRatherThanNull)"
29              )
30          ).assertOk();
31      }
32  }