### Question:
VoteTallyUpdater { public void updateForBlock(final BlockHeader header, final VoteTally voteTally) { if (epochManager.isEpochBlock(header.getNumber())) { voteTally.discardOutstandingVotes(); return; } final Optional<ValidatorVote> vote = blockInterface.extractVoteFromHeader(header); vote.ifPresent(voteTally::addVote); } VoteTallyUpdater(final EpochManager epochManager, final BlockInterface blockInterface); VoteTally buildVoteTallyFromBlockchain(final Blockchain blockchain); void updateForBlock(final BlockHeader header, final VoteTally voteTally);  }### Answer:
@Test public void voteTallyUpdatedWithAddVote() { when(serialiser.extractVoteFromHeader(any())) .thenReturn(Optional.of(new ValidatorVote(VoteType.ADD, proposerAddress, subject))); final BlockHeaderTestFixture headerBuilder = new BlockHeaderTestFixture(); headerBuilder.number(EPOCH_LENGTH - 1); final BlockHeader header = headerBuilder.buildHeader(); updater.updateForBlock(header, voteTally); verify(voteTally).addVote(new ValidatorVote(VoteType.ADD, proposerAddress, subject)); }
@Test public void voteTallyNotUpdatedWhenBlockHasNoVoteSubject() { when(serialiser.extractVoteFromHeader(any())).thenReturn(Optional.empty()); final BlockHeaderTestFixture headerBuilder = new BlockHeaderTestFixture(); headerBuilder.number(EPOCH_LENGTH - 1); final BlockHeader header = headerBuilder.buildHeader(); updater.updateForBlock(header, voteTally); verifyZeroInteractions(voteTally); }
@Test public void outstandingVotesDiscardedWhenEpochReached() { when(serialiser.extractVoteFromHeader(any())).thenReturn(Optional.empty()); final BlockHeaderTestFixture headerBuilder = new BlockHeaderTestFixture(); headerBuilder.number(EPOCH_LENGTH); final BlockHeader header = headerBuilder.buildHeader(); updater.updateForBlock(header, voteTally); verify(voteTally).discardOutstandingVotes(); verifyNoMoreInteractions(voteTally); }