void () { final Pair<ConsentOptions, MemoryIOBackend> data = createConsentOptions("", JSON_CONSENTS_DATA); final ConsentOptions options = data.getFirst(); final MemoryIOBackend storage = data.getSecond(); final Pair<List<Consent>, Boolean> beforeConfirm = options.getConsents(); assertTrue("Consents should require confirmation", beforeConfirm.getSecond()); assertEquals(2, beforeConfirm.getFirst().size()); checkStorage(storage, JSON_CONSENTS_DATA, "", ""); final Consent consentBeforeUpgrade = lookupConsent(CONSENT_ID_1, beforeConfirm.getFirst()); assertNotNull(consentBeforeUpgrade); assertEquals(Version.fromString("1.0"), consentBeforeUpgrade.getVersion()); options.setConsents(beforeConfirm.getFirst()); final Pair<List<Consent>, Boolean> afterConfirm = options.getConsents(); assertFalse("Consents should NOT require confirmation", afterConfirm.getSecond()); assertEquals(2, afterConfirm.getFirst().size()); assertEquals(JSON_CONSENTS_DATA, storage.myBundled); assertEquals("", storage.myDefaults); assertFalse("The storage should contain non-empty confirmed consents", StringUtil.isEmpty(storage.myConfirmed)); options.applyServerUpdates(JSON_MINOR_UPGRADE_CONSENTS_DATA); final Pair<List<Consent>, Boolean> afterUpdate = options.getConsents(); assertFalse("Consents should NOT require confirmation", afterUpdate.getSecond()); assertEquals(2, afterUpdate.getFirst().size()); assertEquals(JSON_CONSENTS_DATA, storage.myBundled); assertFalse("The storage should contain non-empty default consents", StringUtil.isEmpty(storage.myDefaults)); assertFalse("The storage should contain non-empty confirmed consents", StringUtil.isEmpty(storage.myConfirmed)); final Consent consentAfterUpgrade = lookupConsent(CONSENT_ID_1, afterUpdate.getFirst()); assertNotNull(consentAfterUpgrade); assertEquals(Version.fromString("1.5"), consentAfterUpgrade.getVersion()); }