@Test public void testValidateInvalidNode() throws IOException { String parameterName = "boolean"; JsonNode invalidNode = _mapper.readTree("\"I am string\""); Variable variable = new Variable(); variable.setType(BOOLEAN); _thrown.expect(BatfishException.class); _thrown.expectMessage( equalTo(String.format("Invalid value for parameter %s: %s", parameterName, invalidNode))); Client.validateNode(invalidNode, variable, parameterName); }
static void validateNode(JsonNode value, Variable variable, String parameterName) throws BatfishException { try { validateType(value, variable); } catch (BatfishException e) { String errorMessage = String.format("Invalid value for parameter %s: %s", parameterName, value); throw new BatfishException(errorMessage, e); } if (!variable.getValues().isEmpty() && variable.getValues().stream() .noneMatch(allowedValue -> allowedValue.getName().equals(value.asText()))) { throw new BatfishException( String.format( "Invalid value: %s, allowed values are: %s", value.asText(), variable.getValues())); } }
Client extends AbstractClient implements IClient { static void validateNode(JsonNode value, Variable variable, String parameterName) throws BatfishException { try { validateType(value, variable); } catch (BatfishException e) { String errorMessage = String.format("Invalid value for parameter %s: %s", parameterName, value); throw new BatfishException(errorMessage, e); } if (!variable.getValues().isEmpty() && variable.getValues().stream() .noneMatch(allowedValue -> allowedValue.getName().equals(value.asText()))) { throw new BatfishException( String.format( "Invalid value: %s, allowed values are: %s", value.asText(), variable.getValues())); } } }
Client extends AbstractClient implements IClient { static void validateNode(JsonNode value, Variable variable, String parameterName) throws BatfishException { try { validateType(value, variable); } catch (BatfishException e) { String errorMessage = String.format("Invalid value for parameter %s: %s", parameterName, value); throw new BatfishException(errorMessage, e); } if (!variable.getValues().isEmpty() && variable.getValues().stream() .noneMatch(allowedValue -> allowedValue.getName().equals(value.asText()))) { throw new BatfishException( String.format( "Invalid value: %s, allowed values are: %s", value.asText(), variable.getValues())); } } Client(Settings settings);  Client(String[] args); }
Client extends AbstractClient implements IClient { static void validateNode(JsonNode value, Variable variable, String parameterName) throws BatfishException { try { validateType(value, variable); } catch (BatfishException e) { String errorMessage = String.format("Invalid value for parameter %s: %s", parameterName, value); throw new BatfishException(errorMessage, e); } if (!variable.getValues().isEmpty() && variable.getValues().stream() .noneMatch(allowedValue -> allowedValue.getName().equals(value.asText()))) { throw new BatfishException( String.format( "Invalid value: %s, allowed values are: %s", value.asText(), variable.getValues())); } } Client(Settings settings);  Client(String[] args); @Override BatfishLogger getLogger(); Settings getSettings(); void run(List<String> initialCommands); }
Client extends AbstractClient implements IClient { static void validateNode(JsonNode value, Variable variable, String parameterName) throws BatfishException { try { validateType(value, variable); } catch (BatfishException e) { String errorMessage = String.format("Invalid value for parameter %s: %s", parameterName, value); throw new BatfishException(errorMessage, e); } if (!variable.getValues().isEmpty() && variable.getValues().stream() .noneMatch(allowedValue -> allowedValue.getName().equals(value.asText()))) { throw new BatfishException( String.format( "Invalid value: %s, allowed values are: %s", value.asText(), variable.getValues())); } } Client(Settings settings);  Client(String[] args); @Override BatfishLogger getLogger(); Settings getSettings(); void run(List<String> initialCommands);  }