use of org.junit.function.ThrowingRunnable in project aerospike-client-java by aerospike.
the class TestFilterExp method filterMod.
@Test
public void filterMod() {
Policy policy = new Policy();
policy.filterExp = Exp.build(Exp.eq(Exp.mod(Exp.intBin(binA), Exp.val(2)), Exp.val(0)));
policy.failOnFilteredOut = true;
AerospikeException ae = assertThrows(AerospikeException.class, new ThrowingRunnable() {
public void run() {
client.get(policy, keyA);
}
});
assertEquals(ResultCode.FILTERED_OUT, ae.getResultCode());
Record r = client.get(policy, keyB);
assertBinEqual(keyA, r, binA, 2);
}
use of org.junit.function.ThrowingRunnable in project hutool by looly.
the class Ipv4UtilTest method getMaskBitByIllegalMaskTest.
@Test
public void getMaskBitByIllegalMaskTest() {
ThrowingRunnable getMaskBitByMaskRunnable = () -> Ipv4Util.getMaskBitByMask("255.255.0.255");
Assert.assertThrows("非法掩码测试", IllegalArgumentException.class, getMaskBitByMaskRunnable);
}
use of org.junit.function.ThrowingRunnable in project copybara by google.
the class GitMirrorTest method testMergeConflict.
@Test
public void testMergeConflict() throws Exception {
Migration mirror = mergeInit();
GitLogEntry destChange = repoChange(destRepo, "some_file", "Hello", "destination only");
GitLogEntry originChange = repoChange(originRepo, "some_file", "Bye", "new change");
assertThat((assertThrows(ValidationException.class, new ThrowingRunnable() {
@Override
public void run() throws Throwable {
mirror.run(workdir, ImmutableList.of());
}
}))).hasMessageThat().contains("Conflict merging refs/heads/" + primaryBranch);
}
use of org.junit.function.ThrowingRunnable in project hippo by NHS-digital-website.
the class HeadingsHyperlinksFromMarkdownHelperTest method throwsException_onRenderingFailure.
@Test
public void throwsException_onRenderingFailure() {
// given
final Options options = mock(Options.class);
final RuntimeException expectedCause = new RuntimeException();
given(options.buffer()).willThrow(expectedCause);
final String irrelevantMarkdown = "Irrelevant `Markdown`.";
// when
final ThrowingRunnable action = () -> helper.apply(irrelevantMarkdown, options);
// then
final TemplateRenderingException actualException = assertThrows(TemplateRenderingException.class, action);
assertThat("Exception message provides failure's details.", actualException.getMessage(), is("Failed to render hyperlinks for headings from Markdown " + irrelevantMarkdown + "."));
assertThat("Cause exception is included.", actualException.getCause(), sameInstance(expectedCause));
}
use of org.junit.function.ThrowingRunnable in project hippo by NHS-digital-website.
the class MarkdownHelperTest method throwsException_onMarkdownRenderingFailure.
@Test
public void throwsException_onMarkdownRenderingFailure() {
// given
final RuntimeException expectedCause = new RuntimeException();
given(commonmarkMarkdownConverter.toHtml(any(), any(), any(Integer.class))).willThrow(expectedCause);
final Options options = OptionsStub.empty();
final String markdown = "some markdown";
// when
final ThrowingRunnable action = () -> markdownHelper.apply(markdown, options);
// then
final RuntimeException actualException = assertThrows(RuntimeException.class, action);
assertThat("Exception message provides failure's details.", actualException.getMessage(), is("Failed to render Markdown: " + markdown));
assertThat("Cause exception is included.", actualException.getCause(), sameInstance(expectedCause));
}
Aggregations