Quellcode durchsuchen

Add real test for archived payment info for deleted user

tags/v0.10.5
Kristijan Mitrovic vor 4 Jahren
Ursprung
Commit
24ff1aa630
1 geänderte Dateien mit 35 neuen und 1 gelöschten Zeilen
  1. +35
    -1
      bubble-server/src/test/java/bubble/test/system/AccountDeletionTest.java

+ 35
- 1
bubble-server/src/test/java/bubble/test/system/AccountDeletionTest.java Datei anzeigen

@@ -4,9 +4,18 @@
*/
package bubble.test.system;

import bubble.dao.account.AccountDAO;
import bubble.model.bill.AccountPayment;
import bubble.model.bill.AccountPaymentMethod;
import bubble.model.bill.Bill;
import bubble.test.ActivatedBubbleModelTestBase;
import org.cobbzilla.wizard.model.HashedPassword;
import org.junit.Test;

import java.util.List;

import static org.junit.Assert.*;

public class AccountDeletionTest extends ActivatedBubbleModelTestBase {

@Override protected String getManifest() { return "manifest-test"; }
@@ -15,8 +24,33 @@ public class AccountDeletionTest extends ActivatedBubbleModelTestBase {
@Test public void testBlockAccountDeletion() throws Exception { modelTest("account_deletion/block_delete_account"); }

@Test public void testDeleteAccountWithPayments() throws Exception {
final var archivedInfoDAO = getBean(bubble.dao.bill.AccountPaymentArchivedDAO.class);
assertEquals("Starting database contains some archived payments", 0, archivedInfoDAO.countAll().intValue());

modelTest("account_deletion/delete_account_with_payments");

// TODO: Check if all payment data is archived for the deleted user
assertEquals("Archived payments record not created for deleted user", 1, archivedInfoDAO.countAll().intValue());

final var accountDAO = getBean(AccountDAO.class);
// there should be just 1 deleted account - finding it by corresponding hashed password value:
final var deletedAccount = accountDAO.findByUniqueField("hashedPassword", HashedPassword.DELETED);
// just in case:
assertTrue("Account found with 'deleted' password is not marked as deleted", deletedAccount.deleted());

final var archivedInfo = archivedInfoDAO.findByAccountUuid(deletedAccount.getUuid());
assertNotNull("Archived payment info not found for deleted user", archivedInfo);

final List<Bill> archivedBills = archivedInfo.getBills();
assertEquals("Only 1 bill should be in for deleted account", archivedBills.size());

final List<AccountPayment> archivedPayments = archivedInfo.getPayments();
assertEquals("Only 1 bill should be in for deleted account", archivedPayments.size());
assertEquals("Archived payment should be for archived bill",
archivedBills.get(0).getUuid(), archivedPayments.get(0).getBill());

final List<AccountPaymentMethod> archivedPaymentMethods = archivedInfo.getpaymentMethods();
assertEquals("Only 1 bill should be in for deleted account", archivedPaymentMethods.size());
assertEquals("Archived payment method should be for used within archived payment",
archivedPayments.get(0).getPaymentMethod(), archivedPaymentMethods.get(0).getUuid());
}
}

Laden…
Abbrechen
Speichern