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

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

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

IterableAssert.first介绍

暂无

代码示例

代码示例来源:origin: spring-projects/spring-security

@Test
public void oauth2LoginCustomWithConfigurer() throws Exception {
  // setup application context
  loadConfig(OAuth2LoginConfigCustomWithConfigurer.class);
  // setup authorization request
  OAuth2AuthorizationRequest authorizationRequest = createOAuth2AuthorizationRequest();
  this.authorizationRequestRepository.saveAuthorizationRequest(
    authorizationRequest, this.request, this.response);
  // setup authentication parameters
  this.request.setParameter("code", "code123");
  this.request.setParameter("state", authorizationRequest.getState());
  // perform test
  this.springSecurityFilterChain.doFilter(this.request, this.response, this.filterChain);
  // assertions
  Authentication authentication = this.securityContextRepository
      .loadContext(new HttpRequestResponseHolder(this.request, this.response))
      .getAuthentication();
  assertThat(authentication.getAuthorities()).hasSize(2);
  assertThat(authentication.getAuthorities()).first().hasToString("ROLE_USER");
  assertThat(authentication.getAuthorities()).last().hasToString("ROLE_OAUTH2_USER");
}

代码示例来源:origin: spring-projects/spring-security

@Test
public void oauth2LoginCustomWithBeanRegistration() throws Exception {
  // setup application context
  loadConfig(OAuth2LoginConfigCustomWithBeanRegistration.class);
  // setup authorization request
  OAuth2AuthorizationRequest authorizationRequest = createOAuth2AuthorizationRequest();
  this.authorizationRequestRepository.saveAuthorizationRequest(
    authorizationRequest, this.request, this.response);
  // setup authentication parameters
  this.request.setParameter("code", "code123");
  this.request.setParameter("state", authorizationRequest.getState());
  // perform test
  this.springSecurityFilterChain.doFilter(this.request, this.response, this.filterChain);
  // assertions
  Authentication authentication = this.securityContextRepository
      .loadContext(new HttpRequestResponseHolder(this.request, this.response))
      .getAuthentication();
  assertThat(authentication.getAuthorities()).hasSize(2);
  assertThat(authentication.getAuthorities()).first().hasToString("ROLE_USER");
  assertThat(authentication.getAuthorities()).last().hasToString("ROLE_OAUTH2_USER");
}

代码示例来源:origin: spring-projects/spring-security

@Test
public void oidcLoginCustomWithConfigurer() throws Exception {
  // setup application context
  loadConfig(OAuth2LoginConfigCustomWithConfigurer.class, JwtDecoderFactoryConfig.class);
  // setup authorization request
  OAuth2AuthorizationRequest authorizationRequest = createOAuth2AuthorizationRequest("openid");
  this.authorizationRequestRepository.saveAuthorizationRequest(
    authorizationRequest, this.request, this.response);
  // setup authentication parameters
  this.request.setParameter("code", "code123");
  this.request.setParameter("state", authorizationRequest.getState());
  // perform test
  this.springSecurityFilterChain.doFilter(this.request, this.response, this.filterChain);
  // assertions
  Authentication authentication = this.securityContextRepository
      .loadContext(new HttpRequestResponseHolder(this.request, this.response))
      .getAuthentication();
  assertThat(authentication.getAuthorities()).hasSize(2);
  assertThat(authentication.getAuthorities()).first().hasToString("ROLE_USER");
  assertThat(authentication.getAuthorities()).last().hasToString("ROLE_OIDC_USER");
}

代码示例来源:origin: spring-projects/spring-security

@Test
public void oidcLoginCustomWithBeanRegistration() throws Exception {
  // setup application context
  loadConfig(OAuth2LoginConfigCustomWithBeanRegistration.class, JwtDecoderFactoryConfig.class);
  // setup authorization request
  OAuth2AuthorizationRequest authorizationRequest = createOAuth2AuthorizationRequest("openid");
  this.authorizationRequestRepository.saveAuthorizationRequest(
    authorizationRequest, this.request, this.response);
  // setup authentication parameters
  this.request.setParameter("code", "code123");
  this.request.setParameter("state", authorizationRequest.getState());
  // perform test
  this.springSecurityFilterChain.doFilter(this.request, this.response, this.filterChain);
  // assertions
  Authentication authentication = this.securityContextRepository
      .loadContext(new HttpRequestResponseHolder(this.request, this.response))
      .getAuthentication();
  assertThat(authentication.getAuthorities()).hasSize(2);
  assertThat(authentication.getAuthorities()).first().hasToString("ROLE_USER");
  assertThat(authentication.getAuthorities()).last().hasToString("ROLE_OIDC_USER");
}

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

@Test
public void fromFuseableUsesThreadBarrier() {
  final Set<String> between = new HashSet<>();
  final ConcurrentHashMap<String, String> processing = new ConcurrentHashMap<>();
  Flux<Integer> test = Flux.range(1, 10)
               .publishOn(Schedulers.single(), false, 1)
               .doOnNext(v -> between.add(Thread.currentThread()
                               .getName()))
               .parallel(2, 1)
               .runOn(Schedulers.elastic(), 1)
               .map(v -> {
                 processing.putIfAbsent(Thread.currentThread()
                               .getName(), "");
                 return v;
               })
               .sequential();
  StepVerifier.create(test)
        .expectSubscription()
        .recordWith(() -> Collections.synchronizedList(new ArrayList<>(10)))
        .expectNextCount(10)
        .consumeRecordedWith(r -> assertThat(r).containsExactlyInAnyOrder(1, 2, 3, 4, 5, 6, 7, 8, 9, 10))
        .expectComplete()
        .verify(Duration.ofSeconds(5));
  assertThat(between).hasSize(1);
  assertThat(between).first()
            .asString()
            .startsWith("single-");
  assertThat(processing.keySet())
      .allSatisfy(k -> assertThat(k).startsWith("elastic-"));
}

代码示例来源:origin: spring-projects/spring-security

@Test
public void oauth2Login() throws Exception {
  // setup application context
  loadConfig(OAuth2LoginConfig.class);
  // setup authorization request
  OAuth2AuthorizationRequest authorizationRequest = createOAuth2AuthorizationRequest();
  this.authorizationRequestRepository.saveAuthorizationRequest(
    authorizationRequest, this.request, this.response);
  // setup authentication parameters
  this.request.setParameter("code", "code123");
  this.request.setParameter("state", authorizationRequest.getState());
  // perform test
  this.springSecurityFilterChain.doFilter(this.request, this.response, this.filterChain);
  // assertions
  Authentication authentication = this.securityContextRepository
      .loadContext(new HttpRequestResponseHolder(this.request, this.response))
      .getAuthentication();
  assertThat(authentication.getAuthorities()).hasSize(1);
  assertThat(authentication.getAuthorities()).first()
      .isInstanceOf(OAuth2UserAuthority.class).hasToString("ROLE_USER");
}

代码示例来源:origin: spring-projects/spring-security

@Test
public void oidcLogin() throws Exception {
  // setup application context
  loadConfig(OAuth2LoginConfig.class, JwtDecoderFactoryConfig.class);
  // setup authorization request
  OAuth2AuthorizationRequest authorizationRequest = createOAuth2AuthorizationRequest("openid");
  this.authorizationRequestRepository.saveAuthorizationRequest(
    authorizationRequest, this.request, this.response);
  // setup authentication parameters
  this.request.setParameter("code", "code123");
  this.request.setParameter("state", authorizationRequest.getState());
  // perform test
  this.springSecurityFilterChain.doFilter(this.request, this.response, this.filterChain);
  // assertions
  Authentication authentication = this.securityContextRepository
      .loadContext(new HttpRequestResponseHolder(this.request, this.response))
      .getAuthentication();
  assertThat(authentication.getAuthorities()).hasSize(1);
  assertThat(authentication.getAuthorities()).first()
      .isInstanceOf(OidcUserAuthority.class).hasToString("ROLE_USER");
}

代码示例来源:origin: spring-projects/spring-security

@Test
public void oauth2LoginConfigLoginProcessingUrl() throws Exception {
  // setup application context
  loadConfig(OAuth2LoginConfigLoginProcessingUrl.class);
  // setup authorization request
  OAuth2AuthorizationRequest authorizationRequest = createOAuth2AuthorizationRequest();
  this.request.setServletPath("/login/oauth2/google");
  this.authorizationRequestRepository.saveAuthorizationRequest(
      authorizationRequest, this.request, this.response);
  // setup authentication parameters
  this.request.setParameter("code", "code123");
  this.request.setParameter("state", authorizationRequest.getState());
  // perform test
  this.springSecurityFilterChain.doFilter(this.request, this.response, this.filterChain);
  // assertions
  Authentication authentication = this.securityContextRepository
      .loadContext(new HttpRequestResponseHolder(this.request, this.response))
      .getAuthentication();
  assertThat(authentication.getAuthorities()).hasSize(1);
  assertThat(authentication.getAuthorities()).first()
      .isInstanceOf(OAuth2UserAuthority.class).hasToString("ROLE_USER");
}

代码示例来源:origin: RoboZonky/robozonky

@Test
void stableUpdate() {
  final String currentVersion = "1.0.0";
  final String newVersion = "1.0.1";
  final VersionIdentifier newVersionIdentifier = new VersionIdentifier(newVersion);
  final UpdateNotification n = new UpdateNotification(currentVersion);
  // check that the event is fired
  n.valueSet(newVersionIdentifier);
  final Collection<Event> eventsOriginallyFired = this.getEventsRequested();
  assertThat(eventsOriginallyFired).hasSize(1)
      .first()
      .isInstanceOf(RoboZonkyUpdateDetectedEvent.class);
  // check that the event has the proper version
  assertThat(eventsOriginallyFired)
      .first()
      .matches(e -> Objects.equals(((RoboZonkyUpdateDetectedEvent) e).getNewVersion(), newVersion));
  // check that the event is not fired again since there is no change in new version
  n.valueSet(newVersionIdentifier);
  assertThat(this.getEventsRequested()).hasSize(1);
}

代码示例来源:origin: RoboZonky/robozonky

@Test
  void hasJustOneJob() {
    final JobService s = new StonkyJobService();
    assertThat(s.getTenantJobs())
        .hasSize(1)
        .first()
        .isInstanceOf(StonkyJob.class);
    assertThat(s.getSimpleJobs())
        .isEmpty();
  }
}

代码示例来源:origin: RoboZonky/robozonky

@Test
void unstableUpdate() {
  final String currentVersion = "1.0.0";
  final String newVersion = "1.0.1-beta-1";
  final VersionIdentifier newVersionIdentifier = new VersionIdentifier(currentVersion, newVersion);
  final UpdateNotification n = new UpdateNotification(currentVersion);
  // check that the event is fired
  n.valueSet(newVersionIdentifier);
  final Collection<Event> eventsOriginallyFired = this.getEventsRequested();
  assertThat(eventsOriginallyFired).hasSize(1)
      .first()
      .isInstanceOf(RoboZonkyExperimentalUpdateDetectedEvent.class);
  // check that the event has the proper version
  assertThat(eventsOriginallyFired)
      .first()
      .matches(e -> Objects.equals(((RoboZonkyExperimentalUpdateDetectedEvent) e).getNewVersion(),
                     newVersion));
  // check that the event is not fired again since there is no change in new version
  n.valueSet(newVersionIdentifier);
  assertThat(this.getEventsRequested()).hasSize(1);
}

相关文章

微信公众号

最新文章

更多