use of org.jboss.resteasy.specimpl.MultivaluedMapImpl in project microservice_framework by CJSCommonPlatform.
the class DefaultRestProcessorTest method headersWithUserId.
private static ResteasyHttpHeaders headersWithUserId(final String userId) {
final ResteasyHttpHeaders headers;
final MultivaluedMapImpl<String, String> requestHeaders = new MultivaluedMapImpl<>();
requestHeaders.add(HeaderConstants.USER_ID, userId);
headers = new ResteasyHttpHeaders(requestHeaders);
return headers;
}
use of org.jboss.resteasy.specimpl.MultivaluedMapImpl in project candlepin by candlepin.
the class LinkHeaderResponseFilterTest method testAddsUnchangingQueryParameters.
@Test
public void testAddsUnchangingQueryParameters() {
MultivaluedMap<String, String> map = new MultivaluedMapImpl<>();
map.add("baz", "qu=ux");
UriBuilder bu = UriBuilder.fromUri("https://localhost:8443/candlepin/resource");
URI returned = interceptor.addUnchangingQueryParams(bu, map).build();
assertEquals(URI.create("https://localhost:8443/candlepin/resource?baz=qu%3Dux"), returned);
}
use of org.jboss.resteasy.specimpl.MultivaluedMapImpl in project candlepin by candlepin.
the class LinkHeaderResponseFilterTest method testDoesNotAddChangingQueryParameters.
@Test
public void testDoesNotAddChangingQueryParameters() {
MultivaluedMap<String, String> map = new MultivaluedMapImpl<>();
map.add("page", "10");
UriBuilder bu = UriBuilder.fromUri("https://localhost:8443/candlepin/resource");
URI returned = interceptor.addUnchangingQueryParams(bu, map).build();
assertEquals(URI.create("https://localhost:8443/candlepin/resource"), returned);
}
use of org.jboss.resteasy.specimpl.MultivaluedMapImpl in project candlepin by candlepin.
the class OwnerResourceTest method testImportManifestFailure.
@Test
public void testImportManifestFailure() throws IOException, ImporterException {
ManifestManager manifestManager = mock(ManifestManager.class);
EventSink es = mock(EventSink.class);
OwnerResource thisOwnerResource = new OwnerResource(ownerCurator, productCurator, null, null, i18n, es, eventFactory, null, null, manifestManager, null, null, null, null, importRecordCurator, null, null, null, null, null, null, null, contentOverrideValidator, serviceLevelValidator, null, null, null, null, null, this.modelTranslator);
MultipartInput input = mock(MultipartInput.class);
InputPart part = mock(InputPart.class);
File archive = mock(File.class);
List<InputPart> parts = new ArrayList<>();
parts.add(part);
MultivaluedMap<String, String> mm = new MultivaluedMapImpl<>();
List<String> contDis = new ArrayList<>();
contDis.add("form-data; name=\"upload\"; filename=\"test_file.zip\"");
mm.put("Content-Disposition", contDis);
when(input.getParts()).thenReturn(parts);
when(part.getHeaders()).thenReturn(mm);
when(part.getBody(any(GenericType.class))).thenReturn(archive);
ImporterException expectedException = new ImporterException("Bad import");
when(manifestManager.importManifest(eq(owner), any(File.class), any(String.class), any(ConflictOverrides.class))).thenThrow(expectedException);
try {
thisOwnerResource.importManifest(owner.getKey(), new String[] {}, input);
fail("Expected IseException was not thrown");
} catch (IseException ise) {
// expected, so we catch and go on.
}
verify(manifestManager).recordImportFailure(eq(owner), eq(expectedException), eq("test_file.zip"));
}
use of org.jboss.resteasy.specimpl.MultivaluedMapImpl in project candlepin by candlepin.
the class OwnerResourceTest method testImportManifestSynchronousSuccess.
@Test
public void testImportManifestSynchronousSuccess() throws IOException, ImporterException {
ManifestManager manifestManager = mock(ManifestManager.class);
EventSink es = mock(EventSink.class);
OwnerResource thisOwnerResource = new OwnerResource(ownerCurator, productCurator, null, null, i18n, es, eventFactory, null, null, manifestManager, null, null, null, null, importRecordCurator, null, null, null, null, null, null, null, contentOverrideValidator, serviceLevelValidator, null, null, null, null, null, this.modelTranslator);
MultipartInput input = mock(MultipartInput.class);
InputPart part = mock(InputPart.class);
File archive = mock(File.class);
List<InputPart> parts = new ArrayList<>();
parts.add(part);
MultivaluedMap<String, String> mm = new MultivaluedMapImpl<>();
List<String> contDis = new ArrayList<>();
contDis.add("form-data; name=\"upload\"; filename=\"test_file.zip\"");
mm.put("Content-Disposition", contDis);
when(input.getParts()).thenReturn(parts);
when(part.getHeaders()).thenReturn(mm);
when(part.getBody(any(GenericType.class))).thenReturn(archive);
ImportRecord ir = new ImportRecord(owner);
when(manifestManager.importManifest(eq(owner), any(File.class), eq("test_file.zip"), any(ConflictOverrides.class))).thenReturn(ir);
ImportRecord response = thisOwnerResource.importManifest(owner.getKey(), new String[] {}, input);
assertNotNull(response);
assertEquals(ir, response);
}
Aggregations