use of org.batfish.datamodel.questions.Question.InstanceData.Variable in project batfish by batfish.
the class ClientTest method testValidateNodeNotAllowedValue.
@Test
public void testValidateNodeNotAllowedValue() throws IOException {
String parameterName = "boolean";
JsonNode invalidNode = _mapper.readTree("false");
Question.InstanceData.Variable variable = new Question.InstanceData.Variable();
variable.setType(BOOLEAN);
SortedSet<String> allowedValues = new TreeSet<>();
allowedValues.add("true");
variable.setAllowedValues(allowedValues);
_thrown.expect(BatfishException.class);
_thrown.expectMessage(String.format("Invalid value: false, allowed values are: %s", allowedValues));
Client.validateNode(invalidNode, variable, parameterName);
}
use of org.batfish.datamodel.questions.Question.InstanceData.Variable in project batfish by batfish.
the class ClientTest method testValidProtocolValue.
@Test
public void testValidProtocolValue() throws IOException {
JsonNode prefixRangeNode = _mapper.readTree("\"tcp\"");
Question.InstanceData.Variable variable = new Question.InstanceData.Variable();
variable.setType(PROTOCOL);
Client.validateType(prefixRangeNode, variable);
}
use of org.batfish.datamodel.questions.Question.InstanceData.Variable in project batfish by batfish.
the class ClientTest method testValidFloatValue.
@Test
public void testValidFloatValue() {
Float floatValue = 15.0f;
JsonNode floatNode = _mapper.valueToTree(floatValue);
Question.InstanceData.Variable variable = new Question.InstanceData.Variable();
variable.setType(FLOAT);
Client.validateType(floatNode, variable);
}
use of org.batfish.datamodel.questions.Question.InstanceData.Variable in project batfish by batfish.
the class ClientTest method testValidIntegerValue.
@Test
public void testValidIntegerValue() throws IOException {
JsonNode integerNode = _mapper.readTree("15");
Question.InstanceData.Variable variable = new Question.InstanceData.Variable();
variable.setType(INTEGER);
Client.validateType(integerNode, variable);
}
use of org.batfish.datamodel.questions.Question.InstanceData.Variable in project batfish by batfish.
the class ClientTest method testUnsatisfiedMinElementInput.
@Test
public void testUnsatisfiedMinElementInput() throws IOException {
Map<String, JsonNode> parameters = new HashMap<>();
Map<String, Question.InstanceData.Variable> variables = new HashMap<>();
JsonNode jsonArray = _mapper.readTree("[\"action1\", \"action2\"]");
parameters.put("actions", jsonArray);
Variable actionsVariable = new Variable();
actionsVariable.setType(STRING);
actionsVariable.setMinElements(5);
variables.put("actions", actionsVariable);
_thrown.expect(BatfishException.class);
String errorMessage = String.format("Invalid value for parameter actions: %s. Expecting a " + "JSON array of at least 5 elements", jsonArray);
_thrown.expectMessage(equalTo(errorMessage));
Client.validateAndSet(parameters, variables);
}
Aggregations