ClusterMembershipTransactionLogger { @VisibleForTesting static String doFormat(ClusterMembershipEvent event) { if (event instanceof ClusterMembershipChangeEvent) { return doFormat((ClusterMembershipChangeEvent) event); } if (event instanceof LeaderElectionChangeEvent) { return doFormat((LeaderElectionChangeEvent) event); } return null; }    }
@Test public void testMemberChangeEventLogging() { ClusterMembershipRevision<ClusterMember> revision = clusterMemberRegistrationRevision(activeClusterMember("local")); String value = ClusterMembershipTransactionLogger.doFormat(ClusterMembershipEvent.memberAddedEvent(revision)); assertThat(value).isEqualTo("eventType=[membership] memberId=local active=true registered=true enabled=true memberRevision=0 leadershipState=n/a leadershipRevision=n/a"); }
@Test public void testLeadershipChangeEventLogging() { ClusterMembershipRevision<ClusterMemberLeadership> revision = ClusterMembershipRevision.<ClusterMemberLeadership>newBuilder() .withCurrent(ClusterMemberLeadership.newBuilder() .withMemberId("local") .withLeadershipState(ClusterMemberLeadershipState.Leader) .build() ) .build(); String value = ClusterMembershipTransactionLogger.doFormat(ClusterMembershipEvent.leaderElected(revision)); assertThat(value).isEqualTo("eventType=[leadership] memberId=local active=n/a registered=n/a enabled=n/a memberRevision=n/a leadershipState=Leader leadershipRevision=0"); }