### Question:
FederationSupport { public Federation getActiveFederation() { switch (getActiveFederationReference()) { case NEW: return provider.getNewFederation(); case OLD: return provider.getOldFederation(); case GENESIS: default: return bridgeConstants.getGenesisFederation(); } } FederationSupport(BridgeStorageProvider provider, BridgeConstants bridgeConstants, Block executionBlock); int getFederationSize(); byte[] getFederatorPublicKey(int index); Federation getActiveFederation(); @Nullable Federation getRetiringFederation(); List<UTXO> getActiveFederationUldUTXOs(); List<UTXO> getRetiringFederationUldUTXOs(); boolean amAwaitingFederationActivation();  }### Answer:
@Test public void whenNewFederationIsNullThenActiveFederationIsGenesisFederation() { Federation genesisFederation = mock(Federation.class); when(provider.getNewFederation()) .thenReturn(null); when(bridgeConstants.getGenesisFederation()) .thenReturn(genesisFederation); assertThat(federationSupport.getActiveFederation(), is(genesisFederation)); }
@Test public void whenOldFederationIsNullThenActiveFederationIsNewFederation() { Federation newFederation = mock(Federation.class); when(provider.getNewFederation()) .thenReturn(newFederation); when(provider.getOldFederation()) .thenReturn(null); assertThat(federationSupport.getActiveFederation(), is(newFederation)); }
@Test public void whenOldAndNewFederationArePresentReturnOldFederationByActivationAge() { Federation newFederation = mock(Federation.class); Federation oldFederation = mock(Federation.class); when(provider.getNewFederation()) .thenReturn(newFederation); when(provider.getOldFederation()) .thenReturn(oldFederation); when(executionBlock.getNumber()) .thenReturn(80L); when(bridgeConstants.getFederationActivationAge()) .thenReturn(10L); when(newFederation.getCreationBlockNumber()) .thenReturn(75L); assertThat(federationSupport.getActiveFederation(), is(oldFederation)); }
@Test public void whenOldAndNewFederationArePresentReturnNewFederationByActivationAge() { Federation newFederation = mock(Federation.class); Federation oldFederation = mock(Federation.class); when(provider.getNewFederation()) .thenReturn(newFederation); when(provider.getOldFederation()) .thenReturn(oldFederation); when(executionBlock.getNumber()) .thenReturn(80L); when(bridgeConstants.getFederationActivationAge()) .thenReturn(10L); when(newFederation.getCreationBlockNumber()) .thenReturn(65L); assertThat(federationSupport.getActiveFederation(), is(newFederation)); }