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 java.util.concurrent.atomic.AtomicInteger;
8   
9   /**
10   * A test fake {@link MavenValidator} that records how many times its
11   * {@code validate(MavenEnvironment)} entry point was invoked, so tests
12   * can assert that {@code CheckMojo} drove every internal validator
13   * exactly once.
14   * @since 0.27.0
15   */
16  final class FakeMavenValidator implements MavenValidator {
17  
18      /**
19       * Method calls counter.
20       */
21      private final AtomicInteger cnt;
22  
23      FakeMavenValidator() {
24          this.cnt = new AtomicInteger(0);
25      }
26  
27      @Override
28      public void validate(final MavenEnvironment env) {
29          this.cnt.incrementAndGet();
30      }
31  
32      int count() {
33          return this.cnt.get();
34      }
35  }