本文整理了Java中org.assertj.core.api.IterableAssert.extracting()
方法的一些代码示例,展示了IterableAssert.extracting()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IterableAssert.extracting()
方法的具体详情如下:
包路径:org.assertj.core.api.IterableAssert
类名称:IterableAssert
方法名:extracting
暂无
代码示例来源:origin: SonarSource/sonarqube
private void verifyCallActiveRuleIndexerDelete(String... expectedRuleProfileUuids) {
Class<Set<QProfileDto>> setClass = (Class<Set<QProfileDto>>) (Class) Set.class;
ArgumentCaptor<Set<QProfileDto>> setCaptor = ArgumentCaptor.forClass(setClass);
verify(activeRuleIndexer).commitDeletionOfProfiles(any(DbSession.class), setCaptor.capture());
assertThat(setCaptor.getValue())
.extracting(QProfileDto::getKee)
.containsExactlyInAnyOrder(expectedRuleProfileUuids);
}
代码示例来源:origin: spring-projects/spring-security
@Test
public void validateWhenIssuedAt1minAheadAnd0minClockSkewThenHasErrors() {
this.issuedAt = Instant.now().plus(Duration.ofMinutes(1));
this.expiresAt = this.issuedAt.plus(Duration.ofSeconds(60));
this.clockSkew = Duration.ofMinutes(0);
assertThat(this.validateIdToken())
.hasSize(1)
.extracting(OAuth2Error::getDescription)
.allMatch(msg -> msg.contains(IdTokenClaimNames.IAT));
}
代码示例来源:origin: spring-projects/spring-security
@Test
public void validateWhenMultipleAudAzpNotClientIdThenHasErrors() {
this.claims.put(IdTokenClaimNames.AUD, Arrays.asList("client-id-1", "client-id-2"));
this.claims.put(IdTokenClaimNames.AZP, "other-client");
assertThat(this.validateIdToken())
.hasSize(1)
.extracting(OAuth2Error::getDescription)
.allMatch(msg -> msg.contains(IdTokenClaimNames.AZP));
}
代码示例来源:origin: SonarSource/sonarqube
private void verifyDescendants(Collection<QProfileDto> baseProfiles, Collection<QProfileDto> expectedDescendants) {
Collection<QProfileDto> descendants = underTest.selectDescendants(dbSession, baseProfiles);
String[] expectedUuids = expectedDescendants.stream().map(QProfileDto::getKee).toArray(String[]::new);
assertThat(descendants)
.extracting(QProfileDto::getKee)
.containsExactlyInAnyOrder(expectedUuids);
}
代码示例来源:origin: spring-projects/spring-security
@Test
public void validateWhenAudNotClientIdThenHasErrors() {
this.claims.put(IdTokenClaimNames.AUD, Collections.singletonList("other-client"));
assertThat(this.validateIdToken())
.hasSize(1)
.extracting(OAuth2Error::getDescription)
.allMatch(msg -> msg.contains(IdTokenClaimNames.AUD));
}
代码示例来源:origin: SonarSource/sonarqube
private void assertResult(String componentKey, String branch, Tuple... tuples) {
try (CloseableIterator<ServerIssue> result = callStream(componentKey, branch)) {
assertThat(result)
.extracting(ServerIssue::getKey, ServerIssue::getModuleKey)
.containsExactlyInAnyOrder(tuples);
}
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void findAll_returns_all_rules_when_RuleQuery_has_no_non_null_field() {
assertThat(underTest.findAll(RuleQuery.create()))
.extracting(CachingRuleFinderTest::toRuleKey)
.containsOnly(Arrays.stream(ruleDefinitions).map(RuleDefinitionDto::getKey).toArray(RuleKey[]::new));
}
代码示例来源:origin: SonarSource/sonarqube
private void verifyListenerCalled(QGChangeEventListener listener, QGChangeEvent changeEvent, DefaultIssue... issues) {
ArgumentCaptor<Set<ChangedIssue>> changedIssuesCaptor = newSetCaptor();
verify(listener).onIssueChanges(same(changeEvent), changedIssuesCaptor.capture());
Set<ChangedIssue> changedIssues = changedIssuesCaptor.getValue();
Tuple[] expected = Arrays.stream(issues)
.map(issue -> tuple(issue.key(), ChangedIssueImpl.statusOf(issue), issue.type()))
.toArray(Tuple[]::new);
assertThat(changedIssues)
.hasSize(issues.length)
.extracting(ChangedIssue::getKey, t -> t.getStatus(), ChangedIssue::getType)
.containsOnly(expected);
}
代码示例来源:origin: spring-projects/spring-security
@Test
public void validateWhenAudMultipleAndAzpNullThenHasErrors() {
this.claims.put(IdTokenClaimNames.AUD, Arrays.asList("client-id", "other"));
assertThat(this.validateIdToken())
.hasSize(1)
.extracting(OAuth2Error::getDescription)
.allMatch(msg -> msg.contains(IdTokenClaimNames.AZP));
}
代码示例来源:origin: SonarSource/sonarqube
private void assertCondition(QualityGateDto qualityGate, MetricDto metric, String operator, String error) {
assertThat(dbClient.gateConditionDao().selectForQualityGate(dbSession, qualityGate.getId()))
.extracting(QualityGateConditionDto::getQualityGateId, QualityGateConditionDto::getMetricId, QualityGateConditionDto::getOperator,
QualityGateConditionDto::getErrorThreshold)
.containsExactlyInAnyOrder(tuple(qualityGate.getId(), metric.getId().longValue(), operator, error));
}
代码示例来源:origin: spring-projects/spring-security
@Test
public void validateWhenSubNullThenHasErrors() {
this.claims.remove(IdTokenClaimNames.SUB);
assertThat(this.validateIdToken())
.hasSize(1)
.extracting(OAuth2Error::getDescription)
.allMatch(msg -> msg.contains(IdTokenClaimNames.SUB));
}
代码示例来源:origin: SonarSource/sonarqube
private void assertCondition(QualityGateDto qualityGate, MetricDto metric, String operator, String error) {
assertThat(dbClient.gateConditionDao().selectForQualityGate(dbSession, qualityGate.getId()))
.extracting(QualityGateConditionDto::getQualityGateId, QualityGateConditionDto::getMetricId, QualityGateConditionDto::getOperator,
QualityGateConditionDto::getErrorThreshold)
.containsExactlyInAnyOrder(tuple(qualityGate.getId(), metric.getId().longValue(), operator, error));
}
代码示例来源:origin: spring-projects/spring-security
@Test
public void validateWhenExpiredAnd0secClockSkewThenHasErrors() {
this.issuedAt = Instant.now().minus(Duration.ofSeconds(60));
this.expiresAt = this.issuedAt.plus(Duration.ofSeconds(30));
this.clockSkew = Duration.ofSeconds(0);
assertThat(this.validateIdToken())
.hasSize(1)
.extracting(OAuth2Error::getDescription)
.allMatch(msg -> msg.contains(IdTokenClaimNames.EXP));
}
代码示例来源:origin: SonarSource/sonarqube
private void verifyContentOfPreloadedSearchResponseData(IssueDto issue) {
SearchResponseData preloadedSearchResponseData = preloadedSearchResponseDataCaptor.getValue();
assertThat(preloadedSearchResponseData.getIssues())
.extracting(IssueDto::getKey)
.containsOnly(issue.getKey());
assertThat(preloadedSearchResponseData.getRules())
.extracting(RuleDefinitionDto::getKey)
.containsOnly(issue.getRuleKey());
assertThat(preloadedSearchResponseData.getComponents())
.extracting(ComponentDto::uuid)
.containsOnly(issue.getComponentUuid(), issue.getProjectUuid());
}
代码示例来源:origin: spring-projects/spring-security
@Test
public void getAuthenticationManagerWhenProtectedPasswordEncoderBeanThenUsed() throws Exception {
this.spring.register(PasswordEncoderGlobalConfig.class).autowire();
AuthenticationManager manager = this.spring.getContext()
.getBean(AuthenticationConfiguration.class).getAuthenticationManager();
Authentication auth = manager.authenticate(new UsernamePasswordAuthenticationToken("user", "password"));
assertThat(auth.getName()).isEqualTo("user");
assertThat(auth.getAuthorities()).extracting(GrantedAuthority::getAuthority).containsOnly("ROLE_USER");
}
代码示例来源:origin: SonarSource/sonarqube
private void verifyContentOfPreloadedSearchResponseData(IssueDto issue) {
SearchResponseData preloadedSearchResponseData = preloadedSearchResponseDataCaptor.getValue();
assertThat(preloadedSearchResponseData.getIssues())
.extracting(IssueDto::getKey)
.containsOnly(issue.getKey());
assertThat(preloadedSearchResponseData.getRules())
.extracting(RuleDefinitionDto::getKey)
.containsOnly(issue.getRuleKey());
assertThat(preloadedSearchResponseData.getComponents())
.extracting(ComponentDto::uuid)
.containsOnly(issue.getComponentUuid(), issue.getProjectUuid());
}
代码示例来源:origin: spring-projects/spring-security
@Test
public void validateWhenAudNullThenHasErrors() {
this.claims.remove(IdTokenClaimNames.AUD);
assertThat(this.validateIdToken())
.hasSize(1)
.extracting(OAuth2Error::getDescription)
.allMatch(msg -> msg.contains(IdTokenClaimNames.AUD));
}
代码示例来源:origin: spring-projects/spring-security
@Test
public void validateWhenExpiresAtBeforeNowThenHasErrors() {
this.issuedAt = Instant.now().minus(Duration.ofSeconds(10));
this.expiresAt = this.issuedAt.plus(Duration.ofSeconds(5));
this.clockSkew = Duration.ofSeconds(0);
assertThat(this.validateIdToken())
.hasSize(1)
.extracting(OAuth2Error::getDescription)
.allMatch(msg -> msg.contains(IdTokenClaimNames.EXP));
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void list_uninstalled_plugins() throws IOException {
new File(uninstallDir, "file1").createNewFile();
copyTestPluginTo("test-base-plugin", uninstallDir);
assertThat(underTest.getUninstalledPlugins()).extracting("key").containsOnly("testbase");
}
代码示例来源:origin: spring-projects/spring-security
@Test
public void getAuthenticationManagerWhenGlobalPasswordEncoderBeanThenUsed() throws Exception {
this.spring.register(PasswordEncoderGlobalConfig.class).autowire();
AuthenticationManager manager = this.spring.getContext()
.getBean(AuthenticationConfiguration.class).getAuthenticationManager();
Authentication auth = manager.authenticate(new UsernamePasswordAuthenticationToken("user", "password"));
assertThat(auth.getName()).isEqualTo("user");
assertThat(auth.getAuthorities()).extracting(GrantedAuthority::getAuthority).containsOnly("ROLE_USER");
}
内容来源于网络,如有侵权,请联系作者删除!