Examples of TwoPartKey


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

  }

  @Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestComplexKeysBuilderDataProvider")
  public void testGetWithComplexKey(RootBuilderWrapper<ComplexResourceKey<TwoPartKey, TwoPartKey>, Message> builders) throws Exception
  {
    TwoPartKey key = new TwoPartKey();
    key.setMajor(key1());
    key.setMinor(key2());

    TwoPartKey params = new TwoPartKey();
    params.setMajor(key1());
    params.setMinor(key3());

    ComplexResourceKey<TwoPartKey, TwoPartKey> complexKey = new ComplexResourceKey<TwoPartKey, TwoPartKey>(key, params);
    Request<Message> request = builders.get().id(complexKey).build();
    Message response = REST_CLIENT.sendRequest(request).get().getEntity();
    Assert.assertNotNull(response);
View Full Code Here

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

  private static ComplexKeysDataProvider _dataProvider = new ComplexKeysDataProvider();

  @Override
  public Message get(final ComplexResourceKey<TwoPartKey, TwoPartKey> complexKey)
  {
    TwoPartKey key = complexKey.getKey();
    return _dataProvider.get(complexKey);
  }
View Full Code Here

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

  }

  @Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestSubBuilderDataProvider")
  public void testSubGet(RootBuilderWrapper<String, TwoPartKey> builders) throws ExecutionException, InterruptedException
  {
    TwoPartKey key = new TwoPartKey();
    key.setMajor("a");
    key.setMinor("b");
    TwoPartKey param = new TwoPartKey();
    param.setMajor("c");
    param.setMinor("d");
    ComplexResourceKey<TwoPartKey, TwoPartKey> complexKey = new ComplexResourceKey<TwoPartKey, TwoPartKey>(key, param);
    Request<TwoPartKey> request = builders.get().setPathKey("keys", complexKey).id("stringKey").build();
    TwoPartKey response = REST_CLIENT.sendRequest(request).get().getEntity();
    Assert.assertEquals(response.getMajor(), "aANDc");
    Assert.assertEquals(response.getMinor(), "bANDd");
  }
View Full Code Here

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

    return _db.get(keyToString(key.getKey()));
  }

  public ComplexResourceKey<TwoPartKey, TwoPartKey> create(Message message)
  {
    TwoPartKey key = new TwoPartKey();
    key.setMajor(message.getMessage());
    key.setMinor(message.getMessage());

    _db.put(keyToString(key), message);
    return new ComplexResourceKey<TwoPartKey, TwoPartKey>(key, new TwoPartKey());
  }
View Full Code Here

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

  }

  @Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestSubBuilderDataProvider")
  public void testSubGetWithReservedChars(RootBuilderWrapper<String, TwoPartKey> builders) throws ExecutionException, InterruptedException
  {
    TwoPartKey key = new TwoPartKey();
    key.setMajor("a&1");
    key.setMinor("b&2");
    TwoPartKey param = new TwoPartKey();
    param.setMajor("c&3");
    param.setMinor("d&4");
    ComplexResourceKey<TwoPartKey, TwoPartKey> complexKey = new ComplexResourceKey<TwoPartKey, TwoPartKey>(key, param);
    Request<TwoPartKey> request = builders.get().setPathKey("keys", complexKey).id("stringKey").build();
    TwoPartKey response = REST_CLIENT.sendRequest(request).get().getEntity();
    Assert.assertEquals(response.getMajor(), "a&1ANDc&3");
    Assert.assertEquals(response.getMinor(), "b&2ANDd&4");
  }
View Full Code Here

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

    return key.getMajor() + " " + key.getMinor();
  }

  private void addExample(String majorKey, String minorKey, String messageText)
  {
    TwoPartKey key = new TwoPartKey();
    key.setMajor(majorKey);
    key.setMinor(minorKey);
    Message message = new Message();
    message.setId(keyToString(key));
    message.setMessage(messageText);
    message.setTone(Tone.SINCERE);
    _db.put(keyToString(key), message);
View Full Code Here

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

  }

  private static ComplexResourceKey<TwoPartKey, TwoPartKey> getComplexKey(String major, String minor)
  {
    return new ComplexResourceKey<TwoPartKey, TwoPartKey>(
        new TwoPartKey().setMajor(major).setMinor(minor),
        new TwoPartKey());
  }
View Full Code Here

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

    return convert(keys);
  }

  private TwoPartKey convert(ComplexResourceKey<TwoPartKey, TwoPartKey> key)
  {
    TwoPartKey keyKey = key.getKey();
    TwoPartKey keyParam = key.getParams();
    TwoPartKey response = new TwoPartKey();
    response.setMajor(keyKey.getMajor() + "AND" + keyParam.getMajor());
    response.setMinor(keyKey.getMinor() + "AND" + keyParam.getMinor());
    return response;
  }
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.