### Question:
IbftMiningCoordinator implements MiningCoordinator, BlockAddedObserver { @Override public void onBlockAdded(final BlockAddedEvent event) { if (event.isNewCanonicalHead()) { LOG.trace("New canonical head detected"); eventQueue.add(new NewChainHead(event.getBlock().getHeader())); } } IbftMiningCoordinator(
      final IbftExecutors ibftExecutors,
      final IbftController controller,
      final IbftProcessor ibftProcessor,
      final IbftBlockCreatorFactory blockCreatorFactory,
      final Blockchain blockchain,
      final IbftEventQueue eventQueue); @Override void start(); @Override void stop(); @Override void awaitStop(); @Override boolean enable(); @Override boolean disable(); @Override boolean isMining(); @Override Wei getMinTransactionGasPrice(); @Override void setExtraData(final Bytes extraData); @Override Optional<Address> getCoinbase(); @Override Optional<Block> createBlock(
      final BlockHeader parentHeader,
      final List<Transaction> transactions,
      final List<BlockHeader> ommers); @Override void onBlockAdded(final BlockAddedEvent event);  }### Answer:
@Test public void addsNewChainHeadEventWhenNewCanonicalHeadBlockEventReceived() throws Exception { BlockAddedEvent headAdvancement = BlockAddedEvent.createForHeadAdvancement( block, Collections.emptyList(), Collections.emptyList()); ibftMiningCoordinator.onBlockAdded(headAdvancement); assertThat(eventQueue.size()).isEqualTo(1); final NewChainHead ibftEvent = (NewChainHead) eventQueue.poll(1, TimeUnit.SECONDS); assertThat(ibftEvent.getNewChainHeadHeader()).isEqualTo(blockHeader); }
@Test public void doesntAddNewChainHeadEventWhenNotACanonicalHeadBlockEvent() { final BlockAddedEvent fork = BlockAddedEvent.createForFork(block); ibftMiningCoordinator.onBlockAdded(fork); assertThat(eventQueue.isEmpty()).isTrue(); }