package org.opendaylight.controller.cluster.raft;
import static org.junit.Assert.assertEquals;
-import static org.mockito.Matchers.any;
import static org.mockito.Matchers.same;
-import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import akka.japi.Procedure;
-import com.google.common.base.Supplier;
import java.util.Collections;
+import java.util.function.Supplier;
import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
public void setup() {
MockitoAnnotations.initMocks(this);
- doNothing().when(mockPersistence).persist(any(Object.class), any(Procedure.class));
-
context = new RaftActorContextImpl(null, null, "test",
new ElectionTermImpl(mockPersistence, "test", LOG),
-1, -1, Collections.<String,String>emptyMap(), configParams, mockPersistence, LOG);
@SuppressWarnings("unchecked")
@Test
public void testAppendAndPersistExpectingNoCapture() throws Exception {
- ReplicatedLog log = ReplicatedLogImpl.newInstance(context, mockBehavior);
+ ReplicatedLog log = ReplicatedLogImpl.newInstance(context);
MockReplicatedLogEntry logEntry = new MockReplicatedLogEntry(1, 1, new MockPayload("1"));
reset(mockPersistence);
- doNothing().when(mockPersistence).persist(any(MockReplicatedLogEntry.class), any(Procedure.class));
-
Procedure<ReplicatedLogEntry> mockCallback = Mockito.mock(Procedure.class);
- doNothing().when(mockCallback).apply(logEntry);
log.appendAndPersist(logEntry, mockCallback);
verifyPersist(logEntry);
doReturn(1L).when(mockBehavior).getReplicatedToAllIndex();
- ReplicatedLog log = ReplicatedLogImpl.newInstance(context, mockBehavior);
+ ReplicatedLog log = ReplicatedLogImpl.newInstance(context);
MockReplicatedLogEntry logEntry1 = new MockReplicatedLogEntry(1, 2, new MockPayload("2"));
MockReplicatedLogEntry logEntry2 = new MockReplicatedLogEntry(1, 3, new MockPayload("3"));
reset(mockPersistence);
- doNothing().when(mockPersistence).persist(any(MockReplicatedLogEntry.class), any(Procedure.class));
-
log.appendAndPersist(logEntry2);
verifyPersist(logEntry2);
}
});
- ReplicatedLog log = ReplicatedLogImpl.newInstance(context, mockBehavior);
+ ReplicatedLog log = ReplicatedLogImpl.newInstance(context);
int dataSize = 600;
MockReplicatedLogEntry logEntry = new MockReplicatedLogEntry(1, 2, new MockPayload("2", dataSize));
reset(mockPersistence);
- doNothing().when(mockPersistence).persist(any(MockReplicatedLogEntry.class), any(Procedure.class));
-
logEntry = new MockReplicatedLogEntry(1, 3, new MockPayload("3", 5));
log.appendAndPersist(logEntry);
@Test
public void testRemoveFromAndPersist() throws Exception {
- ReplicatedLog log = ReplicatedLogImpl.newInstance(context, mockBehavior);
+ ReplicatedLog log = ReplicatedLogImpl.newInstance(context);
log.append(new MockReplicatedLogEntry(1, 0, new MockPayload("0")));
log.append(new MockReplicatedLogEntry(1, 1, new MockPayload("1")));