Package com.linkedin.restli.client.test

Examples of com.linkedin.restli.client.test.TestRecord


            RestliRequestOptions.DEFAULT_OPTIONS);

    builder.ids(
        Arrays.asList(
            new ComplexResourceKey<TestRecord, TestRecord>(
                new TestRecord().setId(1L),
                new TestRecord().setId(5L))));
    builder.build();
  }
View Full Code Here


  private static ComplexResourceKey<TestRecord, TestRecord> buildComplexKey(Long keyId,
                                                                            String keyMessage,
                                                                            Long paramId,
                                                                            String paramMessage)
  {
    return new ComplexResourceKey<TestRecord, TestRecord>(new TestRecord().setId(keyId)
                                                                          .setMessage(keyMessage),
                                                          new TestRecord().setId(paramId)
                                                                          .setMessage(paramMessage));
  }
View Full Code Here

   */
  private ParSeqRestClient mockClient(final long id,
                                      final int httpCode,
                                      final ProtocolVersion protocolVersion)
  {
    final TestRecord record = new TestRecord().setId(id);

    byte[] mapBytes;
    try
    {
      mapBytes = new JacksonDataCodec().mapToBytes(record.data());
    }
    catch (final IOException e)
    {
      throw new RuntimeException(e);
    }
View Full Code Here

                                                                                       Collections.<String, CompoundKey.TypeInfo>emptyMap(),
                                                                                       keyKeyClass,
                                                                                       keyParamsClass,
                                                                                       protocolVersion);
    final Map<K, TestRecord> outputResults = response.getResults();
    final TestRecord outRecord = outputResults.get(resultKey);
    Assert.assertEquals(outRecord, outRecord);

    final Map<K, ErrorResponse> outputErrors = response.getErrors();
    final ErrorResponse outError = outputErrors.get(errorKey);
    Assert.assertEquals(outError, _error);
View Full Code Here

    KeyValueRecordFactory<Long, TestRecord> factory = new KeyValueRecordFactory<Long, TestRecord>(Long.class,
                                                                                                  null,
                                                                                                  null,
                                                                                                  null,
                                                                                                  TestRecord.class);
    TestRecord testRecord = buildTestRecord(1L, "message");
    KeyValueRecord<Long, TestRecord> kvRecord = factory.create(1L, testRecord);

    @SuppressWarnings("rawtypes")
    CollectionRequest<KeyValueRecord> collectionRequest = new CollectionRequest<KeyValueRecord>(KeyValueRecord.class);
    collectionRequest.getElements().add(kvRecord);
View Full Code Here

    Map<Long, TestRecord> inputs = new HashMap<Long, TestRecord>();
    long[] ids = {1L, 2L, 3L};
    for (long id: ids)
    {
      TestRecord testRecord = buildTestRecord(id, id + "");
      inputs.put(id, testRecord);
      collectionRequest.getElements().add(factory.create(id, testRecord));
    }

    @SuppressWarnings("unchecked")
View Full Code Here

    CollectionRequest<KeyValueRecord> collectionRequest = new CollectionRequest<KeyValueRecord>(KeyValueRecord.class);

    Map<CompoundKey, TestRecord> inputs = new HashMap<CompoundKey, TestRecord>();
    for (CompoundKey key: keys)
    {
      TestRecord testRecord = buildTestRecord(1L, "message" + key.hashCode());
      inputs.put(key, testRecord);
      collectionRequest.getElements().add(factory.create(key, testRecord));
    }

    @SuppressWarnings("unchecked")
View Full Code Here

  @Test(dataProvider = TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "versions")
  @SuppressWarnings({"unchecked", "rawtypes"})
  public void testComplexKeyMultipleEntities(ProtocolVersion version)
  {
    // TestRecord is not keyed by a ComplexResourceKey, but for this test we pretend that it is.
    TestRecord kk1 = buildTestRecord(1, "key key 1");
    TestRecord kp1 = buildTestRecord(2, "key params 1");
    TestRecord kk2 = buildTestRecord(3, "key key 2");
    TestRecord kp2 = buildTestRecord(4, "key params 2");
    ComplexResourceKey<TestRecord, TestRecord> key1 = new ComplexResourceKey<TestRecord, TestRecord>(kk1, kp1);
    ComplexResourceKey<TestRecord, TestRecord> key2 = new ComplexResourceKey<TestRecord, TestRecord>(kk2, kp2);
    ComplexResourceKey keys[] = {key1, key2};

    KeyValueRecordFactory<ComplexResourceKey, TestRecord> factory =
        new KeyValueRecordFactory<ComplexResourceKey, TestRecord>(ComplexResourceKey.class,
                                     TestRecord.class,
                                     TestRecord.class,
                                     null,
                                     TestRecord.class);

    CollectionRequest<KeyValueRecord> collectionRequest = new CollectionRequest<KeyValueRecord>(KeyValueRecord.class);
    Map<ComplexResourceKey<TestRecord, TestRecord>, TestRecord> inputs =
        new HashMap<ComplexResourceKey<TestRecord, TestRecord>, TestRecord>();
    for (ComplexResourceKey key: keys)
    {
      TestRecord testRecord = buildTestRecord(1L, "foo");
      inputs.put(key, testRecord);
      collectionRequest.getElements().add(factory.create(key, testRecord));
    }

    @SuppressWarnings({"unchecked", "rawtypes"})
View Full Code Here

    }
  }

  private TestRecord buildTestRecord(long id, String message)
  {
    return new TestRecord().setId(id).setMessage(message);
  }
View Full Code Here

  public void testCreateCompoundKeyRequestBuilder(ProtocolVersion version, String expectedUri)
  {
    CreateRequestBuilder<CompoundKey, TestRecord> builder =
        new CreateRequestBuilder<CompoundKey, TestRecord>(TEST_URI, TestRecord.class, _ASSOC_SPEC, RestliRequestOptions.DEFAULT_OPTIONS);

    TestRecord record = new TestRecord().setMessage("foo");

    CreateRequest<TestRecord> request = builder.input(record).build();

    Assert.assertEquals(request.isSafe(), false);
    Assert.assertEquals(request.isIdempotent(), false);
View Full Code Here

TOP

Related Classes of com.linkedin.restli.client.test.TestRecord

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.