org.assertj.core.api.IterableAssert.allMatch()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(15.2k)|赞(0)|评价(0)|浏览(82)

本文整理了Java中org.assertj.core.api.IterableAssert.allMatch()方法的一些代码示例,展示了IterableAssert.allMatch()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IterableAssert.allMatch()方法的具体详情如下:
包路径:org.assertj.core.api.IterableAssert
类名称:IterableAssert
方法名:allMatch

IterableAssert.allMatch介绍

暂无

代码示例

代码示例来源:origin: prestodb/presto

@Test
public void testShowTablesLike()
{
  assertThat(computeActual("SHOW TABLES LIKE 'or%'").getOnlyColumnAsSet())
      .contains("orders")
      .allMatch(tableName -> ((String) tableName).startsWith("or"));
}

代码示例来源:origin: prestodb/presto

@Test
public void testShowSchemasLikeWithEscape()
{
  assertQueryFails("SHOW SCHEMAS IN foo LIKE '%$_%' ESCAPE", "line 1:39: mismatched input '<EOF>'. Expecting: <string>");
  assertQueryFails("SHOW SCHEMAS LIKE 't$_%' ESCAPE ''", "Escape string must be a single character");
  assertQueryFails("SHOW SCHEMAS LIKE 't$_%' ESCAPE '$$'", "Escape string must be a single character");
  Set<Object> allSchemas = computeActual("SHOW SCHEMAS").getOnlyColumnAsSet();
  assertEquals(allSchemas, computeActual("SHOW SCHEMAS LIKE '%_%'").getOnlyColumnAsSet());
  Set<Object> result = computeActual("SHOW SCHEMAS LIKE '%$_%' ESCAPE '$'").getOnlyColumnAsSet();
  assertNotEquals(allSchemas, result);
  assertThat(result).contains("information_schema").allMatch(schemaName -> ((String) schemaName).contains("_"));
}

代码示例来源:origin: prestodb/presto

@Test
public void testShowTablesLikeWithEscape()
{
  assertQueryFails("SHOW TABLES IN a LIKE '%$_%' ESCAPE", "line 1:36: mismatched input '<EOF>'. Expecting: <string>");
  assertQueryFails("SHOW TABLES LIKE 't$_%' ESCAPE ''", "Escape string must be a single character");
  assertQueryFails("SHOW TABLES LIKE 't$_%' ESCAPE '$$'", "Escape string must be a single character");
  Set<Object> allTables = computeActual("SHOW TABLES FROM information_schema").getOnlyColumnAsSet();
  assertEquals(allTables, computeActual("SHOW TABLES FROM information_schema LIKE '%_%'").getOnlyColumnAsSet());
  Set<Object> result = computeActual("SHOW TABLES FROM information_schema LIKE '%$_%' ESCAPE '$'").getOnlyColumnAsSet();
  assertNotEquals(allTables, result);
  assertThat(result).contains("table_privileges").allMatch(schemaName -> ((String) schemaName).contains("_"));
}

代码示例来源:origin: reactor/reactor-core

@Test
public void subscribeOnJust() throws Exception {
  scheduler.tasksRemaining.set(0); //1 subscribe
  Flux<Long> flux = Flux.just(1L)
             .subscribeOn(scheduler)
             .doOnError(e -> onError(e));
  CountDownLatch latch = new CountDownLatch(1);
  flux.subscribe(new TestSub(latch));
  latch.await(500, TimeUnit.MILLISECONDS);
  assertThat(onNextDropped).isEmpty();
  assertThat(onErrorDropped).isEmpty();
  assertThat(onSchedulerHandleError).isEmpty();
  assertThat(onOperatorError)
      .hasSize(1)
      .last().isInstanceOf(RejectedExecutionException.class);
  assertThat(onOperatorErrorData)
      .allMatch(l -> l >= 1,
          "Data dropped from onOperatorError should always be >= 1");
  if (!onOperatorErrorData.isEmpty()) {
    System.out.println(testName.getMethodName() + " legitimately has data dropped from onOperatorError: " + onOperatorErrorData);
  }
}

代码示例来源:origin: reactor/reactor-core

@Test
public void monoApiWithinFlatMap() {
  Flux<Integer> test = Flux.just(0, 1, 2, 3)
      .flatMap(i -> Mono.just(i).map(v -> 30 / v))
      .onErrorContinue(OnNextFailureStrategyTest::drop);
  StepVerifier.create(test)
      .expectNext(30, 15, 10)
      .expectComplete()
      .verifyThenAssertThat()
      .hasDroppedExactly(0)
      .hasDroppedErrorsSatisfying(
          errors -> assertThat(errors)
              .hasSize(1)
              .allMatch(e -> e instanceof ArithmeticException));
}

代码示例来源:origin: reactor/reactor-core

private void verifyRejectedExecutionConsistency(Publisher<Long> flux, int elementCount) {
  scheduler.tasksRemaining.set(elementCount + 1);
  StepVerifier verifier = StepVerifier.create(flux, 0)
        .expectSubscription()
        .thenRequest(elementCount)
        .expectNext(0L) //0..elementCount-1
        .expectNextCount(elementCount - 2)
        .expectNext(elementCount - 1L)
        .thenRequest(255)
        .thenConsumeWhile(l -> true)
        .expectError(RejectedExecutionException.class);
  verifier.verify(Duration.ofSeconds(5));
  assertThat(onNexts.size())
      .isGreaterThanOrEqualTo(elementCount)
      .isLessThan(255);
  assertThat(onErrors).hasSize(1);
  assertThat(onNextDropped).isEmpty();
  assertThat(onErrorDropped).isEmpty();
  assertThat(onSchedulerHandleError).isEmpty();
  assertThat(onOperatorError)
      .hasSize(1)
      .last().isInstanceOf(RejectedExecutionException.class);
  assertThat(onOperatorErrorData)
      .allMatch(l -> l >= elementCount,
          "Data dropped from onOperatorError should always be >= elementCount");
  if (!onOperatorErrorData.isEmpty()) {
    System.out.println(testName.getMethodName() + " legitimately has data dropped from onOperatorError: " + onOperatorErrorData);
  }
}

代码示例来源:origin: reactor/reactor-core

@Test
public void fluxApiWithinFlatMap() {
  Flux<Integer> test = Flux.just(1, 2, 3)
               .flatMap(i -> Flux.range(0, i + 1)
                        .map(v -> 30 / v))
               .onErrorContinue(OnNextFailureStrategyTest::drop);
  StepVerifier.create(test)
        .expectNext(30, 30, 15, 30, 15, 10)
        .expectComplete()
        .verifyThenAssertThat()
        .hasDroppedExactly(0, 0, 0)
        .hasDroppedErrorsSatisfying(
            errors -> assertThat(errors)
                .hasSize(3)
                .allMatch(e -> e instanceof ArithmeticException));
}

代码示例来源:origin: com.facebook.presto/presto-tests

@Test
public void testShowTablesLike()
{
  assertThat(computeActual("SHOW TABLES LIKE 'or%'").getOnlyColumnAsSet())
      .contains("orders")
      .allMatch(tableName -> ((String) tableName).startsWith("or"));
}

代码示例来源:origin: prestosql/presto

@Test
public void testShowTablesLike()
{
  assertThat(computeActual("SHOW TABLES LIKE 'or%'").getOnlyColumnAsSet())
      .contains("orders")
      .allMatch(tableName -> ((String) tableName).startsWith("or"));
}

代码示例来源:origin: prestosql/presto

@Test
public void testShowTablesLikeWithEscape()
{
  assertQueryFails("SHOW TABLES IN a LIKE '%$_%' ESCAPE", "line 1:36: mismatched input '<EOF>'. Expecting: <string>");
  assertQueryFails("SHOW TABLES LIKE 't$_%' ESCAPE ''", "Escape string must be a single character");
  assertQueryFails("SHOW TABLES LIKE 't$_%' ESCAPE '$$'", "Escape string must be a single character");
  Set<Object> allTables = computeActual("SHOW TABLES FROM information_schema").getOnlyColumnAsSet();
  assertEquals(allTables, computeActual("SHOW TABLES FROM information_schema LIKE '%_%'").getOnlyColumnAsSet());
  Set<Object> result = computeActual("SHOW TABLES FROM information_schema LIKE '%$_%' ESCAPE '$'").getOnlyColumnAsSet();
  assertNotEquals(allTables, result);
  assertThat(result).contains("table_privileges").allMatch(schemaName -> ((String) schemaName).contains("_"));
}

代码示例来源:origin: com.facebook.presto/presto-tests

@Test
public void testShowTablesLikeWithEscape()
{
  assertQueryFails("SHOW TABLES IN a LIKE '%$_%' ESCAPE", "line 1:36: mismatched input '<EOF>'. Expecting: <string>");
  assertQueryFails("SHOW TABLES LIKE 't$_%' ESCAPE ''", "Escape string must be a single character");
  assertQueryFails("SHOW TABLES LIKE 't$_%' ESCAPE '$$'", "Escape string must be a single character");
  Set<Object> allTables = computeActual("SHOW TABLES FROM information_schema").getOnlyColumnAsSet();
  assertEquals(allTables, computeActual("SHOW TABLES FROM information_schema LIKE '%_%'").getOnlyColumnAsSet());
  Set<Object> result = computeActual("SHOW TABLES FROM information_schema LIKE '%$_%' ESCAPE '$'").getOnlyColumnAsSet();
  assertNotEquals(allTables, result);
  assertThat(result).contains("table_privileges").allMatch(schemaName -> ((String) schemaName).contains("_"));
}

代码示例来源:origin: prestosql/presto

@Test
public void testShowSchemasLikeWithEscape()
{
  assertQueryFails("SHOW SCHEMAS IN foo LIKE '%$_%' ESCAPE", "line 1:39: mismatched input '<EOF>'. Expecting: <string>");
  assertQueryFails("SHOW SCHEMAS LIKE 't$_%' ESCAPE ''", "Escape string must be a single character");
  assertQueryFails("SHOW SCHEMAS LIKE 't$_%' ESCAPE '$$'", "Escape string must be a single character");
  Set<Object> allSchemas = computeActual("SHOW SCHEMAS").getOnlyColumnAsSet();
  assertEquals(allSchemas, computeActual("SHOW SCHEMAS LIKE '%_%'").getOnlyColumnAsSet());
  Set<Object> result = computeActual("SHOW SCHEMAS LIKE '%$_%' ESCAPE '$'").getOnlyColumnAsSet();
  assertNotEquals(allSchemas, result);
  assertThat(result).contains("information_schema").allMatch(schemaName -> ((String) schemaName).contains("_"));
}

代码示例来源:origin: com.facebook.presto/presto-tests

@Test
public void testShowSchemasLikeWithEscape()
{
  assertQueryFails("SHOW SCHEMAS IN foo LIKE '%$_%' ESCAPE", "line 1:39: mismatched input '<EOF>'. Expecting: <string>");
  assertQueryFails("SHOW SCHEMAS LIKE 't$_%' ESCAPE ''", "Escape string must be a single character");
  assertQueryFails("SHOW SCHEMAS LIKE 't$_%' ESCAPE '$$'", "Escape string must be a single character");
  Set<Object> allSchemas = computeActual("SHOW SCHEMAS").getOnlyColumnAsSet();
  assertEquals(allSchemas, computeActual("SHOW SCHEMAS LIKE '%_%'").getOnlyColumnAsSet());
  Set<Object> result = computeActual("SHOW SCHEMAS LIKE '%$_%' ESCAPE '$'").getOnlyColumnAsSet();
  assertNotEquals(allSchemas, result);
  assertThat(result).contains("information_schema").allMatch(schemaName -> ((String) schemaName).contains("_"));
}

代码示例来源:origin: jlink/jqwik

@Property
void willHandDownConfigurations(@ForAll("stringLists") @Size(10) Collection<?> stringList) {
  assertThat(stringList).hasSize(10);
  assertThat(stringList).allMatch(element -> element instanceof String);
}

代码示例来源:origin: jlink/jqwik

@Property
void willHandDownConfigurations(@ForAll("stringLists") @Size(10) Collection<?> stringList) {
  assertThat(stringList).hasSize(10);
  assertThat(stringList).allMatch(element -> element instanceof String);
}

代码示例来源:origin: PegaSysEng/pantheon

@Test
public void pongSentUponPing() {
 // Start an agent with no bootstrap peers.
 final MockPeerDiscoveryAgent agent = helper.startDiscoveryAgent(Collections.emptyList());
 // Start a test peer and send a PING packet to the agent under test.
 final MockPeerDiscoveryAgent otherAgent = helper.startDiscoveryAgent();
 final Packet ping = helper.createPingPacket(otherAgent, agent);
 helper.sendMessageBetweenAgents(otherAgent, agent, ping);
 final List<IncomingPacket> otherAgentIncomingPongs =
   otherAgent
     .getIncomingPackets()
     .stream()
     .filter(p -> p.packet.getType().equals(PacketType.PONG))
     .collect(Collectors.toList());
 assertThat(otherAgentIncomingPongs.size()).isEqualTo(1);
 final PongPacketData pong =
   otherAgentIncomingPongs.get(0).packet.getPacketData(PongPacketData.class).get();
 assertThat(pong.getTo()).isEqualTo(otherAgent.getAdvertisedPeer().getEndpoint());
 // The agent considers the test peer BONDED.
 assertThat(agent.getPeers()).hasSize(1);
 assertThat(agent.getPeers()).allMatch(p -> p.getStatus() == PeerDiscoveryStatus.BONDED);
}

代码示例来源:origin: PegaSysEng/pantheon

@Test
 public void bootstrappingPeersListUpdated() {
  // Start an agent.
  final PeerDiscoveryAgent bootstrapAgent = helper.startDiscoveryAgent(emptyList());

  // Start other five agents, pointing to the one above as a bootstrap peer.
  final List<MockPeerDiscoveryAgent> otherAgents =
    helper.startDiscoveryAgents(5, singletonList(bootstrapAgent.getAdvertisedPeer()));

  final BytesValue[] otherPeersIds =
    otherAgents.stream().map(PeerDiscoveryAgent::getId).toArray(BytesValue[]::new);

  assertThat(bootstrapAgent.getPeers())
    .extracting(Peer::getId)
    .containsExactlyInAnyOrder(otherPeersIds);

  assertThat(bootstrapAgent.getPeers())
    .allMatch(p -> p.getStatus() == PeerDiscoveryStatus.BONDED);

  // This agent will bootstrap off the bootstrap peer, will add all nodes returned by the latter,
  // and will
  // bond with them, ultimately adding all 7 nodes in the network to its table.
  final PeerDiscoveryAgent newAgent =
    helper.startDiscoveryAgent(bootstrapAgent.getAdvertisedPeer());
  assertThat(newAgent.getPeers()).hasSize(6);
 }
}

代码示例来源:origin: h-omer/neo4j-versioner-core

@Test
  public void shouldCreateAnRNodeConnectedToTheEntity() throws Throwable {

    try (Driver driver = GraphDatabase.driver(neo4j.boltURI(), Config.build().withEncryption().toConfig()); Session session = driver.session()) {

      StatementResult result = session.run("CALL graph.versioner.init('Entity')");
      StatementResult rPath = session.run("MATCH rPath = (:R)-[:FOR]->(:Entity) RETURN rPath");

      Assertions.assertThat(result.single().get("node").asNode().id()).isEqualTo(0L);
      Assertions.assertThat(rPath)
          .hasSize(1)
          .allMatch(path -> path.get("rPath").asPath().length() == 1);
    }
  }
}

代码示例来源:origin: h-omer/neo4j-versioner-core

@Test
  public void shouldRollbackNthToZeroWorkCorrectly() {
    // This is in a try-block, to make sure we close the driver after the test
    try (Driver driver = GraphDatabase
        .driver(neo4j.boltURI(), Config.build().withEncryption().toConfig()); Session session = driver.session()) {
      // Given
      session.run("CREATE (:Entity {key:'immutableValue'})-[:CURRENT {date:localdatetime('1988-10-27T00:00:00')}]->(:State:Error {key:'initialValue'})"
          + "-[:PREVIOUS]->(:State {key:'value'})-[:PREVIOUS {date: localdatetime('1988-10-26T00:00:00')}]->(:State:Test {key:'testValue'})");
      session.run("MATCH (e:Entity)-[:CURRENT]->(s:Error) CREATE (e)-[:HAS_STATE {startDate:localdatetime('1988-10-27T00:00:00')}]->(s)");
      session.run("MATCH (e:Entity), (s:State {key:'value'}) CREATE (e)-[:HAS_STATE {startDate:localdatetime('1988-10-26T00:00:00'), endDate:localdatetime('1988-10-27T00:00:00')}]->(s)");
      session.run("MATCH (e:Entity), (s:Test) CREATE (e)-[:HAS_STATE {startDate:localdatetime('1988-10-25T00:00:00'), endDate:localdatetime('1988-10-26T00:00:00')}]->(s)");

      // When
      StatementResult result = session.run("MATCH (e:Entity) WITH e CALL graph.versioner.rollback.nth(e, 0) YIELD node RETURN node");

      // Then
      Assertions.assertThat(result).isEmpty();

      result = session.run("MATCH (e:Entity)-[:CURRENT]->(s:State) RETURN s");

      Assertions.assertThat(result)
          .hasSize(1)
          .allMatch(node -> node.get("s").asNode().hasLabel("Error"));
    }
  }
}

代码示例来源:origin: h-omer/neo4j-versioner-core

@Test
public void shouldCreateTheRelationshipInANewCurrentStatePreservingTheOldOne() {
  try (Driver driver = GraphDatabase
      .driver(neo4j.boltURI(), Config.build().withEncryption().toConfig()); Session session = driver.session()) {
    // Given
    Node entityA = initEntity(session);
    Node entityB = initEntity(session);
    String testType = "testType";
    Long entityACurrentId = session.run(String.format("MATCH (e:Entity)-[:CURRENT]->(s:State) WHERE id(e) = %d RETURN s", entityA.id())).single().get("s").asNode().id();
    // When
    String query = "MATCH (a:Entity), (b:Entity) WHERE id(a) = %d AND id(b) = %d WITH a, b CALL graph.versioner.relationship.create(a, b, '%s') YIELD relationship RETURN relationship";
    Relationship relationship = session.run(String.format(query, entityA.id(), entityB.id(), testType)).single().get("relationship").asRelationship();
    // Then
    String querySourceStates = "MATCH (:R)<-[r:%s]-(s1:State)-[:PREVIOUS]->(s2:State) WHERE id(r) = %d RETURN s1, s2";
    StatementResult result = session.run(String.format(querySourceStates, testType, relationship.id()));
    assertThat(result)
        .hasSize(1)
        .allMatch(r -> r.get("s1").asNode().id() != r.get("s2").asNode().id() && r.get("s2").asNode().id() == entityACurrentId);
  }
}

相关文章

微信公众号

最新文章

更多