ElasticsearchExprValueFactory { public ExprTupleValue construct(String jsonString) { try { return constructStruct(OBJECT_MAPPER.readTree(jsonString), TOP_PATH); } catch (JsonProcessingException e) { throw new IllegalStateException(String.format("invalid json: %s.", jsonString), e); } }  ExprTupleValue construct(String jsonString); ExprValue construct(String field, Object value);  }
@Test public void constructUnsupportedTypeThrowException() { ElasticsearchExprValueFactory exprValueFactory = new ElasticsearchExprValueFactory(ImmutableMap.of("type", new TestType())); IllegalStateException exception = assertThrows(IllegalStateException.class, () -> exprValueFactory.construct("{\"type\":1}")); assertEquals("Unsupported type: TEST_TYPE for field: type, value: 1.", exception.getMessage()); exception = assertThrows(IllegalStateException.class, () -> exprValueFactory.construct("type", 1)); assertEquals( "Unsupported type TEST_TYPE to construct expression value " + "from object for field: type, value: 1.", exception.getMessage()); }