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