Assert that we have a local update

This commit is contained in:
Daniel Lublin
2022-05-16 10:05:15 +02:00
parent 84afc6d934
commit d2728dd29b
3 changed files with 7 additions and 27 deletions

View File

@@ -57,7 +57,6 @@ public interface MailboxPropertyManager {
*/
String MSG_KEY_LOCAL = "local";
@Nullable
MailboxPropertiesUpdate getLocalProperties(Transaction txn, ContactId c)
throws DbException;

View File

@@ -180,10 +180,15 @@ class MailboxPropertyManagerImpl implements MailboxPropertyManager,
}
@Override
@Nullable
public MailboxPropertiesUpdate getLocalProperties(Transaction txn,
ContactId c) throws DbException {
return getProperties(txn, db.getContact(txn, c), true);
MailboxPropertiesUpdate local =
getProperties(txn, db.getContact(txn, c), true);
// An update (with or without mailbox) is created when contact is added
if (local == null) {
throw new DbException();
}
return local;
}
@Override

View File

@@ -673,30 +673,6 @@ public class MailboxPropertyManagerImplTest extends BrambleMockTestCase {
assertTrue(mailboxPropertiesUpdateEqual(local, updateMailbox));
}
@Test
public void testGetLocalPropertiesReturnsNullBecauseNoUpdate()
throws Exception {
Transaction txn = new Transaction(null, false);
Contact contact = getContact();
Group contactGroup = getGroup(CLIENT_ID, MAJOR_VERSION);
Map<MessageId, BdfDictionary> emptyMessageMetadata =
new LinkedHashMap<>();
context.checking(new Expectations() {{
oneOf(db).getContact(txn, contact.getId());
will(returnValue(contact));
oneOf(contactGroupFactory).createContactGroup(CLIENT_ID,
MAJOR_VERSION, contact);
will(returnValue(contactGroup));
oneOf(clientHelper).getMessageMetadataAsDictionary(txn,
contactGroup.getId());
will(returnValue(emptyMessageMetadata));
}});
MailboxPropertyManagerImpl t = createInstance();
assertNull(t.getLocalProperties(txn, contact.getId()));
}
@Test
public void testGetLocalPropertiesNoMailbox()
throws Exception {