本文整理汇总了Java中org.assertj.core.api.Condition类的典型用法代码示例。如果您正苦于以下问题:Java Condition类的具体用法?Java Condition怎么用?Java Condition使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Condition类属于org.assertj.core.api包,在下文中一共展示了Condition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleCycle3DataSubmitted_shouldLogCycle3DataObtainedAndPrincipalIpAddressSeenByHubToEventSink
import org.assertj.core.api.Condition; //导入依赖的package包/类
@Test
public void handleCycle3DataSubmitted_shouldLogCycle3DataObtainedAndPrincipalIpAddressSeenByHubToEventSink() {
final SessionId sessionId = aSessionId().build();
final String principalIpAddressAsSeenByHub = "principal-ip-address-as-seen-by-hub";
final String requestId = "requestId";
final AwaitingCycle3DataStateController awaitingCycle3DataStateController = setUpAwaitingCycle3DataStateController(requestId, sessionId);
awaitingCycle3DataStateController.handleCycle3DataSubmitted(principalIpAddressAsSeenByHub);
ArgumentCaptor<EventSinkHubEvent> argumentCaptor = ArgumentCaptor.forClass(EventSinkHubEvent.class);
verify(eventSinkProxy, atLeastOnce()).logHubEvent(argumentCaptor.capture());
Condition<EventSinkHubEvent> combinedConditions = AllOf.allOf(
hasSessionId(sessionId),
hasDetail(EventDetailsKey.session_event_type, CYCLE3_DATA_OBTAINED),
hasDetail(EventDetailsKey.request_id, requestId),
hasDetail(EventDetailsKey.principal_ip_address_as_seen_by_hub, principalIpAddressAsSeenByHub));
assertThat(argumentCaptor.getAllValues()).haveAtLeast(1, combinedConditions);
}
示例2: cycle3dataInputCancelledFromFrontEnd_shouldLogCancellation
import org.assertj.core.api.Condition; //导入依赖的package包/类
@Test
public void cycle3dataInputCancelledFromFrontEnd_shouldLogCancellation() throws Exception {
final String requestId = "requestId";
final SessionId sessionId = aSessionId().build();
final AwaitingCycle3DataStateController awaitingCycle3DataStateController = setUpAwaitingCycle3DataStateController(requestId, sessionId);
awaitingCycle3DataStateController.handleCancellation();
ArgumentCaptor<EventSinkHubEvent> argumentCaptor = ArgumentCaptor.forClass(EventSinkHubEvent.class);
verify(eventSinkProxy, atLeastOnce()).logHubEvent(argumentCaptor.capture());
Condition<EventSinkHubEvent> combinedConditions = AllOf.allOf(
hasSessionId(sessionId),
hasDetail(EventDetailsKey.session_event_type, CYCLE3_CANCEL),
hasDetail(EventDetailsKey.request_id, requestId));
assertThat(argumentCaptor.getAllValues()).haveAtLeast(1, combinedConditions);
}
示例3: skippedSuiteTest
import org.assertj.core.api.Condition; //导入依赖的package包/类
@Feature("Failed tests")
@Story("Skipped")
@Test(description = "Skipped suite")
public void skippedSuiteTest() {
final Condition<StepResult> skipReason = new Condition<>(step ->
step.getStatusDetails().getTrace().startsWith("java.lang.RuntimeException: Skip all"),
"Suite should be skipped because of an exception in before suite");
runTestNgSuites("suites/skipped-suite.xml");
List<TestResult> testResults = results.getTestResults();
List<TestResultContainer> testContainers = results.getTestContainers();
assertThat(testResults).as("Unexpected quantity of testng case results has been written")
.hasSize(2)
.flatExtracting(TestResult::getStatus).contains(Status.SKIPPED, Status.SKIPPED);
assertThat(testContainers).as("Unexpected quantity of testng containers has been written").hasSize(4);
assertThat(findTestContainerByName("Test suite 8").getBefores())
.as("Before suite container should have a before method with one step")
.hasSize(1)
.flatExtracting(FixtureResult::getSteps)
.hasSize(1).first()
.hasFieldOrPropertyWithValue("status", Status.BROKEN)
.has(skipReason);
}
示例4: try
import org.assertj.core.api.Condition; //导入依赖的package包/类
@Test(timeOut = TEST_TIMEOUT_MILLIS)
public void when_all_of_the_task_are_completed_successfully_it_should_return_the_result_of_the_first_successful_one()
throws Exception {
try (AsyncRetryExecutor executor = create()) {
String first = "first";
String second = "second";
String actual = executor.invokeAny(
Arrays.asList(
successfulCallable(first),
successfulCallable(second)
),
3L,
TimeUnit.SECONDS
);
assertThat(actual)
.is(new Condition<>(
value -> first.equals(value) || second.equals(value),
"One of: '" + first + "', '" + second + "'."
));
}
}
示例5: xmlContent
import org.assertj.core.api.Condition; //导入依赖的package包/类
private Condition<File> xmlContent(URL expected) {
return new Condition<File>("XML Content") {
@Override
public boolean matches(File actual) {
Diff diff = DiffBuilder.compare(Input.from(expected))
.withTest(Input.from(actual)).checkForSimilar().ignoreWhitespace()
.build();
if (diff.hasDifferences()) {
try {
String content = new String(
FileCopyUtils.copyToByteArray(actual));
throw new AssertionError(diff.toString() + "\n" + content);
}
catch (IOException ex) {
throw new IllegalStateException(ex);
}
}
return true;
}
};
}
示例6: serverEnforcerFailsMissing
import org.assertj.core.api.Condition; //导入依赖的package包/类
@Test
public void serverEnforcerFailsMissing() {
// Plumbing
serverRule.getServiceRegistry().addService(ServerInterceptors.interceptForward(svc,
new AmbientContextServerInterceptor("ctx-"),
new AmbientContextEnforcerServerInterceptor("ctx-test")
));
GreeterGrpc.GreeterBlockingStub stub = GreeterGrpc
.newBlockingStub(serverRule.getChannel())
.withInterceptors(new AmbientContextClientInterceptor("ctx-"));
// Test
assertThatThrownBy(() -> stub.sayHello(HelloRequest.newBuilder().setName("World").build()))
.isInstanceOfAny(StatusRuntimeException.class)
.has(new Condition<Throwable>() {
@Override
public boolean matches(Throwable throwable) {
return Statuses.hasStatusCode(throwable, Status.Code.FAILED_PRECONDITION);
}
});
}
示例7: validateMigrations
import org.assertj.core.api.Condition; //导入依赖的package包/类
@SafeVarargs
private final void validateMigrations(Condition<Migration>... migrations) {
List<Migration> records = new ArrayList<>();
this.database.getCollection(SCHEMA_VERSION_COLLECTION)
.find()
.forEach((Consumer<Document>) d ->
records.add(
new Migration(
d.getString("version"),
d.getString("description"),
d.getString("author"),
Optional.ofNullable(d.getDate("started")).map(DateTime::new).orElse(null),
Optional.ofNullable(d.getDate("finished")).map(DateTime::new).orElse(null),
MigrationStatus.valueOf(d.getString("status")),
d.getString("failureMessage")
)
)
);
assertThat(records).hasSize(migrations.length);
for (Condition<Migration> checker : migrations)
assertThat(records).areAtLeastOne(checker);
}
示例8: testScaleByScroll
import org.assertj.core.api.Condition; //导入依赖的package包/类
@Test
public void testScaleByScroll() throws Exception {
pane.scrollModeProperty().set(ScrollMode.ZOOM);
pane.zoomTo(5, pane.targetPointAtViewportCentre());
FxRobot robot = new FxRobot();
assertThat(pane.getCurrentXScale()).isEqualTo(5d);
Thread.sleep(100);
robot.moveTo(pane);
robot.scroll(5, VerticalDirection.UP); // direction is platform dependent
Thread.sleep(100);
double expectedUp = 5 * Math.pow(1 + DEFAULT_SCROLL_FACTOR, 5);
double expectedDown = 5 * Math.pow(1 - DEFAULT_SCROLL_FACTOR, 5);
Condition<Double> eitherUpOrDown = new Condition<>(
v -> Math.abs(v - expectedUp) < 0.01 || Math.abs(v - expectedDown) < 0.01,
"either close to %s or %s",
expectedUp, expectedDown);
assertThat(pane.getCurrentXScale()).is(eitherUpOrDown);
Transform t = target.captureTransform();
assertThat(t.getMxx()).is(eitherUpOrDown);
assertThat(t.getMyy()).is(eitherUpOrDown);
}
示例9: atLeastTwoItemsShouldMeetCondition
import org.assertj.core.api.Condition; //导入依赖的package包/类
@Test
public void atLeastTwoItemsShouldMeetCondition() {
Observable<String> observable = ObservableBuilder.getJediStringEmittingObservable();
Condition<String> containsTheLetterA = new Condition<String>() {
@Override
public boolean matches(String value) {
return value.contains("a");
}
};
assertThatSubscriberTo(observable)
.completes()
.withoutErrors()
.areAtLeast(2, containsTheLetterA)
.haveAtLeast(2, containsTheLetterA);
}
示例10: correctLoading
import org.assertj.core.api.Condition; //导入依赖的package包/类
@Test
public void correctLoading() {
final RoboZonkyStartingEvent e = new RoboZonkyStartingEvent();
final EventListener<RoboZonkyStartingEvent> l = Mockito.mock(EventListener.class);
final ListenerService s1 = Mockito.mock(ListenerService.class);
final EventListenerSupplier<RoboZonkyStartingEvent> returned = () -> Optional.of(l);
Mockito.doReturn(returned).when(s1).findListener(ArgumentMatchers.eq(e.getClass()));
final ListenerService s2 = Mockito.mock(ListenerService.class);
Mockito.doReturn((EventListenerSupplier<RoboZonkyStartingEvent>) Optional::empty)
.when(s2).findListener(ArgumentMatchers.eq(e.getClass()));
final Iterable<ListenerService> s = () -> Arrays.asList(s1, s2).iterator();
final List<EventListenerSupplier<RoboZonkyStartingEvent>> r =
ListenerServiceLoader.load(RoboZonkyStartingEvent.class, s);
Assertions.assertThat(r).hasSize(2);
Assertions.assertThat(r)
.first()
.has(new Condition<>(result -> result.get().isPresent() && result.get().get() == l,
"Exists"));
Assertions.assertThat(r)
.last()
.has(new Condition<>(result -> !result.get().isPresent(), "Does not exist"));
}
示例11: progressUnix
import org.assertj.core.api.Condition; //导入依赖的package包/类
@Test
public void progressUnix() {
final ProgressListener progress = Mockito.mock(ProgressListener.class);
// execute SUT
RoboZonkyInstallerListener.setInstallData(data);
final InstallerListener listener = new RoboZonkyInstallerListener(RoboZonkyInstallerListener.OS.LINUX);
listener.afterPacks(Collections.emptyList(), progress);
// test
SoftAssertions.assertSoftly(softly -> {
softly.assertThat(new File(RoboZonkyInstallerListener.INSTALL_PATH, "logback.xml")).exists();
softly.assertThat(new File(RoboZonkyInstallerListener.INSTALL_PATH, "robozonky.properties")).exists();
softly.assertThat(new File(RoboZonkyInstallerListener.INSTALL_PATH, "robozonky.cli")).exists();
softly.assertThat(new File(RoboZonkyInstallerListener.INSTALL_PATH, "robozonky-exec.bat")).doesNotExist();
softly.assertThat(new File(RoboZonkyInstallerListener.INSTALL_PATH, "robozonky-exec.sh"))
.exists()
.has(new Condition<>(File::canExecute, "Is executable"));
softly.assertThat(new File(RoboZonkyInstallerListener.INSTALL_PATH, "robozonky-systemd.service")).exists();
softly.assertThat(new File(RoboZonkyInstallerListener.INSTALL_PATH, "robozonky-upstart.conf")).exists();
softly.assertThat(RoboZonkyInstallerListener.CLI_CONFIG_FILE).exists();
});
Mockito.verify(progress, times(1)).startAction(ArgumentMatchers.anyString(), ArgumentMatchers.anyInt());
Mockito.verify(progress, times(7))
.nextStep(ArgumentMatchers.anyString(), ArgumentMatchers.anyInt(), ArgumentMatchers.eq(1));
Mockito.verify(progress, times(1)).stopAction();
}
示例12: testAppProvisionsRunningPods
import org.assertj.core.api.Condition; //导入依赖的package包/类
@Test
public void testAppProvisionsRunningPods() throws Exception {
installInitialBuildConfigs();
assertThat(client).pods()
.runningStatus()
.filterNamespace(session.getNamespace())
.haveAtLeast(1, new Condition<Pod>() {
@Override
public boolean matches(Pod podSchema) {
return true;
}
});
System.out.println("Now asserting that we have Jenkins Jobs!");
}
示例13: areExactlyConditionCheckShouldFail
import org.assertj.core.api.Condition; //导入依赖的package包/类
@Test(expected = AssertionError.class)
public void areExactlyConditionCheckShouldFail() {
Observable<String> observable = ObservableBuilder.getJediStringEmittingObservable();
Condition<String> containsTheLetterA = new Condition<String>() {
@Override
public boolean matches(String value) {
return value.contains("a");
}
};
assertThatSubscriberTo(observable)
.completes()
.withoutErrors()
.areExactly(3, containsTheLetterA);
}
示例14: AreAtLeastConditionCheckShouldFail
import org.assertj.core.api.Condition; //导入依赖的package包/类
@Test(expected = AssertionError.class)
public void AreAtLeastConditionCheckShouldFail() {
Observable<String> observable = ObservableBuilder.getJediStringEmittingObservable();
Condition<String> containsTheLetterA = new Condition<String>() {
@Override
public boolean matches(String value) {
return value.contains("a");
}
};
assertThatSubscriberTo(observable)
.completes()
.withoutErrors()
.areAtLeast(3, containsTheLetterA);
}
示例15: atLeastTwoItemsShouldHaveCondition
import org.assertj.core.api.Condition; //导入依赖的package包/类
@Test
public void atLeastTwoItemsShouldHaveCondition() {
Observable<String> observable = ObservableBuilder.getJediStringEmittingObservable();
Condition<String> containsTheLetterA = new Condition<String>() {
@Override
public boolean matches(String value) {
return value.contains("a");
}
};
Rx2Assertions.assertThatSubscriberTo(observable)
.isComplete()
.withoutErrors()
.haveAtLeast(2, containsTheLetterA);
}