public void testBatch() { AuState aus = new AuState(mau, historyRepo); assertEquals(0, historyRepo.getAuStateStoreCount()); aus.setNumAgreePeersLastPoR(1); aus.setNumWillingRepairers(3); aus.setNumCurrentSuspectVersions(5); assertEquals(3, historyRepo.getAuStateStoreCount()); aus.batchSaves(); aus.setNumAgreePeersLastPoR(2); aus.setNumWillingRepairers(4); aus.setNumCurrentSuspectVersions(6); assertEquals(3, historyRepo.getAuStateStoreCount()); aus.unBatchSaves(); assertEquals(4, historyRepo.getAuStateStoreCount()); aus.batchSaves(); aus.setNumAgreePeersLastPoR(4); aus.batchSaves(); aus.setNumWillingRepairers(8); aus.setNumCurrentSuspectVersions(12); assertEquals(4, historyRepo.getAuStateStoreCount()); aus.unBatchSaves(); assertEquals(4, historyRepo.getAuStateStoreCount()); aus.unBatchSaves(); assertEquals(5, historyRepo.getAuStateStoreCount()); }
public void testNumCurrentSuspectVersions() { MyMockLockssRepository repo = new MyMockLockssRepository(); MyAuSuspectUrlVersions asuv = new MyAuSuspectUrlVersions(); repo.setAsuv(asuv); daemon.setLockssRepository(repo, mau); AuState aus = new AuState(mau, historyRepo); assertEquals(0, aus.getNumCurrentSuspectVersions()); // ensure this isn't automatically recomputed, as that would happen // when historyRepo loads the object during startAuManagers, before the // AU is fully created. aus.setNumCurrentSuspectVersions(-1); assertEquals(-1, aus.getNumCurrentSuspectVersions()); asuv.setCountResult(17); aus.recomputeNumCurrentSuspectVersions(); assertEquals(17, aus.getNumCurrentSuspectVersions()); aus.incrementNumCurrentSuspectVersions(-1); assertEquals(16, aus.getNumCurrentSuspectVersions()); aus.setNumCurrentSuspectVersions(-1); asuv.setCountResult(6); aus.incrementNumCurrentSuspectVersions(-1); assertEquals(5, aus.getNumCurrentSuspectVersions()); }