13
13
14
14
import java .io .IOException ;
15
15
import java .util .Map ;
16
+ import java .util .Objects ;
16
17
17
18
public class GetSecurityStatsNodeResponseTests extends AbstractWireSerializingTestCase <GetSecurityStatsNodeResponse > {
18
19
@@ -24,16 +25,24 @@ protected Writeable.Reader<GetSecurityStatsNodeResponse> instanceReader() {
24
25
@ Override
25
26
protected GetSecurityStatsNodeResponse createTestInstance () {
26
27
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 ))
29
30
);
30
31
}
31
32
32
33
@ Override
33
34
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" );
34
37
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 ))));
37
46
default -> throw new IllegalStateException ("Unexpected value" );
38
47
};
39
48
}
0 commit comments