use of com.linkedin.restli.common.test.RecordTemplateWithPrimitiveKey in project rest.li by linkedin.
the class TestKeyValueRecord method testComplex.
@Test
@SuppressWarnings("rawtypes")
public void testComplex() {
KeyValueRecordFactory<ComplexResourceKey, RecordTemplateWithPrimitiveKey> factory = new KeyValueRecordFactory<>(ComplexResourceKey.class, MyComplexKey.class, MyComplexKey.class, null, RecordTemplateWithPrimitiveKey.class);
MyComplexKey key = new MyComplexKey().setA("key").setB(1L);
MyComplexKey params = new MyComplexKey().setA("params").setB(2L);
ComplexResourceKey<MyComplexKey, MyComplexKey> complexKey = new ComplexResourceKey<>(key, params);
RecordTemplateWithPrimitiveKey mockRecord = new RecordTemplateWithPrimitiveKey().setId(1L).setBody("foo");
KeyValueRecord<ComplexResourceKey, RecordTemplateWithPrimitiveKey> keyValueRecord = factory.create(complexKey, mockRecord);
Assert.assertEquals(keyValueRecord.getComplexKey(MyComplexKey.class, MyComplexKey.class), complexKey);
Assert.assertEquals(keyValueRecord.getValue(RecordTemplateWithPrimitiveKey.class), mockRecord);
}
use of com.linkedin.restli.common.test.RecordTemplateWithPrimitiveKey in project rest.li by linkedin.
the class TestKeyValueRecord method testCompoundKey.
private void testCompoundKey(CompoundKey compoundKey, Map<String, CompoundKey.TypeInfo> fieldTypes) {
RecordTemplateWithPrimitiveKey mockRecord = new RecordTemplateWithPrimitiveKey().setId(7L).setBody("foo");
KeyValueRecordFactory<CompoundKey, RecordTemplateWithPrimitiveKey> factory = new KeyValueRecordFactory<>(CompoundKey.class, null, null, fieldTypes, RecordTemplateWithPrimitiveKey.class);
KeyValueRecord<CompoundKey, RecordTemplateWithPrimitiveKey> keyValueRecord = factory.create(compoundKey, mockRecord);
Assert.assertEquals(keyValueRecord.getCompoundKey(fieldTypes), compoundKey);
Assert.assertEquals(keyValueRecord.getValue(RecordTemplateWithPrimitiveKey.class), mockRecord);
}
use of com.linkedin.restli.common.test.RecordTemplateWithPrimitiveKey in project rest.li by linkedin.
the class TestKeyValueRecord method testPrimitive.
@Test
public void testPrimitive() {
KeyValueRecordFactory<Long, RecordTemplateWithPrimitiveKey> factory = new KeyValueRecordFactory<>(Long.class, null, null, null, RecordTemplateWithPrimitiveKey.class);
Long id = 1L;
RecordTemplateWithPrimitiveKey mockRecordTemplate = new RecordTemplateWithPrimitiveKey();
mockRecordTemplate.setId(id).setBody("foo");
KeyValueRecord<Long, RecordTemplateWithPrimitiveKey> keyValueRecord = factory.create(id, mockRecordTemplate);
Assert.assertEquals(keyValueRecord.getPrimitiveKey(Long.class), id);
Assert.assertEquals(keyValueRecord.getValue(RecordTemplateWithPrimitiveKey.class), mockRecordTemplate);
}
use of com.linkedin.restli.common.test.RecordTemplateWithPrimitiveKey in project rest.li by linkedin.
the class TestKeyValueRecord method testTyperefToCustomType.
@Test
@SuppressWarnings({ "unchecked", "rawtypes" })
public void testTyperefToCustomType() {
KeyValueRecordFactory factory = new KeyValueRecordFactory(MyCustomStringRef.class, null, null, null, RecordTemplateWithPrimitiveKey.class);
MyCustomString id = new MyCustomString("1");
RecordTemplateWithPrimitiveKey mockRecord = new RecordTemplateWithPrimitiveKey().setId(1L).setBody("foo");
KeyValueRecord keyValueRecord = factory.create(id, mockRecord);
Assert.assertEquals(keyValueRecord.getPrimitiveKey(MyCustomStringRef.class), id);
Assert.assertEquals(keyValueRecord.getValue(RecordTemplateWithPrimitiveKey.class), mockRecord);
}
use of com.linkedin.restli.common.test.RecordTemplateWithPrimitiveKey in project rest.li by linkedin.
the class TestKeyValueRecord method testEnum.
@Test
public void testEnum() {
KeyValueRecordFactory<SimpleEnum, RecordTemplateWithPrimitiveKey> factory = new KeyValueRecordFactory<>(SimpleEnum.class, null, null, null, RecordTemplateWithPrimitiveKey.class);
SimpleEnum id = SimpleEnum.A;
RecordTemplateWithPrimitiveKey mockRecordTemplate = new RecordTemplateWithPrimitiveKey();
mockRecordTemplate.setId(1L).setBody("foo");
KeyValueRecord<SimpleEnum, RecordTemplateWithPrimitiveKey> keyValueRecord = factory.create(id, mockRecordTemplate);
Assert.assertEquals(keyValueRecord.getPrimitiveKey(SimpleEnum.class), id);
Assert.assertEquals(keyValueRecord.getValue(RecordTemplateWithPrimitiveKey.class), mockRecordTemplate);
}
Aggregations