@Before
  public void setUp() throws Exception {
    configuration = new AnalyzerConfigurationMock();

    checkStorage =
        new CheckStorage(
            new CheckFactory(configuration) {
              @Override
              public HashSet<Check> makeSingleChecks(final RuleInspector ruleInspector) {
                final HashSet<Check> result = new HashSet<>();
                result.add(new MockSingleCheck(ruleInspector));
                return result;
              }
            });

    ruleInspectors = new ArrayList<>();
    when(cache.all()).thenReturn(ruleInspectors);

    ruleInspector1 = mockRowInspector(1);
    ruleInspectors.add(ruleInspector1);
    ruleInspector2 = mockRowInspector(2);
    ruleInspectors.add(ruleInspector2);
    ruleInspector3 = mockRowInspector(3);
    ruleInspectors.add(ruleInspector3);

    checkRunManager.addChecks(ruleInspector1.getChecks());
    checkRunManager.addChecks(ruleInspector2.getChecks());
    checkRunManager.addChecks(ruleInspector3.getChecks());
  }
  @Test
  public void testRemove() throws Exception {

    this.checkRunManager.remove(ruleInspector2);

    final Set<Check> checks = ruleInspector1.getChecks();
    assertEquals(3, checks.size());
    assertTrue(ruleInspector2.getChecks().isEmpty());
    assertEquals(3, ruleInspector3.getChecks().size());
  }
  @Test
  public void testOnlyTestChanges() throws Exception {
    // First run
    this.checkRunManager.run(null, null);

    RuleInspector newRuleInspector = mockRowInspector(3);
    ruleInspectors.add(newRuleInspector);

    this.checkRunManager.addChecks(newRuleInspector.getChecks());

    assertNoIssues(newRuleInspector);

    // Second run
    this.checkRunManager.run(null, null);

    assertHasIssues(newRuleInspector);

    assertEquals(7, ruleInspector1.getChecks().size());
    assertEquals(7, newRuleInspector.getChecks().size());
  }
 @Test
 public void testChecksGetGenerated() throws Exception {
   assertEquals(5, ruleInspector1.getChecks().size());
   assertEquals(5, ruleInspector2.getChecks().size());
   assertEquals(5, ruleInspector3.getChecks().size());
 }
 private void assertNoIssues(final RuleInspector ruleInspector) {
   for (Check check : (ruleInspector.getChecks())) {
     assertFalse(check.hasIssues());
   }
 }
 private void assertHasIssues(final RuleInspector ruleInspector) {
   for (Check check : ruleInspector.getChecks()) {
     assertTrue(check.hasIssues());
   }
 }