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 CompareObjectsWithEquals} rule.
13   *
14   * @since 1.0
15   */
16  final class PmdCompareObjectsWithEqualsTest {
17  
18      @Test
19      void allowsComparingFuturesByReference() throws Exception {
20          new PmdAssert(
21              "CompareFuturesWithEquals.java",
22              Matchers.any(Boolean.class),
23              Matchers.not(
24                  Matchers.containsString("(CompareObjectsWithEquals)")
25              )
26          ).assertOk();
27      }
28  
29      @Test
30      void forbidsComparingPlainObjectsByReference() throws Exception {
31          new PmdAssert(
32              "CompareObjectsByReference.java",
33              Matchers.is(false),
34              Matchers.containsString("(CompareObjectsWithEquals)")
35          ).assertOk();
36      }
37  }