Search in sources :

Example 1 with Request

use of com.linkedin.restli.client.Request in project rest.li by linkedin.

the class TestCustomDocumentationHandler method testOptionsJson.

@Test
public void testOptionsJson() throws RemoteInvocationException {
    Request<OptionsResponse> optionsRequest = new GreetingsRequestBuilders().options().addParam("format", RestLiDocumentationRenderer.DocumentationFormat.JSON.toString().toLowerCase()).build();
    OptionsResponse optionsResponse = getClient().sendRequest(optionsRequest).getResponse().getEntity();
    Assert.assertEquals(1, optionsResponse.getResourceSchemas().size());
    Assert.assertNotNull(optionsResponse.getResourceSchemas().get("com.linkedin.restli.examples.greetings.client.greetings"));
    Assert.assertEquals(optionsResponse.getDataSchemas().size(), 10);
    List<String> expectedModels = new ArrayList<>(Arrays.asList("com.linkedin.restli.examples.greetings.api.Greeting", "com.linkedin.restli.examples.greetings.api.SearchMetadata", "com.linkedin.restli.examples.groups.api.TransferOwnershipRequest", "com.linkedin.restli.examples.greetings.api.Empty", "com.linkedin.restli.examples.greetings.api.Tone"));
    List<String> expectedCustomModels = expectedModels.stream().map(name -> name + CUSTOM_SUFFIX).collect(Collectors.toList());
    expectedModels.addAll(expectedCustomModels);
    Assert.assertTrue(optionsResponse.getDataSchemas().keySet().containsAll(expectedModels));
    for (String schema : expectedModels) {
        NamedDataSchema dataSchema = (NamedDataSchema) optionsResponse.getDataSchemas().get(schema);
        Assert.assertEquals(dataSchema.getFullName(), schema);
    }
}
Also used : AfterClass(org.testng.annotations.AfterClass) Arrays(java.util.Arrays) RemoteInvocationException(com.linkedin.r2.RemoteInvocationException) BeforeClass(org.testng.annotations.BeforeClass) RestLiJSONDocumentationRenderer(com.linkedin.restli.docgen.RestLiJSONDocumentationRenderer) RestLiIntegrationTest(com.linkedin.restli.examples.RestLiIntegrationTest) DefaultDocumentationRequestHandler(com.linkedin.restli.docgen.DefaultDocumentationRequestHandler) RestLiConfig(com.linkedin.restli.server.RestLiConfig) IOException(java.io.IOException) Test(org.testng.annotations.Test) DataSchemaResolver(com.linkedin.data.schema.DataSchemaResolver) RestLiResourceRelationship(com.linkedin.restli.docgen.RestLiResourceRelationship) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) DataMap(com.linkedin.data.DataMap) RestLiDocumentationRenderer(com.linkedin.restli.docgen.RestLiDocumentationRenderer) List(java.util.List) Assert(org.testng.Assert) Request(com.linkedin.restli.client.Request) Map(java.util.Map) NamedDataSchema(com.linkedin.data.schema.NamedDataSchema) GreetingsRequestBuilders(com.linkedin.restli.examples.greetings.client.GreetingsRequestBuilders) OptionsResponse(com.linkedin.restli.common.OptionsResponse) NamedDataSchema(com.linkedin.data.schema.NamedDataSchema) ArrayList(java.util.ArrayList) OptionsResponse(com.linkedin.restli.common.OptionsResponse) GreetingsRequestBuilders(com.linkedin.restli.examples.greetings.client.GreetingsRequestBuilders) RestLiIntegrationTest(com.linkedin.restli.examples.RestLiIntegrationTest) Test(org.testng.annotations.Test)

Aggregations

DataMap (com.linkedin.data.DataMap)1 DataSchemaResolver (com.linkedin.data.schema.DataSchemaResolver)1 NamedDataSchema (com.linkedin.data.schema.NamedDataSchema)1 RemoteInvocationException (com.linkedin.r2.RemoteInvocationException)1 Request (com.linkedin.restli.client.Request)1 OptionsResponse (com.linkedin.restli.common.OptionsResponse)1 DefaultDocumentationRequestHandler (com.linkedin.restli.docgen.DefaultDocumentationRequestHandler)1 RestLiDocumentationRenderer (com.linkedin.restli.docgen.RestLiDocumentationRenderer)1 RestLiJSONDocumentationRenderer (com.linkedin.restli.docgen.RestLiJSONDocumentationRenderer)1 RestLiResourceRelationship (com.linkedin.restli.docgen.RestLiResourceRelationship)1 RestLiIntegrationTest (com.linkedin.restli.examples.RestLiIntegrationTest)1 GreetingsRequestBuilders (com.linkedin.restli.examples.greetings.client.GreetingsRequestBuilders)1 RestLiConfig (com.linkedin.restli.server.RestLiConfig)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 Assert (org.testng.Assert)1