@Test public void testJsonPathNoPathAttribute() throws IOException { String invalidJsonPath = "{\"variable\" : \"I am variable\"}"; _thrown.expect(BatfishException.class); _thrown.expectMessage( equalTo(String.format("Missing 'path' element of %s", JSON_PATH.getName()))); Client.validateJsonPath(_mapper.readTree(invalidJsonPath)); }
static void validateJsonPath(JsonNode jsonPath) throws BatfishException { if (!jsonPath.isContainerNode()) { throw new BatfishException( String.format( "Expecting a JSON dictionary for a Batfish %s", Variable.Type.JSON_PATH.getName())); } if (jsonPath.get("path") == null) { throw new BatfishException( String.format("Missing 'path' element of %s", Variable.Type.JSON_PATH.getName())); } if (!jsonPath.get("path").isTextual()) { throw new BatfishException( String.format( "'path' element of %s must be a JSON string", Variable.Type.JSON_PATH.getName())); } if (jsonPath.get("suffix") != null && !jsonPath.get("suffix").isBoolean()) { throw new BatfishException( String.format( "'suffix' element of %s must be a JSON boolean", Variable.Type.JSON_PATH.getName())); } }
Client extends AbstractClient implements IClient { static void validateJsonPath(JsonNode jsonPath) throws BatfishException { if (!jsonPath.isContainerNode()) { throw new BatfishException( String.format( "Expecting a JSON dictionary for a Batfish %s", Variable.Type.JSON_PATH.getName())); } if (jsonPath.get("path") == null) { throw new BatfishException( String.format("Missing 'path' element of %s", Variable.Type.JSON_PATH.getName())); } if (!jsonPath.get("path").isTextual()) { throw new BatfishException( String.format( "'path' element of %s must be a JSON string", Variable.Type.JSON_PATH.getName())); } if (jsonPath.get("suffix") != null && !jsonPath.get("suffix").isBoolean()) { throw new BatfishException( String.format( "'suffix' element of %s must be a JSON boolean", Variable.Type.JSON_PATH.getName())); } } }
Client extends AbstractClient implements IClient { static void validateJsonPath(JsonNode jsonPath) throws BatfishException { if (!jsonPath.isContainerNode()) { throw new BatfishException( String.format( "Expecting a JSON dictionary for a Batfish %s", Variable.Type.JSON_PATH.getName())); } if (jsonPath.get("path") == null) { throw new BatfishException( String.format("Missing 'path' element of %s", Variable.Type.JSON_PATH.getName())); } if (!jsonPath.get("path").isTextual()) { throw new BatfishException( String.format( "'path' element of %s must be a JSON string", Variable.Type.JSON_PATH.getName())); } if (jsonPath.get("suffix") != null && !jsonPath.get("suffix").isBoolean()) { throw new BatfishException( String.format( "'suffix' element of %s must be a JSON boolean", Variable.Type.JSON_PATH.getName())); } } Client(Settings settings);  Client(String[] args); }
Client extends AbstractClient implements IClient { static void validateJsonPath(JsonNode jsonPath) throws BatfishException { if (!jsonPath.isContainerNode()) { throw new BatfishException( String.format( "Expecting a JSON dictionary for a Batfish %s", Variable.Type.JSON_PATH.getName())); } if (jsonPath.get("path") == null) { throw new BatfishException( String.format("Missing 'path' element of %s", Variable.Type.JSON_PATH.getName())); } if (!jsonPath.get("path").isTextual()) { throw new BatfishException( String.format( "'path' element of %s must be a JSON string", Variable.Type.JSON_PATH.getName())); } if (jsonPath.get("suffix") != null && !jsonPath.get("suffix").isBoolean()) { throw new BatfishException( String.format( "'suffix' element of %s must be a JSON boolean", Variable.Type.JSON_PATH.getName())); } } Client(Settings settings);  Client(String[] args); @Override BatfishLogger getLogger(); Settings getSettings(); void run(List<String> initialCommands); }
Client extends AbstractClient implements IClient { static void validateJsonPath(JsonNode jsonPath) throws BatfishException { if (!jsonPath.isContainerNode()) { throw new BatfishException( String.format( "Expecting a JSON dictionary for a Batfish %s", Variable.Type.JSON_PATH.getName())); } if (jsonPath.get("path") == null) { throw new BatfishException( String.format("Missing 'path' element of %s", Variable.Type.JSON_PATH.getName())); } if (!jsonPath.get("path").isTextual()) { throw new BatfishException( String.format( "'path' element of %s must be a JSON string", Variable.Type.JSON_PATH.getName())); } if (jsonPath.get("suffix") != null && !jsonPath.get("suffix").isBoolean()) { throw new BatfishException( String.format( "'suffix' element of %s must be a JSON boolean", Variable.Type.JSON_PATH.getName())); } } Client(Settings settings);  Client(String[] args); @Override BatfishLogger getLogger(); Settings getSettings(); void run(List<String> initialCommands);  }