Java Code Examples for javax.ws.rs.core.MultivaluedMap#addAll()

The following examples show how to use javax.ws.rs.core.MultivaluedMap#addAll() . 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: CollectionStringProducerTest.java    From everrest with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void createsListAndUsesDefaultValue() throws Exception {
    CollectionStringProducer producer = new CollectionStringProducer(List.class);
    MultivaluedMap<String, String> values = new MultivaluedMapImpl();
    values.addAll("string", "hello", "world");

    Object result = producer.createValue("__string", values, "hello world");

    assertEquals(newArrayList("hello world"), result);
}
 
Example 2
Source File: CollectionStringValueOfProducerTest.java    From everrest with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void createsSetAndUsesValuesFromMap() throws Exception {
    CollectionStringValueOfProducer producer =
            new CollectionStringValueOfProducer(Set.class, Integer.class.getMethod("valueOf", String.class));
    MultivaluedMap<String, String> values = new MultivaluedMapImpl();
    values.addAll("number", "2147483647", "746384741");

    Object result = producer.createValue("number", values, null);

    assertEquals(newHashSet(2147483647, 746384741), result);
}
 
Example 3
Source File: CollectionStringValueOfProducerTest.java    From everrest with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void createsListAndUsesDefaultValue() throws Exception {
    CollectionStringValueOfProducer producer =
            new CollectionStringValueOfProducer(List.class, Integer.class.getMethod("valueOf", String.class));
    MultivaluedMap<String, String> values = new MultivaluedMapImpl();
    values.addAll("number", "2147483647", "746384741");

    Object result = producer.createValue("__number", values, "-2147483647");

    assertEquals(newArrayList(-2147483647), result);
}
 
Example 4
Source File: CollectionStringValueOfProducerTest.java    From everrest with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void createsListAndUsesValuesFromMap() throws Exception {
    CollectionStringValueOfProducer producer =
            new CollectionStringValueOfProducer(List.class, Integer.class.getMethod("valueOf", String.class));
    MultivaluedMap<String, String> values = new MultivaluedMapImpl();
    values.addAll("number", "2147483647", "746384741");

    Object result = producer.createValue("number", values, null);

    assertEquals(newArrayList(2147483647, 746384741), result);
}
 
Example 5
Source File: CollectionStringValueOfProducerTest.java    From everrest with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void createsSortedSetAndUsesValuesFromMap() throws Exception {
    CollectionStringValueOfProducer producer =
            new CollectionStringValueOfProducer(SortedSet.class, Integer.class.getMethod("valueOf", String.class));
    MultivaluedMap<String, String> values = new MultivaluedMapImpl();
    values.addAll("number", "2147483647", "746384741");

    Object result = producer.createValue("number", values, null);

    assertEquals(newTreeSet(newArrayList(2147483647, 746384741)), result);
}
 
Example 6
Source File: CollectionStringConstructorProducerTest.java    From everrest with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void createsSortedSetAndUsesValuesFromMap() throws Exception {
    CollectionStringConstructorProducer producer =
            new CollectionStringConstructorProducer(SortedSet.class, Integer.class.getConstructor(String.class));
    MultivaluedMap<String, String> values = new MultivaluedMapImpl();
    values.addAll("number", "2147483647", "746384741");

    Object result = producer.createValue("number", values, null);

    assertEquals(newTreeSet(newArrayList(2147483647, 746384741)), result);
}
 
Example 7
Source File: CollectionStringConstructorProducerTest.java    From everrest with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void createsSetAndUsesDefaultValue() throws Exception {
    CollectionStringConstructorProducer producer =
            new CollectionStringConstructorProducer(Set.class, Integer.class.getConstructor(String.class));
    MultivaluedMap<String, String> values = new MultivaluedMapImpl();
    values.addAll("number", "2147483647", "746384741");

    Object result = producer.createValue("__number", values, "-2147483647");

    assertEquals(newHashSet(-2147483647), result);
}
 
Example 8
Source File: CollectionStringConstructorProducerTest.java    From everrest with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void createsSetAndUsesValuesFromMap() throws Exception {
    CollectionStringConstructorProducer producer =
            new CollectionStringConstructorProducer(Set.class, Integer.class.getConstructor(String.class));
    MultivaluedMap<String, String> values = new MultivaluedMapImpl();
    values.addAll("number", "2147483647", "746384741");

    Object result = producer.createValue("number", values, null);

    assertEquals(newHashSet(2147483647, 746384741), result);
}
 
Example 9
Source File: CollectionStringProducerTest.java    From everrest with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void createsSortedSetAndUsesDefaultValue() throws Exception {
    CollectionStringProducer producer = new CollectionStringProducer(SortedSet.class);
    MultivaluedMap<String, String> values = new MultivaluedMapImpl();
    values.addAll("string", "hello", "world");

    Object result = producer.createValue("__string", values, "hello world");

    assertEquals(newTreeSet(newArrayList("hello world")), result);
}
 
Example 10
Source File: JaxrsWebContextTest.java    From minnal with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldGetRequestParameters() {
	MultivaluedMap<String, String> params = new MultivaluedHashMap<String, String>();
	params.addAll("key1", Lists.newArrayList("value1", "value2"));
	params.add("key2", "value3");
	UriInfo uriInfo = mock(UriInfo.class);
	when(uriInfo.getQueryParameters()).thenReturn(params);
	when(request.getUriInfo()).thenReturn(uriInfo);
	Map<String, String[]> reqParams = context.getRequestParameters();
	assertEquals(reqParams.get("key1"), new String[]{"value1", "value2"});
	assertEquals(reqParams.get("key2"), new String[]{"value3"});
}
 
Example 11
Source File: CollectionStringValueOfProducerTest.java    From everrest with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void createsSetAndUsesDefaultValue() throws Exception {
    CollectionStringValueOfProducer producer =
            new CollectionStringValueOfProducer(Set.class, Integer.class.getMethod("valueOf", String.class));
    MultivaluedMap<String, String> values = new MultivaluedMapImpl();
    values.addAll("number", "2147483647", "746384741");

    Object result = producer.createValue("__number", values, "-2147483647");

    assertEquals(newHashSet(-2147483647), result);
}
 
Example 12
Source File: CollectionStringProducerTest.java    From everrest with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void createsSetAndUsesValuesFromMap() throws Exception {
    CollectionStringProducer producer = new CollectionStringProducer(Set.class);
    MultivaluedMap<String, String> values = new MultivaluedMapImpl();
    values.addAll("string", "hello", "world");

    Object result = producer.createValue("string", values, null);

    assertEquals(newHashSet("hello", "world"), result);
}
 
Example 13
Source File: CollectionStringProducerTest.java    From everrest with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void createsListAndUsesValuesFromMap() throws Exception {
    CollectionStringProducer producer = new CollectionStringProducer(List.class);
    MultivaluedMap<String, String> values = new MultivaluedMapImpl();
    values.addAll("string", "hello", "world");

    Object result = producer.createValue("string", values, null);

    assertEquals(newArrayList("hello", "world"), result);
}
 
Example 14
Source File: MailForm.java    From mailgun with MIT License 5 votes vote down vote up
@Override
void prepareSend() {
    // apply default parameters
    MultivaluedMap<String, String> parameters = form.asMap();
    Map<String, List<String>> def = configuration().defaultParameters();
    for (Map.Entry<String, List<String>> entry : def.entrySet())
        if (!parameters.containsKey(entry.getKey()))
            parameters.addAll(entry.getKey(), entry.getValue());
}
 
Example 15
Source File: CollectionStringValueOfProducerTest.java    From everrest with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void createsSortedSetAndUsesDefaultValue() throws Exception {
    CollectionStringValueOfProducer producer =
            new CollectionStringValueOfProducer(SortedSet.class, Integer.class.getMethod("valueOf", String.class));
    MultivaluedMap<String, String> values = new MultivaluedMapImpl();
    values.addAll("number", "2147483647", "746384741");

    Object result = producer.createValue("__number", values, "-2147483647");

    assertEquals(newTreeSet(newArrayList(-2147483647)), result);
}
 
Example 16
Source File: UserSecureStreamMetaDataTests.java    From pravega with Apache License 2.0 4 votes vote down vote up
@Override
protected Invocation.Builder addAuthHeaders(Invocation.Builder request) {
    MultivaluedMap<String, Object> map = new MultivaluedHashMap<>();
    map.addAll(HttpHeaders.AUTHORIZATION, TestUtils.basicAuthToken("user1", "1111_aaaa"));
    return request.headers(map);
}
 
Example 17
Source File: PrimitiveTypeProducerTest.java    From everrest with Eclipse Public License 2.0 4 votes vote down vote up
private static MultivaluedMap<String, String> singletonMultiValuedMap(String... values) {
    MultivaluedMap<String, String> map = new MultivaluedMapImpl();
    map.addAll("value", values);
    return map;
}
 
Example 18
Source File: StatisticaQuadraturaConverter.java    From govpay with GNU General Public License v3.0 4 votes vote down vote up
private static void creaURLDettaglio(it.govpay.model.reportistica.statistiche.StatisticaRendicontazione statistica,
		UriInfo uriInfo, StatisticaQuadraturaRendicontazione rsModel) {
	// URL di dettaglio composta da tutti i filtri e da i valori dei gruppi trovati
	UriBuilder uriBuilder = UriBuilderUtils.getListRendicontazioni();
	MultivaluedMap<String, String> parametri = new MultivaluedHashMap<String, String>();
	
	MultivaluedMap<String,String> queryParameters = uriInfo.getQueryParameters();
	
	/*
	 @QueryParam("dataOraFlussoDa") String dataOraFlussoDa, 
	 @QueryParam("dataOraFlussoA") String dataOraFlussoA, 
	 @QueryParam("dataRendicontazioneDa") String dataRendicontazioneDa, 
	 @QueryParam("dataRendicontazioneA") String dataRendicontazioneA, 
	 @QueryParam("idFlusso") String idFlusso, 
	 @QueryParam("iuv") String iuv, 
	 @QueryParam("direzione") List<String> direzione, 
	 @QueryParam("divisione") List<String> divisione
	
	*/
	
	
	if(statistica.getCodFlusso() != null) {
		parametri.add("idFlusso", statistica.getCodFlusso());
	} else {
		if(queryParameters.containsKey("idFlusso"))
			parametri.addAll("idFlusso", queryParameters.get("idFlusso"));
	}
	
	if(statistica.getDirezione() != null) {
		parametri.add("direzione", statistica.getDirezione());
	} else {
		if(queryParameters.containsKey("direzione"))
			parametri.addAll("direzione", queryParameters.get("direzione"));
	}
	
	if(statistica.getDivisione() != null) {
		parametri.add("divisione", statistica.getDivisione());
	} else {
		if(queryParameters.containsKey("divisione"))
			parametri.addAll("divisione", queryParameters.get("divisione"));
	}
	
	if(queryParameters.containsKey("dataOraFlussoDa"))
		parametri.addAll("dataOraFlussoDa", queryParameters.get("dataOraFlussoDa"));
	if(queryParameters.containsKey("dataOraFlussoA"))
		parametri.addAll("dataOraFlussoA", queryParameters.get("dataOraFlussoA"));
	if(queryParameters.containsKey("dataRendicontazioneDa"))
		parametri.addAll("dataRendicontazioneDa", queryParameters.get("dataRendicontazioneDa"));
	if(queryParameters.containsKey("dataRendicontazioneA"))
		parametri.addAll("dataRendicontazioneA", queryParameters.get("dataRendicontazioneA"));
	if(queryParameters.containsKey("iuv"))
		parametri.addAll("iuv", queryParameters.get("iuv"));

	// aggiungo tutti i parametri 
	for (String key : parametri.keySet()) {
		List<String> list = parametri.get(key);
		uriBuilder = uriBuilder.queryParam(key, list.toArray(new Object[list.size()]));
	}
	
	rsModel.setDettaglio(uriBuilder.build().toString());
}
 
Example 19
Source File: Failing403StreamMetaDataTests.java    From pravega with Apache License 2.0 4 votes vote down vote up
@Override
protected Invocation.Builder addAuthHeaders(Invocation.Builder request) {
    MultivaluedMap<String, Object> map = new MultivaluedHashMap<>();
    map.addAll(HttpHeaders.AUTHORIZATION, TestAuthHandler.testAuthToken(TestAuthHandler.DUMMY_USER));
    return request.headers(map);
}
 
Example 20
Source File: SecureStreamMetaDataTests.java    From pravega with Apache License 2.0 4 votes vote down vote up
@Override
protected Invocation.Builder addAuthHeaders(Invocation.Builder request) {
    MultivaluedMap<String, Object> map = new MultivaluedHashMap<>();
    map.addAll(HttpHeaders.AUTHORIZATION, TestUtils.basicAuthToken("admin", "1111_aaaa"));
    return request.headers(map);
}