mirror of
https://codeberg.org/Mercury-IM/Mercury-IM
synced 2024-06-15 16:14:52 +02:00
82 lines
2.1 KiB
Java
82 lines
2.1 KiB
Java
package org.mercury_im.messenger.data.repository;
|
|
|
|
import org.junit.Test;
|
|
import org.mercury_im.messenger.data.di.DaggerInMemoryDatabaseComponent;
|
|
import org.mercury_im.messenger.data.di.InMemoryDatabaseComponent;
|
|
import org.mercury_im.messenger.entity.Account;
|
|
import org.mercury_im.messenger.entity.IAccount;
|
|
|
|
import javax.inject.Inject;
|
|
|
|
import io.reactivex.disposables.CompositeDisposable;
|
|
import io.requery.Persistable;
|
|
import io.requery.reactivex.ReactiveEntityStore;
|
|
|
|
public class AccountRepositoryTest {
|
|
|
|
@Inject
|
|
ReactiveEntityStore<Persistable> dataStore;
|
|
|
|
@Inject
|
|
XmppAccountRepository accountRepository;
|
|
|
|
@Inject
|
|
XmppDirectChatRepository directChatRepository;
|
|
|
|
@Inject
|
|
XmppPeerRepository contactRepository;
|
|
|
|
@Inject
|
|
XmppMessageRepository messageRepository;
|
|
|
|
@Inject
|
|
public AccountRepositoryTest() {
|
|
InMemoryDatabaseComponent testComponent = DaggerInMemoryDatabaseComponent.builder()
|
|
.build();
|
|
testComponent.inject(this);
|
|
}
|
|
|
|
@Test
|
|
public void test() throws InterruptedException {
|
|
CompositeDisposable d = new CompositeDisposable();
|
|
d.add(accountRepository.observeAccounts()
|
|
.distinct(Account::getId)
|
|
.subscribe(a -> System.out.println("Observe: " + a.getAddress())));
|
|
|
|
Thread.sleep(100);
|
|
|
|
Account a1 = new IAccount();
|
|
a1.setAddress("a1@example.com");
|
|
a1.setPassword("a1a1a1");
|
|
a1.setEnabled(true);
|
|
|
|
d.add(accountRepository.insertAccount(a1).subscribe());
|
|
|
|
Thread.sleep(100);
|
|
|
|
Account a2 = new IAccount();
|
|
a2.setAddress("a2@example.com");
|
|
a2.setPassword("a2a2a2");
|
|
a2.setEnabled(false);
|
|
|
|
d.add(accountRepository.insertAccount(a2).subscribe());
|
|
|
|
Thread.sleep(100);
|
|
|
|
Account a3 = new IAccount();
|
|
a3.setAddress("a3@example.com");
|
|
a3.setPassword("a3a3a3");
|
|
a3.setEnabled(false);
|
|
|
|
d.add(accountRepository.insertAccount(a3).subscribe());
|
|
|
|
Thread.sleep(100);
|
|
|
|
a1.setAddress("a11@example.org");
|
|
|
|
d.add(accountRepository.updateAccount(a1).subscribe());
|
|
|
|
Thread.sleep(100);
|
|
}
|
|
}
|