### Question:
BridgeStorageProvider { public void saveFederationElection() { if (federationElection == null) { return; } safeSaveToRepository(FEDERATION_ELECTION_KEY, federationElection, BridgeSerializationUtils::serializeElection); } BridgeStorageProvider(Repository repository, UscAddress contractAddress, BridgeConstants bridgeConstants, BridgeStorageConfiguration bridgeStorageConfiguration); List<UTXO> getNewFederationUldUTXOs(); void saveNewFederationUldUTXOs(); List<UTXO> getOldFederationUldUTXOs(); void saveOldFederationUldUTXOs(); Map<Sha256Hash, Long> getUldTxHashesAlreadyProcessed(); void saveUldTxHashesAlreadyProcessed(); ReleaseRequestQueue getReleaseRequestQueue(); void saveReleaseRequestQueue(); ReleaseTransactionSet getReleaseTransactionSet(); void saveReleaseTransactionSet(); SortedMap<Keccak256, UldTransaction> getUscTxsWaitingForSignatures(); void saveUscTxsWaitingForSignatures(); Federation getNewFederation(); void setNewFederation(Federation federation); void saveNewFederation(); Federation getOldFederation(); void setOldFederation(Federation federation); void saveOldFederation(); PendingFederation getPendingFederation(); void setPendingFederation(PendingFederation federation); void savePendingFederation(); void saveFederationElection(); ABICallElection getFederationElection(AddressBasedAuthorizer authorizer); void saveLockWhitelist(); LockWhitelist getLockWhitelist(); Coin getFeePerKb(); void setFeePerKb(Coin feePerKb); void saveFeePerKb(); void saveFeePerKbElection(); ABICallElection getFeePerKbElection(AddressBasedAuthorizer authorizer); void save();  }### Answer:
@Test public void saveFederationElection() throws IOException { ABICallElection electionMock = mock(ABICallElection.class); List<Integer> storageBytesCalls = new ArrayList<>(); List<Integer> serializeCalls = new ArrayList<>(); PowerMockito.mockStatic(BridgeSerializationUtils.class); Repository repositoryMock = mock(Repository.class); BridgeStorageProvider storageProvider = new BridgeStorageProvider(repositoryMock, mockAddress("aabbccdd"), config.getBlockchainConfig().getCommonConstants().getBridgeConstants(), bridgeStorageConfigurationAtHeightZero); PowerMockito.when(BridgeSerializationUtils.serializeElection(any(ABICallElection.class))).then((InvocationOnMock invocation) -> { ABICallElection election = invocation.getArgumentAt(0, ABICallElection.class); Assert.assertSame(electionMock, election); serializeCalls.add(0); return Hex.decode("aabb"); }); Mockito.doAnswer((InvocationOnMock invocation) -> { storageBytesCalls.add(0); UscAddress contractAddress = invocation.getArgumentAt(0, UscAddress.class); DataWord address = invocation.getArgumentAt(1, DataWord.class); byte[] data = invocation.getArgumentAt(2, byte[].class); Assert.assertTrue(Arrays.equals(new byte[]{(byte)0xaa, (byte)0xbb, (byte)0xcc, (byte)0xdd}, contractAddress.getBytes())); Assert.assertEquals(new DataWord("federationElection".getBytes(StandardCharsets.UTF_8)), address); Assert.assertTrue(Arrays.equals(Hex.decode("aabb"), data)); return null; }).when(repositoryMock).addStorageBytes(any(UscAddress.class), any(DataWord.class), any(byte[].class)); storageProvider.saveFederationElection(); Assert.assertEquals(0, storageBytesCalls.size()); Assert.assertEquals(0, serializeCalls.size()); Whitebox.setInternalState(storageProvider, "federationElection", electionMock); storageProvider.saveFederationElection(); Assert.assertEquals(1, storageBytesCalls.size()); Assert.assertEquals(1, serializeCalls.size()); }