View Javadoc
1   /*
2    * SPDX-FileCopyrightText: Copyright (c) 2011-2026 Yegor Bugayenko
3    * SPDX-License-Identifier: MIT
4    */
5   package com.qulice.maven;
6   
7   import com.qulice.spi.ResourceValidator;
8   import com.qulice.spi.Violation;
9   import java.io.File;
10  import java.util.Collection;
11  import java.util.Collections;
12  import java.util.concurrent.atomic.AtomicInteger;
13  
14  /**
15   * A test fake {@link ResourceValidator} that records how many times
16   * {@code validate} was invoked and reports a configurable name through
17   * {@link #name()}. The validate call always returns an empty
18   * collection, so {@code CheckMojo} treats the run as clean.
19   * @since 0.27.0
20   */
21  final class FakeResourceValidator implements ResourceValidator {
22  
23      /**
24       * Resource validator name.
25       */
26      private final String label;
27  
28      /**
29       * Method calls counter.
30       */
31      private final AtomicInteger cnt;
32  
33      FakeResourceValidator(final String name) {
34          this.label = name;
35          this.cnt = new AtomicInteger(0);
36      }
37  
38      @Override
39      public Collection<Violation> validate(final Collection<File> files) {
40          this.cnt.incrementAndGet();
41          return Collections.emptyList();
42      }
43  
44      @Override
45      public String name() {
46          return this.label;
47      }
48  
49      int count() {
50          return this.cnt.get();
51      }
52  }