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   *
15   * @since 0.27.0
16   */
17  final class FakeMavenValidator implements MavenValidator {
18  
19      /**
20       * Method calls counter.
21       */
22      private final AtomicInteger cnt;
23  
24      FakeMavenValidator() {
25          this.cnt = new AtomicInteger(0);
26      }
27  
28      @Override
29      public void validate(final MavenEnvironment env) {
30          this.cnt.incrementAndGet();
31      }
32  
33      int count() {
34          return this.cnt.get();
35      }
36  }