NpmSearchResponseFactory extends ComponentSupport { public NpmSearchResponse buildResponseForObjects(final List<NpmSearchResponseObject> objects) { NpmSearchResponse response = new NpmSearchResponse(); response.setObjects(objects); response.setTime(formatSearchResponseDate(DateTime.now())); response.setTotal(objects.size()); return response; } @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);  }
@Test public void testBuildResponseFromObjects() { NpmSearchResponseObject object = new NpmSearchResponseObject(); NpmSearchResponse response = underTest.buildResponseForObjects(singletonList(object)); assertThat(response.getObjects(), hasSize(1)); assertThat(response.getTime(), not(nullValue())); assertThat(response.getTotal(), is(1)); }