-
Notifications
You must be signed in to change notification settings - Fork 38.9k
Closed as not planned
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)status: duplicateA duplicate of another issueA duplicate of another issuetype: enhancementA general enhancementA general enhancement
Description
Andy Wilkinson opened SPR-16962 and commented
The introduction of the Profiles type in #17063 has made verifying that a call to Environment.acceptsProfiles has been made more difficult. When String was used, verification with Mockito was easy:
verify(this.environment).acceptsProfiles("dev");With the new Profiles type this will fail as ParsedProfiles does not override equals:
verify(this.environment).acceptsProfiles(Profiles.of("dev"));The best that I have come up with is to capture the argument that's passed into acceptsProfiles, abuse matches to capture the names of the profiles, and assert that they are as expected:
ArgumentCaptor<Profiles> profiles = ArgumentCaptor.forClass(Profiles.class);
verify(this.environment).acceptsProfiles(profiles.capture());
List<String> profileNames = new ArrayList<String>();
profiles.getValue().matches((profile) -> {
profileNames.add(profile);
return false;
});
assertThat(profileNames).containsExactly("dev");Affects: 5.1 RC1
Issue Links:
- Support AND operator in @Profile annotation [SPR-12458] #17063 Support AND operator in
@Profileannotation
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)status: duplicateA duplicate of another issueA duplicate of another issuetype: enhancementA general enhancementA general enhancement