1313
1414import java .io .IOException ;
1515import java .util .Map ;
16+ import java .util .Objects ;
1617
1718public class GetSecurityStatsNodeResponseTests extends AbstractWireSerializingTestCase <GetSecurityStatsNodeResponse > {
1819
@@ -24,16 +25,24 @@ protected Writeable.Reader<GetSecurityStatsNodeResponse> instanceReader() {
2425 @ Override
2526 protected GetSecurityStatsNodeResponse createTestInstance () {
2627 return new GetSecurityStatsNodeResponse (
27- DiscoveryNodeUtils .create ( randomUUID () ),
28- randomBoolean () ? null : Map .of ("key" , randomUUID ( ))
28+ DiscoveryNodeUtils .builder ( randomAlphaOfLength ( 10 )). ephemeralId ( randomAlphanumericOfLength ( 10 )). build ( ),
29+ randomBoolean () ? null : Map .of ("key" , randomAlphaOfLength ( 5 ))
2930 );
3031 }
3132
3233 @ Override
3334 protected GetSecurityStatsNodeResponse mutateInstance (GetSecurityStatsNodeResponse instance ) throws IOException {
35+ final var node = instance .getDiscoveryNode ();
36+ final var value = Objects .requireNonNullElse (instance .getRolesStoreStats (), Map .of ()).get ("key" );
3437 return switch (randomIntBetween (0 , 1 )) {
35- case 0 -> new GetSecurityStatsNodeResponse (DiscoveryNodeUtils .create (randomUUID ()), instance .getRolesStoreStats ());
36- case 1 -> new GetSecurityStatsNodeResponse (instance .getDiscoveryNode (), Map .of ("key" , randomUUID ()));
38+ case 0 -> new GetSecurityStatsNodeResponse (
39+ DiscoveryNodeUtils .builder (randomValueOtherThan (node .getId (), () -> randomAlphaOfLength (10 )))
40+ // DiscoverNode#hashCode only tests ephemeralId, so make sure to change it too
41+ .ephemeralId (randomValueOtherThan (node .getEphemeralId (), () -> randomAlphanumericOfLength (10 )))
42+ .build (),
43+ instance .getRolesStoreStats ()
44+ );
45+ case 1 -> new GetSecurityStatsNodeResponse (node , Map .of ("key" , randomValueOtherThan (value , () -> randomAlphaOfLength (5 ))));
3746 default -> throw new IllegalStateException ("Unexpected value" );
3847 };
3948 }
0 commit comments