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