@Test
  public void openLoadsWalletIfWalletIsNotOpened() {
    // Arrange:
    final TestContext context = new TestContext();

    // Act:
    final Wallet wallet = context.walletServices.open(context.pair);

    // Assert:
    Assert.assertThat(wallet.getName(), IsEqual.equalTo(context.originalWallet.getName()));
    Assert.assertThat(
        context.walletServices.getOpenWalletNames(),
        IsEquivalent.equivalentTo(Collections.singletonList(context.originalWallet.getName())));
    Mockito.verify(context.descriptorFactory, Mockito.times(1))
        .openExisting(context.pair, FILE_EXTENSION);
    Mockito.verify(context.repository, Mockito.times(1)).load(context.descriptor);
  }
  @Test
  public void closeRemovesWalletFromOpenedList() {
    // Arrange:
    final TestContext context = new TestContext();

    // Act:
    context.walletServices.open(context.pair);
    context.walletServices.close(context.pair.getName());

    // Assert:
    Assert.assertThat(
        context.walletServices.getOpenWalletNames(),
        IsEquivalent.equivalentTo(new WalletName[] {}));
    Mockito.verify(context.descriptorFactory, Mockito.times(1))
        .openExisting(context.pair, FILE_EXTENSION);
    Mockito.verify(context.repository, Mockito.times(1)).load(context.descriptor);
  }
  @Test
  public void renamedWalletPreservesAccountInformation() {
    // Arrange:
    final WalletNamePasswordPair pair2 = createPair("n2", "p");
    final WalletDescriptor descriptor2 = createDescriptor("n2");
    final TestContext context = new TestContext();
    context.originalWallet.addOtherAccount(new WalletAccount());
    context.originalWallet.addOtherAccount(new WalletAccount());
    Mockito.when(context.descriptorFactory.createNew(pair2, FILE_EXTENSION))
        .thenReturn(descriptor2);

    // Act:
    context.walletServices.open(context.pair);
    context.walletServices.move(context.pair, pair2);

    // Assert:
    final Wallet updatedWallet = context.walletServices.get(new WalletName("n2"));
    Assert.assertThat(
        updatedWallet.getPrimaryAccount(),
        IsEqual.equalTo(context.originalWallet.getPrimaryAccount()));
    Assert.assertThat(
        updatedWallet.getOtherAccounts(),
        IsEquivalent.equivalentTo(context.originalWallet.getOtherAccounts()));
  }