org.sonatype.nexus.repository.view.Headers Java Examples
The following examples show how to use
org.sonatype.nexus.repository.view.Headers.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ComposerGroupPackagesJsonHandlerTest.java From nexus-repository-composer with Eclipse Public License 1.0 | 5 votes |
@Before public void setUp() throws Exception { when(context.getRepository()).thenReturn(repository); when(context.getRequest()).thenReturn(request); when(context.getAttributes()).thenReturn(new AttributesMap()); when(request.getAction()).thenReturn(GET); when(request.getAttributes()).thenReturn(new AttributesMap()); when(request.getHeaders()).thenReturn(new Headers()); when(repository.facet(GroupFacet.class)).thenReturn(groupFacet); when(groupFacet.members()).thenReturn(asList(memberRepository1, memberRepository2)); when(memberRepository1.getName()).thenReturn("member1"); when(memberRepository1.facet(ViewFacet.class)).thenReturn(memberRepository1ViewFacet); when(memberRepository2.getName()).thenReturn("member2"); when(memberRepository2.facet(ViewFacet.class)).thenReturn(memberRepository2ViewFacet); when(memberRepository1ViewFacet.dispatch(request, context)).thenReturn(response1); when(memberRepository2ViewFacet.dispatch(request, context)).thenReturn(response2); when(response1.getStatus()).thenReturn(status1); when(response1.getPayload()).thenReturn(payload1); when(response2.getStatus()).thenReturn(status2); when(response2.getPayload()).thenReturn(payload2); when(status1.getCode()).thenReturn(OK); when(status2.getCode()).thenReturn(OK); underTest = new ComposerGroupPackagesJsonHandler(composerJsonProcessor); }
Example #2
Source File: ComposerGroupProviderJsonHandlerTest.java From nexus-repository-composer with Eclipse Public License 1.0 | 5 votes |
@Before public void setUp() throws Exception { when(context.getRepository()).thenReturn(repository); when(context.getRequest()).thenReturn(request); when(context.getAttributes()).thenReturn(new AttributesMap()); when(request.getAction()).thenReturn(GET); when(request.getAttributes()).thenReturn(new AttributesMap()); when(request.getHeaders()).thenReturn(new Headers()); when(repository.facet(GroupFacet.class)).thenReturn(groupFacet); when(groupFacet.members()).thenReturn(asList(memberRepository1, memberRepository2)); when(memberRepository1.getName()).thenReturn("member1"); when(memberRepository1.facet(ViewFacet.class)).thenReturn(memberRepository1ViewFacet); when(memberRepository2.getName()).thenReturn("member2"); when(memberRepository2.facet(ViewFacet.class)).thenReturn(memberRepository2ViewFacet); when(memberRepository1ViewFacet.dispatch(request, context)).thenReturn(response1); when(memberRepository2ViewFacet.dispatch(request, context)).thenReturn(response2); when(response1.getStatus()).thenReturn(status1); when(response1.getPayload()).thenReturn(payload1); when(response2.getStatus()).thenReturn(status2); when(response2.getPayload()).thenReturn(payload2); when(status1.getCode()).thenReturn(OK); when(status2.getCode()).thenReturn(OK); underTest = new ComposerGroupProviderJsonHandler(composerJsonProcessor); }
Example #3
Source File: OrientNpmGroupPackageHandlerTest.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Before @SuppressWarnings("unchecked") public void setUp() throws Exception { underTest = new OrientNpmGroupPackageHandler(); AttributesMap attributesMap = new AttributesMap(); attributesMap.set(TokenMatcher.State.class, state); when(context.getAttributes()).thenReturn(attributesMap); when(context.getRepository()).thenReturn(group); when(context.getRequest()).thenReturn(request); when(group.getName()).thenReturn(OrientNpmGroupFacetTest.class.getSimpleName() + "-group"); when(group.facet(GroupFacet.class)).thenReturn(groupFacet); when(group.facet(StorageFacet.class)).thenReturn(storageFacet); when(groupFacet.buildPackageRoot(anyMap(), eq(context))) .thenReturn(new Content(new BytesPayload("test".getBytes(), ""))); when(viewFacet.dispatch(request, context)) .thenReturn(new Response.Builder().status(success(OK)).build()); when(proxy.facet(ViewFacet.class)).thenReturn(viewFacet); when(hosted.facet(ViewFacet.class)).thenReturn(viewFacet); when(request.getHeaders()).thenReturn(new Headers()); when(request.getAttributes()).thenReturn(new AttributesMap()); when(storageFacet.txSupplier()).thenReturn(() -> storageTx); UnitOfWork.beginBatch(storageTx); }
Example #4
Source File: HttpConditions.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
/** * Stashes the conditions of the passed in request, making it non-conditional request. To reverse this change, * use {@link #makeConditional(Request)} method. */ @Nonnull public static Request makeUnconditional(@Nonnull final Request request) { checkNotNull(request); final Headers stashedHeaders = new Headers(); for (String httpHeader : SUPPORTED_HEADERS) { List<String> headerValues = request.getHeaders().getAll(httpHeader); if (headerValues != null) { stashedHeaders.set(httpHeader, headerValues); } request.getHeaders().remove(httpHeader); } request.getAttributes().set(HTTP_CONDITIONS, stashedHeaders); return request; }
Example #5
Source File: HttpConditions.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
/** * Un-stash the conditions originally found in {@link Request}. This method accepts only requests returned by {@link * #makeUnconditional(Request)} method, otherwise will throw {@link IllegalStateException}. This method must be used * in pair with the method above. */ @Nonnull public static Request makeConditional(@Nonnull final Request request) { checkNotNull(request); final Headers stashedHeaders = request.getAttributes().require(HTTP_CONDITIONS, Headers.class); for (Entry<String, String> entry : stashedHeaders.entries()) { request.getHeaders().set(entry.getKey(), stashedHeaders.getAll(entry.getKey())); } return request; }
Example #6
Source File: DefaultHttpResponseSenderTest.java From nexus-public with Eclipse Public License 1.0 | 4 votes |
@Before public void setUp() throws Exception { when(request.getHeaders()).thenReturn(new Headers()); when(payload.openInputStream()).thenReturn(input); when(httpServletResponse.getOutputStream()).thenReturn(output); }
Example #7
Source File: ProxyHandler.java From nexus-public with Eclipse Public License 1.0 | 4 votes |
protected Response buildHttpErrorResponce(final BypassHttpErrorException proxyErrorsException) { return new Response.Builder() .status(new Status(false, proxyErrorsException.getStatusCode(), proxyErrorsException.getReason())) .headers(new Headers(proxyErrorsException.getHeaders())) .build(); }