use of example.models.Publisher in project elide by yahoo.
the class SwaggerBuilderTest method testSparseFieldsParam.
@Test
public void testSparseFieldsParam() throws Exception {
List<Parameter> params = swagger.getPaths().get("/book").getGet().getParameters();
Set<String> paramNames = params.stream().map((param) -> param.getName()).collect(Collectors.toSet());
long fieldParams = paramNames.stream().filter((name) -> name.startsWith("fields")).count();
assertEquals(1, fieldParams);
assertTrue(paramNames.contains("fields[book]"));
QueryParameter fieldParam = (QueryParameter) params.stream().filter((param) -> param.getName().equals("fields[book]")).findFirst().get();
assertEquals("query", fieldParam.getIn());
List<String> filterValues = Arrays.asList("title", "authors", "publisher");
assertTrue(((StringProperty) fieldParam.getItems()).getEnum().containsAll(filterValues));
assertEquals("csv", fieldParam.getCollectionFormat());
}
use of example.models.Publisher in project elide by yahoo.
the class SwaggerBuilderTest method testIncludeParam.
@Test
public void testIncludeParam() throws Exception {
List<Parameter> params = swagger.getPaths().get("/book").getGet().getParameters();
Set<String> paramNames = params.stream().map((param) -> param.getName()).collect(Collectors.toSet());
long includeParams = paramNames.stream().filter((name) -> name.startsWith("include")).count();
assertEquals(1, includeParams);
assertTrue(paramNames.contains("include"));
QueryParameter includeParam = (QueryParameter) params.stream().filter((param) -> param.getName().equals("include")).findFirst().get();
assertEquals("query", includeParam.getIn());
List<String> includeValues = Arrays.asList("authors", "publisher");
assertTrue(((StringProperty) includeParam.getItems()).getEnum().containsAll(includeValues));
assertEquals("csv", includeParam.getCollectionFormat());
}
Aggregations