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

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


  public void testNullHttpStatusCreateResponse(final RootBuilderWrapper<Long, Greeting> builders)
      throws RemoteInvocationException
  {
    //Forces the server to return a valid CreateResponse but with a null HttpStatus inside of it
    final RootBuilderWrapper.MethodBuilderWrapper<Long, Greeting, EmptyRecord> methodBuilderWrapper = builders.create();
    final Greeting illGreeting = new Greeting().setMessage("nullHttpStatus").setTone(Tone.INSULTING);
    createAndAssertNullMessages(methodBuilderWrapper, illGreeting);
  }
View Full Code Here


  private void sendUpdateAndAssert(final RootBuilderWrapper<Long, Greeting> builders, Long id)
      throws RemoteInvocationException
  {
    try
    {
      final Greeting someGreeting = new Greeting().setMessage("Hello").setTone(Tone.INSULTING);
      REST_CLIENT.sendRequest(builders.update().id(id).input(someGreeting).build()).getResponse();
    }
    catch (final RestLiResponseException responseException)
    {
      assertCorrectInternalServerMessageForNull(responseException, "update");
View Full Code Here

  private void sendBatchUpdateAndAssert(final RootBuilderWrapper<Long, Greeting> builders, Long id)
      throws RemoteInvocationException
  {
    try
    {
      final Greeting someGreeting = new Greeting().setMessage("Hello").setTone(Tone.INSULTING);
      Request<BatchKVResponse<Long, UpdateStatus>> writeRequest =
          builders.batchUpdate().input(id, someGreeting).build();
      REST_CLIENT.sendRequest(writeRequest).getResponse();
    }
    catch (final RestLiResponseException responseException)
View Full Code Here

  @Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX
      + "requestBuilderDataProvider")
  public void testBatchCreateNulls(final RootBuilderWrapper<Long, Greeting> builders)
      throws RemoteInvocationException
  {
    final Greeting firstGreeting = new Greeting().setMessage("first").setTone(Tone.INSULTING);
    final Greeting secondGreeting = new Greeting().setMessage("first").setTone(Tone.INSULTING);

    //Forces the server to return a null list
    sendBatchCreateAndAssert(builders, Collections.<Greeting>emptyList());

    //Forces the server to return a BatchCreateResult with a null list in it
View Full Code Here

    Request<Greeting> request = builders.get().id(1L).setQueryParam("auth", "PLEASE").build();
    ResponseFuture<Greeting> future = REST_CLIENT.sendRequest(request);
    Response<Greeting> greetingResponse = future.getResponse();

    // POST
    Greeting greeting = new Greeting(greetingResponse.getEntity().data().copy());
    greeting.setMessage("This is a new message!");

    Request<EmptyRecord>  writeRequest = builders.update().id(1L).input(greeting)
      .setQueryParam("auth", "PLEASE").build();
    REST_CLIENT.sendRequest(writeRequest).getResponse();
View Full Code Here

        .setActionParam("NewTone", Tone.SINCERE)
        .setActionParam("DelOld", false)
        .build();
    ResponseFuture<Greeting> responseFuture = client.sendRequest(request);
    Assert.assertEquals(responseFuture.getResponse().getStatus(), 200);
    final Greeting newGreeting = responseFuture.getResponse().getEntity();
    Assert.assertNotNull(newGreeting);
    Assert.assertEquals(newGreeting.getId().longValue(), 1L);
    Assert.assertEquals(newGreeting.getTone(), Tone.SINCERE);
    checkContentEncodingHeaderIsAbsent(responseFuture.getResponse());
  }
View Full Code Here

    String response1 = greetingResponse.getEntity().getMessage();
    Assert.assertNotNull(response1);
    checkContentEncodingHeaderIsAbsent(future.getResponse());

    // POST
    Greeting greeting = new Greeting(greetingResponse.getEntity().data().copy());
    greeting.setMessage(response1 + "Again");

    Request<EmptyRecord> writeRequest = builders.update().id(1L).input(greeting).build();
    client.sendRequest(writeRequest).getResponse();

    // GET again, to verify that our POST worked.
View Full Code Here

    // GET
    Request<Greeting> request = builders.get().id(1L).build();
    ResponseFuture<Greeting> future = client.sendRequest(request);
    Response<Greeting> greetingResponse = future.getResponse();

    Greeting original = greetingResponse.getEntity();
    checkContentEncodingHeaderIsAbsent(greetingResponse);

    // POST
    Greeting greeting = new Greeting(original.data().copy());
    greeting.setMessage(original.getMessage() + " Again");

    PatchRequest<Greeting> patch = PatchGenerator.diff(original, greeting);

    Request<EmptyRecord> writeRequest = builders.partialUpdate().id(1L).input(patch).build();
    int status = client.sendRequest(writeRequest).getResponse().getStatus();
    Assert.assertEquals(status, HttpStatus.S_204_NO_CONTENT.getCode());

    // GET again, to verify that our POST worked.
    Request<Greeting> request2 = builders.get().id(1L).build();
    ResponseFuture<Greeting> future2 = client.sendRequest(request2);
    String response2 = future2.getResponse().getEntity().getMessage();

    Assert.assertEquals(response2, greeting.getMessage());
    checkContentEncodingHeaderIsAbsent(future2.getResponse());
  }
View Full Code Here

*/
public class TestMockBatchKVResponseFactory
{
  private Greeting buildGreeting(Long id)
  {
    return new Greeting().setId(id).setMessage(id + "");
  }
View Full Code Here

    Map<ComplexResourceKey<Greeting, Greeting>, Greeting> recordTemplates =
        new HashMap<ComplexResourceKey<Greeting, Greeting>, Greeting>();
    Map<ComplexResourceKey<Greeting, Greeting>, ErrorResponse> errorResponses =
        new HashMap<ComplexResourceKey<Greeting, Greeting>, ErrorResponse>();

    Greeting g1 = buildGreeting(1L);
    Greeting g2 = buildGreeting(2L);
    Greeting g3 = buildGreeting(3L);

    recordTemplates.put(new ComplexResourceKey<Greeting, Greeting>(g1, g1), g1);
    recordTemplates.put(new ComplexResourceKey<Greeting, Greeting>(g2, g2), g2);

    errorResponses.put(new ComplexResourceKey<Greeting, Greeting>(g3, g3), new ErrorResponse().setMessage("3"));

    BatchKVResponse<ComplexResourceKey<Greeting, Greeting>, Greeting> response =
        MockBatchKVResponseFactory.createWithComplexKey(Greeting.class,
                                                        Greeting.class,
                                                        Greeting.class,
                                                        recordTemplates,
                                                        errorResponses);

    Map<ComplexResourceKey, Greeting> storedResults = new HashMap<ComplexResourceKey, Greeting>();
    for (Map.Entry<ComplexResourceKey<Greeting, Greeting>, Greeting> entry: recordTemplates.entrySet())
    {
      storedResults.put(new ComplexResourceKey<Greeting, Greeting>(entry.getKey().getKey(),
                                                                   new Greeting()), entry.getValue());
    }

    Map<ComplexResourceKey, ErrorResponse> storedErrorResponses = new HashMap<ComplexResourceKey, ErrorResponse>();
    storedErrorResponses.put(new ComplexResourceKey<Greeting, Greeting>(g3, new Greeting()),
                             new ErrorResponse().setMessage("3"));

    Assert.assertEquals(response.getResults(), storedResults);
    Assert.assertEquals(response.getErrors(), storedErrorResponses);
  }
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.