@SuppressWarnings({ "rawtypes", "unchecked" })

@Test
public void testUpdateAndPersist() throws Exception {
    ElectionTermImpl impl = new ElectionTermImpl(mockPersistence, "test", LOG);
    impl.updateAndPersist(10, "member-1");
    assertEquals("getCurrentTerm", 10, impl.getCurrentTerm());
    assertEquals("getVotedFor", "member-1", impl.getVotedFor());
    ArgumentCaptor<Object> message = ArgumentCaptor.forClass(Object.class);
    ArgumentCaptor<Procedure> procedure = ArgumentCaptor.forClass(Procedure.class);
    verify(mockPersistence).persist(message.capture(), procedure.capture());
    assertEquals("Message type", UpdateElectionTerm.class, message.getValue().getClass());
    UpdateElectionTerm update = (UpdateElectionTerm)message.getValue();
    assertEquals("getCurrentTerm", 10, update.getCurrentTerm());
    assertEquals("getVotedFor", "member-1", update.getVotedFor());
    procedure.getValue().apply(null);
}