SpringProfileModelHandlerTests Class — spring-boot Architecture
Architecture documentation for the SpringProfileModelHandlerTests class in SpringProfileModelHandlerTests.java from the spring-boot codebase.
Entity Profile
Source Code
core/spring-boot/src/test/java/org/springframework/boot/logging/logback/SpringProfileModelHandlerTests.java lines 42–121
class SpringProfileModelHandlerTests {
private final Environment environment = mock(Environment.class);
private final Context context = new ContextBase();
private final SpringProfileModelHandler action = new SpringProfileModelHandler(this.context, this.environment);
private final ModelInterpretationContext interpretationContext = new ModelInterpretationContext(this.context);
@BeforeEach
void setUp() {
this.action.setContext(this.context);
}
@Test
void environmentIsQueriedWithProfileFromModelName() throws ModelHandlerException {
SpringProfileModel model = new SpringProfileModel();
model.setName("dev");
this.action.handle(this.interpretationContext, model);
then(this.environment).should().acceptsProfiles(ArgumentMatchers.<Profiles>assertArg(((profiles) -> {
List<String> profileNames = new ArrayList<>();
profiles.matches((profile) -> {
profileNames.add(profile);
return false;
});
assertThat(profileNames).containsExactly("dev");
})));
}
@Test
void environmentIsQueriedWithMultipleProfilesFromCommaSeparatedModelName() throws ModelHandlerException {
SpringProfileModel model = new SpringProfileModel();
model.setName("dev,qa");
this.action.handle(this.interpretationContext, model);
then(this.environment).should().acceptsProfiles(ArgumentMatchers.<Profiles>assertArg(((profiles) -> {
List<String> profileNames = new ArrayList<>();
profiles.matches((profile) -> {
profileNames.add(profile);
return false;
});
assertThat(profileNames).containsExactly("dev", "qa");
})));
}
@Test
void environmentIsQueriedWithResolvedValueWhenModelNameUsesAPlaceholder() throws ModelHandlerException {
SpringProfileModel model = new SpringProfileModel();
model.setName("${profile}");
this.context.putProperty("profile", "dev");
this.action.handle(this.interpretationContext, model);
then(this.environment).should().acceptsProfiles(ArgumentMatchers.<Profiles>assertArg(((profiles) -> {
List<String> profileNames = new ArrayList<>();
profiles.matches((profile) -> {
profileNames.add(profile);
return false;
});
assertThat(profileNames).containsExactly("dev");
})));
}
@Test
void environmentIsQueriedWithResolvedValuesFromCommaSeparatedNameNameAttributeWithPlaceholders()
throws ModelHandlerException {
SpringProfileModel model = new SpringProfileModel();
model.setName("${profile1},${profile2}");
this.context.putProperty("profile1", "dev");
this.context.putProperty("profile2", "qa");
this.action.handle(this.interpretationContext, model);
then(this.environment).should().acceptsProfiles(ArgumentMatchers.<Profiles>assertArg(((profiles) -> {
List<String> profileNames = new ArrayList<>();
profiles.matches((profile) -> {
profileNames.add(profile);
return false;
});
assertThat(profileNames).containsExactly("dev", "qa");
})));
}
}
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free