Search in sources :

Example 26 with Variable

use of org.batfish.datamodel.questions.Question.InstanceData.Variable in project batfish by batfish.

the class ClientTest method testValidComparatorValue.

@Test
public void testValidComparatorValue() throws IOException {
    JsonNode comparatorNode = _mapper.readTree("\">=\"");
    Question.InstanceData.Variable variable = new Question.InstanceData.Variable();
    variable.setType(COMPARATOR);
    Client.validateType(comparatorNode, variable);
}
Also used : Variable(org.batfish.datamodel.questions.Question.InstanceData.Variable) Variable(org.batfish.datamodel.questions.Question.InstanceData.Variable) JsonNode(com.fasterxml.jackson.databind.JsonNode) Question(org.batfish.datamodel.questions.Question) Test(org.junit.Test)

Example 27 with Variable

use of org.batfish.datamodel.questions.Question.InstanceData.Variable in project batfish by batfish.

the class ClientTest method testValidateInvalidNode.

@Test
public void testValidateInvalidNode() throws IOException {
    String parameterName = "boolean";
    JsonNode invalidNode = _mapper.readTree("\"I am string\"");
    Question.InstanceData.Variable variable = new Question.InstanceData.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);
}
Also used : Variable(org.batfish.datamodel.questions.Question.InstanceData.Variable) Variable(org.batfish.datamodel.questions.Question.InstanceData.Variable) JsonNode(com.fasterxml.jackson.databind.JsonNode) Question(org.batfish.datamodel.questions.Question) Test(org.junit.Test)

Example 28 with Variable

use of org.batfish.datamodel.questions.Question.InstanceData.Variable in project batfish by batfish.

the class ClientTest method testValidIPValue.

@Test
public void testValidIPValue() throws IOException {
    JsonNode ipNode = _mapper.readTree("\"0.0.0.0\"");
    Question.InstanceData.Variable variable = new Question.InstanceData.Variable();
    variable.setType(IP);
    Client.validateType(ipNode, variable);
}
Also used : Variable(org.batfish.datamodel.questions.Question.InstanceData.Variable) Variable(org.batfish.datamodel.questions.Question.InstanceData.Variable) JsonNode(com.fasterxml.jackson.databind.JsonNode) Question(org.batfish.datamodel.questions.Question) Test(org.junit.Test)

Example 29 with Variable

use of org.batfish.datamodel.questions.Question.InstanceData.Variable in project batfish by batfish.

the class ClientTest method testValidPrefixRangeValue.

@Test
public void testValidPrefixRangeValue() throws IOException {
    JsonNode prefixRangeNode = _mapper.readTree("\"10.168.5.5/30:10-50\"");
    Question.InstanceData.Variable variable = new Question.InstanceData.Variable();
    variable.setType(PREFIX_RANGE);
    Client.validateType(prefixRangeNode, variable);
}
Also used : Variable(org.batfish.datamodel.questions.Question.InstanceData.Variable) Variable(org.batfish.datamodel.questions.Question.InstanceData.Variable) JsonNode(com.fasterxml.jackson.databind.JsonNode) Question(org.batfish.datamodel.questions.Question) Test(org.junit.Test)

Example 30 with Variable

use of org.batfish.datamodel.questions.Question.InstanceData.Variable in project batfish by batfish.

the class ClientTest method testValidIpWildcardValue.

@Test
public void testValidIpWildcardValue() throws IOException {
    JsonNode ipWildcardNode = _mapper.readTree("\"10.168.5.5:10.168.100.100\"");
    Question.InstanceData.Variable variable = new Question.InstanceData.Variable();
    variable.setType(IP_WILDCARD);
    Client.validateType(ipWildcardNode, variable);
}
Also used : Variable(org.batfish.datamodel.questions.Question.InstanceData.Variable) Variable(org.batfish.datamodel.questions.Question.InstanceData.Variable) JsonNode(com.fasterxml.jackson.databind.JsonNode) Question(org.batfish.datamodel.questions.Question) Test(org.junit.Test)

Aggregations

Variable (org.batfish.datamodel.questions.Question.InstanceData.Variable)30 JsonNode (com.fasterxml.jackson.databind.JsonNode)25 Question (org.batfish.datamodel.questions.Question)24 Test (org.junit.Test)23 BatfishException (org.batfish.common.BatfishException)6 JSONObject (org.codehaus.jettison.json.JSONObject)3 IOException (java.io.IOException)2 TreeSet (java.util.TreeSet)2 JSONException (org.codehaus.jettison.json.JSONException)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 TypeReference (com.fasterxml.jackson.core.type.TypeReference)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Path (java.nio.file.Path)1 HashMap (java.util.HashMap)1 PatternSyntaxException (java.util.regex.PatternSyntaxException)1 WorkItem (org.batfish.common.WorkItem)1 BatfishObjectMapper (org.batfish.common.util.BatfishObjectMapper)1 Ip (org.batfish.datamodel.Ip)1 IpWildcard (org.batfish.datamodel.IpWildcard)1 SubRange (org.batfish.datamodel.SubRange)1