Package org.sonatype.nexus.rest.model

Examples of org.sonatype.nexus.rest.model.SearchNGResponse


  {
    wairForAsyncEventsToCalmDown();
    waitForTasksToStop();

    int artifactCount = 60; // this is above collapse threshold
    SearchNGResponse result = deployAndSearch(artifactCount, DeployType.BOTH);
    Assert.assertEquals(1, result.getData().size()); // collapse by GA, so rel/snap is irrelevant
    ensureLatestIsPresent(result, DeployType.BOTH, "60");
  }
View Full Code Here


    deployDummyArtifact(releases, key, "2.0.0.0.0");

    wairForAsyncEventsToCalmDown();
    waitForTasksToStop();

    SearchNGResponse result = search(key);

    Assert.assertEquals(5, result.getData().size());
  }
View Full Code Here

    deployDummyArtifact(releases2, key, "2");

    wairForAsyncEventsToCalmDown();
    waitForTasksToStop();

    SearchNGResponse result = search(key);

    Assert.assertEquals(2, result.getData().size());
    for (int i = 0; i < 2; i++) {
      NexusNGArtifact nexusNGArtifact = result.getData().get(0);
      Assert.assertEquals(2, nexusNGArtifact.getArtifactHits().size());
      Assert.assertEquals(releases.getId(), nexusNGArtifact.getArtifactHits().get(0).getRepositoryId());
      Assert.assertEquals(releases2.getId(), nexusNGArtifact.getArtifactHits().get(1).getRepositoryId());
    }
  }
View Full Code Here

      throws Exception
  {
    wairForAsyncEventsToCalmDown();
    waitForTasksToStop();

    SearchNGResponse result = search("notfound");

    // have to bypass getXXX methods because they are not used by JSON renderer
    Assert.assertNotNull(Whitebox.getInternalState(result, "repoDetails"));
    Assert.assertNotNull(Whitebox.getInternalState(result, "data"));
  }
View Full Code Here

    request.setRootRef(ref);
    request.setResourceRef(new Reference(ref, SearchNGIndexPlexusResource.RESOURCE_URI
        + "?q=nexus&collapseresults=true"));

    Response response = new Response(request);
    SearchNGResponse result = subject.get(context, request, response, null);

    // explanation:
    // we test here, does this resource "expand" the result set even if the request told to collaps
    // (like UI does). This happens when result set (the grid count in search UI) would contain less
    // rows than COLLAPSE_OVERRIDE_TRESHOLD = 35 lines. If yes, it will repeat the search but uncollapsed
    // kinda overriding the "hint" that was in original request (see request query parameters above).
    //
    // Found items uncollapsed (without any specific order, is unstable):
    // org.sonatype.nexus:nexus:1.3.0-SNAPSHOT
    // org.sonatype.nexus:nexus-indexer:1.0-beta-4
    // org.sonatype.nexus:nexus-indexer:1.0-beta-5-SNAPSHOT
    // org.sonatype.nexus:nexus-indexer:1.0-beta-4-SNAPSHOT
    // org.sonatype.nexus:nexus-indexer:1.0-beta-3-SNAPSHOT
    // org.sonatype.nexus:nexus:1.2.2-SNAPSHOT
    // org.sonatype:nexus-3148:1.0.SNAPSHOT
    //
    // Found items collapsed (G:A:maxVersion):
    // org.sonatype.nexus:nexus:1.3.0-SNAPSHOT
    // org.sonatype.nexus:nexus-indexer:1.0-beta-4 (rel preferred over snap)
    // org.sonatype:nexus-3148:1.0.SNAPSHOT

    // we assert that the grid would contain 7, not 3 hits (corresponds to grid lines in Search UI)
    Assert.assertEquals(7, result.getData().size());
  }
View Full Code Here

      try {
        IteratorSearchResponse searchResult =
            searchByTerms(terms, repositoryId, from, count, exact, searchers);

        try {
          SearchNGResponse searchResponse = packSearchNGResponse(request, terms, searchResult, forceExpand);
          searchResponse.setTotalCount(searchResult.getTotalHitsCount());
          searchResponse.setFrom(from == null ? -1 : from.intValue());
          searchResponse.setCount(count == LUCENE_HIT_LIMIT ? -1 : count);
          return searchResponse;
        }
        finally {
          searchResult.close();
        }
View Full Code Here

            + " ms.");

    // expand if explicitly requested or if number of unique GAV matches is less than threshold
    boolean expand = forceExpand || gavcount <= COLLAPSE_OVERRIDE_TRESHOLD;

    SearchNGResponse response = new SearchNGResponse();
    response.setTooManyResults(tooManyResults || iterator.getTotalHitsCount() + 1 >= LUCENE_HIT_LIMIT);
    response.setCollapsed(!expand);

    List<NexusNGArtifact> responseData = new ArrayList<NexusNGArtifact>();

    LinkedHashSet<String> repositoryIds = new LinkedHashSet<String>();

    for (GAHolder gahit : gahits.values()) {
      if (expand) {
        // expand, i.e. include all versions
        for (NexusNGArtifact artifact : gahit.getOrderedVersionHits()) {
          responseData.add(artifact);
          setLatest(artifact, gahit.getLatestRelease(), gahit.getLatestSnapshot());
          addRepositoryIds(repositoryIds, artifact);
        }
      }
      else {
        // collapse, i.e. only include latest version in each GA
        NexusNGArtifact artifact = gahit.getLatestVersionHit();
        setLatest(artifact, gahit.getLatestRelease(), gahit.getLatestSnapshot());
        responseData.add(artifact);
        addRepositoryIds(repositoryIds, artifact);
      }
    }

    response.setData(responseData);

    List<NexusNGRepositoryDetail> repoDetails = new ArrayList<NexusNGRepositoryDetail>();

    for (String repositoryId : repositoryIds) {
      Repository repository;
      try {
        repository = getUnprotectedRepositoryRegistry().getRepository(repositoryId);
        addRepositoryDetails(repoDetails, request, repository);
      }
      catch (NoSuchRepositoryException e) {
        // XXX can't happen, can it?
      }
    }

    response.setRepoDetails(repoDetails);

    return response;
  }
View Full Code Here

TOP

Related Classes of org.sonatype.nexus.rest.model.SearchNGResponse

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.