Package com.linkedin.restli.examples.greetings.api

Examples of com.linkedin.restli.examples.greetings.api.Greeting


  @Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestOptionsDataProvider")
  public void testCollectionBatchCreate(RestliRequestOptions options) throws RemoteInvocationException
  {
    CustomTypes2Builders builders = new CustomTypes2Builders(options);
    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));
View Full Code Here


  @Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestOptionsDataProvider")
  public void testCollectionBatchCreateId(RestliRequestOptions options) throws RemoteInvocationException
  {
    CustomTypes2RequestBuilders builders = new CustomTypes2RequestBuilders(options);
    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));
View Full Code Here

  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

    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

  {
    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));
View Full Code Here

  {
    Long lo = 29L;
    Long date = 10L;
    ChainedTyperefsBuilders.Key key = new ChainedTyperefsBuilders.Key().setAge(new CustomNonNegativeLong(lo)).setBirthday(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(1, response.getResults().keySet().size());
    CompoundKey expected = new CompoundKey();
    expected.append("birthday", new Date(date));
View Full Code Here

  @Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestBuilderDataProvider")
  public void testRootSimpleResourceGet(RootBuilderWrapper<Void, Greeting> builders) throws RemoteInvocationException
  {
    Request<Greeting> request = builders.get().build();
    Response<Greeting> response = REST_CLIENT.sendRequest(request).getResponse();
    Greeting greeting = response.getEntity();
    Assert.assertEquals(greeting.getId().longValue(), 12345L);
  }
View Full Code Here

  }

  @Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestBuilderDataProvider")
  public void testRootSimpleResourceUpdate(RootBuilderWrapper<Void, Greeting> builders) throws RemoteInvocationException
  {
    Greeting greeting = new Greeting();
    greeting.setMessage("Message1");
    greeting.setTone(Tone.INSULTING);
    greeting.setId(12345L);

    // PUT
    Request<EmptyRecord> writeRequest = builders.update().input(greeting).build();
    REST_CLIENT.sendRequest(writeRequest).getResponse();

    // GET again, to verify that our PUT worked.
    Request<Greeting> request = builders.get().build();
    Response<Greeting> response = REST_CLIENT.sendRequest(request).getResponse();
    greeting = response.getEntity();

    Assert.assertEquals(greeting.getTone(), Tone.INSULTING);
  }
View Full Code Here

  }

  @Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestBuilderDataProvider")
  public void testRootSimpleResourcePartialUpdate(RootBuilderWrapper<Void, Greeting> builders) throws RemoteInvocationException
  {
    Greeting greeting = new Greeting();
    greeting.setMessage("Message1");
    greeting.setTone(Tone.SINCERE);
    greeting.setId(12345L);
    PatchRequest<Greeting> patch = PatchGenerator.diffEmpty(greeting);

    // PUT
    Request<EmptyRecord> writeRequest = builders.partialUpdate().input(patch).build();
    REST_CLIENT.sendRequest(writeRequest).getResponse();

    // GET again, to verify that our PUT worked.
    Request<Greeting> request = builders.get().build();
    Response<Greeting> response = REST_CLIENT.sendRequest(request).getResponse();
    greeting = response.getEntity();

    Assert.assertEquals(greeting.getTone(), Tone.SINCERE);
  }
View Full Code Here

    // GET again, to verify that our DELETE worked.
    try
    {
      Request<Greeting> request = builders.get().build();
      Response<Greeting> response = REST_CLIENT.sendRequest(request).getResponse();
      Greeting greeting = response.getEntity();
      Assert.fail("Entity should have been removed.");
    }
    catch (RestLiResponseException e)
    {
      Assert.assertEquals(e.getStatus(), HttpStatus.S_404_NOT_FOUND.getCode());
View Full Code Here

TOP

Related Classes of com.linkedin.restli.examples.greetings.api.Greeting

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.