### Question:
RoleProcedure extends CallableProcedure.BasicProcedure { @Override public RawIterator<Object[],ProcedureException> apply( Context ctx, Object[] input, ResourceTracker resourceTracker ) { return RawIterator.<Object[],ProcedureException>of( new Object[]{role().name()} ); } RoleProcedure(); @Override RawIterator<Object[],ProcedureException> apply(
            Context ctx, Object[] input, ResourceTracker resourceTracker );  }### Answer:
@Test public void shouldReturnLeader() throws Exception { RaftMachine raft = mock( RaftMachine.class ); when( raft.isLeader() ).thenReturn( true ); RoleProcedure proc = new CoreRoleProcedure( raft ); RawIterator<Object[], ProcedureException> result = proc.apply( null, null, null ); assertEquals( RoleInfo.LEADER.name(), single( result )[0]); }
@Test public void shouldReturnFollower() throws Exception { RaftMachine raft = mock( RaftMachine.class ); when( raft.isLeader() ).thenReturn( false ); RoleProcedure proc = new CoreRoleProcedure( raft ); RawIterator<Object[], ProcedureException> result = proc.apply( null, null, null ); assertEquals( RoleInfo.FOLLOWER.name(), single( result )[0]); }
@Test public void shouldReturnReadReplica() throws Exception { RoleProcedure proc = new ReadReplicaRoleProcedure(); RawIterator<Object[], ProcedureException> result = proc.apply( null, null, null ); assertEquals( RoleInfo.READ_REPLICA.name(), single( result )[0]); }