Package org.sonar.batch.protocol.input

Examples of org.sonar.batch.protocol.input.ProjectReferentials


      LOG.warn("Ability to set quality profile from command line using '" + ModuleQProfiles.SONAR_PROFILE_PROP
        + "' is deprecated and will be dropped in a future SonarQube version. Please configure quality profile used by your project on SonarQube server.");
      url += "&profile=" + ServerClient.encodeForUrl(taskProperties.properties().get(ModuleQProfiles.SONAR_PROFILE_PROP));
    }
    url += "&preview=" + analysisMode.isPreview();
    ProjectReferentials ref = ProjectReferentials.fromJson(serverClient.request(url));

    for (ProjectDefinition module : reactor.getProjects()) {

      for (Map.Entry<String, String> hashByPaths : hashByRelativePath(module.getKeyWithBranch()).entrySet()) {
        String path = hashByPaths.getKey();
        String hash = hashByPaths.getValue();
        String lastCommits = null;
        String revisions = null;
        String authors = null;
        List<Object[]> measuresByKey = query(projectKey + ":" + path, CoreMetrics.SCM_LAST_COMMIT_DATETIMES_BY_LINE_KEY, CoreMetrics.SCM_REVISIONS_BY_LINE_KEY,
          CoreMetrics.SCM_AUTHORS_BY_LINE_KEY);
        for (Object[] measureByKey : measuresByKey) {
          if (measureByKey[0].equals(CoreMetrics.SCM_LAST_COMMIT_DATETIMES_BY_LINE_KEY)) {
            lastCommits = ((MeasureModel) measureByKey[1]).getData(CoreMetrics.SCM_LAST_COMMIT_DATETIMES_BY_LINE);
          } else if (measureByKey[0].equals(CoreMetrics.SCM_REVISIONS_BY_LINE_KEY)) {
            revisions = ((MeasureModel) measureByKey[1]).getData(CoreMetrics.SCM_REVISIONS_BY_LINE);
          } else if (measureByKey[0].equals(CoreMetrics.SCM_AUTHORS_BY_LINE_KEY)) {
            authors = ((MeasureModel) measureByKey[1]).getData(CoreMetrics.SCM_AUTHORS_BY_LINE);
          }
        }
        ref.addFileData(module.getKeyWithBranch(), path, new FileData(hash, lastCommits, revisions, authors));
      }
    }
    ref.setLastAnalysisDate(lastSnapshotCreationDate(projectKey));
    return ref;
  }
View Full Code Here


import static org.fest.assertions.Assertions.assertThat;

public class StatusDetectionTest {
  @Test
  public void detect_status() throws Exception {
    ProjectReferentials ref = new ProjectReferentials();
    ref.addFileData("foo", "src/Foo.java", new FileData("ABCDE", null, null, null));
    ref.addFileData("foo", "src/Bar.java", new FileData("FGHIJ", null, null, null));
    StatusDetection statusDetection = new StatusDetection(ref);

    assertThat(statusDetection.status("foo", "src/Foo.java", "ABCDE")).isEqualTo(InputFile.Status.SAME);
    assertThat(statusDetection.status("foo", "src/Foo.java", "XXXXX")).isEqualTo(InputFile.Status.CHANGED);
    assertThat(statusDetection.status("foo", "src/Other.java", "QWERT")).isEqualTo(InputFile.Status.ADDED);
View Full Code Here

  }

  private ComponentIndexer createIndexer(Languages languages) {
    SnapshotCache snapshotCache = new SnapshotCache();
    snapshotCache.put("myProject", mock(Snapshot.class));
    ComponentIndexer indexer = new ComponentIndexer(project, languages, sonarIndex, mock(ResourceKeyMigration.class), sourcePersister, new ProjectReferentials(),
      snapshotCache);
    return indexer;
  }
View Full Code Here

  ProjectReferentials projectRef;
  private AnalysisMode mode;

  @Before
  public void before() {
    projectRef = new ProjectReferentials();
    mode = mock(AnalysisMode.class);
  }
View Full Code Here

  private AnalysisMode mode;

  @Before
  public void prepare() {
    projectRef = new ProjectReferentials();
    mode = mock(AnalysisMode.class);
    bootstrapProps = new GlobalSettings(new BootstrapProperties(Collections.<String, String>emptyMap()), new PropertyDefinitions(), new GlobalReferentials(), mode);
  }
View Full Code Here

    settings = new GlobalSettings(bootstrapProperties, new PropertyDefinitions(), globalRef, analysisMode);
    parentContainer.add(settings);
    ProjectReferentialsLoader projectReferentialsLoader = new ProjectReferentialsLoader() {
      @Override
      public ProjectReferentials load(ProjectReactor reactor, TaskProperties taskProperties) {
        return new ProjectReferentials();
      }
    };
    parentContainer.add(projectReferentialsLoader);
    parentContainer.add(mock(TaskProperties.class));
    container = new ProjectScanContainer(parentContainer);
View Full Code Here

    boolean preview = request.mandatoryParamAsBoolean(PARAM_PREVIEW);
    checkPermission(preview);

    DbSession session = dbClient.openSession(false);
    try {
      ProjectReferentials ref = new ProjectReferentials();

      String projectOrModuleKey = request.mandatoryParam(PARAM_KEY);
      String profileName = request.param(PARAM_PROFILE);

      String projectKey = null;
      ComponentDto module = dbClient.componentDao().getNullableByKey(session, projectOrModuleKey);
      // Current project can be null when analysing a new project
      if (module != null) {
        ComponentDto project = dbClient.componentDao().getNullableRootProjectByKey(projectOrModuleKey, session);
        // Can be null if the given project is a provisioned one
        if (project != null) {
          if (!project.key().equals(module.key())) {
            addSettings(ref, module.getKey(), getSettingsFromParents(module.key(), hasScanPerm, session));
          }
          projectKey = project.key();
          addSettingsToChildrenModules(ref, projectOrModuleKey, Maps.<String, String>newHashMap(), hasScanPerm, session);
        } else {
          // Add settings of the provisioned project
          addSettings(ref, projectOrModuleKey, getPropertiesMap(propertiesDao.selectProjectProperties(projectOrModuleKey, session), hasScanPerm));
          projectKey = projectOrModuleKey;
        }
      }

      addProfiles(ref, projectKey, profileName, session);
      addActiveRules(ref);

      response.stream().setMediaType(MimeTypes.JSON);
      IOUtils.write(ref.toJson(), response.stream().output());
    } finally {
      MyBatis.closeQuietly(session);
    }
  }
View Full Code Here

TOP

Related Classes of org.sonar.batch.protocol.input.ProjectReferentials

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.