@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"); }
@VisibleForTesting static String doFormat(ClusterMembershipEvent event) { if (event instanceof ClusterMembershipChangeEvent) { return doFormat((ClusterMembershipChangeEvent) event); } if (event instanceof LeaderElectionChangeEvent) { return doFormat((LeaderElectionChangeEvent) event); } return null; }
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; } }
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; }  }
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; }   }
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; }    }