@Test
  public void testCreate() throws Exception {
    Configuration configuration = mock(Configuration.class);
    when(configuration.getProperty(eq(GeneralOption.SONAR_ENABLED))).thenReturn("true");

    ReviewProcessorFactory factory = new SonarReviewProcessorFactory();
    assertNotNull(factory.create(configuration));
  }
  @NotNull
  private GerritPatchset buildGerritPatchset(Configuration configuration) {
    String changeId = configuration.getProperty(CliOption.CHANGE_ID);
    String revisionId = configuration.getProperty(CliOption.REVISION_ID);

    notBlank(changeId, "You must provide non blank Gerrit change Id");
    notBlank(revisionId, "You must provide non blank Gerrit revision Id");

    return new GerritPatchset(changeId, revisionId);
  }
示例#3
0
 @NotNull
 public static List<ReviewProcessor> buildProcessors(Configuration configuration) {
   List<ReviewProcessor> processors = new ArrayList<>();
   if (Boolean.valueOf(configuration.getProperty(GeneralOption.CHECKSTYLE_ENABLED))) {
     processors.add(new CheckstyleProcessor(configuration));
   }
   if (Boolean.valueOf(configuration.getProperty(GeneralOption.PMD_ENABLED))) {
     processors.add(new PmdProcessor(configuration));
   }
   if (Boolean.valueOf(configuration.getProperty(GeneralOption.FINDBUGS_ENABLED))) {
     processors.add(new FindBugsProcessor(configuration));
   }
   if (Boolean.valueOf(configuration.getProperty(GeneralOption.SCALASTYLE_ENABLED))) {
     processors.add(new ScalastyleProcessor(configuration));
   }
   if (Boolean.valueOf(configuration.getProperty(GeneralOption.CODE_NARC_ENABLED))) {
     processors.add(new CodeNarcProcessor(configuration));
   }
   if (Boolean.valueOf(configuration.getProperty(GeneralOption.JSLINT_ENABLED))) {
     processors.add(new JsLintProcessor(configuration));
   }
   if (Boolean.valueOf(configuration.getProperty(GeneralOption.JSHINT_ENABLED))) {
     processors.add(new JsHintProcessor(configuration));
   }
   if (Boolean.valueOf(configuration.getProperty(GeneralOption.SONAR_ENABLED))) {
     processors.add(new SonarProcessor(configuration));
   }
   return processors;
 }
示例#4
0
  public static void main(String[] args) {
    printWelcomeMessage();
    CliWrapper cliWrapper = new CliWrapper();
    CommandLine commandLine = null;
    try {
      commandLine = cliWrapper.parse(args);
    } catch (ParseException e) {
      printUsage(cliWrapper);
      System.out.println(e.getMessage());
      System.exit(1);
    }

    Configuration configuration =
        ConfigurationBuilder.initFromFile(
            commandLine.getOptionValue(CliOption.CONF.getCommandLineParam()));
    configuration.updateWithCliOptions(commandLine);

    ConnectorFacade facade = getConnectorFacade(configuration);
    new Engine(facade, facade, configuration).run();
  }
示例#5
0
 private static ConnectorFacade getConnectorFacade(Configuration configuration) {
   ConnectorType connectorType =
       ConnectorType.getValidConnectorType(
           configuration.getProperty(GeneralOption.CONNECTOR_TYPE));
   ConnectorFacade facade = null;
   try {
     facade = ConnectorFacadeFactory.INSTANCE.build(connectorType, configuration);
     facade.validate(configuration);
   } catch (GeneralOptionNotSupportedException e) {
     System.out.println(e.getMessage());
     System.exit(2);
   }
   return facade;
 }