use of org.jboss.resteasy.specimpl.MultivaluedMapImpl in project candlepin by candlepin.
the class ConsumerContentOverrideResourceTest method setUp.
@Before
public void setUp() {
ConsumerType ctype = new ConsumerType("test-consumer-type");
ctype.setId("test-ctype");
consumer = new Consumer("test-consumer", "test-user", new Owner("Test Owner"), ctype);
MultivaluedMap<String, String> mvm = new MultivaluedMapImpl<>();
mvm.add("consumer_uuid", consumer.getUuid());
context = mock(UriInfo.class);
when(context.getPathParameters()).thenReturn(mvm);
when(consumerCurator.verifyAndLookupConsumer(eq(consumer.getUuid()))).thenReturn(consumer);
when(overrideRules.canOverrideForConsumer(any(String.class))).thenReturn(true);
i18n = I18nFactory.getI18n(getClass(), Locale.US, I18nFactory.FALLBACK);
contentOverrideValidator = new ContentOverrideValidator(i18n, overrideRules);
resource = new ConsumerContentOverrideResource(consumerContentOverrideCurator, consumerCurator, contentOverrideValidator, i18n);
when(principal.canAccess(any(Object.class), any(SubResource.class), any(Access.class))).thenReturn(true);
}
use of org.jboss.resteasy.specimpl.MultivaluedMapImpl in project robozonky by RoboZonky.
the class AbstractCommonFilterTest method userAgent.
@Test
void userAgent() throws URISyntaxException {
final MultivaluedMap<String, Object> map = new MultivaluedMapImpl<>();
final ClientRequestContext ctx = mock(ClientRequestContext.class);
when(ctx.getUri()).thenReturn(new URI("http://localhost/"));
when(ctx.getHeaders()).thenReturn(map);
getTestedFilter().filter(ctx);
assertThat(map.get("User-Agent").get(0)).isEqualTo(Defaults.ROBOZONKY_USER_AGENT);
}
use of org.jboss.resteasy.specimpl.MultivaluedMapImpl in project robozonky by RoboZonky.
the class RoboZonkyFilterTest method response.
@Test
void response() throws IOException {
final String key = UUID.randomUUID().toString();
final String key2 = UUID.randomUUID().toString();
final String value = UUID.randomUUID().toString();
final MultivaluedMap<String, String> map = new MultivaluedMapImpl<>();
map.add(key, value);
map.addAll(key2, Collections.emptyList());
final ClientRequestContext ctx = mock(ClientRequestContext.class);
final ClientResponseContext ctx2 = mock(ClientResponseContext.class);
when(ctx2.getHeaders()).thenReturn(map);
when(ctx2.getStatusInfo()).thenReturn(mock(Response.StatusType.class));
final RoboZonkyFilter filter = new RoboZonkyFilter();
filter.filter(ctx, ctx2);
assertSoftly(softly -> {
softly.assertThat(filter.getLastResponseHeader(key)).contains(value);
softly.assertThat(filter.getLastResponseHeader(key2)).isEmpty();
});
}
use of org.jboss.resteasy.specimpl.MultivaluedMapImpl in project candlepin by candlepin.
the class OwnerResourceTest method testImportManifestAsyncSuccess.
@Test
public void testImportManifestAsyncSuccess() 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);
JobDetail job = mock(JobDetail.class);
when(input.getParts()).thenReturn(parts);
when(part.getHeaders()).thenReturn(mm);
when(part.getBody(any(GenericType.class))).thenReturn(archive);
when(manifestManager.importManifestAsync(eq(owner), any(File.class), eq("test_file.zip"), any(ConflictOverrides.class))).thenReturn(job);
JobDetail response = thisOwnerResource.importManifestAsync(owner.getKey(), new String[] {}, input);
assertNotNull(response);
assertEquals(job, response);
verify(manifestManager, never()).importManifest(eq(owner), any(File.class), any(String.class), any(ConflictOverrides.class));
}
use of org.jboss.resteasy.specimpl.MultivaluedMapImpl in project candlepin by candlepin.
the class ActivationKeyContentOverrideResourceTest method setUp.
@Before
public void setUp() throws URISyntaxException {
key = new ActivationKey("actkey", owner);
key.setId("keyid");
MultivaluedMap<String, String> mvm = new MultivaluedMapImpl<>();
mvm.add("activation_key_id", key.getId());
when(context.getPathParameters()).thenReturn(mvm);
akcor = new ActivationKeyContentOverrideResource(activationKeyContentOverrideCurator, akc, contentOverrideValidator, i18n);
when(akc.verifyAndLookupKey(eq(key.getId()))).thenReturn(key);
when(principal.canAccess(any(Object.class), any(SubResource.class), any(Access.class))).thenReturn(true);
}
Aggregations