Search in sources :

Example 1 with SimpleEnum

use of com.linkedin.restli.common.test.SimpleEnum in project rest.li by linkedin.

the class TestKeyValueRecord method testCompoundKeyWithEnum.

@Test
public void testCompoundKeyWithEnum() {
    CompoundKey compoundKey = new CompoundKey();
    Long longKey = 1L;
    compoundKey.append("longKey", longKey);
    SimpleEnum simpleEnum = SimpleEnum.A;
    compoundKey.append("enumKey", simpleEnum);
    Map<String, CompoundKey.TypeInfo> fieldTypes = new HashMap<>();
    fieldTypes.put("longKey", new CompoundKey.TypeInfo(Long.class, Long.class));
    fieldTypes.put("enumKey", new CompoundKey.TypeInfo(SimpleEnum.class, String.class));
    testCompoundKey(compoundKey, fieldTypes);
}
Also used : SimpleEnum(com.linkedin.restli.common.test.SimpleEnum) HashMap(java.util.HashMap) Test(org.testng.annotations.Test)

Example 2 with SimpleEnum

use of com.linkedin.restli.common.test.SimpleEnum in project rest.li by linkedin.

the class TestActionArgumentBuilder method getEnumParams.

private List<Parameter<?>> getEnumParams() {
    EnumDataSchema simpleEnumSchema = new EnumDataSchema(new Name("com.linkedin.restli.common.test.SimpleEnum"));
    simpleEnumSchema.setSymbols(Arrays.asList("A", "B", "C"), null);
    return Collections.singletonList(new Parameter<>("simpleEnum", SimpleEnum.class, simpleEnumSchema, false, null, Parameter.ParamType.POST, true, new AnnotationSet(new Annotation[] {})));
}
Also used : EnumDataSchema(com.linkedin.data.schema.EnumDataSchema) SimpleEnum(com.linkedin.restli.common.test.SimpleEnum) AnnotationSet(com.linkedin.restli.internal.server.model.AnnotationSet) Name(com.linkedin.data.schema.Name)

Example 3 with SimpleEnum

use of com.linkedin.restli.common.test.SimpleEnum 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);
}
Also used : RecordTemplateWithPrimitiveKey(com.linkedin.restli.common.test.RecordTemplateWithPrimitiveKey) SimpleEnum(com.linkedin.restli.common.test.SimpleEnum) Test(org.testng.annotations.Test)

Aggregations

SimpleEnum (com.linkedin.restli.common.test.SimpleEnum)3 Test (org.testng.annotations.Test)2 EnumDataSchema (com.linkedin.data.schema.EnumDataSchema)1 Name (com.linkedin.data.schema.Name)1 RecordTemplateWithPrimitiveKey (com.linkedin.restli.common.test.RecordTemplateWithPrimitiveKey)1 AnnotationSet (com.linkedin.restli.internal.server.model.AnnotationSet)1 HashMap (java.util.HashMap)1