Polish "Migrate legacy endpoint that have a dash in their id"
See gh-21615
This commit is contained in:
parent
0f9f10f97e
commit
dd9c9fd171
|
@ -101,22 +101,30 @@ class EndpointIdTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void ofWhenMigratingLegacyNameRemovesDots(CapturedOutput output) {
|
void ofWhenMigratingLegacyNameRemovesDots(CapturedOutput output) {
|
||||||
EndpointId.resetLoggedWarnings();
|
EndpointId endpointId = migrateLegacyName("one.two.three");
|
||||||
MockEnvironment environment = new MockEnvironment();
|
assertThat(endpointId.toString()).isEqualTo("onetwothree");
|
||||||
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");
|
assertThat(output).doesNotContain("contains invalid characters");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void ofWhenMigratingLegacyNameRemovesHyphens(CapturedOutput output) {
|
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();
|
EndpointId.resetLoggedWarnings();
|
||||||
MockEnvironment environment = new MockEnvironment();
|
MockEnvironment environment = new MockEnvironment();
|
||||||
environment.setProperty("management.endpoints.migrate-legacy-ids", "true");
|
environment.setProperty("management.endpoints.migrate-legacy-ids", "true");
|
||||||
EndpointId endpointId = EndpointId.of(environment, "foo-bar");
|
return EndpointId.of(environment, name);
|
||||||
assertThat(endpointId.toString()).isEqualTo("foobar");
|
|
||||||
assertThat(output).doesNotContain("contains invalid characters");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2019 the original author or authors.
|
* Copyright 2012-2020 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -25,7 +25,7 @@ import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Endpoint(id = "lega.cy")
|
@Endpoint(id = "lega.cy")
|
||||||
public class SampleLegacyEndpoint {
|
public class SampleLegacyEndpointWithDot {
|
||||||
|
|
||||||
@ReadOperation
|
@ReadOperation
|
||||||
public Map<String, String> example() {
|
public Map<String, String> example() {
|
Loading…
Reference in New Issue