Polish "Migrate legacy endpoint that have a dash in their id"

See gh-21615
This commit is contained in:
Stephane Nicoll
2020-08-10 14:53:18 +02:00
parent 0f9f10f97e
commit dd9c9fd171
2 changed files with 18 additions and 10 deletions

View File

@@ -101,22 +101,30 @@ class EndpointIdTests {
@Test
void ofWhenMigratingLegacyNameRemovesDots(CapturedOutput output) {
EndpointId.resetLoggedWarnings();
MockEnvironment environment = new MockEnvironment();
environment.setProperty("management.endpoints.migrate-legacy-ids", "true");
EndpointId endpointId = EndpointId.of(environment, "foo.bar");
assertThat(endpointId.toString()).isEqualTo("foobar");
EndpointId endpointId = migrateLegacyName("one.two.three");
assertThat(endpointId.toString()).isEqualTo("onetwothree");
assertThat(output).doesNotContain("contains invalid characters");
}
@Test
void ofWhenMigratingLegacyNameRemovesHyphens(CapturedOutput output) {
EndpointId endpointId = migrateLegacyName("one-two-three");
assertThat(endpointId.toString()).isEqualTo("onetwothree");
assertThat(output).doesNotContain("contains invalid characters");
}
@Test
void ofWhenMigratingLegacyNameRemovesMixOfDashAndDot(CapturedOutput output) {
EndpointId endpointId = migrateLegacyName("one.two-three");
assertThat(endpointId.toString()).isEqualTo("onetwothree");
assertThat(output).doesNotContain("contains invalid characters");
}
private EndpointId migrateLegacyName(String name) {
EndpointId.resetLoggedWarnings();
MockEnvironment environment = new MockEnvironment();
environment.setProperty("management.endpoints.migrate-legacy-ids", "true");
EndpointId endpointId = EndpointId.of(environment, "foo-bar");
assertThat(endpointId.toString()).isEqualTo("foobar");
assertThat(output).doesNotContain("contains invalid characters");
return EndpointId.of(environment, name);
}
@Test