當前位置: 首頁>>代碼示例>>Java>>正文


Java MultivaluedMap.put方法代碼示例

本文整理匯總了Java中javax.ws.rs.core.MultivaluedMap.put方法的典型用法代碼示例。如果您正苦於以下問題:Java MultivaluedMap.put方法的具體用法?Java MultivaluedMap.put怎麽用?Java MultivaluedMap.put使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.ws.rs.core.MultivaluedMap的用法示例。


在下文中一共展示了MultivaluedMap.put方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: map_ReturnsCorrectParameterName_ForQueryParameter

import javax.ws.rs.core.MultivaluedMap; //導入方法依賴的package包/類
@Test
public void map_ReturnsCorrectParameterName_ForQueryParameter() {
  // Arrange
  QueryParameter queryParameter = new QueryParameter();

  queryParameter.setName("param1");
  queryParameter.setIn("query");
  queryParameter.setVendorExtension(OpenApiSpecificationExtensions.PARAMETER,
      parameter.getIdentifier().stringValue());

  Operation operation = new Operation();
  operation.addParameter(queryParameter);

  MultivaluedMap<String, String> queryParameters = new MultivaluedHashMap<>();
  queryParameters.put(queryParameter.getName(), ImmutableList.of("value", "valueB"));

  // Act
  Map<String, String> result = mapper.map(operation, product, requestParameters);

  // Assert
  assertThat(result.size(), is(1));
  assertThat(result, hasEntry(parameter.getName(), "value"));
}
 
開發者ID:dotwebstack,項目名稱:dotwebstack-framework,代碼行數:24,代碼來源:RequestParameterMapperTest.java

示例2: map_ReturnsRequiredParameter_WithValidData

import javax.ws.rs.core.MultivaluedMap; //導入方法依賴的package包/類
@Test
public void map_ReturnsRequiredParameter_WithValidData() {
  // Arrange
  MultivaluedMap<String, String> queryParameters = new MultivaluedHashMap<>();

  // Note there are multiple values for this parameter, to test that the first value is used only
  queryParameters.put(requiredParameter.getName(), ImmutableList.of("value", "valueB"));

  when(uriInfoMock.getQueryParameters()).thenReturn(queryParameters);

  // Act
  Map<String, String> result = representationRequestParameterMapper.map(product, contextMock);

  // Assert
  assertThat(result.size(), is(1));
  assertThat(result, hasEntry(requiredParameter.getName(), "value"));
}
 
開發者ID:dotwebstack,項目名稱:dotwebstack-framework,代碼行數:18,代碼來源:RepresentationRequestParameterMapperTest.java

示例3: map_ReturnsOptionalParameter_WithValidData

import javax.ws.rs.core.MultivaluedMap; //導入方法依賴的package包/類
@Test
public void map_ReturnsOptionalParameter_WithValidData() {
  // Arrange
  MultivaluedMap<String, String> queryParameters = new MultivaluedHashMap<>();

  // Note there are multiple values for this parameter, to test that the first value is used only
  queryParameters.put(optionalParameter.getName(), ImmutableList.of("value", "valueB"));

  when(uriInfoMock.getQueryParameters()).thenReturn(queryParameters);

  // Act
  Map<String, String> result = representationRequestParameterMapper.map(product, contextMock);

  // Assert
  assertThat(result.size(), is(1));
  assertThat(result, hasEntry(optionalParameter.getName(), "value"));
}
 
開發者ID:dotwebstack,項目名稱:dotwebstack-framework,代碼行數:18,代碼來源:RepresentationRequestParameterMapperTest.java

示例4: setUp

import javax.ws.rs.core.MultivaluedMap; //導入方法依賴的package包/類
@Before
public void setUp() {
  SimpleValueFactory valueFactory = SimpleValueFactory.getInstance();

  parameter = new StringTermParameter(valueFactory.createIRI("http://parameter-iri"),
      "parameter-name", true);
  parameter2 = new StringTermParameter(valueFactory.createIRI("http://parameter2-iri"),
      "parameter2-name", true);

  product = new TestInformationProduct(DBEERPEDIA.ORIGIN_INFORMATION_PRODUCT,
      DBEERPEDIA.BREWERIES_LABEL.stringValue(), ResultType.GRAPH,
      ImmutableList.of(parameter, parameter2), templateProcessorMock);

  mapper = new RequestParameterMapper();

  requestParameters = new RequestParameters();
  MultivaluedMap<String, String> mvMap = new MultivaluedHashMap<>();
  mvMap.put("param1", ImmutableList.of("value", "valueB"));
  mvMap.put("param2", ImmutableList.of("value2"));
  requestParameters.putAll(mvMap);
}
 
開發者ID:dotwebstack,項目名稱:dotwebstack-framework,代碼行數:22,代碼來源:RequestParameterMapperTest.java

示例5: map_ReturnsCorrectParameterName_ForHeaderParameter

import javax.ws.rs.core.MultivaluedMap; //導入方法依賴的package包/類
@Test
public void map_ReturnsCorrectParameterName_ForHeaderParameter() {
  // Arrange
  HeaderParameter headerParameter = new HeaderParameter();

  headerParameter.setName("param1");
  headerParameter.setIn("header");
  headerParameter.setVendorExtension(OpenApiSpecificationExtensions.PARAMETER,
      parameter.getIdentifier().stringValue());

  Operation operation = new Operation();
  operation.addParameter(headerParameter);

  MultivaluedMap<String, String> headerParameters = new MultivaluedHashMap<>();
  headerParameters.put(headerParameter.getName(), ImmutableList.of("value", "valueB"));

  // Act
  Map<String, String> result = mapper.map(operation, product, requestParameters);

  // Assert
  assertThat(result.size(), is(1));
  assertThat(result, hasEntry(parameter.getName(), "value"));
}
 
開發者ID:dotwebstack,項目名稱:dotwebstack-framework,代碼行數:24,代碼來源:RequestParameterMapperTest.java

示例6: map_ReturnsParameters_WithMultipleParameters

import javax.ws.rs.core.MultivaluedMap; //導入方法依賴的package包/類
@Test
public void map_ReturnsParameters_WithMultipleParameters() {
  // Arrange
  MultivaluedMap<String, String> queryParameters = new MultivaluedHashMap<>();

  // Note there are multiple values for this parameter, to test that the first value is used only
  queryParameters.put(requiredParameter.getName(), ImmutableList.of("value", "valueB"));
  queryParameters.put(optionalParameter.getName(), ImmutableList.of("value2"));

  when(uriInfoMock.getQueryParameters()).thenReturn(queryParameters);

  // Act
  Map<String, String> result = representationRequestParameterMapper.map(product, contextMock);

  // Assert
  assertThat(result.size(), is(2));
  assertThat(result, hasEntry(requiredParameter.getName(), "value"));
  assertThat(result, hasEntry(optionalParameter.getName(), "value2"));
}
 
開發者ID:dotwebstack,項目名稱:dotwebstack-framework,代碼行數:20,代碼來源:RepresentationRequestParameterMapperTest.java

示例7: applyTo

import javax.ws.rs.core.MultivaluedMap; //導入方法依賴的package包/類
/**
 * Transfer this list parameter the the passed multi valued map.
 * @param requestParams the target of the list params.
 * */
void applyTo(final MultivaluedMap<String, String> requestParams) {
    log.info("list={}", this);
    if (getOrder() != null) {
        requestParams.put("order",
                Collections.singletonList(getOrder().name()));
    }
    if (getReverseOrder() != null) {
        requestParams.put("reverse", Collections.singletonList(
                getReverseOrder().toString()));
    }
}
 
開發者ID:sfuhrm,項目名稱:radiobrowser4j,代碼行數:16,代碼來源:ListParameter.java

示例8: applyPaging

import javax.ws.rs.core.MultivaluedMap; //導入方法依賴的package包/類
/**
 * Transfer the paging parameters the the passed multi valued map.
 * @param paging the source of the paging params.
 * @param requestParams the target of the paging params.
 * */
private static void applyPaging(final Paging paging,
                final MultivaluedMap<String, String> requestParams) {
    Objects.requireNonNull(paging, "Paging must be non-null");
    log.info("paging={}", paging);
    requestParams.put("limit", Collections.singletonList(
            Integer.toString(paging.getLimit())));
    requestParams.put("offset", Collections.singletonList(
            Integer.toString(paging.getOffset())));
}
 
開發者ID:sfuhrm,項目名稱:radiobrowser4j,代碼行數:15,代碼來源:RadioBrowser.java

示例9: transferToMultivaluedMap

import javax.ws.rs.core.MultivaluedMap; //導入方法依賴的package包/類
/** Transfers all parameters for a new station to the given target params.
 * @param sourceStation the station to get fields from.
 * @param targetParams the target multi valued map to write the
 *                     request params to.
 * */
private static void transferToMultivaluedMap(final Station sourceStation,
                 final MultivaluedMap<String, String> targetParams) {
    targetParams.put("name",
            Collections.singletonList(sourceStation.getName()));
    targetParams.put("url",
            Collections.singletonList(sourceStation.getUrl()));

    if (sourceStation.getHomepage() != null) {
        targetParams.put("homepage",
                Collections.singletonList(sourceStation.getHomepage()));
    }
    if (sourceStation.getFavicon() != null) {
        targetParams.put("favicon",
                Collections.singletonList(sourceStation.getFavicon()));
    }
    if (sourceStation.getCountry() != null) {
        targetParams.put("country",
                Collections.singletonList(sourceStation.getCountry()));
    }
    if (sourceStation.getState() != null) {
        targetParams.put("state",
                Collections.singletonList(sourceStation.getState()));
    }
    if (sourceStation.getLanguage() != null) {
        targetParams.put("language",
                Collections.singletonList(sourceStation.getLanguage()));
    }
    if (sourceStation.getTags() != null) {
        targetParams.put("tagList",
                Collections.singletonList(
                        sourceStation.getTags()));
    }
}
 
開發者ID:sfuhrm,項目名稱:radiobrowser4j,代碼行數:39,代碼來源:RadioBrowser.java

示例10: map_ReturnsCorrectParameterName_ForPathParameters

import javax.ws.rs.core.MultivaluedMap; //導入方法依賴的package包/類
@Test
public void map_ReturnsCorrectParameterName_ForPathParameters() {
  // Arrange
  PathParameter pathParameter = new PathParameter();

  pathParameter.setName("param1");
  pathParameter.setIn("path");

  // Note this parameter has multiple vendor extensions
  pathParameter.setVendorExtension(OpenApiSpecificationExtensions.PARAMETER,
      parameter.getIdentifier().stringValue());
  pathParameter.setVendorExtension("x-dotwebstack-another-vendor-extension", "foo");

  // Note this operation has multiple parameters
  Operation operation = new Operation();
  operation.addParameter(pathParameter);

  PathParameter pathParameter2 = new PathParameter();

  pathParameter2.setName("param2");
  pathParameter2.setIn("path");
  pathParameter2.setVendorExtension(OpenApiSpecificationExtensions.PARAMETER,
      parameter2.getIdentifier().stringValue());

  operation.addParameter(pathParameter2);

  MultivaluedMap<String, String> pathParameters = new MultivaluedHashMap<>();

  // Note there are multiple values for this parameter, to test that the first value is used only
  pathParameters.put(pathParameter.getName(), ImmutableList.of("value", "valueB"));
  pathParameters.put(pathParameter2.getName(), ImmutableList.of("value2"));

  // Act
  Map<String, String> result = mapper.map(operation, product, requestParameters);

  // Assert
  assertThat(result.size(), is(2));
  assertThat(result, hasEntry(parameter.getName(), "value"));
  assertThat(result, hasEntry(parameter2.getName(), "value2"));
}
 
開發者ID:dotwebstack,項目名稱:dotwebstack-framework,代碼行數:41,代碼來源:RequestParameterMapperTest.java

示例11: mockCtx

import javax.ws.rs.core.MultivaluedMap; //導入方法依賴的package包/類
private ContainerRequestContext mockCtx() throws URISyntaxException {
  ContainerRequestContext ctx = mock(ContainerRequestContext.class);

  UriInfo uriInfo = mock(UriInfo.class);
  when(uriInfo.getPath()).thenReturn("/endpoint");
  URI requestUri = new URI("/endpoint");
  when(uriInfo.getRequestUri()).thenReturn(requestUri);

  when(ctx.getUriInfo()).thenReturn(uriInfo);
  when(ctx.getEntityStream()).thenReturn(mock(InputStream.class));

  MultivaluedMap<String, String> pathParameters = new MultivaluedHashMap<>();
  pathParameters.put(ID, ImmutableList.of(BPG));
  pathParameters.put("random-header-parameter", ImmutableList.of(EPSG));
  when(uriInfo.getPathParameters()).thenReturn(pathParameters);

  when(uriInfo.getQueryParameters()).thenReturn(new MultivaluedHashMap<>());

  MultivaluedMap<String, String> headers = new MultivaluedHashMap<>();
  headers.put("random-header-parameter", ImmutableList.of(EPSG));
  headers.put(HttpHeaders.CONTENT_TYPE,
      ImmutableList.of(ContentType.APPLICATION_JSON.toString()));
  when(ctx.getHeaders()).thenReturn(headers);

  return ctx;
}
 
開發者ID:dotwebstack,項目名稱:dotwebstack-framework,代碼行數:27,代碼來源:ApiRequestValidatorTest.java

示例12: putAll_MapContainsValues_WithMultivaluedMap

import javax.ws.rs.core.MultivaluedMap; //導入方法依賴的package包/類
@Test
public void putAll_MapContainsValues_WithMultivaluedMap() {
  MultivaluedMap<String, String> multivaluedMap = new MultivaluedHashMap<>();
  multivaluedMap.put("X", ImmutableList.of("A", "B"));
  RequestParameters parameters = new RequestParameters();

  parameters.putAll(multivaluedMap);

  Assert.assertEquals("A", parameters.get("X"));
}
 
開發者ID:dotwebstack,項目名稱:dotwebstack-framework,代碼行數:11,代碼來源:RequestParametersTest.java

示例13: convert

import javax.ws.rs.core.MultivaluedMap; //導入方法依賴的package包/類
/**
 * Convert the given map into {@link MultivaluedMap}.
 * @param data Map to convert
 * @return Converted map
 */
private static MultivaluedMap<String, String> convert(Map<String, List<String>> data) {
	if (data != null) {
		MultivaluedMap<String, String> mvm = new MultivaluedHashMap<>();
		for (Entry<String, List<String>> entry : data.entrySet()) {
			mvm.put(entry.getKey(), entry.getValue());
		}
		return mvm;
	}
	return null;
}
 
開發者ID:holon-platform,項目名稱:holon-jaxrs,代碼行數:16,代碼來源:JaxrsClientRestClient.java

示例14: apply

import javax.ws.rs.core.MultivaluedMap; //導入方法依賴的package包/類
@Override
public ClientResponse apply(final ClientRequest clientRequest) throws ProcessingException {
    final HttpUriRequest request = this.toUriHttpRequest(clientRequest);
    final Map<String, String> clientHeadersSnapshot = writeOutBoundHeaders(clientRequest.getHeaders(), request);

    try {
        final CloseableHttpResponse response;
        response = client.execute(new HttpHost(request.getURI().getHost(), request.getURI().getPort(), request.getURI().getScheme()), request, new BasicHttpContext(context));
        HeaderUtils.checkHeaderChanges(clientHeadersSnapshot, clientRequest.getHeaders(), this.getClass().getName());

        final Response.StatusType status = response.getStatusLine().getReasonPhrase() == null
                ? Statuses.from(response.getStatusLine().getStatusCode())
                : Statuses.from(response.getStatusLine().getStatusCode(), response.getStatusLine().getReasonPhrase());

        final ClientResponse responseContext = new ClientResponse(status, clientRequest);
        final List<URI> redirectLocations = context.getRedirectLocations();
        if(redirectLocations != null && !redirectLocations.isEmpty()) {
            responseContext.setResolvedRequestUri(redirectLocations.get(redirectLocations.size() - 1));
        }

        final Header[] respHeaders = response.getAllHeaders();
        final MultivaluedMap<String, String> headers = responseContext.getHeaders();
        for(final Header header : respHeaders) {
            final String headerName = header.getName();
            List<String> list = headers.get(headerName);
            if(list == null) {
                list = new ArrayList<>();
            }
            list.add(header.getValue());
            headers.put(headerName, list);
        }

        final HttpEntity entity = response.getEntity();

        if(entity != null) {
            if(headers.get(HttpHeaders.CONTENT_LENGTH) == null) {
                headers.add(HttpHeaders.CONTENT_LENGTH, String.valueOf(entity.getContentLength()));
            }

            final Header contentEncoding = entity.getContentEncoding();
            if(headers.get(HttpHeaders.CONTENT_ENCODING) == null && contentEncoding != null) {
                headers.add(HttpHeaders.CONTENT_ENCODING, contentEncoding.getValue());
            }
        }
        responseContext.setEntityStream(this.toInputStream(response));
        return responseContext;
    }
    catch(final Exception e) {
        throw new ProcessingException(e);
    }
}
 
開發者ID:iterate-ch,項目名稱:cyberduck,代碼行數:52,代碼來源:HttpComponentsConnector.java


注:本文中的javax.ws.rs.core.MultivaluedMap.put方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。