當前位置: 首頁>>代碼示例>>Java>>正文


Java Assertions.assertThrows方法代碼示例

本文整理匯總了Java中org.junit.jupiter.api.Assertions.assertThrows方法的典型用法代碼示例。如果您正苦於以下問題:Java Assertions.assertThrows方法的具體用法?Java Assertions.assertThrows怎麽用?Java Assertions.assertThrows使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.junit.jupiter.api.Assertions的用法示例。


在下文中一共展示了Assertions.assertThrows方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testCpcPlusFileFailures

import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@ParameterizedTest
@MethodSource("failureData")
void testCpcPlusFileFailures(Path entry) throws IOException {
	String fileName = entry.getFileName().toString();
	assertWithMessage("No associated entry in fixture.json for the file %s", fileName).that(fixtureValues).containsKey(fileName);

	Converter converter = new Converter(new PathSource(entry));

	TransformException expected = Assertions.assertThrows(TransformException.class, converter::transform);
	//runnning conversions on individual files
	List<Detail> details = expected.getDetails().getErrors().get(0).getDetails();
	verifyOutcome(fileName, details);
}
 
開發者ID:CMSgov,項目名稱:qpp-conversion-tool,代碼行數:14,代碼來源:CpcPlusAcceptanceTest.java

示例2: nonexistentJsonPath

import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@Test
void nonexistentJsonPath() throws IOException, XmlException {
	Assertions.assertThrows(PathNotFoundException.class, () -> {
		String jsonPath = "meep.mawp";
		helper.executeAttributeTest(jsonPath, "", "");
	});
}
 
開發者ID:CMSgov,項目名稱:qpp-conversion-tool,代碼行數:8,代碼來源:XpathJsonPathComparisonTest.java

示例3: throwWithWrongCountValueBuildCondition3AndMore

import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@Test
void throwWithWrongCountValueBuildCondition3AndMore() {
    // TODO Should we care about not enough or too many ? (not supposed to happen if use public API)
    Assertions.assertThrows(IllegalArgumentException.class, () -> filterValue3.buildCondition(Collections.emptyList()));
    filterValue3.buildCondition(Arrays.asList("val1", "val2"));
    filterValue3.buildCondition(Arrays.asList("val1", "val2", "val3", "val4"));

    Assertions.assertThrows(IllegalArgumentException.class, () -> filterValue5.buildCondition(Collections.emptyList()));
    filterValue5.buildCondition(Arrays.asList("val1", "val2"));
    filterValue5.buildCondition(Arrays.asList("val1", "val2", "val3", "val4", "val5", "val6"));
}
 
開發者ID:Blackdread,項目名稱:filter-sort-jooq-api,代碼行數:12,代碼來源:FilterValueTest.java

示例4: testFalseCondition

import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@Test
public void testFalseCondition() throws Exception {
    UnsupportedOperationException e = Assertions.assertThrows(UnsupportedOperationException.class, () ->
        Ensure.ensureCondition(false, UnsupportedOperationException.class, of("foo"))
    );
    Assertions.assertEquals("foo", e.getMessage(), "Exception message didn't match!");
}
 
開發者ID:mikroskeem,項目名稱:Shuriken,代碼行數:8,代碼來源:EnsureTester.java

示例5: buildConditionsThrowsOnMissingValueForConditionCreator

import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@Test
void buildConditionsThrowsOnMissingValueForConditionCreator() {
    filteringJooqImpl1.getFilterValues().add(Filter.of("key1", v1 -> "val1", val1 -> DSL.trueCondition()));
    filteringJooqImpl1.getFilterValues().add(Filter.of("key2", v1 -> "val1", val1 -> DSL.trueCondition()));
    Assertions.assertThrows(FilteringApiException.class, () -> filteringJooqImpl1.buildConditions(ImmutableMap.of("key1", "", "key2", "12:25:30")));
    Assertions.assertThrows(FilteringApiException.class, () -> filteringJooqImpl1.buildConditions(ImmutableMap.of("key1", "   ")));
}
 
開發者ID:Blackdread,項目名稱:filter-sort-jooq-api,代碼行數:8,代碼來源:FilteringJooqTest.java

示例6: parseWithApiExceptionThrows

import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@Test
void parseWithApiExceptionThrows() {
    Assertions.assertThrows(FilteringApiException.class, () -> FilterParser.ofTime().parseWithApiException("12 43"));
    Assertions.assertThrows(FilteringApiException.class, () -> FilterParser.ofTime().parseWithApiException("12:23 45"));
    Assertions.assertThrows(FilteringApiException.class, () -> FilterParser.ofTime().parseWithApiException("Odwdw0"));
    Assertions.assertThrows(FilteringApiException.class, () -> FilterParser.ofTime().parseWithApiException("O"));
    Assertions.assertThrows(FilteringApiException.class, () -> FilterParser.ofTime().parseWithApiException(" 5   "));
}
 
開發者ID:Blackdread,項目名稱:filter-sort-jooq-api,代碼行數:9,代碼來源:FilterParserLocalTimeTest.java

示例7: testBadFormattedMeasureDataFile

import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@Test
void testBadFormattedMeasureDataFile() {
	IllegalArgumentException thrown = Assertions.assertThrows(IllegalArgumentException.class, () ->
		MeasureConfigs.setMeasureDataFile("bad_formatted_measures_data.json"));

	assertThat(thrown).hasCauseThat().isInstanceOf(JsonMappingException.class);
}
 
開發者ID:CMSgov,項目名稱:qpp-conversion-tool,代碼行數:8,代碼來源:MeasureConfigsTest.java

示例8: ofSupplierThrowsIfWrongBuildCondition

import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@Test
void ofSupplierThrowsIfWrongBuildCondition() {
    final FilterValue filter = Filter.of("myKey", () -> null);
    Assertions.assertThrows(IllegalStateException.class, () -> filter.buildCondition(Collections.singletonList("obj1")));
    Assertions.assertThrows(IllegalStateException.class, () -> filter.buildCondition(Arrays.asList("obj1", "obj2")));
    Assertions.assertThrows(IllegalStateException.class, () -> filter.buildCondition(Arrays.asList("obj1", "obj2", "obj3")));
}
 
開發者ID:Blackdread,項目名稱:filter-sort-jooq-api,代碼行數:8,代碼來源:FilterSupplierTest.java

示例9: shouldAllowEmptyTemplateScope

import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@Test
void shouldAllowEmptyTemplateScope() throws ParseException {
	//when
	Assertions.assertThrows(MissingArgumentException.class, () -> {
		CommandLine line = ConversionEntry.cli("-t");
		ConversionEntry.shouldContinue(line);
	});
}
 
開發者ID:CMSgov,項目名稱:qpp-conversion-tool,代碼行數:9,代碼來源:ConversionEntryTest.java

示例10: getInvalidUriTest

import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
/**
 * In this test case a driver is requested which is not registered with the {@link PlcDriverManager}.
 */
@Test
@Tag("fast")
void getInvalidUriTest() throws PlcException {
    Assertions.assertThrows(PlcConnectionException.class,
        () -> new PlcDriverManager().getConnection("The quick brown fox jumps over the lazy dog"));
}
 
開發者ID:apache,項目名稱:incubator-plc4x,代碼行數:10,代碼來源:PlcDriverManagerTest.java

示例11: noValuesThrows

import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@Test
void noValuesThrows() {
    Assertions.assertThrows(FilteringApiException.class, () -> FilterMultipleValueParser.ofInt().parse(""));
    Assertions.assertThrows(FilteringApiException.class, () -> FilterMultipleValueParser.ofInt().parse("", 3));
    Assertions.assertThrows(FilteringApiException.class, () -> FilterMultipleValueParser.ofInt().parse("", ","));
    Assertions.assertThrows(FilteringApiException.class, () -> FilterMultipleValueParser.ofInt().parse("", ",", 3));
}
 
開發者ID:Blackdread,項目名稱:filter-sort-jooq-api,代碼行數:8,代碼來源:FilterMultipleValueParserIntTest.java

示例12: throwWithWrongCountValueBuildCondition2

import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@Test
void throwWithWrongCountValueBuildCondition2() {
    Assertions.assertThrows(IndexOutOfBoundsException.class, () -> filterValue2.buildCondition(Collections.emptyList()));
    Assertions.assertThrows(IndexOutOfBoundsException.class, () -> filterValue2.buildCondition(Collections.singletonList("val1")));

    // TODO Should we care about too many ? (not supposed to happen if use public API)
    filterValue2.buildCondition(Arrays.asList("val1", "val2", "val3"));
}
 
開發者ID:Blackdread,項目名稱:filter-sort-jooq-api,代碼行數:9,代碼來源:FilterValueTest.java

示例13: emptyValueThrows

import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@Test
void emptyValueThrows() {
    Assertions.assertThrows(IllegalArgumentException.class, ValueImpl::new);
    Assertions.assertThrows(IllegalArgumentException.class, () -> new ValueImpl<>(new Object[0]));
    final Object ff = null;
    Assertions.assertThrows(IllegalArgumentException.class, () -> new ValueImpl<>(ff));
    Assertions.assertThrows(IllegalArgumentException.class, () -> new ValueImpl<>(Collections.emptyList()));
}
 
開發者ID:Blackdread,項目名稱:filter-sort-jooq-api,代碼行數:9,代碼來源:ValueTest.java

示例14: buildConditionsThrowsByDefaultForMissingKeyMultiple

import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@ParameterizedTest
@MethodSource("incompleteMapOfFilterMultipleKeys")
void buildConditionsThrowsByDefaultForMissingKeyMultiple(final Map<String, String> params, final List<FilterValue> filterValues) {
    filteringJooqImpl1.getFilterValues().addAll(filterValues);
    Assertions.assertThrows(FilteringApiException.class, () -> filteringJooqImpl1.buildConditions(params));
}
 
開發者ID:Blackdread,項目名稱:filter-sort-jooq-api,代碼行數:7,代碼來源:FilteringJooqTest.java

示例15: testGetUniqueIdForKeyNullSubPopulationThrowsNullPointerException

import org.junit.jupiter.api.Assertions; //導入方法依賴的package包/類
@Test
void testGetUniqueIdForKeyNullSubPopulationThrowsNullPointerException() {
	Assertions.assertThrows(NullPointerException.class, () ->
		SubPopulations.getUniqueIdForKey("not null", null));
}
 
開發者ID:CMSgov,項目名稱:qpp-conversion-tool,代碼行數:6,代碼來源:SubPopulationsTest.java


注:本文中的org.junit.jupiter.api.Assertions.assertThrows方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。