HupaStorage { public Promise gettingFolders() { return gettingFolders(false); } @Inject  HupaStorage(EventBus eventBus); Function waitingForLogin(); Promise gettingFolders(); Promise gettingFolders(final boolean skipCache); Promise gettingMessages(final boolean skipCache, final String folderFullName, final int start, final int offset, final String search); Promise gettingSettings(final boolean skipCache); void expireFolders(); Settings getSettingsByEmail(String email); void saveSettings(String email, Settings settings);  }
@Test public void testFolderList() { storage.gettingFolders().done(new Function() { public void f() { List<ImapFolder> folderNodes = arguments(0); Assert.assertEquals(4, folderNodes.size()); } }); Assert.assertEquals(5,cache.getLength()); cache.removeItem("Mock-Sent"); storage.gettingFolders().done(new Function() { public void f() { List<ImapFolder> folderNodes = arguments(0); Assert.assertEquals(3, folderNodes.size()); } }); cache.setExpires("fld", 0); Assert.assertEquals(0,cache.getLength()); storage.gettingFolders().done(new Function() { public void f() { List<ImapFolder> folderNodes = arguments(0); Assert.assertEquals(4, folderNodes.size()); } }); Assert.assertEquals(5,cache.getLength()); eventBus.fireEvent(new LoginEvent(testUser)); storage.gettingFolders().done(new Function() { public void f() { List<ImapFolder> folderNodes = arguments(0); Assert.assertEquals(4, folderNodes.size()); } }); Assert.assertEquals(10,cache.getLength()); }
@Test public void testEncrypt() { storage.gettingFolders().done(new Function() { public void f() { List<ImapFolder> folderNodes = arguments(0); Assert.assertEquals(4, folderNodes.size()); Assert.assertEquals(5,cache.getLength()); cache.storeProxiesCrypt("fld", folderNodes); Assert.assertEquals(5,cache.getLength()); folderNodes = cache.restoreProxiesCrypt(ImapFolder.class, "fld"); Assert.assertEquals(4, folderNodes.size()); folderNodes = cache.restoreProxies(ImapFolder.class, "fld"); Assert.assertEquals(0, folderNodes.size()); } }); }