import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
import org.opendaylight.yangtools.yang.parser.util.YangParseException;
import org.opendaylight.yangtools.yang.parser.util.YangValidationException;
+import com.google.common.base.Throwables;
public class YangParserNegativeTest {
fail("SomeModifiersUnresolvedException should be thrown");
}
} catch (SomeModifiersUnresolvedException e) {
- final Throwable suppressed2levelsDown = e.getSuppressed()[0].getSuppressed()[0];
- assertTrue(suppressed2levelsDown instanceof InferenceException);
- assertTrue(suppressed2levelsDown.getMessage().startsWith("Imported module"));
- assertTrue(suppressed2levelsDown.getMessage().endsWith("was not found."));
+ Throwable rootCause = Throwables.getRootCause(e);
+ assertTrue(rootCause instanceof InferenceException);
+ assertTrue(rootCause.getMessage().startsWith("Imported module"));
+ assertTrue(rootCause.getMessage().endsWith("was not found."));
}
}
TestUtils.loadModule(stream);
fail("IllegalArgumentException should be thrown");
}
- } catch (IllegalStateException e) {
- assertTrue(e.getMessage().startsWith(
- "Type '(urn:simple.types.data.demo?revision=2013-02-27)int-ext' was not found"));
+ } catch (SomeModifiersUnresolvedException e) {
+ Throwable rootCause = Throwables.getRootCause(e);
+ assertTrue(rootCause instanceof InferenceException);
+ assertTrue(rootCause.getMessage()
+ .startsWith("Type [(urn:simple.types.data.demo?revision=2013-02-27)int-ext] was not found."));
}
}
}
}
} catch (SomeModifiersUnresolvedException e) {
- final Throwable suppressed2levelsDown = e.getSuppressed()[0].getSuppressed()[0];
- assertTrue(suppressed2levelsDown instanceof InferenceException);
+ final Throwable rootCause = Throwables.getRootCause(e);
+ assertTrue(rootCause instanceof InferenceException);
assertEquals(
"Augment target not found: Absolute{path=[(urn:simple.container.demo?revision=1970-01-01)unknown]}",
- suppressed2levelsDown.getMessage());
+ rootCause.getMessage());
}
}
TestUtils.loadModule(stream);
fail("YangParseException should be thrown");
}
- } catch (YangParseException e) {
+ } catch (SourceException e) {
assertTrue(e.getMessage().contains("Invalid length constraint: <4, 10>"));
}
}
TestUtils.loadModule(stream);
fail("Exception should be thrown");
}
- } catch (YangParseException e) {
+ } catch (SourceException e) {
assertTrue(e.getMessage().contains("Invalid range constraint: <5, 20>"));
}
}