Java 类org.assertj.core.api.Condition 实例源码

项目:verify-hub    文件:AwaitingCycle3DataStateControllerTest.java   
@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);
}
项目:verify-hub    文件:AwaitingCycle3DataStateControllerTest.java   
@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);

}
项目:allure-java    文件:AllureTestNgTest.java   
@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);
}
项目:yet-another-try    文件:AsyncRetryExecutorTestKit.java   
@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 + "'."
        ));
  }
}
项目:artifactory-resource    文件:MavenMetadataGeneratorTests.java   
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;
        }

    };
}
项目:grpc-java-contrib    文件:AmbientContextEnforcerTest.java   
@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);
                }
            });
}
项目:mongo-trek    文件:MongoTrekIntegrationTest.java   
@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);
}
项目:GestureFX    文件:GesturePaneTest.java   
@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);
}
项目:RxAssertJ    文件:RxAssertionsTests.java   
@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);
}
项目:robozonky    文件:ListenerServiceLoaderTest.java   
@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"));
}
项目:robozonky    文件:RoboZonkyInstallerListenerTest.java   
@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();
}
项目:openshift-sync-plugin    文件:JenkinsOpenShiftSysTest.java   
@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!");
}
项目:RxAssertJ    文件:RxAssertionsTests.java   
@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);
}
项目:RxAssertJ    文件:RxAssertionsTests.java   
@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);
}
项目:RxAssertJ    文件:Rx2AssertionsTests.java   
@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);
}
项目:RxAssertJ    文件:Rx2AssertionsTests.java   
@Test
public void atMostTwoItemsShouldHaveCondition() {
    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()
            .haveAtMost(2, containsTheLetterA);
}
项目:RxAssertJ    文件:Rx2AssertionsTests.java   
@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");
        }
    };

    Rx2Assertions.assertThatSubscriberTo(observable)
            .completes()
            .withoutErrors()
            .areExactly(3, containsTheLetterA);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:SpringApplicationTests.java   
private Condition<ConfigurableEnvironment> matchingPropertySource(
        final Class<?> propertySourceClass, final String name) {
    return new Condition<ConfigurableEnvironment>("has property source") {

        @Override
        public boolean matches(ConfigurableEnvironment value) {
            for (PropertySource<?> source : value.getPropertySources()) {
                if (propertySourceClass.isInstance(source)
                        && (name == null || name.equals(source.getName()))) {
                    return true;
                }
            }
            return false;
        }

    };
}
项目:RxAssertJ    文件:RxAssertionsTests.java   
@Test(expected = AssertionError.class)
public void AreAtMostConditionCheckShouldFail() {
    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()
            .areAtMost(1, containsTheLetterA);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ResourceMatcherTests.java   
@Test
public void jarFileAlwaysMatches() throws Exception {
    ResourceMatcher resourceMatcher = new ResourceMatcher(Arrays.asList("*"),
            Arrays.asList("**/*.jar"));
    List<MatchedResource> found = resourceMatcher
            .find(Arrays.asList(new File("src/test/resources/templates"),
                    new File("src/test/resources/foo.jar")));
    assertThat(found).areAtLeastOne(new Condition<MatchedResource>() {

        @Override
        public boolean matches(MatchedResource value) {
            return value.getFile().getName().equals("foo.jar") && value.isRoot();
        }

    });
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:WebMvcAutoConfigurationTests.java   
private void testLogResolvedExceptionCustomization(final boolean expected) {
    HandlerExceptionResolver exceptionResolver = this.context
            .getBean(HandlerExceptionResolver.class);
    assertThat(exceptionResolver)
            .isInstanceOf(HandlerExceptionResolverComposite.class);
    List<HandlerExceptionResolver> delegates = ((HandlerExceptionResolverComposite) exceptionResolver)
            .getExceptionResolvers();
    for (HandlerExceptionResolver delegate : delegates) {
        if (delegate instanceof AbstractHandlerMethodAdapter) {
            assertThat(
                    new DirectFieldAccessor(delegate).getPropertyValue("warnLogger"))
                            .is(new Condition<Object>() {
                                @Override
                                public boolean matches(Object value) {
                                    return (expected ? value != null : value == null);
                                }
                            });
        }
    }
}
项目:springlets    文件:ColumnsParametersParserTest.java   
@Test
public void checkMaxColumnsAreIgnored() {
  // Prepare
  parser = createParser(new String[] {"columns[0][data]", "columns[100][data]"},
      new String[] {"data0", "data50"});

  // Exercise
  DatatablesColumns columns = parser.getColumns();

  // Validate
  assertThat(columns.getColumns()).areExactly(1, new Condition<Column>() {

    @Override
    public boolean matches(Column value) {
      switch (value.getIndex()) {
        case 0:
          return true;
        default:
          return false;
      }
    }
  });
}
项目:RxAssertJ    文件:Rx2AssertionsTests.java   
@Test
public void allItemsShouldNotMeetCondition() {
    Observable<String> observable = ObservableBuilder.getJediStringEmittingObservable();

    Condition<String> isNull = new Condition<String>() {
        @Override
        public boolean matches(String value) {
            return value == null;
        }
    };

    Rx2Assertions.assertThatSubscriberTo(observable)
            .completes()
            .withoutErrors()
            .noItemMatches(isNull);
}
项目:RxAssertJ    文件:RxAssertionsTests.java   
@Test(expected = AssertionError.class)
public void haveAtLeastConditionCheckShouldFail() {
    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()
            .haveAtLeast(3, containsTheLetterA);
}
项目:RxAssertJ    文件:Rx2AssertionsTests.java   
@Test
public void exactlyTwoItemsShouldHaveCondition() {
    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()
            .haveExactly(2, containsTheLetterA);
}
项目:RxAssertJ    文件:Rx2AssertionsTests.java   
@Test(expected = AssertionError.class)
public void atLeastOneConditionCheckShouldFail() {
    Observable<String> observable = ObservableBuilder.getJediStringEmittingObservable();

    Condition<String> isDarthVader = new Condition<String>() {
        @Override
        public boolean matches(String value) {
            return value.equals("Darth Vader");
        }
    };

    Rx2Assertions.assertThatSubscriberTo(observable)
            .completes()
            .withoutErrors()
            .atLeastOneItemMatches(isDarthVader);
}
项目:RxAssertJ    文件:Rx2AssertionsTests.java   
@Test
public void atLeastOneItemShouldMeetCondition() {
    Observable<String> observable = ObservableBuilder.getJediStringEmittingObservable();

    Condition<String> isLuke = new Condition<String>() {
        @Override
        public boolean matches(String value) {
            return value.equals("Luke");
        }
    };

    Rx2Assertions.assertThatSubscriberTo(observable)
            .isComplete()
            .withoutErrors()
            .atLeastOneItemMatches(isLuke);

}
项目:RxAssertJ    文件:RxAssertionsTests.java   
@Test
public void atMostTwoItemsShouldMeetCondition() {
    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()
            .areAtMost(2, containsTheLetterA)
            .haveAtMost(2, containsTheLetterA);
}
项目:mongo-trek    文件:MongoTrekIntegrationTest.java   
@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);
}
项目:RxAssertJ    文件:RxAssertionsTests.java   
@Test
public void allItemsShouldNotMeetCondition() {
    Observable<String> observable = ObservableBuilder.getJediStringEmittingObservable();

    Condition<String> isNull = new Condition<String>() {
        @Override
        public boolean matches(String value) {
            return value == null;
        }
    };

    assertThatSubscriberTo(observable)
            .completes()
            .withoutErrors()
            .noItemMatches(isNull);
}
项目:spring-boot-concourse    文件:ResourceMatcherTests.java   
@Test
public void jarFileAlwaysMatches() throws Exception {
    ResourceMatcher resourceMatcher = new ResourceMatcher(Arrays.asList("*"),
            Arrays.asList("**/*.jar"));
    List<MatchedResource> found = resourceMatcher
            .find(Arrays.asList(new File("src/test/resources/templates"),
                    new File("src/test/resources/foo.jar")));
    assertThat(found).areAtLeastOne(new Condition<MatchedResource>() {

        @Override
        public boolean matches(MatchedResource value) {
            return value.getFile().getName().equals("foo.jar") && value.isRoot();
        }

    });
}
项目:RxAssertJ    文件:RxAssertionsTests.java   
@Test(expected = AssertionError.class)
public void haveExactlyConditionCheckShouldFail() {
    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()
            .haveExactly(3, containsTheLetterA);
}
项目:spring-boot-concourse    文件:SpringApplicationTests.java   
private Condition<ConfigurableEnvironment> matchingPropertySource(
        final Class<?> propertySourceClass, final String name) {
    return new Condition<ConfigurableEnvironment>("has property source") {

        @Override
        public boolean matches(ConfigurableEnvironment value) {
            for (PropertySource<?> source : value.getPropertySources()) {
                if (propertySourceClass.isInstance(source)
                        && (name == null || name.equals(source.getName()))) {
                    return true;
                }
            }
            return false;
        }

    };
}
项目:azure-documentdb-rxjava    文件:ResourceResponseValidator.java   
public Builder<T> withProperty(String propertyName, Condition<Object> validatingCondition) {
    validators.add(new ResourceResponseValidator<T>() {

        @Override
        public void validate(ResourceResponse<T> resourceResponse) {
            assertThat(resourceResponse.getResource()).isNotNull();
            assertThat(resourceResponse.getResource().get(propertyName)).is(validatingCondition);

        }
    });
    return this;
}
项目:azure-documentdb-rxjava    文件:ResourceResponseValidator.java   
public Builder<T> validatePropertyCondition(String key, Condition<Object> condition) {
    validators.add(new ResourceResponseValidator<T>() {

        @Override
        public void validate(ResourceResponse<T> resourceResponse) {
            assertThat(resourceResponse.getResource()).isNotNull();
            assertThat(resourceResponse.getResource().get(key)).is(condition);

        }
    });
    return this;
}
项目:allure-java    文件:AllureTestNgTest.java   
@Feature("Basic framework support")
@Test(description = "Nested steps")
public void nestedSteps() {
    String beforeMethod = "io.qameta.allure.testng.samples.NestedSteps.beforeMethod";
    String nestedStep = "nestedStep";
    String stepInBefore = "stepTwo";
    String stepInTest = "stepThree";
    final Condition<StepResult> substep = new Condition<>(step ->
            step.getSteps().get(0).getName().equals(nestedStep),
            "Given step should have a substep with name " + nestedStep);

    runTestNgSuites("suites/nested-steps.xml");
    List<TestResult> testResults = results.getTestResults();
    List<TestResultContainer> containers = results.getTestContainers();
    assertThat(testResults).as("Unexpected quantity of testng case results has been written")
            .hasSize(1);

    assertThat(containers)
            .filteredOn("name", beforeMethod)
            .flatExtracting(TestResultContainer::getBefores)
            .flatExtracting(FixtureResult::getSteps)
            .as("Before method should have a step")
            .hasSize(1).first()
            .hasFieldOrPropertyWithValue("name", stepInBefore)
            .has(substep);

    assertThat(testResults)
            .flatExtracting(TestResult::getSteps)
            .hasSize(1).first()
            .hasFieldOrPropertyWithValue("name", stepInTest)
            .has(substep);
}
项目:allure-java    文件:AllureTestNgTest.java   
@Step("Check containers per method")
private static void assertContainersPerMethod(String name, List<TestResultContainer> containersList,
                                              List<String> uids) {
    final Condition<List<? extends TestResultContainer>> singlyMapped = new Condition<>(containers ->
            containers.stream().allMatch(c -> c.getChildren().size() == 1),
            format("All containers for per-method fixture %s should be linked to only one testng result", name));

    assertThat(containersList)
            .filteredOn("name", name)
            .is(singlyMapped)
            .flatExtracting(TestResultContainer::getChildren)
            .as("Unexpected children for per-method fixtures " + name)
            .containsOnlyElementsOf(uids);
}
项目:micrometer    文件:PrometheusMeterRegistryTest.java   
private Condition<Enumeration<Collector.MetricFamilySamples>> withNameAndTagKey(String name, String tagKey) {
    return new Condition<>(m -> {
        while (m.hasMoreElements()) {
            Collector.MetricFamilySamples samples = m.nextElement();
            if (samples.samples.stream().anyMatch(s -> s.name.equals(name) && s.labelNames.contains(tagKey))) {
                return true;
            }
        }
        return false;
    }, "a meter with name `%s` and tag `%s`", name, tagKey);
}
项目:android-perftracking    文件:TestCondition.java   
public static Condition<Map<String, String>> keyValue(final String key, final String value) {
  return new Condition<Map<String, String>>() {
    @Override
    public boolean matches(Map<String, String> map) {
      return map.keySet().contains(key) &&
          (value == null && map.get(key) == null ||
              value != null && value.equals(map.get(key)));
    }
  };
}
项目:android-perftracking    文件:SenderSpec.java   
private Condition<Measurement> cleared() {
  return new Condition<Measurement>() {
    @Override
    public boolean matches(Measurement value) {
      return value.trackingId == 0 && value.type == 0 && value.a == null
          && value.b == null && value.startTime == 0 && value.endTime == 0;
    }
  };
}