use of com.linkedin.restli.common.OptionsResponse in project rest.li by linkedin.
the class TestGreetingsClient method testModelsForOptionsRequest.
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "optionsData")
public void testModelsForOptionsRequest(OptionsRequestBuilder request, NamedDataSchema[] schemas) throws RemoteInvocationException, URISyntaxException, IOException {
Request<OptionsResponse> optionsRequest = request.build();
OptionsResponse optionsResponse = getClient().sendRequest(optionsRequest).getResponse().getEntity();
Map<String, DataSchema> rawDataSchemas = optionsResponse.getDataSchemas();
for (NamedDataSchema dataSchema : schemas) {
DataSchema optionsDataSchema = rawDataSchemas.get(dataSchema.getFullName());
Assert.assertEquals(optionsDataSchema, dataSchema);
}
}
use of com.linkedin.restli.common.OptionsResponse in project rest.li by linkedin.
the class OptionsResponseDecoder method wrapResponse.
@Override
public OptionsResponse wrapResponse(DataMap dataMap, Map<String, String> headers, ProtocolVersion version) throws IOException {
if (dataMap == null) {
return null;
}
DataMap resources = dataMap.getDataMap(RESOURCES);
if (resources == null)
resources = new DataMap();
HashMap<String, ResourceSchema> resourceMap = new HashMap<String, ResourceSchema>(resources.size());
for (Map.Entry<String, Object> entry : resources.entrySet()) {
resourceMap.put(entry.getKey(), new ResourceSchema((DataMap) entry.getValue()));
}
DataMap schemas = dataMap.getDataMap(MODELS);
if (schemas == null)
schemas = new DataMap();
HashMap<String, DataSchema> dataSchemaMap = new HashMap<String, DataSchema>(schemas.size());
for (Map.Entry<String, Object> entry : schemas.entrySet()) {
String schemaText = CODEC.mapToString((DataMap) entry.getValue());
dataSchemaMap.put(entry.getKey(), DataTemplateUtil.parseSchema(schemaText));
}
return new OptionsResponse(resourceMap, dataSchemaMap);
}
use of com.linkedin.restli.common.OptionsResponse in project rest.li by linkedin.
the class TestGreetingsClient method testOptions.
@Test(dataProvider = com.linkedin.restli.internal.common.TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestBuilderWithResourceNameDataProvider")
public void testOptions(RootBuilderWrapper<Long, Greeting> builders, String resourceName, ProtocolVersion protocolVersion) throws RemoteInvocationException, URISyntaxException, IOException {
Request<OptionsResponse> optionsRequest = builders.options().build();
OptionsResponse optionsResponse = getClient().sendRequest(optionsRequest).getResponse().getEntity();
Map<String, ResourceSchema> resources = optionsResponse.getResourceSchemas();
Assert.assertEquals(resources.size(), 1);
ResourceSchema resourceSchema = resources.get("com.linkedin.restli.examples.greetings.client." + resourceName);
// sanity check the resource schema
Assert.assertEquals(resourceSchema.getName(), resourceName);
Assert.assertTrue(resourceSchema.hasCollection());
}
Aggregations