Examples of Greeting


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

  }

  private ResponseFuture<Greeting> buildWithEntity(ErrorHandlingBehavior errorHandlingBehavior)
  {
    MockFailedResponseFutureBuilder<Long, Greeting> builder = new MockFailedResponseFutureBuilder<Long, Greeting>();
    Greeting greeting = new Greeting().setId(1L).setMessage("foo");

    builder.setEntity(greeting).setErrorHandlingBehavior(errorHandlingBehavior).setStatus(500);
    return builder.build();
  }
View Full Code Here

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

    }
    catch (RemoteInvocationException e)
    {
      Assert.assertTrue(e instanceof RestLiResponseException);
      Assert.assertEquals(((RestLiResponseException) e).getDecodedResponse().getEntity(),
                          new Greeting().setId(1L).setMessage("foo"));
      Assert.assertEquals(((RestLiResponseException) e).getDecodedResponse().getStatus(), 500);
    }
  }
View Full Code Here

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

    ResponseFuture<Greeting> future = buildWithEntity(ErrorHandlingBehavior.TREAT_SERVER_ERROR_AS_SUCCESS);

    try
    {
      Response<Greeting> response = future.getResponse();
      Assert.assertEquals(response.getEntity(), new Greeting().setId(1L).setMessage("foo"));
      Assert.assertEquals(response.getStatus(), 500);
      Assert.assertEquals(response.getError().getStatus(), 500);
    }
    catch (RemoteInvocationException e)
    {
View Full Code Here

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

  @Test
  public void testBuild()
      throws RemoteInvocationException
  {
    MockSuccessfulResponseFutureBuilder<Long, Greeting> builder = new MockSuccessfulResponseFutureBuilder<Long, Greeting>();
    Greeting greeting = new Greeting().setId(1L).setMessage("foo");
    ResponseFuture<Greeting> future = builder.setEntity(greeting).setStatus(200).build();

    Assert.assertEquals(future.getResponseEntity(), greeting);
    Assert.assertEquals(future.getResponse().getStatus(), 200);
  }
View Full Code Here

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

public class TestMockBatchResponseFactory
{
  @Test
  public void testCreate()
  {
    Greeting g1 = new Greeting().setId(1L).setMessage("g1");
    Greeting g2 = new Greeting().setId(2L).setMessage("g2");

    Map<String, Greeting> recordTemplates = new HashMap<String, Greeting>();
    recordTemplates.put("1", g1);
    recordTemplates.put("2", g2);
View Full Code Here

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

    verifyFilters(tone, responseFilter);
  }

  private Greeting generateTestGreeting(String message, Tone tone)
  {
    return new Greeting().setMessage(message).setTone(tone);
  }
View Full Code Here

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

        if (requestContext.getMethodType() == ResourceMethod.CREATE)
        {
          RecordTemplate entity = requestContext.getRequestData().getEntity();
          if (entity != null && entity instanceof Greeting)
          {
            Greeting greeting = (Greeting) entity;
            if (greeting.hasTone())
            {
              Tone tone = greeting.getTone();
              if (tone == Tone.INSULTING)
              {
                throw new RestLiServiceException(REQ_FILTER_ERROR_STATUS, REQ_FILTER_ERROR_MESSAGE);
              }
              greeting.setTone(mapToneForIncomingRequest(tone));
            }
          }
        }
        return null;
      }
    }).when(_requestFilter).onRequest(any(FilterRequestContext.class));
    List<RequestFilter> reqFilters = Arrays.asList(_requestFilter);

    List<ResponseFilter> respFilters = null;
    if (responseFilter)
    {
      reset(_responseFilter);
      doAnswer(new Answer<Object>()
      {
        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable
        {
          Object[] args = invocation.getArguments();
          FilterRequestContext requestContext = (FilterRequestContext) args[0];
          FilterResponseContext responseContext = (FilterResponseContext) args[1];
          // Verify the scratch pad value.
          assertTrue(requestContext.getFilterScratchpad().get(spKey) == spValue);
          RecordTemplate entity = responseContext.getResponseData().getEntityResponse();
          if (entity != null && requestContext.getMethodType() == ResourceMethod.GET
              && responseContext.getHttpStatus() == HttpStatus.S_200_OK)
          {
            Greeting greeting = new Greeting(entity.data());
            if (greeting.hasTone())
            {
              greeting.setTone(mapToneForOutgoingResponse(greeting.getTone()));
              responseContext.getResponseData().setEntityResponse(greeting);
            }
          }
          ErrorResponse errorResponse = responseContext.getResponseData().getErrorResponse();
          if (errorResponse != null && requestContext.getMethodType() == ResourceMethod.CREATE
View Full Code Here

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

  public void testEqualRecordTemplates()
  {
    String message = "foo";
    Long id = 1L;

    Greeting actual = new Greeting().setMessage(message).setId(id);
    Greeting expected = new Greeting().setMessage(message).setId(id);

    DataAssert.assertRecordTemplateDataEqual(actual, expected, null);
  }
View Full Code Here

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

  }

  @Test
  public void testUnequalRecordTemplates()
  {
    Greeting actual = new Greeting().setMessage("actual").setId(1L);
    Greeting expected = new Greeting().setMessage("expected").setId(2L);

    String expectedErrorMessage1 = "Mismatch on property \"message\", expected:<expected> but was:<actual>";
    String expectedErrorMessage2 = "Mismatch on property \"id\", expected:<2> but was:<1>";

    try
View Full Code Here

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

  }

  @Test
  public void testEqualCollections()
  {
    Greeting g1 = new Greeting().setMessage("foo").setId(1L);
    Greeting g2 = new Greeting().setMessage("foo").setId(2L);

    Greeting g3 = new Greeting().setMessage("foo").setId(1L);
    Greeting g4 = new Greeting().setMessage("foo").setId(2L);

    List<Greeting> actual = Arrays.asList(g1, g2);
    List<Greeting> expected = Arrays.asList(g3, g4);

    DataAssert.assertRecordTemplateCollectionsEqual(actual, expected, null);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.