DeleteSendingAddressAction extends MultiBitSubmitAction { @Override public void actionPerformed(ActionEvent e) { if (abort()) { return; } mainFrame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); setEnabled(false); try { DeleteSendingAddressConfirmDialog deleteSendingAddressConfirmDialog = new DeleteSendingAddressConfirmDialog(super.bitcoinController, mainFrame, sendBitcoinPanel); deleteSendingAddressConfirmDialog.setVisible(true); } finally { setEnabled(true); mainFrame.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } } DeleteSendingAddressAction(BitcoinController bitcoinController, MultiBitFrame mainFrame, SendBitcoinPanel sendBitcoinPanel); @Override void actionPerformed(ActionEvent e);  }
@Test public void testDeleteSendingAddress() throws Exception { final CreateControllers.Controllers controllers = CreateControllers.createControllers(); BitcoinController controller = controllers.bitcoinController; ActionTestUtils.createNewActiveWallet(controller, "testDeleteSendingAddress", false, null); ColorAndFontConstants.init(); FontSizer.INSTANCE.initialise(controller); SendBitcoinPanel sendBitcoinPanel = new SendBitcoinPanel(controller, null); DeleteSendingAddressSubmitAction deleteSubmitAction = new DeleteSendingAddressSubmitAction(controller, sendBitcoinPanel, null); assertNotNull("deleteSubmitAction was not created successfully", deleteSubmitAction); assertEquals("Wrong number of send addresses at beginning", 0, sendBitcoinPanel.getAddressesTableModel().getRowCount()); deleteSubmitAction.actionPerformed(null); assertEquals("Wrong number of send addresses after initial delete", 0, sendBitcoinPanel.getAddressesTableModel().getRowCount()); WalletData perWalletModelData = controller.getModel().getActivePerWalletModelData(); perWalletModelData.getWalletInfo().addSendingAddress(new WalletAddressBookData(LABEL1, ADDRESS1)); perWalletModelData.getWalletInfo().addSendingAddress(new WalletAddressBookData(LABEL2, ADDRESS2)); assertEquals("Wrong number of send addresses on wallet model after adding new send addresses", 2, perWalletModelData.getWalletInfo().getSendingAddresses().size()); assertEquals("Wrong number of send addresses on table after adding new send addresses", 2, sendBitcoinPanel.getAddressesTableModel().getRowCount()); sendBitcoinPanel.getAddressesTableModel().fireTableStructureChanged(); sendBitcoinPanel.getAddressesTable().setRowSelectionInterval(1,1); deleteSubmitAction.actionPerformed(null); assertEquals("Wrong number of send addresses on wallet model after deleting send address", 1, perWalletModelData.getWalletInfo().getSendingAddresses().size()); assertEquals("Wrong number of send addresses on table after deleting send address", 1, sendBitcoinPanel.getAddressesTableModel().getRowCount()); assertEquals("Wrong send address deleted", LABEL1, (String)sendBitcoinPanel.getAddressesTableModel().getValueAt(0, 0)); }