当前位置: 首页>>代码示例>>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;未经允许,请勿转载。