Java 类com.sun.jersey.api.client.GenericType 实例源码

项目:USM    文件:RoleRestServiceIT.java   
/**
 * Tests the getRoleNames operation.
 */
@Test
public void testRoleNames() {
    // Execute
    ServiceRequest<RoleQuery> request = new ServiceRequest<>();
    request.setRequester(vms_admin_com);
    request.setBody(new RoleQuery());

    ClientResponse response = client.getRoleNames(ClientResponse.class,
            request);
    GenericType<ServiceArrayResponse<String>> gType = new GenericType<ServiceArrayResponse<String>>() {
    };
    ServiceArrayResponse<String> sar = response.getEntity(gType);

    // Verify
    assertNotNull("Unexpected null result", response);
    List<String> roleNames = sar.getResults();
    assertNotNull("Expected Role " + USER_BROWSER + " not found",
            getRoleName(roleNames, USER_BROWSER));
    assertNotNull("Expected Role " + ADMINISTRATOR + "not found",
            getRoleName(roleNames, ADMINISTRATOR));
    assertNotNull("Expected Role " + SUPER_USER + "not found",
            getRoleName(roleNames, SUPER_USER));
}
项目:USM    文件:RoleRestServiceIT.java   
/**
 * Tests the findRoleNames operation.
 */
@Test
public void testFindRoles() 
 {
    // Execute
    ServiceRequest<FindRolesQuery> request = new ServiceRequest<>();
    request.setRequester(vms_admin_com);
    FindRolesQuery query = new FindRolesQuery();
    query.setPaginator(getDefaultPaginator());
   query.getPaginator().setLimit(50);
   query.setApplicationName("USM");
    request.setBody(query);
    ClientResponse response = client.findRoles(ClientResponse.class,
            request);
    GenericType<PaginationResponse<ComprehensiveRole>> gType = new GenericType<PaginationResponse<ComprehensiveRole>>() {
    };
    PaginationResponse<ComprehensiveRole> sar = response.getEntity(gType);
    // Verify
    assertNotNull("Unexpected null result", response);
    List<ComprehensiveRole> roles = sar.getResults();
    assertNotNull("Expected Role " + USER_BROWSER + " not found",
            getRole(roles, USER_BROWSER));
}
项目:USM    文件:RoleRestServiceIT.java   
@Test
public void testGetPermissions(){

 ServiceRequest<FindPermissionsQuery> request=new ServiceRequest<>();
 request.setRequester(vms_admin_com);
 FindPermissionsQuery query=new FindPermissionsQuery();
 query.setApplication("USM");
 query.setGroup(null);

 ClientResponse retrievedGroups=client.findPermissions(ClientResponse.class, request);
 GenericType<ServiceArrayResponse<Feature>> gtype=new GenericType<ServiceArrayResponse<Feature>>(){};

 ServiceArrayResponse<Feature> features=retrievedGroups.getEntity(gtype);
 assertNotNull("Response is not null",features);
 assertTrue("The list is bigger than 0", features.getResults().size()>0);
}
项目:USM    文件:RoleRestServiceIT.java   
/**
 * Tests the getRoles operation.
 */
@Test
public void testRoles() {
    // Execute
    ServiceRequest<RoleQuery> request = new ServiceRequest<>();
    request.setRequester(vms_admin_com);
    request.setBody(new RoleQuery());

    ClientResponse response = client.getRoles(ClientResponse.class,
            request);
    GenericType<ServiceArrayResponse<ComprehensiveRole>> gType = new GenericType<ServiceArrayResponse<ComprehensiveRole>>() {
    };
    ServiceArrayResponse<ComprehensiveRole> sar = response
            .getEntity(gType);

    // Verify
    assertNotNull("Unexpected null result", response);
    List<ComprehensiveRole> scopeNames = sar.getResults();
    assertNotNull("Expected Role " + USER_BROWSER + " not found",
            getRole(scopeNames, USER_BROWSER));
    assertNotNull("Expected Role " + ADMINISTRATOR + "not found",
            getRole(scopeNames, ADMINISTRATOR));
    assertNotNull("Expected Role " + SUPER_USER + "not found",
            getRole(scopeNames, SUPER_USER));
}
项目:USM    文件:ApplicationRestServiceIT.java   
/**
 * Tests the findApplications operation.
 */
@Test
public void testFindApplications() {
    // Execute
    ServiceRequest<FindApplicationQuery> request = new ServiceRequest<>();
    request.setRequester(vms_admin_com);
    FindApplicationQuery query = new FindApplicationQuery();
    query.setName(APPLICATION_USM);
    query.setPaginator(getDefaultPaginator());
    request.setBody(query);
    ClientResponse response = client.findApplications(ClientResponse.class, request);
    GenericType<PaginationResponse<Application>> gType = new GenericType<PaginationResponse<Application>>() {
    };
    PaginationResponse<Application> sar = response.getEntity(gType);
    // Verify
    assertNotNull("Unexpected null result", response);
    List<Application> applications = sar.getResults();
    assertNotNull("Expected Scope " + APPLICATION_USM + " not found", getApplication(applications, APPLICATION_USM));
}
项目:USM    文件:ApplicationRestServiceIT.java   
/**
 * Tests the getApplicationNames operation.
 */
@Test
public void testApplicationNames() {
    // Execute
    ServiceRequest<ApplicationQuery> request = new ServiceRequest<>();
    request.setRequester(vms_admin_com);
    request.setBody(new ApplicationQuery());

    ClientResponse response = client.getApplicationNames(ClientResponse.class, request);
    GenericType<ServiceArrayResponse<String>> gType = new GenericType<ServiceArrayResponse<String>>() {
    };
    ServiceArrayResponse<String> sar = response.getEntity(gType);

    // Verify
    assertNotNull("Unexpected null result", response);
    List<String> appNames = sar.getResults();
    assertEquals("Unexpected 'orgName' value", APPLICATION_USM,
            getAppName(appNames, APPLICATION_USM));
    assertEquals("Unexpected 'orgName' value", APPLICATION_QUOTA,
            getAppName(appNames, APPLICATION_QUOTA));
    assertEquals("Unexpected 'orgName' value", APPLICATION_UVMS,
            getAppName(appNames, APPLICATION_UVMS));
}
项目:USM    文件:AuthenticationRestServiceIT.java   
public void setMaxSessionAnySite(int newValue)
{
ServiceRequest<FindPoliciesQuery> findReq = new ServiceRequest<>();
    findReq.setRequester(usm_admin);
    FindPoliciesQuery q = new FindPoliciesQuery();
    q.setName("account.maxSessionAnySite");
    q.setSubject("Account");
    findReq.setBody(q);
ClientResponse findResp = client.findPolicies(ClientResponse.class, findReq);
    GenericType<List<Policy>> gtype = new GenericType<List<Policy>>(){};
    List<Policy> policiesFound = findResp.getEntity(gtype);

ServiceRequest<Policy> req = new ServiceRequest<>();
    req.setRequester(usm_admin);    

    Policy uPolicy = policiesFound.get(0);
    uPolicy.setValue(""+newValue);
    req.setBody(uPolicy);

ClientResponse resp = client.updatePolicy(ClientResponse.class, req);
}
项目:USM    文件:PolicyRestServiceIT.java   
/**
 * Tests the getSubjects operation.
 */
@Test
public void testSubjects() {
    // Execute
    ServiceRequest<NoBody> request = new ServiceRequest<>();
    request.setRequester(usm_admin);

    ClientResponse response = client.getSubjects(ClientResponse.class, request);
    GenericType<ServiceArrayResponse<String>> gType = new GenericType<ServiceArrayResponse<String>>() {
    };
    ServiceArrayResponse<String> sar = response.getEntity(gType);

    // Verify
    assertNotNull("Unexpected null result", sar);
    List<String> subjects = sar.getResults();
    assertNotNull("Expected Subject " + POL_PASSWORD + " not found",
            getSubject(subjects, POL_PASSWORD));
    assertNotNull("Expected Subject " + POL_ACCOUNT + "not found",
            getSubject(subjects, POL_ACCOUNT));
    assertNotNull("Expected Subject " + POL_FEATURE + "not found",
            getSubject(subjects, POL_FEATURE));
    assertNotNull("Expected Subject " + POL_ADMINISTRATION + "not found",
            getSubject(subjects, POL_ADMINISTRATION));
    assertNotNull("Expected Subject " + POL_AUTHENTICATION + "not found",
            getSubject(subjects, POL_AUTHENTICATION));
}
项目:USM    文件:UserRestServiceIT.java   
@Test
public void testGetNames() 
{
 ServiceRequest<String> request = new ServiceRequest<>();
 request.setRequester(usmAdmin);
  request.setBody("");

  // Execute
  ClientResponse response = manageUserClient.getUserNames(request);

  // Verify
  assertEquals("Unexpected http response status", 200, response.getStatus());
  GenericType<ServiceArrayResponse<String>> gType = new GenericType<ServiceArrayResponse<String>>() {
  };
  ServiceArrayResponse<String> sar = response.getEntity(gType);
  assertNotNull("Unexpected null service-response", response);
  List<String> result = sar.getResults();
  assertNotNull("Unexpected null result", result);
  assertFalse("Unexpected empty result", result.isEmpty());
}
项目:USM    文件:UserRestServiceIT.java   
@Test
    public void testGetChallenges() {
        ServiceRequest<String> request = new ServiceRequest<String>();
        request.setRequester(vms_admin_com);
        String userName = "vms_admin_com";

        // Execute
        ClientResponse response = manageUserClient.getChallenges(ClientResponse.class, userName, request);

        GenericType<ChallengeInformationResponse> gType = new GenericType<ChallengeInformationResponse>() {
        };
;
        // Verify
        String expectedRoleName = "User";
        assertNotNull("Unexpected null response", response);
        ChallengeInformationResponse challengeInformationResponse = response.getEntity(gType);
        assertNotNull("Unexpected null UserContextResponse", challengeInformationResponse);
        assertNotNull("Unexpected null UserContextResponse.results", challengeInformationResponse.getResults());

    }
项目:USM    文件:ScopeRestServiceIT.java   
/**
 * Tests the findScopes operation.
 */
@Test
public void testFindScopes() 
 {
    // Execute
    ServiceRequest<FindScopesQuery> request = new ServiceRequest<>();
    request.setRequester(vms_admin_com);
    FindScopesQuery query = new FindScopesQuery();
    query.setScopeName(GRC_QUOTAS);
    query.setPaginator(getDefaultPaginator());
    request.setBody(query);
    ClientResponse response = client.findScopes(ClientResponse.class,request);
    GenericType<PaginationResponse<Scope>> gType = new GenericType<PaginationResponse<Scope>>() {
    };
    PaginationResponse<Scope> sar = response.getEntity(gType);
    // Verify
    assertNotNull("Unexpected null result", response);
    List<Scope> scopes = sar.getResults();
    assertNotNull("Expected Scope " + GRC_QUOTAS + " not found",
            getScope(scopes, GRC_QUOTAS));
}
项目:USM    文件:ScopeRestServiceIT.java   
public Long findScope(String scopeName) 
 {
    // Set-up
    ServiceRequest<FindScopesQuery> request = new ServiceRequest<>();
    request.setRequester(vms_admin_com);
    FindScopesQuery query = new FindScopesQuery();
    query.setScopeName(scopeName);
    query.setPaginator(getDefaultPaginator());
    request.setBody(query);

    // Execute
    ClientResponse response = client.findScopes(ClientResponse.class,
            request);
    GenericType<PaginationResponse<Scope>> gType = new GenericType<PaginationResponse<Scope>>() {
    };
    PaginationResponse<Scope> sar = response.getEntity(gType);
    // Verify
    assertNotNull("Unexpected null result", response);
    List<Scope> scopes = sar.getResults();
    assertEquals("Unexpected result size", 1, scopes.size());
    return scopes.get(0).getScopeId();
}
项目:USM    文件:ScopeRestServiceIT.java   
private void addDatasets(Scope scope){
    ServiceRequest<FindDataSetQuery> datasetReq=new ServiceRequest<FindDataSetQuery>();
    datasetReq.setRequester(vms_admin_com);
    FindDataSetQuery bodyReq=new FindDataSetQuery();

    bodyReq.setApplicationName("Quota");
    bodyReq.setCategory("all");
    datasetReq.setBody(bodyReq);

    ClientResponse datasetRet=client.findDatasets(ClientResponse.class, datasetReq);

    //if no datasets are found prevent creating useless variables
    if (datasetRet.getStatus()!=204){
        GenericType<ServiceArrayResponse<DataSet>> gtype=new GenericType<ServiceArrayResponse<DataSet>>(){};
        ServiceArrayResponse<DataSet> retrievedDataSets=datasetRet.getEntity(gtype);
        scope.setDataSets(retrievedDataSets.getResults());
    }

}
项目:USM    文件:ScopeRestServiceIT.java   
/**
 * Tests the getScopeNames operation.
 */
@Test
public void testScopes() {
    // Execute
    ServiceRequest<ScopeQuery> request = new ServiceRequest<>();
    request.setRequester(vms_admin_com);
    request.setBody(new ScopeQuery());

    ClientResponse response = client.getScopes(ClientResponse.class,
            request);
    GenericType<ServiceArrayResponse<ComprehensiveScope>> gType = new GenericType<ServiceArrayResponse<ComprehensiveScope>>() {
    };
    ServiceArrayResponse<ComprehensiveScope> sar = response.getEntity(gType);

    // Verify
    assertNotNull("Unexpected null result", response);
    List<ComprehensiveScope> scopeNames = sar.getResults();
    assertNotNull("Expected Scope " + FRA_QUOTAS + " not found",
            getScopeName(scopeNames, FRA_QUOTAS));
    assertNotNull("Expected Scope " + GRC_QUOTAS + "not found",
            getScopeName(scopeNames, GRC_QUOTAS));
    assertNotNull("Expected Scope " + SOME_REPORTS + "not found",
            getScopeName(scopeNames, SOME_REPORTS));
}
项目:USM    文件:OrganisationRestServiceIT.java   
@Test
public void testGetOrganisation() {
  // Set-up
  Long organisationId = findOrganisation(ORGANISATION_GRC);

  // Execute
  ServiceRequest<Long> request = new ServiceRequest<>();
  request.setRequester(vms_admin_com);
  request.setBody(organisationId);

  ClientResponse response = client.getOrganisation(ClientResponse.class, request);
  GenericType<Organisation> gType = new GenericType<Organisation>() {
  };
  Organisation organisation = response.getEntity(gType);
  // Verify
  assertNotNull("Unexpected null result", response);
  assertEquals("Unexpected 'scopeName' value", ORGANISATION_GRC, organisation.getName());
}
项目:USM    文件:OrganisationRestServiceIT.java   
@Test
public void testUpdateOrganisation() {
  ServiceRequest<Organisation> request = createOrgRequest();

  ClientResponse response = client.createOrganisation(ClientResponse.class, request);
  assertEquals("Unexpected Response.Status", Response.Status.OK.getStatusCode(), response.getStatus());

  Organisation sar = response.getEntity(Organisation.class);
  sar.setStatus("D");
  request.setBody(sar);

  //responseUpdate
  response = client.updateOrganisation(ClientResponse.class, request);
  assertEquals("Unexpected Response.Status", Response.Status.OK.getStatusCode(), response.getStatus());

  GenericType<Organisation> orgType = new GenericType<Organisation>() {
  };
  Organisation org = response.getEntity(orgType);

  assertNotNull("Unexpected returned organisation is null", org);
  assertTrue("Unexpected Status", org.getStatus().equals("D"));
}
项目:USM    文件:OrganisationRestServiceIT.java   
@Test
public void testDeleteOrganisation() {
  //prepare the role
  ServiceRequest<Organisation> request = createOrgRequest();

  ClientResponse response = client.createOrganisation(ClientResponse.class, request);

  assertEquals("Unexpected Response.Status", Response.Status.OK.getStatusCode(), response.getStatus());

  GenericType<Organisation> gType = new GenericType<Organisation>() {
  };
  Organisation sar = response.getEntity(gType);

  //delete the role
  ServiceRequest<String> deleteRequest = new ServiceRequest<>();
  deleteRequest.setBody(sar.getOrganisationId().toString());
  deleteRequest.setRequester(request.getRequester());

  response = client.deleteOrganisation(ClientResponse.class, deleteRequest);
  assertEquals("Unexpected Response.Status", Response.Status.OK.getStatusCode(), response.getStatus());

}
项目:USM    文件:OrganisationRestServiceIT.java   
@Test
public void testUpdateEndpoint() {
  ServiceRequest<EndPoint> request = createEndpointRequest();

  ClientResponse response = client.createEndPoint(ClientResponse.class, request);
  assertEquals("Unexpected Response.Status", Response.Status.OK.getStatusCode(), response.getStatus());

  EndPoint sar = response.getEntity(EndPoint.class);
  sar.setStatus("D");
  sar.setOrganisationName(ORGANISATION_EC);
  request.setBody(sar);

  //responseUpdate
  response = client.updateEndPoint(ClientResponse.class, request);
  assertEquals("Unexpected Response.Status", Response.Status.OK.getStatusCode(), response.getStatus());

  GenericType<EndPoint> orgType = new GenericType<EndPoint>() {
  };
  EndPoint endPoint = response.getEntity(orgType);

  assertNotNull("Unexpected returned endpoint is null", endPoint);
  assertTrue("Unexpected Status", endPoint.getStatus().equals("D"));
}
项目:USM    文件:OrganisationRestServiceIT.java   
@Test
public void testUpdateChannel() {
  ServiceRequest<Channel> request = createChannelRequest();

  ClientResponse response = client.createChannel(ClientResponse.class, request);
  assertEquals("Unexpected Response.Status", Response.Status.OK.getStatusCode(), response.getStatus());

  Channel sar = response.getEntity(Channel.class);
  sar.setPriority(2);
  request.setBody(sar);

  //responseUpdate
  response = client.updateChannel(ClientResponse.class, request);
  assertEquals("Unexpected Response.Status", Response.Status.OK.getStatusCode(), response.getStatus());

  GenericType<Channel> orgType = new GenericType<Channel>() {
  };
  Channel channel = response.getEntity(orgType);

  assertNotNull("Unexpected returned endpoint is null", channel);
  assertTrue("Unexpected priority", channel.getPriority().equals(2));
}
项目:USM    文件:OrganisationRestServiceIT.java   
@Test
public void testDeleteChannel() {
  //prepare the role
  ServiceRequest<Channel> request = createChannelRequest();

  ClientResponse response = client.createChannel(ClientResponse.class, request);

  assertEquals("Unexpected Response.Status", Response.Status.OK.getStatusCode(), response.getStatus());

  GenericType<Channel> gType = new GenericType<Channel>() {
  };
  Channel sar = response.getEntity(gType);

  //delete the role
  ServiceRequest<String> deleteRequest = new ServiceRequest<>();
  deleteRequest.setBody(sar.getChannelId().toString());
  deleteRequest.setRequester(request.getRequester());

  response = client.deleteChannel(ClientResponse.class, deleteRequest);
  assertEquals("Unexpected Response.Status", Response.Status.OK.getStatusCode(), response.getStatus());

}
项目:USM    文件:OrganisationRestServiceIT.java   
public Long findOrganisation(String organisationName) {
  ServiceRequest<FindOrganisationsQuery> request = new ServiceRequest<>();
  request.setRequester(vms_admin_com);
  FindOrganisationsQuery query = new FindOrganisationsQuery();
  query.setName(organisationName);
  query.setPaginator(getDefaultPaginator());
  request.setBody(query);

  ClientResponse response = client.findOrganisations(ClientResponse.class, request);
  GenericType<PaginationResponse<Organisation>> gType = new GenericType<PaginationResponse<Organisation>>() {
  };
  PaginationResponse<Organisation> sar = response.getEntity(gType);
  // Verify
  assertNotNull("Unexpected null result", response);
  List<Organisation> organisations = sar.getResults();
  assertEquals("Unexpected result size", 1, organisations.size());
  return organisations.get(0).getOrganisationId();
}
项目:USM    文件:PersonRestClient.java   
public Boolean isUpdateContactDetailsEnabled(ServiceRequest<NoBody> request) 
{
  ClientResponse r = webResource.path("/isUpdateContactDetailsEnabled").
                         header("Authorization", request.getRequester()).
                         type(MediaType.APPLICATION_JSON).
                         get(ClientResponse.class);

  Boolean ret = null;
  if (Response.Status.OK.getStatusCode() == r.getStatus()) {
    GenericType<ResponseWrapper<Boolean>> gType;
    gType = new GenericType< ResponseWrapper<Boolean>>() {};
    ResponseWrapper<Boolean> sar = r.getEntity(gType);
    ret = sar.getResult();
  }

  return ret;
}
项目:USM    文件:PersonRestClient.java   
public List<PendingContactDetails> findPendingContactDetails(ServiceRequest<NoBody> request)
{
  ClientResponse r = webResource.path("/pendingContactDetails/").
                              header("Authorization", request.getRequester()).
                              type(MediaType.APPLICATION_JSON).
                              get(ClientResponse.class);

  List<PendingContactDetails> ret = null;
  if (Response.Status.OK.getStatusCode() == r.getStatus()) {
    GenericType< ServiceArrayResponse<PendingContactDetails>> gType;
    gType = new GenericType< ServiceArrayResponse<PendingContactDetails>>() {};
    ServiceArrayResponse<PendingContactDetails> sar = r.getEntity(gType);
    ret = sar.getResults();
  }

  return ret;
}
项目:USM    文件:InformationRestClient.java   
public List<Organisation> findOrganisations(String nation) 
throws IllegalArgumentException, RuntimeException 
{
  String path = MessageFormat.format("organisation/nation/{0}", 
                                     new Object[]{nation});

  ClientResponse response =  webResource.path(path).
                                         accept(MediaType.APPLICATION_JSON).
                                         get(ClientResponse.class);
  List<Organisation> ret = null;

  if (ClientResponse.Status.OK == response.getClientResponseStatus()) {
    ret = response.getEntity(new GenericType<List<Organisation>>(){});
  } else if (ClientResponse.Status.NO_CONTENT == response.getClientResponseStatus()) {
    ret = new ArrayList<>();
  } else if (ClientResponse.Status.NOT_FOUND  != response.getClientResponseStatus()) {
    handleError(response);
  }

  return ret;
}
项目:twitter-java-ads-sdk    文件:Cursor.java   
@SuppressWarnings("hiding")
protected <T> GenericType<Collection<T>> getParameterizedCollectionType(Object obj) {
    ParameterizedType parameterizedGenericType = new ParameterizedType() {
        public Type[] getActualTypeArguments() {
            return new Type[] { obj.getClass() };
        }

        public Type getRawType() {
            return Collection.class;
        }

        public Type getOwnerType() {
            return Collection.class;
        }
    };
    return new GenericType<Collection<T>>(parameterizedGenericType) {
    };
}
项目:emodb    文件:DataStoreJerseyTest.java   
/** Test getTimeline() with timestamp start/end instead of UUIDs. */
@Test
public void testGetTimelineRESTTimestampsForward() throws Exception {
    Date start = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").parse("2012-03-15 16:12:34.567");
    Date end = new Date();
    UUID startUuid = TimeUUIDs.uuidForTimestamp(start);
    UUID endUuid = TimeUUIDs.getPrevious(TimeUUIDs.uuidForTimeMillis(end.getTime() + 1));
    when(_server.getTimeline("table-name", "row-key", true, false, startUuid, endUuid, false, 10, ReadConsistency.STRONG))
            .thenReturn(Iterators.<Change>emptyIterator());

    DateTimeFormatter format = ISODateTimeFormat.dateTime().withZoneUTC();
    URI uri = UriBuilder.fromUri("/sor/1")
            .segment("table-name", "row-key", "timeline")
            .queryParam("start", format.print(start.getTime()))
            .queryParam("end", format.print(end.getTime()))
            .queryParam("reversed", "false")
            .build();
    _resourceTestRule.client().resource(uri)
            .accept(MediaType.APPLICATION_JSON_TYPE)
            .header(ApiKeyRequest.AUTHENTICATION_HEADER, APIKEY_TABLE)
            .get(new GenericType<List<Change>>() {
            });

    verify(_server).getTimeline("table-name", "row-key", true, false, startUuid, endUuid, false, 10, ReadConsistency.STRONG);
    verifyNoMoreInteractions(_server);
}
项目:emodb    文件:DataStoreJerseyTest.java   
/** Test getTimeline() with timestamp start/end instead of UUIDs. */
@Test
public void testGetTimelineRESTTimestampsReversed() throws Exception {
    Date start = new Date();
    Date end = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").parse("2012-03-15 16:12:34.567");
    UUID startUuid = TimeUUIDs.getPrevious(TimeUUIDs.uuidForTimeMillis(start.getTime() + 1));
    UUID endUuid = TimeUUIDs.uuidForTimestamp(end);
    when(_server.getTimeline("table-name", "row-key", true, false, startUuid, endUuid, true, 10, ReadConsistency.STRONG))
            .thenReturn(Iterators.<Change>emptyIterator());

    DateTimeFormatter format = ISODateTimeFormat.dateTime().withZoneUTC();
    URI uri = UriBuilder.fromUri("/sor/1")
            .segment("table-name", "row-key", "timeline")
            .queryParam("start", format.print(start.getTime()))
            .queryParam("end", format.print(end.getTime()))
            .build();
    _resourceTestRule.client().resource(uri)
            .accept(MediaType.APPLICATION_JSON_TYPE)
            .header(ApiKeyRequest.AUTHENTICATION_HEADER, APIKEY_TABLE)
            .get(new GenericType<List<Change>>() {
            });

    verify(_server).getTimeline("table-name", "row-key", true, false, startUuid, endUuid, true, 10, ReadConsistency.STRONG);
    verifyNoMoreInteractions(_server);
}
项目:emodb    文件:ReplicationClient.java   
@Override
public List<ReplicationEvent> get(String channel, int limit) {
    checkNotNull(channel, "channel");
    try {
        URI uri = _replicationSource.clone()
                .segment(channel)
                .queryParam("limit", limit)
                .build();
        return _client.resource(uri)
                .accept(MediaType.APPLICATION_JSON_TYPE)
                .header(ApiKeyRequest.AUTHENTICATION_HEADER, _apiKey)
                .get(new GenericType<List<ReplicationEvent>>() {});
    } catch (UniformInterfaceException e) {
        throw convertException(e);
    }
}
项目:conductor    文件:ClientBase.java   
protected <T> T postForEntity(String url, Object request, Object[] queryParams, GenericType<T> responseType, Object... uriVariables) {
    try {

        URI URI = getURI(root + url, queryParams).build(uriVariables);
        if(responseType == null) {
            resource(URI, request).post();
            return null;
        }
        T response = resource(URI, request).post(responseType);
        return response;
    } catch(Exception e){
        handleException(e);
    }
    return null;
}
项目:conductor    文件:ClientBase.java   
protected <T> T getForEntity(String url, Object[] queryParams, GenericType<T> responseType, Object... uriVariables) {
    try {
        URI URI = getURI(root + url, queryParams).build(uriVariables);
        T response = client.resource(URI).accept(MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN).get(responseType);
        return response;
    } catch (Exception e) {
        handleException(e);
    }
    return null;
}
项目:forge-api-java-client    文件:HubsApi.java   
/**
 * 
 * Returns a collection of accessible hubs for this member. A Hub represents an A360 Team/Personal hub or a BIM 360 account. 
 * @param filterId filter by the &#x60;id&#x60; of the &#x60;ref&#x60; target (optional)
 * @param filterExtensionType filter by the extension type (optional)
 * @return Hubs
 * @throws ApiException if fails to make API call
 */
public ApiResponse<Hubs> getHubs(List<String> filterId, List<String> filterExtensionType,  Authentication oauth2, Credentials credentials) throws ApiException, Exception {

  Object localVarPostBody = null;

  // create path and map variables
  String localVarPath = "/project/v1/hubs".replaceAll("\\{format\\}","json");

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

  localVarQueryParams.addAll(apiClient.parameterToPairs("csv", "filter[id]", filterId));
  localVarQueryParams.addAll(apiClient.parameterToPairs("csv", "filter[extension.type]", filterExtensionType));



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

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

  GenericType<Hubs> localVarReturnType = new GenericType<Hubs>() {};
  return apiClient.invokeAPI(oauth2, credentials, localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarReturnType);
    }
项目:forge-api-java-client    文件:DerivativesApi.java   
/**
 * 
 * Translate a source file from one format to another.  Derivatives are stored in a manifest that is updated each time this endpoint is used on a source file.  Note that this endpoint is asynchronous and initiates a process that runs in the background, rather than keeping an open HTTP connection until completion. Use the [GET {urn}/manifest](https://developer.autodesk.com/en/docs/model-derivative/v2/reference/http/urn-manifest-GET) endpoint to poll for the job’s completion. 
 * @param job  (required)
 * @param xAdsForce &#x60;true&#x60;: the endpoint replaces previously translated output file types with the newly generated derivatives  &#x60;false&#x60; (default): previously created derivatives are not replaced  (optional, default to false)
 * @return Job
 * @throws ApiException if fails to make API call
 */
public ApiResponse<Job> translate(JobPayload job, Boolean xAdsForce,  Authentication oauth2, Credentials credentials) throws ApiException, Exception {

  Object localVarPostBody = job;

  // verify the required parameter 'job' is set
  if (job == null) {
    throw new ApiException(400, "Missing the required parameter 'job' when calling translate");
  }

  // create path and map variables
  String localVarPath = "/modelderivative/v2/designdata/job".replaceAll("\\{format\\}","json");

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


  if (xAdsForce != null)
    localVarHeaderParams.put("x-ads-force", apiClient.parameterToString(xAdsForce));


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

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

  GenericType<Job> localVarReturnType = new GenericType<Job>() {};
  return apiClient.invokeAPI(oauth2, credentials, localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarReturnType);
    }
项目:forge-api-java-client    文件:BucketsApi.java   
/**
 * 
 * This endpoint will return the buckets owned by the application. This endpoint supports pagination. 
 * @param region The region where the bucket resides Acceptable values: &#x60;US&#x60;, &#x60;EMEA&#x60; Default is &#x60;US&#x60;  (optional, default to US)
 * @param limit Limit to the response size, Acceptable values: 1-100 Default &#x3D; 10  (optional, default to 10)
 * @param startAt Key to use as an offset to continue pagination This is typically the last bucket key found in a preceding GET buckets response  (optional)
 * @return Buckets
 * @throws ApiException if fails to make API call
 */
public ApiResponse<Buckets> getBuckets(String region, Integer limit, String startAt,  Authentication oauth2, Credentials credentials) throws ApiException, Exception {

  Object localVarPostBody = null;

  // create path and map variables
  String localVarPath = "/oss/v2/buckets".replaceAll("\\{format\\}","json");

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

  localVarQueryParams.addAll(apiClient.parameterToPairs("", "region", region));
  localVarQueryParams.addAll(apiClient.parameterToPairs("", "limit", limit));
  localVarQueryParams.addAll(apiClient.parameterToPairs("", "startAt", startAt));



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

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

  GenericType<Buckets> localVarReturnType = new GenericType<Buckets>() {};
  return apiClient.invokeAPI(oauth2, credentials, localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarReturnType);
    }
项目:forge-api-java-client    文件:WorkItemsApi.java   
/**
 * Returns the details of all WorkItems.
 * 
 * @param skip  (optional)
 * @return DesignAutomationWorkItems
 * @throws ApiException if fails to make API call
 */
public ApiResponse<DesignAutomationWorkItems> getAllWorkItems(Integer skip,  Authentication oauth2, Credentials credentials) throws ApiException, Exception {

  Object localVarPostBody = null;

  // create path and map variables
  String localVarPath = "/autocad.io/us-east/v2/WorkItems".replaceAll("\\{format\\}","json");

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

  localVarQueryParams.addAll(apiClient.parameterToPairs("", "$skip", skip));



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

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

  GenericType<DesignAutomationWorkItems> localVarReturnType = new GenericType<DesignAutomationWorkItems>() {};
  return apiClient.invokeAPI(oauth2, credentials, localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarReturnType);
    }
项目:USM    文件:RoleRestServiceIT.java   
/**
 * Tests the getRole operation.
 */
@Test
public void testGetRole() 
 {
  // Set-up
  Long roleId = findRole();

    // Execute
    ServiceRequest<GetRoleQuery> request = new ServiceRequest<>();
    request.setRequester(vms_admin_com);
    GetRoleQuery getRoleQuery = new GetRoleQuery();
    getRoleQuery.setRoleId(roleId);
    request.setBody(getRoleQuery);

    ClientResponse response = client.getRole(ClientResponse.class,
            request);
    GenericType<Role> gType = new GenericType<Role>() {
    };
    Role role = response.getEntity(gType);

    // Verify
    assertNotNull("Unexpected null result", response);
    assertNotNull("Unexpected null result.Features", role.getFeatures());
    assertEquals("Unexpected 'roleName' value", ROLE_NAME, role.getName());
    assertEquals("Unexpected 'roleDescription' value", ROLE_DESCRIPTION, role.getDescription());
    assertEquals("Unexpected 'roleStatus' value", ROLE_STATUS, role.getStatus());
}
项目:forge-api-java-client    文件:AppPackagesApi.java   
/**
 * Returns the details of all AppPackages.
 * 
 * @return DesignAutomationAppPackages
 * @throws ApiException if fails to make API call
 */
public ApiResponse<DesignAutomationAppPackages> getAllAppPackages( Authentication oauth2, Credentials credentials) throws ApiException, Exception {

  Object localVarPostBody = null;

  // create path and map variables
  String localVarPath = "/autocad.io/us-east/v2/AppPackages".replaceAll("\\{format\\}","json");

  // 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/vnd.api+json", "application/json"
  };
  final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);

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

  GenericType<DesignAutomationAppPackages> localVarReturnType = new GenericType<DesignAutomationAppPackages>() {};
  return apiClient.invokeAPI(oauth2, credentials, localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarReturnType);
    }
项目:USM    文件:RoleRestServiceIT.java   
@Test
public void deleteRole()
 {
    //prepare the role
   ServiceRequest<ComprehensiveRole> request=createRequest();

    ClientResponse response = client.createRole(ClientResponse.class, 
                                               request);

    assertEquals("Unexpected Response.Status", 
    Response.Status.OK.getStatusCode(), 
    response.getStatus());

    GenericType<ComprehensiveRole> gType = new GenericType<ComprehensiveRole>() {
    };
    ComprehensiveRole sar = response.getEntity(gType);

    //delete the role
    ServiceRequest<String> deleteRequest=new ServiceRequest<>();
    deleteRequest.setBody(sar.getRoleId().toString());
    deleteRequest.setRequester(request.getRequester());

     response = client.deleteRole(ClientResponse.class, 
               deleteRequest);

     assertEquals("Unexpected Response.Status",Response.Status.OK.getStatusCode(),
             response.getStatus());

}
项目:USM    文件:RoleRestServiceIT.java   
private ServiceRequest<ComprehensiveRole> createRequest()
 {
   ComprehensiveRole requestBody = new ComprehensiveRole();
   requestBody.setName("testRole" + System.currentTimeMillis());
   requestBody.setStatus("E");

   ServiceRequest<ComprehensiveRole> request = new ServiceRequest<>();
   request.setRequester(usm_admin);
   request.setBody(requestBody);

   ServiceRequest<String> featureReq = new ServiceRequest<>();
   featureReq.setBody("USM");
   featureReq.setRequester(request.getRequester());

   ClientResponse featureResponse = appClient.getApplicationFeatures(ClientResponse.class, featureReq);
   GenericType<ServiceArrayResponse<Feature>> gType1 = new GenericType<ServiceArrayResponse<Feature>>() {
   };
   ServiceArrayResponse<Feature> features = featureResponse.getEntity(gType1);

   List<Feature> featureList = features.getResults();
   List<Long> permissions = new ArrayList<>();
   //execute
   if (featureList != null && !featureList.isEmpty()) {
     for (Feature element : featureList) {
       permissions.add(element.getFeatureId());
     }
   }
   request.getBody().setFeatures(permissions);
   return request;
}
项目:USM    文件:AuthenticationRestServiceIT.java   
public int getMaxSessionAnySite()
{
   ServiceRequest<FindPoliciesQuery> findReq = new ServiceRequest<>();
    findReq.setRequester(usm_admin);
    FindPoliciesQuery q = new FindPoliciesQuery();
    q.setName("account.maxSessionAnySite");
    q.setSubject("Account");
    findReq.setBody(q);
ClientResponse findResp = client.findPolicies(ClientResponse.class, findReq);
    GenericType<List<Policy>> gtype = new GenericType<List<Policy>>(){};
    List<Policy> policiesFound = findResp.getEntity(gtype);

    return Integer.parseInt(policiesFound.get(0).getValue());
}
项目:USM    文件:AuthenticationRestServiceIT.java   
public int getMaxSessionOneSite()
{
   ServiceRequest<FindPoliciesQuery> findReq = new ServiceRequest<>();
    findReq.setRequester(usm_admin);
    FindPoliciesQuery q = new FindPoliciesQuery();
    q.setName("account.maxSessionOneSite");
    q.setSubject("Account");
    findReq.setBody(q);
ClientResponse findResp = client.findPolicies(ClientResponse.class, findReq);
    GenericType<List<Policy>> gtype = new GenericType<List<Policy>>(){};
    List<Policy> policiesFound = findResp.getEntity(gtype);

    return Integer.parseInt(policiesFound.get(0).getValue());
}