mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-21 15:19:53 +01:00
Add AuthorManager#getMyAuthorInfo() without transaction
and add test for it
This commit is contained in:
@@ -19,6 +19,11 @@ public interface AuthorManager {
|
|||||||
*/
|
*/
|
||||||
AuthorInfo getAuthorInfo(Transaction txn, AuthorId a) throws DbException;
|
AuthorInfo getAuthorInfo(Transaction txn, AuthorId a) throws DbException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the {@link AuthorInfo} for the {@link LocalAuthor}.
|
||||||
|
*/
|
||||||
|
AuthorInfo getMyAuthorInfo() throws DbException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the {@link AuthorInfo} for the {@link LocalAuthor}.
|
* Returns the {@link AuthorInfo} for the {@link LocalAuthor}.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -59,6 +59,11 @@ class AuthorManagerImpl implements AuthorManager {
|
|||||||
else return new AuthorInfo(UNVERIFIED, c.getAlias(), avatar);
|
else return new AuthorInfo(UNVERIFIED, c.getAlias(), avatar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AuthorInfo getMyAuthorInfo() throws DbException {
|
||||||
|
return db.transactionWithResult(true, this::getMyAuthorInfo);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AuthorInfo getMyAuthorInfo(Transaction txn) throws DbException {
|
public AuthorInfo getMyAuthorInfo(Transaction txn) throws DbException {
|
||||||
AttachmentHeader avatar = avatarManager.getMyAvatarHeader(txn);
|
AttachmentHeader avatar = avatarManager.getMyAvatarHeader(txn);
|
||||||
|
|||||||
@@ -106,7 +106,6 @@ public class AuthorManagerImplTest extends BrambleMockTestCase {
|
|||||||
public void testGetAuthorInfoOurselves() throws DbException {
|
public void testGetAuthorInfoOurselves() throws DbException {
|
||||||
Transaction txn = new Transaction(null, true);
|
Transaction txn = new Transaction(null, true);
|
||||||
|
|
||||||
// check ourselves
|
|
||||||
context.checking(new Expectations() {{
|
context.checking(new Expectations() {{
|
||||||
oneOf(identityManager).getLocalAuthor(txn);
|
oneOf(identityManager).getLocalAuthor(txn);
|
||||||
will(returnValue(localAuthor));
|
will(returnValue(localAuthor));
|
||||||
@@ -122,6 +121,22 @@ public class AuthorManagerImplTest extends BrambleMockTestCase {
|
|||||||
assertEquals(avatarHeader, authorInfo.getAvatarHeader());
|
assertEquals(avatarHeader, authorInfo.getAvatarHeader());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetMyAuthorInfo() throws DbException {
|
||||||
|
Transaction txn = new Transaction(null, true);
|
||||||
|
|
||||||
|
context.checking(new Expectations() {{
|
||||||
|
oneOf(avatarManager).getMyAvatarHeader(txn);
|
||||||
|
will(returnValue(avatarHeader));
|
||||||
|
}});
|
||||||
|
|
||||||
|
AuthorInfo authorInfo =
|
||||||
|
authorManager.getMyAuthorInfo(txn);
|
||||||
|
assertEquals(OURSELVES, authorInfo.getStatus());
|
||||||
|
assertNull(authorInfo.getAlias());
|
||||||
|
assertEquals(avatarHeader, authorInfo.getAvatarHeader());
|
||||||
|
}
|
||||||
|
|
||||||
private void checkAuthorInfoContext(Transaction txn, AuthorId authorId,
|
private void checkAuthorInfoContext(Transaction txn, AuthorId authorId,
|
||||||
Collection<Contact> contacts) throws DbException {
|
Collection<Contact> contacts) throws DbException {
|
||||||
context.checking(new Expectations() {{
|
context.checking(new Expectations() {{
|
||||||
|
|||||||
Reference in New Issue
Block a user