mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-17 21:29:54 +01:00
Reformat code.
This commit is contained in:
@@ -144,8 +144,8 @@ class ClientHelperImpl implements ClientHelper {
|
|||||||
@Override
|
@Override
|
||||||
public BdfDictionary getMessageMetadataAsDictionary(MessageId m)
|
public BdfDictionary getMessageMetadataAsDictionary(MessageId m)
|
||||||
throws DbException, FormatException {
|
throws DbException, FormatException {
|
||||||
return db.transactionWithResult(true,
|
return db.transactionWithResult(true, txn ->
|
||||||
txn -> getMessageMetadataAsDictionary(txn, m));
|
getMessageMetadataAsDictionary(txn, m));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -158,8 +158,8 @@ class ClientHelperImpl implements ClientHelper {
|
|||||||
@Override
|
@Override
|
||||||
public Map<MessageId, BdfDictionary> getMessageMetadataAsDictionary(
|
public Map<MessageId, BdfDictionary> getMessageMetadataAsDictionary(
|
||||||
GroupId g) throws DbException, FormatException {
|
GroupId g) throws DbException, FormatException {
|
||||||
return db.transactionWithResult(true,
|
return db.transactionWithResult(true, txn ->
|
||||||
txn -> getMessageMetadataAsDictionary(txn, g));
|
getMessageMetadataAsDictionary(txn, g));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -176,8 +176,8 @@ class ClientHelperImpl implements ClientHelper {
|
|||||||
public Map<MessageId, BdfDictionary> getMessageMetadataAsDictionary(
|
public Map<MessageId, BdfDictionary> getMessageMetadataAsDictionary(
|
||||||
GroupId g, BdfDictionary query) throws DbException,
|
GroupId g, BdfDictionary query) throws DbException,
|
||||||
FormatException {
|
FormatException {
|
||||||
return db.transactionWithResult(true,
|
return db.transactionWithResult(true, txn ->
|
||||||
txn -> getMessageMetadataAsDictionary(txn, g, query));
|
getMessageMetadataAsDictionary(txn, g, query));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -79,8 +79,8 @@ class ContactManagerImpl implements ContactManager {
|
|||||||
public ContactId addContact(Author remote, AuthorId local, SecretKey master,
|
public ContactId addContact(Author remote, AuthorId local, SecretKey master,
|
||||||
long timestamp, boolean alice, boolean verified, boolean active)
|
long timestamp, boolean alice, boolean verified, boolean active)
|
||||||
throws DbException {
|
throws DbException {
|
||||||
return db.transactionWithResult(false,
|
return db.transactionWithResult(false, txn ->
|
||||||
txn -> addContact(txn, remote, local, master, timestamp, alice,
|
addContact(txn, remote, local, master, timestamp, alice,
|
||||||
verified, active));
|
verified, active));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,8 +92,8 @@ class ContactManagerImpl implements ContactManager {
|
|||||||
@Override
|
@Override
|
||||||
public Contact getContact(AuthorId remoteAuthorId, AuthorId localAuthorId)
|
public Contact getContact(AuthorId remoteAuthorId, AuthorId localAuthorId)
|
||||||
throws DbException {
|
throws DbException {
|
||||||
return db.transactionWithResult(true,
|
return db.transactionWithResult(true, txn ->
|
||||||
txn -> getContact(txn, remoteAuthorId, localAuthorId));
|
getContact(txn, remoteAuthorId, localAuthorId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -155,8 +155,8 @@ class ContactManagerImpl implements ContactManager {
|
|||||||
@Override
|
@Override
|
||||||
public boolean contactExists(AuthorId remoteAuthorId,
|
public boolean contactExists(AuthorId remoteAuthorId,
|
||||||
AuthorId localAuthorId) throws DbException {
|
AuthorId localAuthorId) throws DbException {
|
||||||
return db.transactionWithResult(true,
|
return db.transactionWithResult(true, txn ->
|
||||||
txn -> contactExists(txn, remoteAuthorId, localAuthorId));
|
contactExists(txn, remoteAuthorId, localAuthorId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -218,8 +218,8 @@ class TransportPropertyManagerImpl implements TransportPropertyManager,
|
|||||||
@Override
|
@Override
|
||||||
public TransportProperties getRemoteProperties(ContactId c, TransportId t)
|
public TransportProperties getRemoteProperties(ContactId c, TransportId t)
|
||||||
throws DbException {
|
throws DbException {
|
||||||
return db.transactionWithResult(true,
|
return db.transactionWithResult(true, txn ->
|
||||||
txn -> getRemoteProperties(txn, db.getContact(txn, c), t));
|
getRemoteProperties(txn, db.getContact(txn, c), t));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ class SettingsManagerImpl implements SettingsManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Settings getSettings(String namespace) throws DbException {
|
public Settings getSettings(String namespace) throws DbException {
|
||||||
return db.transactionWithResult(true,
|
return db.transactionWithResult(true, txn ->
|
||||||
txn -> db.getSettings(txn, namespace));
|
db.getSettings(txn, namespace));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -230,8 +230,8 @@ class DuplexOutgoingSession implements SyncSession, EventListener {
|
|||||||
if (interrupted) return;
|
if (interrupted) return;
|
||||||
if (!generateAckQueued.getAndSet(false)) throw new AssertionError();
|
if (!generateAckQueued.getAndSet(false)) throw new AssertionError();
|
||||||
try {
|
try {
|
||||||
Maybe<Ack> a = db.transactionWithResult(false,
|
Maybe<Ack> a = db.transactionWithResult(false, txn ->
|
||||||
txn -> new Maybe<>(db.generateAck(txn, contactId,
|
new Maybe<>(db.generateAck(txn, contactId,
|
||||||
MAX_MESSAGE_IDS)));
|
MAX_MESSAGE_IDS)));
|
||||||
if (LOG.isLoggable(INFO))
|
if (LOG.isLoggable(INFO))
|
||||||
LOG.info("Generated ack: " + a.isPresent());
|
LOG.info("Generated ack: " + a.isPresent());
|
||||||
@@ -357,8 +357,8 @@ class DuplexOutgoingSession implements SyncSession, EventListener {
|
|||||||
if (!generateRequestQueued.getAndSet(false))
|
if (!generateRequestQueued.getAndSet(false))
|
||||||
throw new AssertionError();
|
throw new AssertionError();
|
||||||
try {
|
try {
|
||||||
Maybe<Request> r = db.transactionWithResult(false,
|
Maybe<Request> r = db.transactionWithResult(false, txn ->
|
||||||
txn -> new Maybe<>(db.generateRequest(txn, contactId,
|
new Maybe<>(db.generateRequest(txn, contactId,
|
||||||
MAX_MESSAGE_IDS)));
|
MAX_MESSAGE_IDS)));
|
||||||
if (LOG.isLoggable(INFO))
|
if (LOG.isLoggable(INFO))
|
||||||
LOG.info("Generated request: " + r.isPresent());
|
LOG.info("Generated request: " + r.isPresent());
|
||||||
|
|||||||
@@ -119,8 +119,8 @@ class IncomingSession implements SyncSession, EventListener {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
db.transaction(false,
|
db.transaction(false, txn ->
|
||||||
txn -> db.receiveAck(txn, contactId, ack));
|
db.receiveAck(txn, contactId, ack));
|
||||||
} catch (DbException e) {
|
} catch (DbException e) {
|
||||||
logException(LOG, WARNING, e);
|
logException(LOG, WARNING, e);
|
||||||
interrupt();
|
interrupt();
|
||||||
@@ -140,8 +140,8 @@ class IncomingSession implements SyncSession, EventListener {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
db.transaction(false,
|
db.transaction(false, txn ->
|
||||||
txn -> db.receiveMessage(txn, contactId, message));
|
db.receiveMessage(txn, contactId, message));
|
||||||
} catch (DbException e) {
|
} catch (DbException e) {
|
||||||
logException(LOG, WARNING, e);
|
logException(LOG, WARNING, e);
|
||||||
interrupt();
|
interrupt();
|
||||||
@@ -161,8 +161,8 @@ class IncomingSession implements SyncSession, EventListener {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
db.transaction(false,
|
db.transaction(false, txn ->
|
||||||
txn -> db.receiveOffer(txn, contactId, offer));
|
db.receiveOffer(txn, contactId, offer));
|
||||||
} catch (DbException e) {
|
} catch (DbException e) {
|
||||||
logException(LOG, WARNING, e);
|
logException(LOG, WARNING, e);
|
||||||
interrupt();
|
interrupt();
|
||||||
@@ -182,8 +182,8 @@ class IncomingSession implements SyncSession, EventListener {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
db.transaction(false,
|
db.transaction(false, txn ->
|
||||||
txn -> db.receiveRequest(txn, contactId, request));
|
db.receiveRequest(txn, contactId, request));
|
||||||
} catch (DbException e) {
|
} catch (DbException e) {
|
||||||
logException(LOG, WARNING, e);
|
logException(LOG, WARNING, e);
|
||||||
interrupt();
|
interrupt();
|
||||||
|
|||||||
@@ -129,8 +129,8 @@ class SimplexOutgoingSession implements SyncSession, EventListener {
|
|||||||
public void run() {
|
public void run() {
|
||||||
if (interrupted) return;
|
if (interrupted) return;
|
||||||
try {
|
try {
|
||||||
Maybe<Ack> a = db.transactionWithResult(false,
|
Maybe<Ack> a = db.transactionWithResult(false, txn ->
|
||||||
txn -> new Maybe<>(db.generateAck(txn, contactId,
|
new Maybe<>(db.generateAck(txn, contactId,
|
||||||
MAX_MESSAGE_IDS)));
|
MAX_MESSAGE_IDS)));
|
||||||
if (LOG.isLoggable(INFO))
|
if (LOG.isLoggable(INFO))
|
||||||
LOG.info("Generated ack: " + a.isPresent());
|
LOG.info("Generated ack: " + a.isPresent());
|
||||||
|
|||||||
@@ -434,8 +434,8 @@ class ValidationManagerImpl implements ValidationManager, Service,
|
|||||||
@DatabaseExecutor
|
@DatabaseExecutor
|
||||||
private void loadGroupAndValidate(Message m) {
|
private void loadGroupAndValidate(Message m) {
|
||||||
try {
|
try {
|
||||||
Group g = db.transactionWithResult(true,
|
Group g = db.transactionWithResult(true, txn ->
|
||||||
txn -> db.getGroup(txn, m.getGroupId()));
|
db.getGroup(txn, m.getGroupId()));
|
||||||
validateMessageAsync(m, g);
|
validateMessageAsync(m, g);
|
||||||
} catch (NoSuchGroupException e) {
|
} catch (NoSuchGroupException e) {
|
||||||
LOG.info("Group removed before validation");
|
LOG.info("Group removed before validation");
|
||||||
|
|||||||
@@ -137,8 +137,8 @@ class KeyManagerImpl implements KeyManager, Service, EventListener {
|
|||||||
if (LOG.isLoggable(INFO)) LOG.info("No key manager for " + t);
|
if (LOG.isLoggable(INFO)) LOG.info("No key manager for " + t);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return db.transactionWithResult(false,
|
return db.transactionWithResult(false, txn ->
|
||||||
txn -> m.getStreamContext(txn, c));
|
m.getStreamContext(txn, c));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -149,8 +149,8 @@ class KeyManagerImpl implements KeyManager, Service, EventListener {
|
|||||||
if (LOG.isLoggable(INFO)) LOG.info("No key manager for " + t);
|
if (LOG.isLoggable(INFO)) LOG.info("No key manager for " + t);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return db.transactionWithResult(false,
|
return db.transactionWithResult(false, txn ->
|
||||||
txn -> m.getStreamContext(txn, tag));
|
m.getStreamContext(txn, tag));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -303,17 +303,17 @@ public class IntroductionIntegrationTest
|
|||||||
.getMessageHeaders(txn, contactId1From0));
|
.getMessageHeaders(txn, contactId1From0));
|
||||||
assertEquals(2, messages.size());
|
assertEquals(2, messages.size());
|
||||||
assertGroupCount(messageTracker0, g1.getId(), 2, 1);
|
assertGroupCount(messageTracker0, g1.getId(), 2, 1);
|
||||||
messages = db0.transactionWithResult(true,
|
messages = db0.transactionWithResult(true, txn ->
|
||||||
txn -> introductionManager0.getMessageHeaders(txn, contactId2From0));
|
introductionManager0.getMessageHeaders(txn, contactId2From0));
|
||||||
assertEquals(2, messages.size());
|
assertEquals(2, messages.size());
|
||||||
assertGroupCount(messageTracker0, g2.getId(), 2, 1);
|
assertGroupCount(messageTracker0, g2.getId(), 2, 1);
|
||||||
messages = db1.transactionWithResult(true,
|
messages = db1.transactionWithResult(true, txn ->
|
||||||
txn -> introductionManager1.getMessageHeaders(txn, contactId0From1));
|
introductionManager1.getMessageHeaders(txn, contactId0From1));
|
||||||
assertEquals(2, messages.size());
|
assertEquals(2, messages.size());
|
||||||
assertGroupCount(messageTracker1, g1.getId(), 2, 1);
|
assertGroupCount(messageTracker1, g1.getId(), 2, 1);
|
||||||
// introducee2 should also have the decline response of introducee1
|
// introducee2 should also have the decline response of introducee1
|
||||||
messages = db2.transactionWithResult(true,
|
messages = db2.transactionWithResult(true, txn ->
|
||||||
txn -> introductionManager2.getMessageHeaders(txn, contactId0From2));
|
introductionManager2.getMessageHeaders(txn, contactId0From2));
|
||||||
assertEquals(3, messages.size());
|
assertEquals(3, messages.size());
|
||||||
assertGroupCount(messageTracker2, g2.getId(), 3, 2);
|
assertGroupCount(messageTracker2, g2.getId(), 3, 2);
|
||||||
|
|
||||||
@@ -368,17 +368,14 @@ public class IntroductionIntegrationTest
|
|||||||
db0.transactionWithResult(true, txn -> introductionManager0
|
db0.transactionWithResult(true, txn -> introductionManager0
|
||||||
.getMessageHeaders(txn, contactId1From0));
|
.getMessageHeaders(txn, contactId1From0));
|
||||||
assertEquals(2, messages.size());
|
assertEquals(2, messages.size());
|
||||||
messages = db0.transactionWithResult(true,
|
messages = db0.transactionWithResult(true, txn ->
|
||||||
txn -> introductionManager0
|
introductionManager0.getMessageHeaders(txn, contactId2From0));
|
||||||
.getMessageHeaders(txn, contactId2From0));
|
|
||||||
assertEquals(2, messages.size());
|
assertEquals(2, messages.size());
|
||||||
messages = db1.transactionWithResult(true,
|
messages = db1.transactionWithResult(true, txn ->
|
||||||
txn -> introductionManager1
|
introductionManager1.getMessageHeaders(txn, contactId0From1));
|
||||||
.getMessageHeaders(txn, contactId0From1));
|
|
||||||
assertEquals(3, messages.size());
|
assertEquals(3, messages.size());
|
||||||
messages = db2.transactionWithResult(true,
|
messages = db2.transactionWithResult(true, txn ->
|
||||||
txn -> introductionManager2
|
introductionManager2.getMessageHeaders(txn, contactId0From2));
|
||||||
.getMessageHeaders(txn, contactId0From2));
|
|
||||||
assertEquals(3, messages.size());
|
assertEquals(3, messages.size());
|
||||||
assertFalse(listener0.aborted);
|
assertFalse(listener0.aborted);
|
||||||
assertFalse(listener1.aborted);
|
assertFalse(listener1.aborted);
|
||||||
@@ -525,20 +522,20 @@ public class IntroductionIntegrationTest
|
|||||||
|
|
||||||
Group g1 = introductionManager0.getContactGroup(introducee1);
|
Group g1 = introductionManager0.getContactGroup(introducee1);
|
||||||
Group g2 = introductionManager0.getContactGroup(introducee2);
|
Group g2 = introductionManager0.getContactGroup(introducee2);
|
||||||
assertEquals(2, db0.transactionWithResult(true,
|
assertEquals(2, db0.transactionWithResult(true, txn ->
|
||||||
txn -> introductionManager0.getMessageHeaders(txn, contactId1From0))
|
introductionManager0.getMessageHeaders(txn, contactId1From0))
|
||||||
.size());
|
.size());
|
||||||
assertGroupCount(messageTracker0, g1.getId(), 2, 1);
|
assertGroupCount(messageTracker0, g1.getId(), 2, 1);
|
||||||
assertEquals(2, db0.transactionWithResult(true,
|
assertEquals(2, db0.transactionWithResult(true, txn ->
|
||||||
txn -> introductionManager0.getMessageHeaders(txn, contactId2From0))
|
introductionManager0.getMessageHeaders(txn, contactId2From0))
|
||||||
.size());
|
.size());
|
||||||
assertGroupCount(messageTracker0, g2.getId(), 2, 1);
|
assertGroupCount(messageTracker0, g2.getId(), 2, 1);
|
||||||
assertEquals(3, db1.transactionWithResult(true,
|
assertEquals(3, db1.transactionWithResult(true, txn ->
|
||||||
txn -> introductionManager1.getMessageHeaders(txn, contactId0From1))
|
introductionManager1.getMessageHeaders(txn, contactId0From1))
|
||||||
.size());
|
.size());
|
||||||
assertGroupCount(messageTracker1, g1.getId(), 3, 2);
|
assertGroupCount(messageTracker1, g1.getId(), 3, 2);
|
||||||
assertEquals(3, db2.transactionWithResult(true,
|
assertEquals(3, db2.transactionWithResult(true, txn ->
|
||||||
txn -> introductionManager2.getMessageHeaders(txn, contactId0From2))
|
introductionManager2.getMessageHeaders(txn, contactId0From2))
|
||||||
.size());
|
.size());
|
||||||
assertGroupCount(messageTracker2, g2.getId(), 3, 2);
|
assertGroupCount(messageTracker2, g2.getId(), 3, 2);
|
||||||
|
|
||||||
@@ -563,8 +560,8 @@ public class IntroductionIntegrationTest
|
|||||||
assertFalse(listener1.requestReceived);
|
assertFalse(listener1.requestReceived);
|
||||||
|
|
||||||
// make really sure we don't have that request
|
// make really sure we don't have that request
|
||||||
assertTrue(db1.transactionWithResult(true,
|
assertTrue(db1.transactionWithResult(true, txn ->
|
||||||
txn -> introductionManager1.getMessageHeaders(txn, contactId0From1))
|
introductionManager1.getMessageHeaders(txn, contactId0From1))
|
||||||
.isEmpty());
|
.isEmpty());
|
||||||
|
|
||||||
// The message was invalid, so no abort message was sent
|
// The message was invalid, so no abort message was sent
|
||||||
@@ -1104,23 +1101,23 @@ public class IntroductionIntegrationTest
|
|||||||
|
|
||||||
private void assertDefaultUiMessages() throws DbException {
|
private void assertDefaultUiMessages() throws DbException {
|
||||||
Collection<ConversationMessageHeader> messages =
|
Collection<ConversationMessageHeader> messages =
|
||||||
db0.transactionWithResult(true, txn -> introductionManager0
|
db0.transactionWithResult(true, txn ->
|
||||||
.getMessageHeaders(txn, contactId1From0));
|
introductionManager0.getMessageHeaders(txn, contactId1From0));
|
||||||
assertEquals(2, messages.size());
|
assertEquals(2, messages.size());
|
||||||
assertMessagesAreAcked(messages);
|
assertMessagesAreAcked(messages);
|
||||||
|
|
||||||
messages = db0.transactionWithResult(true, txn -> introductionManager0
|
messages = db0.transactionWithResult(true, txn ->
|
||||||
.getMessageHeaders(txn, contactId2From0));
|
introductionManager0.getMessageHeaders(txn, contactId2From0));
|
||||||
assertEquals(2, messages.size());
|
assertEquals(2, messages.size());
|
||||||
assertMessagesAreAcked(messages);
|
assertMessagesAreAcked(messages);
|
||||||
|
|
||||||
messages = db1.transactionWithResult(true, txn -> introductionManager1
|
messages = db1.transactionWithResult(true, txn ->
|
||||||
.getMessageHeaders(txn, contactId0From1));
|
introductionManager1.getMessageHeaders(txn, contactId0From1));
|
||||||
assertEquals(2, messages.size());
|
assertEquals(2, messages.size());
|
||||||
assertMessagesAreAcked(messages);
|
assertMessagesAreAcked(messages);
|
||||||
|
|
||||||
messages = db2.transactionWithResult(true, txn -> introductionManager2
|
messages = db2.transactionWithResult(true, txn ->
|
||||||
.getMessageHeaders(txn, contactId0From2));
|
introductionManager2.getMessageHeaders(txn, contactId0From2));
|
||||||
assertEquals(2, messages.size());
|
assertEquals(2, messages.size());
|
||||||
assertMessagesAreAcked(messages);
|
assertMessagesAreAcked(messages);
|
||||||
}
|
}
|
||||||
@@ -1303,8 +1300,9 @@ public class IntroductionIntegrationTest
|
|||||||
private IntroductionRequest getIntroductionRequest(DatabaseComponent db,
|
private IntroductionRequest getIntroductionRequest(DatabaseComponent db,
|
||||||
IntroductionManager manager, ContactId contactId)
|
IntroductionManager manager, ContactId contactId)
|
||||||
throws DbException {
|
throws DbException {
|
||||||
Collection<ConversationMessageHeader> messages = db.transactionWithResult(
|
Collection<ConversationMessageHeader> messages =
|
||||||
true, txn -> manager.getMessageHeaders(txn, contactId));
|
db.transactionWithResult(true, txn ->
|
||||||
|
manager.getMessageHeaders(txn, contactId));
|
||||||
for (ConversationMessageHeader im : messages) {
|
for (ConversationMessageHeader im : messages) {
|
||||||
if (im instanceof IntroductionRequest) {
|
if (im instanceof IntroductionRequest) {
|
||||||
return (IntroductionRequest) im;
|
return (IntroductionRequest) im;
|
||||||
|
|||||||
@@ -497,8 +497,8 @@ public class PrivateGroupManagerIntegrationTest
|
|||||||
assertFalse(groupManager1.isDissolved(groupId0));
|
assertFalse(groupManager1.isDissolved(groupId0));
|
||||||
|
|
||||||
// creator dissolves group
|
// creator dissolves group
|
||||||
db1.transaction(false,
|
db1.transaction(false, txn ->
|
||||||
txn -> groupManager1.markGroupDissolved(txn, groupId0));
|
groupManager1.markGroupDissolved(txn, groupId0));
|
||||||
|
|
||||||
// group is dissolved now
|
// group is dissolved now
|
||||||
assertTrue(groupManager1.isDissolved(groupId0));
|
assertTrue(groupManager1.isDissolved(groupId0));
|
||||||
|
|||||||
@@ -137,8 +137,9 @@ public class GroupInvitationIntegrationTest
|
|||||||
|
|
||||||
sync1To0(1, true);
|
sync1To0(1, true);
|
||||||
|
|
||||||
messages = db0.transactionWithResult(true, txn -> groupInvitationManager0
|
messages = db0.transactionWithResult(true, txn ->
|
||||||
.getMessageHeaders(txn, contactId1From0));
|
groupInvitationManager0
|
||||||
|
.getMessageHeaders(txn, contactId1From0));
|
||||||
assertEquals(2, messages.size());
|
assertEquals(2, messages.size());
|
||||||
foundResponse = false;
|
foundResponse = false;
|
||||||
for (ConversationMessageHeader m : messages) {
|
for (ConversationMessageHeader m : messages) {
|
||||||
@@ -191,8 +192,9 @@ public class GroupInvitationIntegrationTest
|
|||||||
|
|
||||||
sync1To0(1, true);
|
sync1To0(1, true);
|
||||||
|
|
||||||
messages = db1.transactionWithResult(true, txn -> groupInvitationManager0
|
messages = db1.transactionWithResult(true, txn ->
|
||||||
.getMessageHeaders(txn, contactId1From0));
|
groupInvitationManager0
|
||||||
|
.getMessageHeaders(txn, contactId1From0));
|
||||||
assertEquals(2, messages.size());
|
assertEquals(2, messages.size());
|
||||||
foundResponse = false;
|
foundResponse = false;
|
||||||
for (ConversationMessageHeader m : messages) {
|
for (ConversationMessageHeader m : messages) {
|
||||||
@@ -227,10 +229,9 @@ public class GroupInvitationIntegrationTest
|
|||||||
// 1 has one unread message
|
// 1 has one unread message
|
||||||
Group g0 = groupInvitationManager1.getContactGroup(contact0From1);
|
Group g0 = groupInvitationManager1.getContactGroup(contact0From1);
|
||||||
assertGroupCount(messageTracker1, g0.getId(), 1, 1, timestamp);
|
assertGroupCount(messageTracker1, g0.getId(), 1, 1, timestamp);
|
||||||
ConversationMessageHeader m = db1.transactionWithResult(true,
|
ConversationMessageHeader m = db1.transactionWithResult(true, txn ->
|
||||||
txn -> groupInvitationManager1
|
groupInvitationManager1.getMessageHeaders(txn, contactId0From1)
|
||||||
.getMessageHeaders(txn, contactId0From1).iterator()
|
.iterator().next());
|
||||||
.next());
|
|
||||||
|
|
||||||
groupInvitationManager1
|
groupInvitationManager1
|
||||||
.respondToInvitation(contactId0From1, privateGroup0, true);
|
.respondToInvitation(contactId0From1, privateGroup0, true);
|
||||||
|
|||||||
@@ -242,8 +242,8 @@ public class BlogSharingIntegrationTest
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// sharer has own invitation message and response
|
// sharer has own invitation message and response
|
||||||
assertEquals(2, db0.transactionWithResult(true,
|
assertEquals(2, db0.transactionWithResult(true, txn ->
|
||||||
txn -> blogSharingManager0.getMessageHeaders(txn, contactId1From0))
|
blogSharingManager0.getMessageHeaders(txn, contactId1From0))
|
||||||
.size());
|
.size());
|
||||||
// blog can not be shared again
|
// blog can not be shared again
|
||||||
assertFalse(blogSharingManager0.canBeShared(rssBlog.getId(),
|
assertFalse(blogSharingManager0.canBeShared(rssBlog.getId(),
|
||||||
@@ -304,8 +304,8 @@ public class BlogSharingIntegrationTest
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// sharer has own invitation message and response
|
// sharer has own invitation message and response
|
||||||
assertEquals(2, db0.transactionWithResult(true,
|
assertEquals(2, db0.transactionWithResult(true, txn ->
|
||||||
txn -> blogSharingManager0.getMessageHeaders(txn, contactId1From0))
|
blogSharingManager0.getMessageHeaders(txn, contactId1From0))
|
||||||
.size());
|
.size());
|
||||||
// blog can be shared again
|
// blog can be shared again
|
||||||
assertTrue(
|
assertTrue(
|
||||||
|
|||||||
@@ -152,7 +152,8 @@ public class ForumSharingIntegrationTest
|
|||||||
}
|
}
|
||||||
// sharer has own invitation message and response
|
// sharer has own invitation message and response
|
||||||
assertEquals(2, db0.transactionWithResult(true, txn ->
|
assertEquals(2, db0.transactionWithResult(true, txn ->
|
||||||
forumSharingManager0.getMessageHeaders(txn, contactId1From0)).size());
|
forumSharingManager0.getMessageHeaders(txn, contactId1From0))
|
||||||
|
.size());
|
||||||
// forum can not be shared again
|
// forum can not be shared again
|
||||||
Contact c1 = contactManager0.getContact(contactId1From0);
|
Contact c1 = contactManager0.getContact(contactId1From0);
|
||||||
assertFalse(forumSharingManager0.canBeShared(forum0.getId(), c1));
|
assertFalse(forumSharingManager0.canBeShared(forum0.getId(), c1));
|
||||||
@@ -209,7 +210,8 @@ public class ForumSharingIntegrationTest
|
|||||||
}
|
}
|
||||||
// sharer has own invitation message and response
|
// sharer has own invitation message and response
|
||||||
assertEquals(2, db0.transactionWithResult(true, txn ->
|
assertEquals(2, db0.transactionWithResult(true, txn ->
|
||||||
forumSharingManager0.getMessageHeaders(txn, contactId1From0)).size());
|
forumSharingManager0.getMessageHeaders(txn, contactId1From0))
|
||||||
|
.size());
|
||||||
// forum can be shared again
|
// forum can be shared again
|
||||||
Contact c1 = contactManager0.getContact(contactId1From0);
|
Contact c1 = contactManager0.getContact(contactId1From0);
|
||||||
assertTrue(forumSharingManager0.canBeShared(forum0.getId(), c1));
|
assertTrue(forumSharingManager0.canBeShared(forum0.getId(), c1));
|
||||||
@@ -736,8 +738,9 @@ public class ForumSharingIntegrationTest
|
|||||||
|
|
||||||
// get invitation MessageId for later
|
// get invitation MessageId for later
|
||||||
MessageId invitationId = null;
|
MessageId invitationId = null;
|
||||||
Collection<ConversationMessageHeader> list = db1.transactionWithResult(true,
|
Collection<ConversationMessageHeader> list =
|
||||||
txn -> forumSharingManager1.getMessageHeaders(txn, contactId0From1));
|
db1.transactionWithResult(true, txn -> forumSharingManager1
|
||||||
|
.getMessageHeaders(txn, contactId0From1));
|
||||||
for (ConversationMessageHeader m : list) {
|
for (ConversationMessageHeader m : list) {
|
||||||
if (m instanceof ForumInvitationRequest) {
|
if (m instanceof ForumInvitationRequest) {
|
||||||
invitationId = m.getId();
|
invitationId = m.getId();
|
||||||
|
|||||||
Reference in New Issue
Block a user