@Test
public void testConjureSpec() {
testCaseDef.positive().orElse(new TreeMap<>()).entrySet().stream().forEach(entry -> {
String testName = String.format("positive case %s", entry.getKey());
String yml = getYmlAsString(testName, entry.getValue().conjure());
try {
ConjureParserUtils.parseConjureDef(ImmutableList.of(MAPPER.readValue(yml, ConjureSourceFile.class)));
} catch (Exception e) {
Assertions.fail("Conjure for case should be valid according to the spec: " + testName, e);
}
});
testCaseDef.negative().orElse(new TreeMap<>()).entrySet().stream().forEach(entry -> {
String testName = String.format("negative case %s", entry.getKey());
String yml = getYmlAsString(testName, entry.getValue().conjure());
try {
ConjureParserUtils.parseConjureDef(ImmutableList.of(MAPPER.readValue(yml, ConjureSourceFile.class)));
Assertions.fail("Conjure for case should be invalid according to the spec: " + testName);
} catch (Exception e) {
Assertions.assertThat(e).withFailMessage("Failure message for case did not match expectation: "
+ testName + "\nMessage:\n" + e.getMessage() + "\ndid not contain:\n"
+ entry.getValue().expectedError()).hasMessageContaining(entry.getValue().expectedError());
}
});
}