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

x33g5p2x  于2022-01-23 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(122)

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

ListAssert.anySatisfy介绍

暂无

代码示例

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

@Test(groups = {LDAP, LDAP_CLI, PROFILE_SPECIFIC_TESTS}, timeOut = TIMEOUT)
public void shouldFailQueryForLdapUserInChildGroup()
    throws IOException
{
  ldapUserName = CHILD_GROUP_USER.getAttributes().get("cn");
  launchPrestoCliWithServerArgument("--catalog", "hive", "--schema", "default", "--execute", "select * from nation;");
  assertThat(trimLines(presto.readRemainingErrorLines())).anySatisfy(line ->
      assertThat(line).contains(format("User [%s] not a member of the authorized group", ldapUserName)));
}

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

@Test(groups = {LDAP, LDAP_CLI, PROFILE_SPECIFIC_TESTS}, timeOut = TIMEOUT)
public void shouldFailQueryForWrongLdapPassword()
    throws IOException
{
  ldapUserPassword = "wrong_password";
  launchPrestoCliWithServerArgument("--execute", "select * from hive.default.nation;");
  assertThat(trimLines(presto.readRemainingErrorLines())).anySatisfy(line ->
      assertThat(line).contains("Invalid credentials"));
}

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

@Test(groups = {LDAP, LDAP_CLI, PROFILE_SPECIFIC_TESTS}, timeOut = TIMEOUT)
public void shouldFailQueryForWrongLdapUser()
    throws IOException
{
  ldapUserName = "invalid_user";
  launchPrestoCliWithServerArgument("--execute", "select * from hive.default.nation;");
  assertThat(trimLines(presto.readRemainingErrorLines())).anySatisfy(line ->
      assertThat(line).contains("Invalid credentials"));
}

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

@Test(groups = {LDAP, LDAP_CLI, PROFILE_SPECIFIC_TESTS}, timeOut = TIMEOUT)
public void shouldFailQueryForLdapWithoutPassword()
    throws IOException
{
  launchPrestoCli("--server", ldapServerAddress,
      "--truststore-path", ldapTruststorePath,
      "--truststore-password", ldapTruststorePassword,
      "--user", ldapUserName,
      "--execute", "select * from hive.default.nation;");
  assertThat(trimLines(presto.readRemainingErrorLines())).anySatisfy(line ->
      assertThat(line).contains("Authentication failed: Unauthorized"));
}

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

@Test(groups = {LDAP, LDAP_CLI, PROFILE_SPECIFIC_TESTS}, timeOut = TIMEOUT)
public void shouldFailQueryForEmptyUser()
    throws IOException
{
  ldapUserName = "";
  launchPrestoCliWithServerArgument("--execute", "select * from hive.default.nation;");
  assertThat(trimLines(presto.readRemainingErrorLines())).anySatisfy(line ->
      assertThat(line).contains("Malformed decoded credentials"));
}

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

@Test(groups = {LDAP, LDAP_CLI, PROFILE_SPECIFIC_TESTS}, timeOut = TIMEOUT)
public void shouldFailQueryForLdapUserInParentGroup()
    throws IOException
{
  ldapUserName = PARENT_GROUP_USER.getAttributes().get("cn");
  launchPrestoCliWithServerArgument("--catalog", "hive", "--schema", "default", "--execute", "select * from nation;");
  assertThat(trimLines(presto.readRemainingErrorLines())).anySatisfy(line ->
      assertThat(line).contains(format("User [%s] not a member of the authorized group", ldapUserName)));
}

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

@Test(groups = {LDAP, LDAP_CLI, PROFILE_SPECIFIC_TESTS}, timeOut = TIMEOUT)
public void shouldFailQueryForOrphanLdapUser()
    throws IOException
{
  ldapUserName = ORPHAN_USER.getAttributes().get("cn");
  launchPrestoCliWithServerArgument("--catalog", "hive", "--schema", "default", "--execute", "select * from nation;");
  assertThat(trimLines(presto.readRemainingErrorLines())).anySatisfy(line ->
      assertThat(line).contains(format("User [%s] not a member of the authorized group", ldapUserName)));
}

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

@Test(groups = {LDAP, LDAP_CLI, PROFILE_SPECIFIC_TESTS}, timeOut = TIMEOUT)
public void shouldFailForIncorrectTrustStore()
    throws IOException
{
  ldapTruststorePassword = "wrong_password";
  launchPrestoCliWithServerArgument("--execute", "select * from hive.default.nation;");
  assertThat(trimLines(presto.readRemainingErrorLines())).anySatisfy(line ->
      assertThat(line).contains("Keystore was tampered with, or password was incorrect"));
  skipAfterTestWithContext();
}

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

@Test(groups = {LDAP, LDAP_CLI, PROFILE_SPECIFIC_TESTS}, timeOut = TIMEOUT)
public void shouldFailQueryForLdapWithoutHttps()
    throws IOException
{
  ldapServerAddress = format("http://%s:8443", serverHost);
  launchPrestoCliWithServerArgument("--execute", "select * from hive.default.nation;");
  assertThat(trimLines(presto.readRemainingErrorLines())).anySatisfy(line ->
      assertThat(line).contains("Authentication using username/password requires HTTPS to be enabled"));
  skipAfterTestWithContext();
}

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

@Test(groups = {LDAP, LDAP_CLI, PROFILE_SPECIFIC_TESTS}, timeOut = TIMEOUT)
public void shouldFailForUserWithColon()
    throws IOException
{
  ldapUserName = "UserWith:Colon";
  launchPrestoCliWithServerArgument("--execute", "select * from hive.default.nation;");
  assertThat(trimLines(presto.readRemainingErrorLines())).anySatisfy(line ->
      assertThat(line).contains("Illegal character ':' found in username"));
  skipAfterTestWithContext();
}

代码示例来源:origin: haasted/TestLogCollectors

public void sometimesFails() {
    log.warn("This is a warning.");
    log.info("This is purely informational.");

    List<LoggingEvent> logs = (List<LoggingEvent>) TestNGLogCollector.getRawLogs();

    assertThat(logs)
        .hasSize(2)
        .anySatisfy(e -> assertThat(e.getLevel()).isEqualTo(Level.WARN))
        .anySatisfy(e -> assertThat(e.getLevel()).isEqualTo(Level.INFO));

    invocationCount++;

    if (invocationCount > 8) {
      Assert.fail();
    }
  }
}

代码示例来源:origin: org.apache.james.protocols/protocols-imap

@Test
public void processorShouldWorkOnValidRights() throws Exception {
  GetQuotaRootRequest getQuotaRootRequest = new GetQuotaRootRequest("A004", ImapCommand.anyStateCommand("Name"), "INBOX");
  when(mockedImapSession.getState()).thenReturn(ImapSessionState.AUTHENTICATED);
  when(mockedImapSession.getAttribute(ImapSessionUtils.MAILBOX_SESSION_ATTRIBUTE_SESSION_KEY)).thenReturn(mailboxSession);
  when(mockedQuotaRootResolver.getQuotaRoot(MAILBOX_PATH)).thenReturn(QUOTA_ROOT);
  when(mockedMailboxManager.hasRight(MAILBOX_PATH, MailboxACL.Right.Read, mailboxSession)).thenReturn(true);
  when(mockedQuotaManager.getMessageQuota(QUOTA_ROOT)).thenReturn(MESSAGE_QUOTA);
  when(mockedQuotaManager.getStorageQuota(QUOTA_ROOT)).thenReturn(STORAGE_QUOTA);
  final QuotaResponse storageQuotaResponse = new QuotaResponse("STORAGE", "plop", STORAGE_QUOTA);
  final QuotaResponse messageQuotaResponse = new QuotaResponse("MESSAGE", "plop", MESSAGE_QUOTA);
  final QuotaRootResponse quotaRootResponse = new QuotaRootResponse("INBOX", "plop");
  testee.doProcess(getQuotaRootRequest, mockedResponder, mockedImapSession);
  verify(mockedMailboxManager, times(1)).startProcessingRequest(mailboxSession);
  verify(mockedMailboxManager, times(1)).endProcessingRequest(mailboxSession);
  ArgumentCaptor<ImapResponseMessage> responseCaptor = ArgumentCaptor.forClass(ImapResponseMessage.class);
  verify(mockedResponder, times(4)).respond(responseCaptor.capture());
  List<ImapResponseMessage> captorValues = responseCaptor.getAllValues();
  assertThat(captorValues).contains(quotaRootResponse, storageQuotaResponse, messageQuotaResponse);
  assertThat(captorValues).anySatisfy(response -> assertThat(response).isInstanceOfSatisfying(
    StatusResponse.class,
    st -> assertThat(st.getServerResponseType()).isEqualTo(OK)));
}

相关文章

微信公众号

最新文章

更多

ListAssert类方法