@@ -0,0 +1,3051 @@
+package org.robotninjas.barge.state;%0A%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.mockito.Mock;%0Aimport org.mockito.MockitoAnnotations;%0Aimport org.robotninjas.barge.RaftException;%0A%0Aimport static junit.framework.Assert.assertEquals;%0Aimport static org.mockito.Mockito.*;%0Aimport static org.robotninjas.barge.proto.ClientProto.CommitOperation;%0Aimport static org.robotninjas.barge.proto.RaftProto.AppendEntries;%0Aimport static org.robotninjas.barge.proto.RaftProto.RequestVote;%0Aimport static org.robotninjas.barge.state.Context.StateType;%0A%0Apublic class DefaultContextTest %7B%0A%0A  private @Mock StateFactory mockStateFactory;%0A  private @Mock Leader mockLeader;%0A  private @Mock Follower mockFollower;%0A  private @Mock Candidate mockCandidate;%0A  private final AppendEntries appendEntries = AppendEntries.getDefaultInstance();%0A  private final RequestVote requestVote = RequestVote.getDefaultInstance();%0A  private final CommitOperation commitOperation = CommitOperation.getDefaultInstance();%0A%0A  @Before%0A  public void initMocks() %7B%0A%0A    MockitoAnnotations.initMocks(this);%0A%0A    when(mockStateFactory.candidate()).thenReturn(mockCandidate);%0A    when(mockStateFactory.leader()).thenReturn(mockLeader);%0A    when(mockStateFactory.follower()).thenReturn(mockFollower);%0A%0A  %7D%0A%0A  @Test%0A  public void testDefaultContext() throws RaftException %7B%0A%0A    DefaultContext ctx = new DefaultContext(mockStateFactory);%0A%0A    ctx.init();%0A    verify(mockFollower).init(ctx);%0A    assertEquals(StateType.FOLLOWER, ctx.getState());%0A%0A    ctx.appendEntries(appendEntries);%0A    verify(mockFollower).appendEntries(ctx, appendEntries);%0A    verifyNoMoreInteractions(mockFollower);%0A%0A    ctx.requestVote(requestVote);%0A    verify(mockFollower).requestVote(ctx, requestVote);%0A    verifyNoMoreInteractions(mockFollower);%0A%0A    ctx.commitOperation(commitOperation);%0A    verify(mockFollower).commitOperation(ctx, commitOperation);%0A    verifyNoMoreInteractions(mockFollower);%0A%0A%0A    ctx.setState(StateType.LEADER);%0A    verify(mockLeader).init(ctx);%0A    assertEquals(StateType.LEADER, ctx.getState());%0A%0A    ctx.appendEntries(appendEntries);%0A    verify(mockLeader).appendEntries(ctx, appendEntries);%0A    verifyNoMoreInteractions(mockLeader);%0A%0A    ctx.requestVote(requestVote);%0A    verify(mockLeader).requestVote(ctx, requestVote);%0A    verifyNoMoreInteractions(mockLeader);%0A%0A    ctx.commitOperation(commitOperation);%0A    verify(mockLeader).commitOperation(ctx, commitOperation);%0A    verifyNoMoreInteractions(mockLeader);%0A%0A%0A    ctx.setState(StateType.CANDIDATE);%0A    verify(mockCandidate).init(ctx);%0A    assertEquals(StateType.CANDIDATE, ctx.getState());%0A%0A    ctx.appendEntries(appendEntries);%0A    verify(mockCandidate).appendEntries(ctx, appendEntries);%0A    verifyNoMoreInteractions(mockCandidate);%0A%0A    ctx.requestVote(requestVote);%0A    verify(mockCandidate).requestVote(ctx, requestVote);%0A    verifyNoMoreInteractions(mockCandidate);%0A%0A    ctx.commitOperation(commitOperation);%0A    verify(mockCandidate).commitOperation(ctx, commitOperation);%0A    verifyNoMoreInteractions(mockCandidate);%0A%0A  %7D%0A%0A%7D%0A

Add DefaultContext tests