@Test public void testSkipResultWithBadResponse() throws Exception { when(status1.getCode()).thenReturn(HttpStatus.INTERNAL_SERVER_ERROR); Response response = underTest.doGet(context, dispatchedRepositories); assertThat(response.getStatus().getCode(), is(OK)); assertThat(response.getPayload(), not(nullValue())); try (InputStream in = response.getPayload().openInputStream()) { assertThat(CharStreams.toString(new InputStreamReader(in, UTF_8)), is("response")); } ArgumentCaptor<NpmSearchResponse> searchResponseCaptor = ArgumentCaptor.forClass(NpmSearchResponse.class); verify(npmSearchResponseMapper).writeString(searchResponseCaptor.capture()); NpmSearchResponse searchResponse = searchResponseCaptor.getValue(); assertThat(searchResponse.getTotal(), is(1)); assertThat(searchResponse.getObjects(), hasSize(1)); assertThat(searchResponse.getObjects(), contains(npmSearchResponseObject2)); }
@Override protected Response doGet(@Nonnull final Context context, @Nonnull final DispatchedRepositories dispatched) throws Exception { checkNotNull(context); checkNotNull(dispatched); Request request = context.getRequest(); Parameters parameters = request.getParameters(); String text = npmSearchParameterExtractor.extractText(parameters); NpmSearchResponse response; if (text.isEmpty()) { response = npmSearchResponseFactory.buildEmptyResponse(); } else { response = searchMembers(context, dispatched, parameters); } String content = npmSearchResponseMapper.writeString(response); return HttpResponses.ok(new StringPayload(content, ContentTypes.APPLICATION_JSON)); }
NpmSearchGroupHandler extends GroupHandler { @Override protected Response doGet(@Nonnull final Context context, @Nonnull final DispatchedRepositories dispatched) throws Exception { checkNotNull(context); checkNotNull(dispatched); Request request = context.getRequest(); Parameters parameters = request.getParameters(); String text = npmSearchParameterExtractor.extractText(parameters); NpmSearchResponse response; if (text.isEmpty()) { response = npmSearchResponseFactory.buildEmptyResponse(); } else { response = searchMembers(context, dispatched, parameters); } String content = npmSearchResponseMapper.writeString(response); return HttpResponses.ok(new StringPayload(content, ContentTypes.APPLICATION_JSON)); } }
NpmSearchGroupHandler extends GroupHandler { @Override protected Response doGet(@Nonnull final Context context, @Nonnull final DispatchedRepositories dispatched) throws Exception { checkNotNull(context); checkNotNull(dispatched); Request request = context.getRequest(); Parameters parameters = request.getParameters(); String text = npmSearchParameterExtractor.extractText(parameters); NpmSearchResponse response; if (text.isEmpty()) { response = npmSearchResponseFactory.buildEmptyResponse(); } else { response = searchMembers(context, dispatched, parameters); } String content = npmSearchResponseMapper.writeString(response); return HttpResponses.ok(new StringPayload(content, ContentTypes.APPLICATION_JSON)); } @Inject  NpmSearchGroupHandler(final NpmSearchParameterExtractor npmSearchParameterExtractor,
                               final NpmSearchResponseFactory npmSearchResponseFactory,
                               final NpmSearchResponseMapper npmSearchResponseMapper,
                               @Named("${nexus.npm.v1SearchMaxResults:-250}") final int v1SearchMaxResults); }
NpmSearchGroupHandler extends GroupHandler { @Override protected Response doGet(@Nonnull final Context context, @Nonnull final DispatchedRepositories dispatched) throws Exception { checkNotNull(context); checkNotNull(dispatched); Request request = context.getRequest(); Parameters parameters = request.getParameters(); String text = npmSearchParameterExtractor.extractText(parameters); NpmSearchResponse response; if (text.isEmpty()) { response = npmSearchResponseFactory.buildEmptyResponse(); } else { response = searchMembers(context, dispatched, parameters); } String content = npmSearchResponseMapper.writeString(response); return HttpResponses.ok(new StringPayload(content, ContentTypes.APPLICATION_JSON)); } @Inject  NpmSearchGroupHandler(final NpmSearchParameterExtractor npmSearchParameterExtractor,
                               final NpmSearchResponseFactory npmSearchResponseFactory,
                               final NpmSearchResponseMapper npmSearchResponseMapper,
                               @Named("${nexus.npm.v1SearchMaxResults:-250}") final int v1SearchMaxResults);  }
NpmSearchGroupHandler extends GroupHandler { @Override protected Response doGet(@Nonnull final Context context, @Nonnull final DispatchedRepositories dispatched) throws Exception { checkNotNull(context); checkNotNull(dispatched); Request request = context.getRequest(); Parameters parameters = request.getParameters(); String text = npmSearchParameterExtractor.extractText(parameters); NpmSearchResponse response; if (text.isEmpty()) { response = npmSearchResponseFactory.buildEmptyResponse(); } else { response = searchMembers(context, dispatched, parameters); } String content = npmSearchResponseMapper.writeString(response); return HttpResponses.ok(new StringPayload(content, ContentTypes.APPLICATION_JSON)); } @Inject  NpmSearchGroupHandler(final NpmSearchParameterExtractor npmSearchParameterExtractor,
                               final NpmSearchResponseFactory npmSearchResponseFactory,
                               final NpmSearchResponseMapper npmSearchResponseMapper,
                               @Named("${nexus.npm.v1SearchMaxResults:-250}") final int v1SearchMaxResults);   }