MemberPathTests Class — spring-boot Architecture
Architecture documentation for the MemberPathTests class in JsonWriterTests.java from the spring-boot codebase.
Entity Profile
Source Code
core/spring-boot/src/test/java/org/springframework/boot/json/JsonWriterTests.java lines 481–545
@Nested
class MemberPathTests {
@Test
void createWhenIndexAndNamedThrowException() {
assertThatIllegalArgumentException().isThrownBy(() -> new MemberPath(null, "boot", 0))
.withMessage("'name' and 'index' cannot be mixed");
assertThatIllegalArgumentException().isThrownBy(() -> new MemberPath(null, null, -1))
.withMessage("'name' and 'index' cannot be mixed");
}
@Test
void toStringReturnsUsefulString() {
assertThat(MemberPath.ROOT).hasToString("");
MemberPath spring = new MemberPath(MemberPath.ROOT, "spring", MemberPath.UNINDEXED);
MemberPath springDotBoot = new MemberPath(spring, "boot", MemberPath.UNINDEXED);
MemberPath springZero = new MemberPath(spring, null, 0);
MemberPath springZeroDotBoot = new MemberPath(springZero, "boot", MemberPath.UNINDEXED);
assertThat(spring).hasToString("spring");
assertThat(springDotBoot).hasToString("spring.boot");
assertThat(springZero).hasToString("spring[0]");
assertThat(springZeroDotBoot).hasToString("spring[0].boot");
}
@Test
void childWithNameCreatesChild() {
assertThat(MemberPath.ROOT.child("spring").child("boot")).hasToString("spring.boot");
}
@Test
void childWithNameWhenNameSpecialChars() {
assertThat(MemberPath.ROOT.child("spring.io").child("boot")).hasToString("spring\\.io.boot");
assertThat(MemberPath.ROOT.child("spring[io]").child("boot")).hasToString("spring\\[io\\].boot");
assertThat(MemberPath.ROOT.child("spring.[io]").child("boot")).hasToString("spring\\.\\[io\\].boot");
assertThat(MemberPath.ROOT.child("spring\\io").child("boot")).hasToString("spring\\\\io.boot");
assertThat(MemberPath.ROOT.child("spring.\\io").child("boot")).hasToString("spring\\.\\\\io.boot");
assertThat(MemberPath.ROOT.child("spring[\\io]").child("boot")).hasToString("spring\\[\\\\io\\].boot");
assertThat(MemberPath.ROOT.child("123").child("boot")).hasToString("123.boot");
assertThat(MemberPath.ROOT.child("1.2.3").child("boot")).hasToString("1\\.2\\.3.boot");
}
@Test
void childWithIndexCreatesChild() {
assertThat(MemberPath.ROOT.child("spring").child(0)).hasToString("spring[0]");
}
@Test
void ofParsesPaths() {
assertOfFromToString(MemberPath.ROOT.child("spring").child("boot"));
assertOfFromToString(MemberPath.ROOT.child("spring").child(0));
assertOfFromToString(MemberPath.ROOT.child("spring.io").child("boot"));
assertOfFromToString(MemberPath.ROOT.child("spring[io]").child("boot"));
assertOfFromToString(MemberPath.ROOT.child("spring.[io]").child("boot"));
assertOfFromToString(MemberPath.ROOT.child("spring\\io").child("boot"));
assertOfFromToString(MemberPath.ROOT.child("spring.\\io").child("boot"));
assertOfFromToString(MemberPath.ROOT.child("spring[\\io]").child("boot"));
assertOfFromToString(MemberPath.ROOT.child("123").child("boot"));
assertOfFromToString(MemberPath.ROOT.child("1.2.3").child("boot"));
}
private void assertOfFromToString(MemberPath path) {
assertThat(MemberPath.of(path.toString())).isEqualTo(path);
}
}
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free