mirror of
https://codeberg.org/Mercury-IM/Mercury-IM
synced 2024-06-18 09:34:52 +02:00
Test that uncovered the NPE fixed in last commit
This commit is contained in:
parent
6cb9ce5362
commit
86c16f32bf
|
@ -6,6 +6,10 @@ import org.mercury_im.messenger.data.di.InMemoryDatabaseComponent;
|
|||
import org.mercury_im.messenger.entity.Account;
|
||||
import org.mercury_im.messenger.entity.IAccount;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import io.reactivex.disposables.CompositeDisposable;
|
||||
|
@ -14,6 +18,8 @@ import io.requery.reactivex.ReactiveEntityStore;
|
|||
|
||||
public class AccountRepositoryTest {
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(AccountRepositoryTest.class.getName());
|
||||
|
||||
@Inject
|
||||
ReactiveEntityStore<Persistable> dataStore;
|
||||
|
||||
|
@ -78,4 +84,37 @@ public class AccountRepositoryTest {
|
|||
|
||||
Thread.sleep(100);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void observeDeletionTest() throws InterruptedException {
|
||||
CompositeDisposable d = new CompositeDisposable();
|
||||
|
||||
UUID uuid = UUID.randomUUID();
|
||||
d.add(accountRepository.observeAccount(uuid)
|
||||
.subscribe(optAccount -> {
|
||||
LOGGER.log(Level.INFO, "Changed");
|
||||
if (!optAccount.isPresent()) {
|
||||
LOGGER.log(Level.INFO, "Changed: Account " + uuid.toString() + " is not present.");
|
||||
} else {
|
||||
LOGGER.log(Level.INFO, "Changed: Account " + uuid.toString() + ": " + optAccount.getItem().toString());
|
||||
}
|
||||
}));
|
||||
|
||||
Account account = new IAccount(uuid);
|
||||
account.setEnabled(true);
|
||||
account.setAddress("hello@world");
|
||||
account.setPassword("wooooooh");
|
||||
|
||||
d.add(accountRepository.insertAccount(account)
|
||||
.subscribe(insert -> LOGGER.log(Level.INFO, "Inserted."),
|
||||
error -> LOGGER.log(Level.SEVERE, "Inserted", error)));
|
||||
|
||||
Thread.sleep(100);
|
||||
|
||||
d.add(accountRepository.deleteAccount(uuid)
|
||||
.subscribe(() -> LOGGER.log(Level.INFO, "Deleted")));
|
||||
|
||||
Thread.sleep(1000);
|
||||
d.dispose();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue