/** Decide if the given Sensor should be executed. */
 public boolean shouldExecute(DefaultSensorDescriptor descriptor) {
   if (!fsCondition(descriptor)) {
     LOG.debug(
         "'{}' skipped because there is no related file in current project", descriptor.name());
     return false;
   }
   if (!activeRulesCondition(descriptor)) {
     LOG.debug(
         "'{}' skipped because there is no related rule activated in the quality profile",
         descriptor.name());
     return false;
   }
   if (!settingsCondition(descriptor)) {
     LOG.debug(
         "'{}' skipped because one of the required properties is missing", descriptor.name());
     return false;
   }
   if (descriptor.isDisabledInPreview() && analysisMode.isPreview()) {
     LOG.debug("'{}' skipped in preview mode", descriptor.name());
     return false;
   }
   if (descriptor.isDisabledInIssues() && analysisMode.isIssues()) {
     LOG.debug("'{}' skipped in issues mode", descriptor.name());
     return false;
   }
   return true;
 }
 @Test
 public void no_cache_by_default_in_issues_mode() {
   when(mode.isIssues()).thenReturn(true);
   WSLoader loader =
       underTest.provide(
           mode, cache, wsClient, new AnalysisProperties(Maps.<String, String>newHashMap()));
   assertThat(loader.getDefaultStrategy()).isEqualTo(LoadStrategy.SERVER_ONLY);
 }
 @Override
 public HighlightingBuilder newHighlighting() {
   if (analysisMode.isIssues()) {
     return NO_OP_BUILDER;
   }
   DefaultHighlighting defaultHighlighting = new DefaultHighlighting(sensorStorage);
   defaultHighlighting.onFile(inputFile);
   return new DefaultHighlightingBuilder(defaultHighlighting);
 }
  @Test
  public void should_disabled_in_issues_mode() {
    DefaultSensorDescriptor descriptor = new DefaultSensorDescriptor().disabledInIssues();
    assertThat(optimizer.shouldExecute(descriptor)).isTrue();

    when(analysisMode.isIssues()).thenReturn(true);

    assertThat(optimizer.shouldExecute(descriptor)).isFalse();
  }
 @Test
 public void enable_cache_in_issues_mode() {
   when(mode.isIssues()).thenReturn(true);
   WSLoader loader =
       underTest.provide(
           mode,
           cache,
           wsClient,
           new AnalysisProperties(
               ImmutableMap.of(AnalysisWSLoaderProvider.SONAR_USE_WS_CACHE, "true")));
   assertThat(loader.getDefaultStrategy()).isEqualTo(LoadStrategy.CACHE_ONLY);
 }
 private static void prepareNonAssociatedProject(Map<String, String> props, AnalysisMode mode) {
   if (mode.isIssues() && !props.containsKey(CoreProperties.PROJECT_KEY_PROPERTY)) {
     props.put(CoreProperties.PROJECT_KEY_PROPERTY, NON_ASSOCIATED_PROJECT_KEY);
   }
 }