当前位置: 首页>>代码示例>>Java>>正文


Java GenericType类代码示例

本文整理汇总了Java中javax.ws.rs.core.GenericType的典型用法代码示例。如果您正苦于以下问题:Java GenericType类的具体用法?Java GenericType怎么用?Java GenericType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


GenericType类属于javax.ws.rs.core包,在下文中一共展示了GenericType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testRegister

import javax.ws.rs.core.GenericType; //导入依赖的package包/类
/**
 * Test if after registration of service they can be found in registry.
 */
@Test
public void testRegister() {
	 Response response1 = ClientBuilder.newBuilder().build().target("http://localhost:" 
			 + getTomcatPort() + "/test/rest/services/service1/abbaasd")
			 .request(MediaType.APPLICATION_JSON).put(Entity.text(""));
	 Assert.assertTrue(response1.getStatus() == Response.Status.OK.getStatusCode());
	 Response response2 = ClientBuilder.newBuilder().build().target("http://localhost:" 
			 + getTomcatPort() + "/test/rest/services/service1/abbaasd2")
			 .request(MediaType.APPLICATION_JSON).put(Entity.text(""));
	 Assert.assertTrue(response2.getStatus() == Response.Status.OK.getStatusCode());
	 Response response = ClientBuilder.newBuilder().build().target("http://localhost:" 
			 + getTomcatPort() + "/test/rest/services/service1").request(MediaType.APPLICATION_JSON).get();
	 Assert.assertTrue(response.getStatus() == Response.Status.OK.getStatusCode());
	 List<String> list = response.readEntity(new GenericType<List<String>>() { }); 
	 Assert.assertTrue(list != null);
	 Assert.assertTrue(list.size() == 2);
	 Assert.assertTrue(list.get(0).equals("abbaasd"));
	 Assert.assertTrue(list.get(1).equals("abbaasd2"));
}
 
开发者ID:DescartesResearch,项目名称:Pet-Supply-Store,代码行数:23,代码来源:RegistryTest.java

示例2: deserialize

import javax.ws.rs.core.GenericType; //导入依赖的package包/类
/**
 * Deserialize response body to Java object according to the Content-Type.
 * @param <T> Type
 * @param response Response
 * @param returnType Return type
 * @return Deserialize object
 * @throws ApiException API exception
 */
@SuppressWarnings("unchecked")
public <T> T deserialize(Response response, GenericType<T> returnType) throws ApiException {
  if (response == null || returnType == null) {
    return null;
  }

  if ("byte[]".equals(returnType.toString())) {
    // Handle binary response (byte array).
    return (T) response.readEntity(byte[].class);
  } else if (returnType.getRawType() == File.class) {
    // Handle file downloading.
    T file = (T) downloadFileFromResponse(response);
    return file;
  }

  String contentType = null;
  List<Object> contentTypes = response.getHeaders().get("Content-Type");
  if (contentTypes != null && !contentTypes.isEmpty())
    contentType = String.valueOf(contentTypes.get(0));
  if (contentType == null)
    throw new ApiException(500, "missing Content-Type in response");

  return response.readEntity(returnType);
}
 
开发者ID:square,项目名称:connect-java-sdk,代码行数:33,代码来源:ApiClient.java

示例3: getEnabledTransactions_returnsOkAndEnabledTransactions

import javax.ws.rs.core.GenericType; //导入依赖的package包/类
@Test
public void getEnabledTransactions_returnsOkAndEnabledTransactions(){
    URI uri = configAppRule.getUri("/config/transactions" + Urls.ConfigUrls.ENABLED_TRANSACTIONS_PATH).build();
    Response response = client.target(uri).request().get();
    assertThat(response.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
    List<TransactionDisplayData> transactionDisplayItems
                = response.readEntity(new GenericType<List<TransactionDisplayData>>() {});
    for (TransactionDisplayData transactionDisplayItem : transactionDisplayItems) {
        List<LevelOfAssurance> loas = transactionDisplayItem.getLoaList();
        assertThat(loas != null);
    }
}
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:13,代码来源:TransactionsResourceIntegrationTest.java

示例4: shouldSuccessfullyCreateRequestWithCustomRange

import javax.ws.rs.core.GenericType; //导入依赖的package包/类
@Test
public void shouldSuccessfullyCreateRequestWithCustomRange() {
    final String symbol = "IBM";
    final SplitsRange splitsRange = SplitsRange.ONE_YEAR;

    final RestRequest<List<Split>> request = new SplitsRequestBuilder()
            .withSymbol(symbol)
            .withSplitsRange(splitsRange)
            .build();

    assertThat(request.getMethodType()).isEqualTo(MethodType.GET);
    assertThat(request.getPath()).isEqualTo("/stock/{symbol}/splits/{range}");
    assertThat(request.getResponseType()).isEqualTo(new GenericType<List<Split>>() {});
    assertThat(request.getPathParams()).containsExactly(
            entry("symbol", symbol),
            entry("range", splitsRange.getCode()));
    assertThat(request.getQueryParams()).isEmpty();
}
 
开发者ID:WojciechZankowski,项目名称:iextrading4j,代码行数:19,代码来源:SplitsRequestBuilderTest.java

示例5: shouldReturnFibonacciNos

import javax.ws.rs.core.GenericType; //导入依赖的package包/类
@Test
public void shouldReturnFibonacciNos() {
    List<Sequence> first10FibonacciNos = ImmutableList.of(
            new Sequence(new BigInteger("1"), new BigInteger("0")),
            new Sequence(new BigInteger("2"), new BigInteger("1")),
            new Sequence(new BigInteger("3"), new BigInteger("1")),
            new Sequence(new BigInteger("4"), new BigInteger("2")),
            new Sequence(new BigInteger("5"), new BigInteger("3")),
            new Sequence(new BigInteger("6"), new BigInteger("5")),
            new Sequence(new BigInteger("7"), new BigInteger("8")),
            new Sequence(new BigInteger("8"), new BigInteger("13")),
            new Sequence(new BigInteger("9"), new BigInteger("21")),
            new Sequence(new BigInteger("10"), new BigInteger("34"))
    );
    List<Sequence> evenNos = resources.client().target("/fibonacci?limit=100").request().get(new GenericType<List<Sequence>>(){});

    assertThat(evenNos).hasSize(100);
    assertThat(evenNos).containsAll(first10FibonacciNos);
    assertThat(evenNos).contains(new Sequence(new BigInteger("100"), new BigInteger("218922995834555169026")));
}
 
开发者ID:kishaningithub,项目名称:infinitestreams,代码行数:21,代码来源:FibonacciResourceTest.java

示例6: testUnregisterSuccess

import javax.ws.rs.core.GenericType; //导入依赖的package包/类
/**
 * Test if unregistering a service actually removes it from the registry.
 */
@Test
public void testUnregisterSuccess() {
	 Response response1 = ClientBuilder.newBuilder().build().target("http://localhost:" 
			 + getTomcatPort() + "/test/rest/services/service2/abbaasd")
			 .request(MediaType.APPLICATION_JSON).put(Entity.text(""));
	 Assert.assertTrue(response1.getStatus() == Response.Status.OK.getStatusCode());
	 Response response2 = ClientBuilder.newBuilder().build().target("http://localhost:" 
			 + getTomcatPort() + "/test/rest/services/service2/abbaasd")
			 .request(MediaType.APPLICATION_JSON).delete();
	 Assert.assertTrue(response2.getStatus() == Response.Status.OK.getStatusCode());
	 Response response = ClientBuilder.newBuilder().build().target("http://localhost:" 
			 + getTomcatPort() + "/test/rest/services/service2").request(MediaType.APPLICATION_JSON).get();
	 Assert.assertTrue(response.getStatus() == Response.Status.OK.getStatusCode());
	 List<String> list = response.readEntity(new GenericType<List<String>>() { }); 
	 Assert.assertTrue(list != null);
	 Assert.assertTrue(list.size() == 0);
}
 
开发者ID:DescartesResearch,项目名称:Pet-Supply-Store,代码行数:21,代码来源:RegistryTest.java

示例7: getWebImages

import javax.ws.rs.core.GenericType; //导入依赖的package包/类
/**
 * Retrieves a series of web image.
 * @param names list of name of image.
 * @param size target size
 * @throws NotFoundException If 404 was returned.
 * @throws LoadBalancerTimeoutException On receiving the 408 status code
    * and on repeated load balancer socket timeouts.
 * @return HashMap containing requested images.
 */
public static HashMap<String, String> getWebImages(List<String> names, ImageSize size)
		throws NotFoundException, LoadBalancerTimeoutException {
	HashMap<String, String> img = new HashMap<>();
	for (String name : names) {
		img.put(name, size.toString());
	}
	
	Response r = ServiceLoadBalancer.loadBalanceRESTOperation(Service.IMAGE, "image", HashMap.class,
			client -> client.getService().path(client.getApplicationURI())
			.path(client.getEndpointURI()).path("getWebImages").request(MediaType.APPLICATION_JSON)
			.accept(MediaType.APPLICATION_JSON).post(Entity.entity(img, MediaType.APPLICATION_JSON)));
	
	if (r == null) {
		return new HashMap<String, String>();
	}
	
	HashMap<String, String> result = r.readEntity(new GenericType<HashMap<String, String>>() { });
	if (result == null) {
		return new HashMap<String, String>();
	}
	return result;
}
 
开发者ID:DescartesResearch,项目名称:Pet-Supply-Store,代码行数:32,代码来源:LoadBalancedImageOperations.java

示例8: testBeanParameter

import javax.ws.rs.core.GenericType; //导入依赖的package包/类
@Test
public void testBeanParameter() throws Exception {
  WebTarget webTarget = client.target(server.getURI().toString());
  Invocation.Builder invocationBuilder = webTarget.path("/book")
      .queryParam("author", "Scott Oaks")
      .request(MediaType.APPLICATION_JSON);

  Response response = invocationBuilder.get();
  Map<String, String> entity = response.readEntity(new GenericType<Map<String, String>>() {});

  assertThat(response.getStatus(), equalTo(OK.getStatusCode()));
  assertThat(entity.get("author"), equalTo("Scott Oaks"));
}
 
开发者ID:sorskod,项目名称:webserver,代码行数:14,代码来源:BeanParamIntegrationTest.java

示例9: if

import javax.ws.rs.core.GenericType; //导入依赖的package包/类
/**
 * Lists all of a location&#39;s item categories.
 * Lists all of a location&#39;s item categories.
 * @param locationId The ID of the location to list categories for. (required)
 * @return CompleteResponse<List<V1Category>>
 * @throws ApiException if fails to make API call
 */
public CompleteResponse<List<V1Category>>listCategoriesWithHttpInfo(String locationId) throws ApiException {
  Object localVarPostBody = null;
  
  // verify the required parameter 'locationId' is set
  if (locationId == null) {
    throw new ApiException(400, "Missing the required parameter 'locationId' when calling listCategories");
  }
  
  // create path and map variables
  String localVarPath = "/v1/{location_id}/categories"
    .replaceAll("\\{" + "location_id" + "\\}", apiClient.escapeString(locationId.toString()));

  // query params
  List<Pair> localVarQueryParams = new ArrayList<Pair>();
  Map<String, String> localVarHeaderParams = new HashMap<String, String>();
  Map<String, Object> localVarFormParams = new HashMap<String, Object>();


  
  
  final String[] localVarAccepts = {
    "application/json"
  };
  final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);

  final String[] localVarContentTypes = {
    "application/json"
  };
  final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);

  String[] localVarAuthNames = new String[] { "oauth2" };

  GenericType<List<V1Category>> localVarReturnType = new GenericType<List<V1Category>>() {};
  return (CompleteResponse<List<V1Category>>)apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
}
 
开发者ID:square,项目名称:connect-java-sdk,代码行数:43,代码来源:V1ItemsApi.java

示例10: listBankAccounts

import javax.ws.rs.core.GenericType; //导入依赖的package包/类
/**
 * Provides non-confidential details for all of a location&#39;s associated bank accounts. This endpoint does not provide full bank account numbers, and there is no way to obtain a full bank account number with the Connect API.
 * Provides non-confidential details for all of a location&#39;s associated bank accounts. This endpoint does not provide full bank account numbers, and there is no way to obtain a full bank account number with the Connect API.
 * @param locationId The ID of the location to list bank accounts for. (required)
 * @return List&lt;V1BankAccount&gt;
 * @throws ApiException if fails to make API call
 */
public List<V1BankAccount> listBankAccounts(String locationId) throws ApiException {
  Object localVarPostBody = null;
  
  // verify the required parameter 'locationId' is set
  if (locationId == null) {
    throw new ApiException(400, "Missing the required parameter 'locationId' when calling listBankAccounts");
  }
  
  // create path and map variables
  String localVarPath = "/v1/{location_id}/bank-accounts"
    .replaceAll("\\{" + "location_id" + "\\}", apiClient.escapeString(locationId.toString()));

  // query params
  List<Pair> localVarQueryParams = new ArrayList<Pair>();
  Map<String, String> localVarHeaderParams = new HashMap<String, String>();
  Map<String, Object> localVarFormParams = new HashMap<String, Object>();


  
  
  final String[] localVarAccepts = {
    "application/json"
  };
  final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);

  final String[] localVarContentTypes = {
    "application/json"
  };
  final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);

  String[] localVarAuthNames = new String[] { "oauth2" };

  GenericType<List<V1BankAccount>> localVarReturnType = new GenericType<List<V1BankAccount>>() {};
  CompleteResponse<List<V1BankAccount>> completeResponse = (CompleteResponse<List<V1BankAccount>>)apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
  return completeResponse.getData();
    }
 
开发者ID:square,项目名称:connect-java-sdk,代码行数:44,代码来源:V1TransactionsApi.java

示例11: doubleInMapTest

import javax.ws.rs.core.GenericType; //导入依赖的package包/类
@Test
public void doubleInMapTest() {
  MapTest response = client.target(SERVER_URI)
      .path("/doubleInMapTest")
      .request()
      .accept(MediaType.APPLICATION_JSON_TYPE)
      .get(new GenericType<MapTest>() {});
  check(response.mapDouble().values()).isOf(5.0d);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:10,代码来源:JaxrsTest.java

示例12: getOpenShiftClusters

import javax.ws.rs.core.GenericType; //导入依赖的package包/类
public List<String> getOpenShiftClusters(String authHeader) {
    URI targetURI = UriBuilder.fromUri(missionControlOpenShiftURI).path("/clusters").build();
    try {
        return perform(client -> client
                .target(targetURI)
                .request(MediaType.APPLICATION_JSON_TYPE)
                .header(HttpHeaders.AUTHORIZATION, authHeader)
                .get().readEntity(new GenericType<List<String>>() {
                }));
    } catch (Exception e) {
        log.log(Level.SEVERE, "Error while returning openshift clusters", e);
        return Collections.emptyList();
    }
}
 
开发者ID:fabric8-launcher,项目名称:launcher-backend,代码行数:15,代码来源:MissionControl.java

示例13: retrieveBusiness

import javax.ws.rs.core.GenericType; //导入依赖的package包/类
/**
 * Get a business&#39;s information.
 * Get a business&#39;s information.
 * @return V1Merchant
 * @throws ApiException if fails to make API call
 */
public V1Merchant retrieveBusiness() throws ApiException {
  Object localVarPostBody = null;
  
  // create path and map variables
  String localVarPath = "/v1/me";

  // query params
  List<Pair> localVarQueryParams = new ArrayList<Pair>();
  Map<String, String> localVarHeaderParams = new HashMap<String, String>();
  Map<String, Object> localVarFormParams = new HashMap<String, Object>();


  
  
  final String[] localVarAccepts = {
    "application/json"
  };
  final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);

  final String[] localVarContentTypes = {
    "application/json"
  };
  final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);

  String[] localVarAuthNames = new String[] { "oauth2" };

  GenericType<V1Merchant> localVarReturnType = new GenericType<V1Merchant>() {};
  CompleteResponse<V1Merchant> completeResponse = (CompleteResponse<V1Merchant>)apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
  return completeResponse.getData();
    }
 
开发者ID:square,项目名称:connect-java-sdk,代码行数:37,代码来源:V1LocationsApi.java

示例14: shouldSuccessfullyCreateRequest

import javax.ws.rs.core.GenericType; //导入依赖的package包/类
@Test
public void shouldSuccessfullyCreateRequest() {
    final String symbol = "IBM";

    final RestRequest<Map<String, SsrStatus>> request = new SsrStatusRequestBuilder()
            .withSymbol(symbol)
            .build();

    assertThat(request.getMethodType()).isEqualTo(MethodType.GET);
    assertThat(request.getPath()).isEqualTo("/deep/ssr-status");
    assertThat(request.getResponseType()).isEqualTo(new GenericType<Map<String, SsrStatus>>() {});
    assertThat(request.getPathParams()).isEmpty();
    assertThat(request.getQueryParams()).contains(entry("symbols", symbol));
}
 
开发者ID:WojciechZankowski,项目名称:iextrading4j,代码行数:15,代码来源:SsrStatusRequestBuilderTest.java

示例15: readEntity

import javax.ws.rs.core.GenericType; //导入依赖的package包/类
@Override
public <U> U readEntity(GenericType<U> entityType) {
  if (!entityType.getRawType().equals(bodyClass)) {
    throw new IllegalArgumentException(
        "Raw generic type is not the same type as the body entity");
  }

  return rawResponse.readEntity(entityType);
}
 
开发者ID:cerner,项目名称:beadledom,代码行数:10,代码来源:DelegatingGenericResponse.java


注:本文中的javax.ws.rs.core.GenericType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。