@Test public void testBuildResponseWithoutAuthorInformation() { NpmSearchResponse response = underTest.buildResponseForResults(generateBuckets(1, false, false), 20, 0); assertThat(response.getObjects(), hasSize(1)); assertThat(response.getTime(), not(nullValue())); assertThat(response.getTotal(), is(1)); NpmSearchResponseObject object = response.getObjects().get(0); NpmSearchResponsePackage entry = object.getPackageEntry(); assertThat(entry.getPublisher(), is(nullValue())); assertThat(entry.getMaintainers(), hasSize(0)); }
public NpmSearchResponse buildResponseForResults(final List<Terms.Bucket> buckets, final int size, final int from) { List<NpmSearchResponseObject> objects = buckets.stream() .map(bucket -> (TopHits) bucket.getAggregations().get("versions")) .map(TopHits::getHits) .map(searchHits -> searchHits.getAt(0)) .map(this::buildSearchResponseObject) .skip(from) .limit(size) .collect(toList()); return buildResponseForObjects(objects); }
NpmSearchResponseFactory extends ComponentSupport { public NpmSearchResponse buildResponseForResults(final List<Terms.Bucket> buckets, final int size, final int from) { List<NpmSearchResponseObject> objects = buckets.stream() .map(bucket -> (TopHits) bucket.getAggregations().get("versions")) .map(TopHits::getHits) .map(searchHits -> searchHits.getAt(0)) .map(this::buildSearchResponseObject) .skip(from) .limit(size) .collect(toList()); return buildResponseForObjects(objects); } }
NpmSearchResponseFactory extends ComponentSupport { public NpmSearchResponse buildResponseForResults(final List<Terms.Bucket> buckets, final int size, final int from) { List<NpmSearchResponseObject> objects = buckets.stream() .map(bucket -> (TopHits) bucket.getAggregations().get("versions")) .map(TopHits::getHits) .map(searchHits -> searchHits.getAt(0)) .map(this::buildSearchResponseObject) .skip(from) .limit(size) .collect(toList()); return buildResponseForObjects(objects); } @Inject  NpmSearchResponseFactory(final NpmSearchHitExtractor npmSearchHitExtractor); }
NpmSearchResponseFactory extends ComponentSupport { public NpmSearchResponse buildResponseForResults(final List<Terms.Bucket> buckets, final int size, final int from) { List<NpmSearchResponseObject> objects = buckets.stream() .map(bucket -> (TopHits) bucket.getAggregations().get("versions")) .map(TopHits::getHits) .map(searchHits -> searchHits.getAt(0)) .map(this::buildSearchResponseObject) .skip(from) .limit(size) .collect(toList()); return buildResponseForObjects(objects); } @Inject  NpmSearchResponseFactory(final NpmSearchHitExtractor npmSearchHitExtractor); NpmSearchResponse buildEmptyResponse(); NpmSearchResponse buildResponseForResults(final List<Terms.Bucket> buckets, final int size, final int from); NpmSearchResponse buildResponseForObjects(final List<NpmSearchResponseObject> objects); }
NpmSearchResponseFactory extends ComponentSupport { public NpmSearchResponse buildResponseForResults(final List<Terms.Bucket> buckets, final int size, final int from) { List<NpmSearchResponseObject> objects = buckets.stream() .map(bucket -> (TopHits) bucket.getAggregations().get("versions")) .map(TopHits::getHits) .map(searchHits -> searchHits.getAt(0)) .map(this::buildSearchResponseObject) .skip(from) .limit(size) .collect(toList()); return buildResponseForObjects(objects); } @Inject  NpmSearchResponseFactory(final NpmSearchHitExtractor npmSearchHitExtractor); NpmSearchResponse buildEmptyResponse(); NpmSearchResponse buildResponseForResults(final List<Terms.Bucket> buckets, final int size, final int from); NpmSearchResponse buildResponseForObjects(final List<NpmSearchResponseObject> objects);  }