Search in sources :

Example 6 with Variable

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

the class ClientTest method testValidSubRangeIntegerValue.

@Test
public void testValidSubRangeIntegerValue() throws IOException {
    JsonNode subRangeNode = _mapper.readTree("10");
    Question.InstanceData.Variable variable = new Question.InstanceData.Variable();
    variable.setType(SUBRANGE);
    Client.validateType(subRangeNode, 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 7 with Variable

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

the class ClientTest method testUnsatisfiedMinLengthValue.

@Test
public void testUnsatisfiedMinLengthValue() throws IOException {
    String shortString = "\"short\"";
    Question.InstanceData.Variable variable = new Question.InstanceData.Variable();
    variable.setMinLength(8);
    _thrown.expect(BatfishException.class);
    _thrown.expectMessage(equalTo("Must be at least 8 characters in length"));
    Client.validateType(_mapper.readTree(shortString), variable);
}
Also used : Variable(org.batfish.datamodel.questions.Question.InstanceData.Variable) Variable(org.batfish.datamodel.questions.Question.InstanceData.Variable) Question(org.batfish.datamodel.questions.Question) Test(org.junit.Test)

Example 8 with Variable

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

the class ClientTest method validateTypeWithInvalidInput.

private void validateTypeWithInvalidInput(String input, Class<? extends Throwable> expectedException, String expectedMessage, Type type) throws IOException {
    JsonNode node = _mapper.readTree(input);
    Question.InstanceData.Variable variable = new Question.InstanceData.Variable();
    variable.setType(type);
    _thrown.expect(expectedException);
    _thrown.expectMessage(equalTo(expectedMessage));
    Client.validateType(node, 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)

Example 9 with Variable

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

the class ClientTest method testValidJsonPathValue.

@Test
public void testValidJsonPathValue() throws IOException {
    JsonNode jsonPathNode = _mapper.readTree("{\"path\" : \"I am path.\", \"suffix\" : true}");
    Question.InstanceData.Variable variable = new Question.InstanceData.Variable();
    variable.setType(JSON_PATH);
    Client.validateType(jsonPathNode, 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 10 with Variable

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

the class ClientTest method testValidJavaRegexValue.

@Test
public void testValidJavaRegexValue() throws IOException {
    JsonNode inputNode = _mapper.readTree("\".*\"");
    Question.InstanceData.Variable variable = new Question.InstanceData.Variable();
    variable.setType(JAVA_REGEX);
    Client.validateType(inputNode, 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