Search in sources :

Example 36 with BatfishException

use of org.batfish.common.BatfishException in project batfish by batfish.

the class ConvertConfigurationAnswerElementTest method testPrettyPrint.

@Test
public void testPrettyPrint() {
    BatfishException exception = new BatfishException("sample exception");
    BatfishStackTrace stackTrace = new BatfishStackTrace(exception);
    _element.getErrors().put("sampleError", stackTrace);
    StringBuilder expected = new StringBuilder();
    expected.append("Results from converting vendor configurations\n");
    expected.append("\n  sampleError[Conversion errors]\n");
    for (String line : _element.getErrors().get("sampleError").getLineMap()) {
        expected.append("    " + line + "\n");
    }
    assertThat(_element.prettyPrint(), equalTo(expected.toString()));
}
Also used : BatfishException(org.batfish.common.BatfishException) BatfishStackTrace(org.batfish.common.BatfishException.BatfishStackTrace) Test(org.junit.Test)

Example 37 with BatfishException

use of org.batfish.common.BatfishException in project batfish by batfish.

the class ConvertConfigurationAnswerElementTest method testGetErrors.

@Test
public void testGetErrors() {
    BatfishException exception = new BatfishException("sample exception");
    BatfishStackTrace stackTrace = new BatfishStackTrace(exception);
    _element.getErrors().put("error", stackTrace);
    assertThat(_element.getErrors().get("error"), is(stackTrace));
}
Also used : BatfishException(org.batfish.common.BatfishException) BatfishStackTrace(org.batfish.common.BatfishException.BatfishStackTrace) Test(org.junit.Test)

Example 38 with BatfishException

use of org.batfish.common.BatfishException in project batfish by batfish.

the class ConvertConfigurationAnswerElementTest method checkNonEmptyErrors.

@Test
public void checkNonEmptyErrors() {
    BatfishException exception = new BatfishException("sample exception");
    _element.getErrors().put("error", new BatfishStackTrace(exception));
    assertThat(_element.getErrors().size(), is(1));
}
Also used : BatfishException(org.batfish.common.BatfishException) BatfishStackTrace(org.batfish.common.BatfishException.BatfishStackTrace) Test(org.junit.Test)

Example 39 with BatfishException

use of org.batfish.common.BatfishException in project batfish by batfish.

the class InitInfoAnswerElementTest method testGetErrors.

@Test
public void testGetErrors() {
    BatfishException exception = new BatfishException("sample exception");
    BatfishStackTrace stackTrace = new BatfishStackTrace(exception);
    List<BatfishStackTrace> errors = new ArrayList<>();
    errors.add(stackTrace);
    _element.getErrors().put("error", errors);
    assertThat(_element.getErrors().get("error"), is(errors));
}
Also used : BatfishException(org.batfish.common.BatfishException) ArrayList(java.util.ArrayList) BatfishStackTrace(org.batfish.common.BatfishException.BatfishStackTrace) Test(org.junit.Test)

Example 40 with BatfishException

use of org.batfish.common.BatfishException in project batfish by batfish.

the class InitInfoAnswerElementTest method checkNonEmptyErrorsSet.

@Test
public void checkNonEmptyErrorsSet() {
    BatfishException exception = new BatfishException("sample exception");
    BatfishStackTrace stackTrace = new BatfishStackTrace(exception);
    _element.getErrors().put("error", new ArrayList<>());
    _element.getErrors().get("error").add(stackTrace);
    assertThat(_element.getErrors().get("error").size(), is(1));
    assertTrue(_element.getErrors().get("error").contains(stackTrace));
}
Also used : BatfishException(org.batfish.common.BatfishException) BatfishStackTrace(org.batfish.common.BatfishException.BatfishStackTrace) Test(org.junit.Test)

Aggregations

BatfishException (org.batfish.common.BatfishException)264 IOException (java.io.IOException)61 Path (java.nio.file.Path)54 CleanBatfishException (org.batfish.common.CleanBatfishException)35 RedFlagBatfishException (org.batfish.common.RedFlagBatfishException)34 TreeMap (java.util.TreeMap)31 ArrayList (java.util.ArrayList)30 JSONException (org.codehaus.jettison.json.JSONException)30 Ip (org.batfish.datamodel.Ip)25 JSONObject (org.codehaus.jettison.json.JSONObject)25 Configuration (org.batfish.datamodel.Configuration)24 Map (java.util.Map)23 Prefix (org.batfish.datamodel.Prefix)22 HashMap (java.util.HashMap)20 HashSet (java.util.HashSet)20 TreeSet (java.util.TreeSet)20 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)18 Test (org.junit.Test)18 Set (java.util.Set)17 SortedMap (java.util.SortedMap)17