本文整理汇总了Java中org.junit.jupiter.api.Assumptions类的典型用法代码示例。如果您正苦于以下问题:Java Assumptions类的具体用法?Java Assumptions怎么用?Java Assumptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Assumptions类属于org.junit.jupiter.api包,在下文中一共展示了Assumptions类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: updateGreeting
import org.junit.jupiter.api.Assumptions; //导入依赖的package包/类
@Test
@DisplayName("Updating a greeting should work")
void updateGreeting() {
// Given we have a greeting already saved
GreetingDto savedGreeting = service.createGreeting(createGreetingDto("We come in peace!"));
Assumptions.assumeTrue(savedGreeting != null);
// When we update it
savedGreeting.setMessage("Updated message");
service.updateGreetingWithId(savedGreeting.getId(), savedGreeting);
// Then it should be updated
Optional<GreetingDto> updatedGreetingOptional = service.findGreetingById(savedGreeting.getId());
Assertions.assertAll("Updating a greeting by id should work",
() -> assertTrue(updatedGreetingOptional.isPresent(), "Could not find greeting by id"),
() -> assertEquals(savedGreeting.getId(), updatedGreetingOptional.get().getId(), "Updated greeting has invalid id"),
() -> assertEquals("Updated message", updatedGreetingOptional.get().getMessage(), "Updated greeting has different message from the expected updated one"));
}
开发者ID:bmariesan,项目名称:iStudent,代码行数:18,代码来源:GreetingServiceTest.java
示例2: testDefaultValidityFailedValidationExecutorRemovesValidityStackFrames
import org.junit.jupiter.api.Assumptions; //导入依赖的package包/类
@Test
void testDefaultValidityFailedValidationExecutorRemovesValidityStackFrames() {
Exception exception = new NullPointerException();
Assumptions.assumeTrue(null != exception.getStackTrace() && exception.getStackTrace().length > 0,
"This test can only work if the JVM is filling in stack traces.");
IllegalArgumentException thrown = Assertions.assertThrows(IllegalArgumentException.class,
() -> FVE.fail("expected", "subject", () -> "message"));
int firstLineNumber = exception.getStackTrace()[0].getLineNumber();
Assertions.assertTrue(null != thrown.getStackTrace() && thrown.getStackTrace().length > 0,
"If the JVM is filling in stack traces the thrown exception should have a stack trace.");
Assertions.assertEquals(firstLineNumber + 4,
thrown.getStackTrace()[0].getLineNumber(),
"Default stack trace should have the caller as the first line number.");
Assertions.assertEquals(exception.getStackTrace()[0].getClassName(),
thrown.getStackTrace()[0].getClassName(),
"Default stack trace should have the caller as the first line");
Assertions.assertTrue(thrown.getStackTrace().length > 1,
"Default stack trace should have more than the caller.");
}
开发者ID:redfin,项目名称:validity,代码行数:20,代码来源:StackTraceTest.java
示例3: testSubmissionApiPostSuccess
import org.junit.jupiter.api.Assumptions; //导入依赖的package包/类
@Test
void testSubmissionApiPostSuccess() throws IOException {
HttpResponse httpResponse = servicePost(qpp);
Assumptions.assumeTrue(endpointIsUp(httpResponse), "Validation api is down");
assertThat(getStatus(httpResponse)).isEqualTo(200);
}
开发者ID:CMSgov,项目名称:qpp-conversion-tool,代码行数:8,代码来源:SubmissionIntegrationTest.java
示例4: testSubmissionApiPostFailure
import org.junit.jupiter.api.Assumptions; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
void testSubmissionApiPostFailure() throws IOException {
Map<String, Object> obj = (Map<String, Object>) qpp.getObject();
obj.remove("performanceYear");
HttpResponse httpResponse = servicePost(qpp);
Assumptions.assumeTrue(endpointIsUp(httpResponse), "Validation api is down");
assertWithMessage("QPP submission should be unprocessable")
.that(getStatus(httpResponse))
.isEqualTo(422);
}
开发者ID:CMSgov,项目名称:qpp-conversion-tool,代码行数:13,代码来源:SubmissionIntegrationTest.java
示例5: testCopyBasicFileAttributesFromNioToFuse
import org.junit.jupiter.api.Assumptions; //导入依赖的package包/类
@Test
public void testCopyBasicFileAttributesFromNioToFuse() {
Instant instant = Instant.ofEpochSecond(424242l, 42);
FileTime ftime = FileTime.from(instant);
BasicFileAttributes attr = Mockito.mock(BasicFileAttributes.class);
Mockito.when(attr.isDirectory()).thenReturn(true);
Mockito.when(attr.lastModifiedTime()).thenReturn(ftime);
Mockito.when(attr.creationTime()).thenReturn(ftime);
Mockito.when(attr.lastAccessTime()).thenReturn(ftime);
Mockito.when(attr.size()).thenReturn(42l);
FileAttributesUtil util = new FileAttributesUtil();
FileStat stat = new FileStat(jnr.ffi.Runtime.getSystemRuntime());
util.copyBasicFileAttributesFromNioToFuse(attr, stat);
Assertions.assertTrue((FileStat.S_IFDIR & stat.st_mode.intValue()) == FileStat.S_IFDIR);
Assertions.assertEquals(424242l, stat.st_mtim.tv_sec.get());
Assertions.assertEquals(42, stat.st_mtim.tv_nsec.intValue());
Assertions.assertEquals(424242l, stat.st_ctim.tv_sec.get());
Assertions.assertEquals(42, stat.st_ctim.tv_nsec.intValue());
Assumptions.assumingThat(Platform.IS_MAC || Platform.IS_WINDOWS, () -> {
Assertions.assertEquals(424242l, stat.st_birthtime.tv_sec.get());
Assertions.assertEquals(42, stat.st_birthtime.tv_nsec.intValue());
});
Assertions.assertEquals(424242l, stat.st_atim.tv_sec.get());
Assertions.assertEquals(42, stat.st_atim.tv_nsec.intValue());
Assertions.assertEquals(42l, stat.st_size.longValue());
}
开发者ID:cryptomator,项目名称:fuse-nio-adapter,代码行数:29,代码来源:FileAttributesUtilTest.java
示例6: testBasicFileAttributesToFileStat
import org.junit.jupiter.api.Assumptions; //导入依赖的package包/类
@Test
public void testBasicFileAttributesToFileStat() {
Instant instant = Instant.ofEpochSecond(424242l, 42);
FileTime ftime = FileTime.from(instant);
BasicFileAttributes attr = Mockito.mock(BasicFileAttributes.class);
Mockito.when(attr.isDirectory()).thenReturn(true);
Mockito.when(attr.lastModifiedTime()).thenReturn(ftime);
Mockito.when(attr.creationTime()).thenReturn(ftime);
Mockito.when(attr.lastAccessTime()).thenReturn(ftime);
Mockito.when(attr.size()).thenReturn(42l);
FileAttributesUtil util = new FileAttributesUtil();
FileStat stat = util.basicFileAttributesToFileStat(attr);
Assertions.assertTrue((FileStat.S_IFDIR & stat.st_mode.intValue()) == FileStat.S_IFDIR);
Assertions.assertEquals(424242l, stat.st_mtim.tv_sec.get());
Assertions.assertEquals(42, stat.st_mtim.tv_nsec.intValue());
Assertions.assertEquals(424242l, stat.st_ctim.tv_sec.get());
Assertions.assertEquals(42, stat.st_ctim.tv_nsec.intValue());
Assumptions.assumingThat(Platform.IS_MAC || Platform.IS_WINDOWS, () -> {
Assertions.assertEquals(424242l, stat.st_birthtime.tv_sec.get());
Assertions.assertEquals(42, stat.st_birthtime.tv_nsec.intValue());
});
Assertions.assertEquals(424242l, stat.st_atim.tv_sec.get());
Assertions.assertEquals(42, stat.st_atim.tv_nsec.intValue());
Assertions.assertEquals(42l, stat.st_size.longValue());
}
开发者ID:cryptomator,项目名称:fuse-nio-adapter,代码行数:28,代码来源:FileAttributesUtilTest.java
示例7: onlyRunThisOnCIEnvironment
import org.junit.jupiter.api.Assumptions; //导入依赖的package包/类
@Test
public void onlyRunThisOnCIEnvironment() {
String result = new RomanConverter().convert(166);
Assumptions.assumingThat(System.getenv("CI") != null, () ->
assertEquals("CLXVI", result)
);
}
开发者ID:JanMosigItemis,项目名称:codingdojoleipzig,代码行数:9,代码来源:UnitTest.java
示例8: commonSetUp
import org.junit.jupiter.api.Assumptions; //导入依赖的package包/类
@BeforeEach
public void commonSetUp() {
settingsBuilder = TrautePluginSettingsBuilder.settingsBuilder();
expectCompilationResult = CompilationResultExpectationBuilder.expectCompilationResult();
expectRunResult = RunResultExpectationBuilder.expectRunResult();
Assumptions.assumeTrue(Boolean.getBoolean(ACTIVATION_PROPERTY));
}
开发者ID:denis-zhdanov,项目名称:traute,代码行数:9,代码来源:AbstractTrauteTest.java
示例9: testFromEnvironment
import org.junit.jupiter.api.Assumptions; //导入依赖的package包/类
@Test
void testFromEnvironment() {
List<String> keysMissingFromEnvironment = WebHookToken.Env.missingTokenKeys();
Assumptions.assumeTrue(keysMissingFromEnvironment.isEmpty(),
() -> String.format("Skipping test, environment keys not found: [%s]",
Joiner.on(", ").join(keysMissingFromEnvironment)));
WebHookToken token = WebHookToken.fromEnvironment();
Assertions.assertFalse(Strings.isNullOrEmpty(token.partB()));
Assertions.assertFalse(Strings.isNullOrEmpty(token.partT()));
Assertions.assertFalse(Strings.isNullOrEmpty(token.partX()));
Assertions.assertFalse(Strings.isNullOrEmpty(token.toString()));
}
开发者ID:palantir,项目名称:roboslack,代码行数:13,代码来源:WebHookTokenTests.java
示例10: findGreetingById
import org.junit.jupiter.api.Assumptions; //导入依赖的package包/类
@Test
@DisplayName("Retrieving a greeting by id should work")
void findGreetingById() {
// Given we have a greeting already saved
GreetingDto savedGreeting = service.createGreeting(createGreetingDto("We come in peace!"));
Assumptions.assumeTrue(savedGreeting != null);
// When we try to retrieve it
Optional<GreetingDto> greetingByIdOptional = service.findGreetingById(savedGreeting.getId());
// Then it should be there
Assertions.assertAll("Retrieving a greeting by id should work",
() -> assertTrue(greetingByIdOptional.isPresent(), "Could not find greeting by id"),
() -> assertEquals(savedGreeting.getId(), greetingByIdOptional.get().getId(), "Retrieved greeting has invalid id"),
() -> assertEquals(savedGreeting.getMessage(), greetingByIdOptional.get().getMessage(), "Retrieved greeting has different message from the saved one"));
}
开发者ID:bmariesan,项目名称:iStudent,代码行数:16,代码来源:GreetingServiceTest.java
示例11: deleteGreetingById
import org.junit.jupiter.api.Assumptions; //导入依赖的package包/类
@Test
@DisplayName("Removing a greeting by id should work")
void deleteGreetingById() {
// Given we have a greeting already saved
GreetingDto savedGreeting = service.createGreeting(createGreetingDto("We come in peace!"));
Assumptions.assumeTrue(savedGreeting != null);
// When we delete it
service.deleteGreetingById(savedGreeting.getId());
// Then it should be removed
Optional<GreetingDto> deletedGreetingOptional = service.findGreetingById(savedGreeting.getId());
Assertions.assertAll("Removing a greeting by id should work",
() -> assertFalse(deletedGreetingOptional.isPresent(), "Found greeting by id when it should be deleted"));
}
开发者ID:bmariesan,项目名称:iStudent,代码行数:15,代码来源:GreetingServiceTest.java
示例12: testReturnsExpectedDelaySupplier
import org.junit.jupiter.api.Assumptions; //导入依赖的package包/类
@ParameterizedTest
@DisplayName("it returns a delay supplier that returns the expected duration supplier")
@ArgumentsSource(ValidFixedArgumentsProvider.class)
void testReturnsExpectedDelaySupplier(Duration duration,
List<Duration> expectedSuppliedDurations) {
Assumptions.assumeTrue(null != expectedSuppliedDurations && !expectedSuppliedDurations.isEmpty(),
"Should have received a non-null and non-empty list of expected durations.");
Supplier<Duration> supplier = DelaySuppliers.fixed(duration).create();
Assertions.assertAll(expectedSuppliedDurations.stream().map(next -> () -> Assertions.assertEquals(next, supplier.get())));
}
开发者ID:redfin,项目名称:patience,代码行数:11,代码来源:DelaySuppliersTest.java
示例13: testReturnsExpectedSupplier
import org.junit.jupiter.api.Assumptions; //导入依赖的package包/类
@ParameterizedTest
@DisplayName("it returns the expected type of Supplier")
@ArgumentsSource(ExpectedDurations.class)
void testReturnsExpectedSupplier(int base,
Duration duration,
List<Duration> expectedDurations) {
Assumptions.assumeTrue(null != expectedDurations && !expectedDurations.isEmpty(),
"Should be given at least 1 expected result duration.");
Supplier<Duration> supplier = getInstance(base, duration).create();
Assertions.assertAll(expectedDurations.stream()
.map(d -> (Executable) () -> Assertions.assertEquals(d,
supplier.get(),
"Duration supplier should return the expected durations."))
.toArray(Executable[]::new));
}
开发者ID:redfin,项目名称:patience,代码行数:16,代码来源:ExponentialDelaySupplierFactoryTest.java
示例14: assumeIsPresent
import org.junit.jupiter.api.Assumptions; //导入依赖的package包/类
static void assumeIsPresent(String variable) {
Assumptions.assumeTrue(EnvironmentHelper.isPresent(variable));
}
开发者ID:CMSgov,项目名称:qpp-conversion-tool,代码行数:4,代码来源:VariableDependantTestHelper.java
注:本文中的org.junit.jupiter.api.Assumptions类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论