Search in sources :

Example 1 with BatfishStackTrace

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

the class Answer method append.

public void append(Answer answer) {
    if (answer._question != null) {
        _question = answer._question;
    }
    _answerElements.addAll(answer._answerElements);
    _status = answer._status;
    _summary.combine(answer.getSummary());
    for (AnswerElement answerElement : answer._answerElements) {
        if (answerElement instanceof BatfishStackTrace) {
            BatfishException e = ((BatfishStackTrace) answerElement).getException();
            throw new QuestionException("Exception answering question", e, this);
        }
    }
}
Also used : BatfishException(org.batfish.common.BatfishException) QuestionException(org.batfish.common.QuestionException) BatfishStackTrace(org.batfish.common.BatfishException.BatfishStackTrace)

Example 2 with BatfishStackTrace

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

the class ConvertConfigurationAnswerElementTest method testSetErrors.

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

Example 3 with BatfishStackTrace

use of org.batfish.common.BatfishException.BatfishStackTrace 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 4 with BatfishStackTrace

use of org.batfish.common.BatfishException.BatfishStackTrace 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 5 with BatfishStackTrace

use of org.batfish.common.BatfishException.BatfishStackTrace 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)

Aggregations

BatfishStackTrace (org.batfish.common.BatfishException.BatfishStackTrace)15 BatfishException (org.batfish.common.BatfishException)14 Test (org.junit.Test)12 ArrayList (java.util.ArrayList)4 TreeMap (java.util.TreeMap)3 List (java.util.List)2 Warning (org.batfish.common.Warning)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 TypeReference (com.fasterxml.jackson.core.type.TypeReference)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Verify (com.google.common.base.Verify)1 Cache (com.google.common.cache.Cache)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 ImmutableSortedMap (com.google.common.collect.ImmutableSortedMap)1 ImmutableSortedSet (com.google.common.collect.ImmutableSortedSet)1 Lists (com.google.common.collect.Lists)1 Sets (com.google.common.collect.Sets)1 ActiveSpan (io.opentracing.ActiveSpan)1