use of com.linkedin.restli.common.ActionResponse in project rest.li by linkedin.
the class TestMockActionResponseFactory method testDynamicSchema.
@Test
public void testDynamicSchema() {
final RecordTemplateWithDefaultValue record = new RecordTemplateWithDefaultValue();
record.setId(42L);
record.setMessage("Lorem ipsum");
final CollectionResponse<RecordTemplateWithDefaultValue> collectionResponse = new CollectionResponse<>(RecordTemplateWithDefaultValue.class);
collectionResponse.getElements().add(record);
@SuppressWarnings("unchecked") final ActionResponse<CollectionResponse<RecordTemplateWithDefaultValue>> response = (ActionResponse<CollectionResponse<RecordTemplateWithDefaultValue>>) (Object) MockActionResponseFactory.create(CollectionResponse.class, collectionResponse.schema(), collectionResponse);
Assert.assertEquals(response.getValue(), collectionResponse);
final RecordDataSchema schema = response.schema();
Assert.assertEquals(schema.getName(), ActionResponse.class.getSimpleName());
Assert.assertEquals(schema.getField(ActionResponse.VALUE_NAME).getType(), collectionResponse.schema());
}
use of com.linkedin.restli.common.ActionResponse in project rest.li by linkedin.
the class TestActionResponseBuilder method getActionResponse.
private static ActionResponse<Long> getActionResponse(long returnValue) {
DataMap dataMap = new DataMap();
dataMap.put(LONG_RETURN.getName(), returnValue);
return new ActionResponse<>(dataMap, LONG_RETURN, LONG_RETURN.getField().getRecord());
}
Aggregations