Package com.linkedin.restli.examples.custom.types

Examples of com.linkedin.restli.examples.custom.types.CustomLong


  {
    CreateIdRequest<CustomLong, Greeting> request = new CustomTypes2RequestBuilders(requestOptions).create().input(new Greeting().setId(10)).build();
    Response<IdResponse<CustomLong>> response = REST_CLIENT.sendRequest(request).getResponse();

    Assert.assertEquals(response.getStatus(), HttpStatus.S_201_CREATED.getCode());
    Assert.assertEquals(response.getEntity().getId(), new CustomLong(10L));
  }
View Full Code Here


    BatchCreateRequest<Greeting> request = builders.batchCreate().input(new Greeting().setId(1)).input(new Greeting().setId(2)).build();
    Response<CollectionResponse<CreateStatus>> response = REST_CLIENT.sendRequest(request).getResponse();
    List<CreateStatus> results = response.getEntity().getElements();

    Set<CustomLong> expectedKeys = new HashSet<CustomLong>();
    expectedKeys.add(new CustomLong(1L));
    expectedKeys.add(new CustomLong(2L));

    for(CreateStatus status: results)
    {
      @SuppressWarnings("unchecked")
      CreateIdStatus<CustomLong> createIdStatus = (CreateIdStatus<CustomLong>) status;
View Full Code Here

    BatchCreateIdRequest<CustomLong, Greeting> request = builders.batchCreate().input(new Greeting().setId(1)).input(new Greeting().setId(2)).build();
    Response<BatchCreateIdResponse<CustomLong>> response = REST_CLIENT.sendRequest(request).getResponse();
    List<CreateIdStatus<CustomLong>> results = response.getEntity().getElements();

    Set<CustomLong> expectedKeys = new HashSet<CustomLong>();
    expectedKeys.add(new CustomLong(1L));
    expectedKeys.add(new CustomLong(2L));

    for(CreateIdStatus<CustomLong> status: results)
    {
      Assert.assertEquals(status.getStatus().intValue(), HttpStatus.S_204_NO_CONTENT.getCode());
      Assert.assertTrue(expectedKeys.contains(status.getKey()));
View Full Code Here

  @Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "request4BuilderDataProvider")
  public void testCollectionSubResourceGet(RootBuilderWrapper<CustomLong, Greeting> builders) throws RemoteInvocationException
  {
    Long id2 = 2L;
    Long id4 = 4L;
    Request<Greeting> request = builders.get().setPathKey("customTypes2Id", new CustomLong(id2)).id(new CustomLong(id4)).build();
    Greeting result = REST_CLIENT.sendRequest(request).getResponse().getEntity();

    Assert.assertEquals(result.getId(), new Long(id2*id4));
  }
View Full Code Here

  @Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "request3BuilderDataProvider")
  public void testAssociationGet(RootBuilderWrapper<CompoundKey, Greeting> builders) throws RemoteInvocationException
  {
    Long lo = 5L;
    Long date = 13L;
    CustomTypes3Builders.Key key = new CustomTypes3Builders.Key().setLongId(new CustomLong(lo)).setDateId(new Date(date));

    Request<Greeting> request = builders.get().id(key).build();
    Greeting result = REST_CLIENT.sendRequest(request).getResponse().getEntity();

    Assert.assertEquals(result.getId()new Long(lo+date));
View Full Code Here

  @Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "request3BuilderDataProvider")
  public void testBatchUpdate(RootBuilderWrapper<CompoundKey, Greeting> builders) throws RemoteInvocationException
  {
    Long lo = 5L;
    Long date = 13L;
    CustomTypes3Builders.Key key = new CustomTypes3Builders.Key().setLongId(new CustomLong(lo)).setDateId(new Date(date));

    RequestBuilder<? extends Request<BatchKVResponse<CompoundKey, UpdateStatus>>> batchUpdateRequest = builders.batchUpdate().input(key, new Greeting().setId(1).setMessage("foo")).getBuilder();
    BatchKVResponse<CompoundKey, UpdateStatus> response = REST_CLIENT.sendRequest(batchUpdateRequest).getResponse().getEntity();

    Assert.assertEquals(response.getResults().keySet().size(), 1);
    CompoundKey expected = new CompoundKey();
    expected.append("dateId", new Date(date));
    expected.append("longId", new CustomLong(lo));
    Assert.assertEquals(response.getResults().keySet().iterator().next(), expected);
  }
View Full Code Here

  @Override
  public CreateResponse create(final Greeting greeting)
  {
    // just echo back the provided id (for testing only, this would not a be correct implementation of POST)
    return new CreateResponse(new CustomLong(greeting.getId()));
  }
View Full Code Here

  {
    List<CreateResponse> results = new ArrayList<CreateResponse>();
    for (Greeting greeting: entities.getInput())
    {
      // just echo back the provided ids (for testing only, this would not a be correct implementation of POST)
      results.add(new CreateResponse(new CustomLong(greeting.getId()), HttpStatus.S_204_NO_CONTENT));
    }
    return new BatchCreateResult<CustomLong, Greeting>(results);
  }
View Full Code Here

{

  @Override
  public Greeting get(CompoundKey key)
  {
    CustomLong longId = (CustomLong)key.getPart("longId");
    Date dateId = (Date)key.getPart("dateId");

    return new Greeting().setId(longId.toLong() + dateId.getTime());
  }
View Full Code Here

{

  @Override
  public Greeting get(CustomLong lo)
  {
    CustomLong customTypes2Id = (CustomLong)getContext().getPathKeys().get("customTypes2Id");
    return new Greeting().setId(customTypes2Id.toLong() * lo.toLong());
  }
View Full Code Here

TOP

Related Classes of com.linkedin.restli.examples.custom.types.CustomLong

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.