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 * 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 ).validate();
29 }
30 }