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 PMD's
12   * clone-method rules: {@code CloneMethodMustBePublic} and
13   * {@code CloneMethodReturnTypeMustMatchClassName}.
14   * @since 0.25.1
15   */
16  final class PmdCloneMethodTest {
17  
18      @Test
19      void forbidsNonPublicCloneMethod() throws Exception {
20          new PmdAssert(
21              "CloneMethodMustBePublic.java",
22              Matchers.is(false),
23              Matchers.containsString("(CloneMethodMustBePublic)")
24          ).assertOk();
25      }
26  
27      @Test
28      void forbidsCloneMethodReturnTypeNotMatchingClassName() throws Exception {
29          new PmdAssert(
30              "CloneMethodReturnTypeMustMatchClassName.java",
31              Matchers.is(false),
32              Matchers.containsString("(CloneMethodReturnTypeMustMatchClassName)")
33          ).assertOk();
34      }
35  }