SchemaServlet extends HttpServlet { @Override public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { PrintWriter out = resp.getWriter(); Document doc = Document.newBuilder() .setId("theOnlyCar") .addField(Field.newBuilder().setName("maker").setText("Toyota")) .addField(Field.newBuilder().setName("price").setNumber(300000)) .addField(Field.newBuilder().setName("color").setText("lightblue")) .addField(Field.newBuilder().setName("model").setText("Prius")) .build(); try { Utils.indexADocument(SEARCH_INDEX, doc); } catch (InterruptedException e) { } GetResponse<Index> response = SearchServiceFactory.getSearchService() .getIndexes(GetIndexesRequest.newBuilder().setSchemaFetched(true).build()); for (Index index : response) { Schema schema = index.getSchema(); for (String fieldName : schema.getFieldNames()) { List<FieldType> typesForField = schema.getFieldTypes(fieldName); for (FieldType type : typesForField) { out.println(index.getName() + ":" + fieldName + ":" + type.name()); } } } }  @Override void doGet(HttpServletRequest req, HttpServletResponse resp);  }
@Test public void doGet_successfulyInvoked() throws Exception { servletUnderTest.doGet(mockRequest, mockResponse); String content = responseWriter.toString(); assertWithMessage("SchemaServlet response").that(content).contains("schemaIndex:maker:TEXT"); assertWithMessage("SchemaServlet response").that(content).contains("schemaIndex:price:NUMBER"); assertWithMessage("SchemaServlet response").that(content).contains("schemaIndex:color:TEXT"); assertWithMessage("SchemaServlet response").that(content).contains("schemaIndex:model:TEXT"); }