Add @Inject constructor.

This commit is contained in:
akwizgran
2022-06-23 14:14:14 +01:00
parent 4ba4e41e69
commit feb8854678
16 changed files with 122 additions and 61 deletions

View File

@@ -11,7 +11,7 @@ import javax.annotation.concurrent.Immutable;
@NotNullByDefault @NotNullByDefault
public class MailboxProperties { public class MailboxProperties {
private final String baseUrl; private final String onion;
private final MailboxAuthToken authToken; private final MailboxAuthToken authToken;
private final boolean owner; private final boolean owner;
private final List<MailboxVersion> serverSupports; private final List<MailboxVersion> serverSupports;
@@ -23,9 +23,9 @@ public class MailboxProperties {
/** /**
* Constructor for properties used by the mailbox's owner. * Constructor for properties used by the mailbox's owner.
*/ */
public MailboxProperties(String baseUrl, MailboxAuthToken authToken, public MailboxProperties(String onion, MailboxAuthToken authToken,
List<MailboxVersion> serverSupports) { List<MailboxVersion> serverSupports) {
this.baseUrl = baseUrl; this.onion = onion;
this.authToken = authToken; this.authToken = authToken;
this.owner = true; this.owner = true;
this.serverSupports = serverSupports; this.serverSupports = serverSupports;
@@ -36,10 +36,10 @@ public class MailboxProperties {
/** /**
* Constructor for properties used by a contact of the mailbox's owner. * Constructor for properties used by a contact of the mailbox's owner.
*/ */
public MailboxProperties(String baseUrl, MailboxAuthToken authToken, public MailboxProperties(String onion, MailboxAuthToken authToken,
List<MailboxVersion> serverSupports, MailboxFolderId inboxId, List<MailboxVersion> serverSupports, MailboxFolderId inboxId,
MailboxFolderId outboxId) { MailboxFolderId outboxId) {
this.baseUrl = baseUrl; this.onion = onion;
this.authToken = authToken; this.authToken = authToken;
this.owner = false; this.owner = false;
this.serverSupports = serverSupports; this.serverSupports = serverSupports;
@@ -47,13 +47,11 @@ public class MailboxProperties {
this.outboxId = outboxId; this.outboxId = outboxId;
} }
public String getBaseUrl() { /**
return baseUrl; * Returns the onion address of the mailbox, excluding the .onion suffix.
} */
public String getOnion() { public String getOnion() {
return baseUrl.replaceFirst("^http://", "") return onion;
.replaceFirst("\\.onion$", "");
} }
public MailboxAuthToken getAuthToken() { public MailboxAuthToken getAuthToken() {

View File

@@ -29,19 +29,35 @@ public interface MailboxUpdateManager {
/** /**
* The number of properties required for an update message with a mailbox. * The number of properties required for an update message with a mailbox.
* <p>
* The required properties are {@link #PROP_KEY_ONION},
* {@link #PROP_KEY_AUTHTOKEN}, {@link #PROP_KEY_INBOXID} and
* {@link #PROP_KEY_OUTBOXID}.
*/ */
int PROP_COUNT = 4; int PROP_COUNT = 4;
/** /**
* The required properties of an update message with a mailbox. * The onion address of the mailbox, excluding the .onion suffix.
*/ */
String PROP_KEY_ONION = "onion"; String PROP_KEY_ONION = "onion";
/**
* A bearer token for accessing the mailbox (64 hex digits).
*/
String PROP_KEY_AUTHTOKEN = "authToken"; String PROP_KEY_AUTHTOKEN = "authToken";
/**
* A folder ID for downloading messages (64 hex digits).
*/
String PROP_KEY_INBOXID = "inboxId"; String PROP_KEY_INBOXID = "inboxId";
/**
* A folder ID for uploading messages (64 hex digits).
*/
String PROP_KEY_OUTBOXID = "outboxId"; String PROP_KEY_OUTBOXID = "outboxId";
/** /**
* Length of the Onion property. * Length of the {@link #PROP_KEY_ONION} property.
*/ */
int PROP_ONION_LENGTH = 56; int PROP_ONION_LENGTH = 56;

View File

@@ -230,14 +230,14 @@ public class TestUtils {
public static MailboxProperties getMailboxProperties(boolean owner, public static MailboxProperties getMailboxProperties(boolean owner,
List<MailboxVersion> serverSupports) { List<MailboxVersion> serverSupports) {
String baseUrl = "http://" + getRandomString(56) + ".onion"; // TODO String onion = getRandomString(56);
MailboxAuthToken authToken = new MailboxAuthToken(getRandomId()); MailboxAuthToken authToken = new MailboxAuthToken(getRandomId());
if (owner) { if (owner) {
return new MailboxProperties(baseUrl, authToken, serverSupports); return new MailboxProperties(onion, authToken, serverSupports);
} }
MailboxFolderId inboxId = new MailboxFolderId(getRandomId()); MailboxFolderId inboxId = new MailboxFolderId(getRandomId());
MailboxFolderId outboxId = new MailboxFolderId(getRandomId()); MailboxFolderId outboxId = new MailboxFolderId(getRandomId());
return new MailboxProperties(baseUrl, authToken, serverSupports, return new MailboxProperties(onion, authToken, serverSupports,
inboxId, outboxId); inboxId, outboxId);
} }

View File

@@ -456,8 +456,7 @@ class ClientHelperImpl implements ClientHelper {
checkLength(inboxId, UniqueId.LENGTH); checkLength(inboxId, UniqueId.LENGTH);
byte[] outboxId = properties.getRaw(PROP_KEY_OUTBOXID); byte[] outboxId = properties.getRaw(PROP_KEY_OUTBOXID);
checkLength(outboxId, UniqueId.LENGTH); checkLength(outboxId, UniqueId.LENGTH);
String baseUrl = "http://" + onion + ".onion"; // TODO MailboxProperties props = new MailboxProperties(onion,
MailboxProperties props = new MailboxProperties(baseUrl,
new MailboxAuthToken(authToken), serverSupportsList, new MailboxAuthToken(authToken), serverSupportsList,
new MailboxFolderId(inboxId), new MailboxFolderId(outboxId)); new MailboxFolderId(inboxId), new MailboxFolderId(outboxId));
return new MailboxUpdateWithMailbox(clientSupportsList, props); return new MailboxUpdateWithMailbox(clientSupportsList, props);

View File

@@ -42,18 +42,22 @@ import static org.briarproject.bramble.util.IoUtils.copyAndClose;
@NotNullByDefault @NotNullByDefault
class MailboxApiImpl implements MailboxApi { class MailboxApiImpl implements MailboxApi {
private final WeakSingletonProvider<OkHttpClient> httpClientProvider;
private final JsonMapper mapper = JsonMapper.builder()
.enable(BLOCK_UNSAFE_POLYMORPHIC_BASE_TYPES)
.build();
private static final MediaType JSON = private static final MediaType JSON =
requireNonNull(MediaType.parse("application/json; charset=utf-8")); requireNonNull(MediaType.parse("application/json; charset=utf-8"));
private static final MediaType FILE = private static final MediaType FILE =
requireNonNull(MediaType.parse("application/octet-stream")); requireNonNull(MediaType.parse("application/octet-stream"));
private final WeakSingletonProvider<OkHttpClient> httpClientProvider;
private final JsonMapper mapper = JsonMapper.builder()
.enable(BLOCK_UNSAFE_POLYMORPHIC_BASE_TYPES)
.build();
private final UrlConverter urlConverter;
@Inject @Inject
MailboxApiImpl(WeakSingletonProvider<OkHttpClient> httpClientProvider) { MailboxApiImpl(WeakSingletonProvider<OkHttpClient> httpClientProvider,
UrlConverter urlConverter) {
this.httpClientProvider = httpClientProvider; this.httpClientProvider = httpClientProvider;
this.urlConverter = urlConverter;
} }
@Override @Override
@@ -78,7 +82,7 @@ class MailboxApiImpl implements MailboxApi {
throws IOException, ApiException { throws IOException, ApiException {
if (!properties.isOwner()) throw new IllegalArgumentException(); if (!properties.isOwner()) throw new IllegalArgumentException();
Request request = getRequestBuilder(properties.getAuthToken()) Request request = getRequestBuilder(properties.getAuthToken())
.url(properties.getBaseUrl() + "/setup") .url(getBaseUrl(properties) + "/setup")
.put(EMPTY_REQUEST) .put(EMPTY_REQUEST)
.build(); .build();
OkHttpClient client = httpClientProvider.get(); OkHttpClient client = httpClientProvider.get();
@@ -93,7 +97,7 @@ class MailboxApiImpl implements MailboxApi {
if (tokenNode == null) { if (tokenNode == null) {
throw new ApiException(); throw new ApiException();
} }
return new MailboxProperties(properties.getBaseUrl(), return new MailboxProperties(properties.getOnion(),
MailboxAuthToken.fromString(tokenNode.textValue()), MailboxAuthToken.fromString(tokenNode.textValue()),
parseServerSupports(node)); parseServerSupports(node));
} catch (JacksonException | InvalidMailboxIdException e) { } catch (JacksonException | InvalidMailboxIdException e) {
@@ -137,7 +141,7 @@ class MailboxApiImpl implements MailboxApi {
throws IOException, ApiException { throws IOException, ApiException {
if (!properties.isOwner()) throw new IllegalArgumentException(); if (!properties.isOwner()) throw new IllegalArgumentException();
Request request = getRequestBuilder(properties.getAuthToken()) Request request = getRequestBuilder(properties.getAuthToken())
.url(properties.getBaseUrl() + "/") .url(getBaseUrl(properties) + "/")
.delete() .delete()
.build(); .build();
OkHttpClient client = httpClientProvider.get(); OkHttpClient client = httpClientProvider.get();
@@ -162,7 +166,7 @@ class MailboxApiImpl implements MailboxApi {
public void deleteContact(MailboxProperties properties, ContactId contactId) public void deleteContact(MailboxProperties properties, ContactId contactId)
throws IOException, ApiException, TolerableFailureException { throws IOException, ApiException, TolerableFailureException {
if (!properties.isOwner()) throw new IllegalArgumentException(); if (!properties.isOwner()) throw new IllegalArgumentException();
String url = properties.getBaseUrl() + "/contacts/" + String url = getBaseUrl(properties) + "/contacts/" +
contactId.getInt(); contactId.getInt();
Request request = getRequestBuilder(properties.getAuthToken()) Request request = getRequestBuilder(properties.getAuthToken())
.delete() .delete()
@@ -266,7 +270,7 @@ class MailboxApiImpl implements MailboxApi {
String path = "/files/" + folderId + "/" + fileId; String path = "/files/" + folderId + "/" + fileId;
Request request = getRequestBuilder(properties.getAuthToken()) Request request = getRequestBuilder(properties.getAuthToken())
.delete() .delete()
.url(properties.getBaseUrl() + path) .url(getBaseUrl(properties) + path)
.build(); .build();
OkHttpClient client = httpClientProvider.get(); OkHttpClient client = httpClientProvider.get();
Response response = client.newCall(request).execute(); Response response = client.newCall(request).execute();
@@ -308,7 +312,7 @@ class MailboxApiImpl implements MailboxApi {
private Response sendGetRequest(MailboxProperties properties, String path) private Response sendGetRequest(MailboxProperties properties, String path)
throws IOException { throws IOException {
Request request = getRequestBuilder(properties.getAuthToken()) Request request = getRequestBuilder(properties.getAuthToken())
.url(properties.getBaseUrl() + path) .url(getBaseUrl(properties) + path)
.build(); .build();
OkHttpClient client = httpClientProvider.get(); OkHttpClient client = httpClientProvider.get();
return client.newCall(request).execute(); return client.newCall(request).execute();
@@ -317,7 +321,7 @@ class MailboxApiImpl implements MailboxApi {
private Response sendPostRequest(MailboxProperties properties, String path, private Response sendPostRequest(MailboxProperties properties, String path,
RequestBody body) throws IOException { RequestBody body) throws IOException {
Request request = getRequestBuilder(properties.getAuthToken()) Request request = getRequestBuilder(properties.getAuthToken())
.url(properties.getBaseUrl() + path) .url(getBaseUrl(properties) + path)
.post(body) .post(body)
.build(); .build();
OkHttpClient client = httpClientProvider.get(); OkHttpClient client = httpClientProvider.get();
@@ -339,4 +343,7 @@ class MailboxApiImpl implements MailboxApi {
return (ArrayNode) arrayNode; return (ArrayNode) arrayNode;
} }
private String getBaseUrl(MailboxProperties properties) {
return urlConverter.convertOnionToBaseUrl(properties.getOnion());
}
} }

View File

@@ -59,7 +59,12 @@ public class MailboxModule {
} }
@Provides @Provides
MailboxApi providesMailboxApi(MailboxApiImpl mailboxApi) { UrlConverter provideUrlConverter(UrlConverterImpl urlConverter) {
return urlConverter;
}
@Provides
MailboxApi provideMailboxApi(MailboxApiImpl mailboxApi) {
return mailboxApi; return mailboxApi;
} }

View File

@@ -177,10 +177,9 @@ class MailboxPairingTaskImpl implements MailboxPairingTask {
LOG.info("QR code is valid"); LOG.info("QR code is valid");
byte[] onionPubKey = Arrays.copyOfRange(bytes, 1, 33); byte[] onionPubKey = Arrays.copyOfRange(bytes, 1, 33);
String onion = crypto.encodeOnion(onionPubKey); String onion = crypto.encodeOnion(onionPubKey);
String baseUrl = "http://" + onion + ".onion"; // TODO
byte[] tokenBytes = Arrays.copyOfRange(bytes, 33, 65); byte[] tokenBytes = Arrays.copyOfRange(bytes, 33, 65);
MailboxAuthToken setupToken = new MailboxAuthToken(tokenBytes); MailboxAuthToken setupToken = new MailboxAuthToken(tokenBytes);
return new MailboxProperties(baseUrl, setupToken, new ArrayList<>()); return new MailboxProperties(onion, setupToken, new ArrayList<>());
} }
} }

View File

@@ -74,7 +74,7 @@ class MailboxSettingsManagerImpl implements MailboxSettingsManager {
public void setOwnMailboxProperties(Transaction txn, MailboxProperties p) public void setOwnMailboxProperties(Transaction txn, MailboxProperties p)
throws DbException { throws DbException {
Settings s = new Settings(); Settings s = new Settings();
s.put(SETTINGS_KEY_ONION, p.getBaseUrl()); s.put(SETTINGS_KEY_ONION, p.getOnion());
s.put(SETTINGS_KEY_TOKEN, p.getAuthToken().toString()); s.put(SETTINGS_KEY_TOKEN, p.getAuthToken().toString());
List<MailboxVersion> serverSupports = p.getServerSupports(); List<MailboxVersion> serverSupports = p.getServerSupports();
encodeServerSupports(serverSupports, s); encodeServerSupports(serverSupports, s);

View File

@@ -242,8 +242,7 @@ class MailboxUpdateManagerImpl implements MailboxUpdateManager,
private void createAndSendUpdateWithMailbox(Transaction txn, Contact c, private void createAndSendUpdateWithMailbox(Transaction txn, Contact c,
List<MailboxVersion> serverSupports, String ownOnion) List<MailboxVersion> serverSupports, String ownOnion)
throws DbException { throws DbException {
String baseUrl = "http://" + ownOnion + ".onion"; // TODO MailboxProperties properties = new MailboxProperties(ownOnion,
MailboxProperties properties = new MailboxProperties(baseUrl,
new MailboxAuthToken(crypto.generateUniqueId().getBytes()), new MailboxAuthToken(crypto.generateUniqueId().getBytes()),
serverSupports, serverSupports,
new MailboxFolderId(crypto.generateUniqueId().getBytes()), new MailboxFolderId(crypto.generateUniqueId().getBytes()),

View File

@@ -0,0 +1,17 @@
package org.briarproject.bramble.mailbox;
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
/**
* An interface for converting an onion address to an HTTP URL, allowing the
* conversion to be customised for integration tests.
*/
@NotNullByDefault
interface UrlConverter {
/**
* Converts a raw onion address, excluding the .onion suffix, into an
* HTTP URL.
*/
String convertOnionToBaseUrl(String onion);
}

View File

@@ -0,0 +1,18 @@
package org.briarproject.bramble.mailbox;
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
import javax.inject.Inject;
@NotNullByDefault
class UrlConverterImpl implements UrlConverter {
@Inject
UrlConverterImpl() {
}
@Override
public String convertOnionToBaseUrl(String onion) {
return "http://" + onion + ".onion";
}
}

View File

@@ -68,7 +68,10 @@ public class MailboxApiTest extends BrambleTestCase {
return client; return client;
} }
}; };
private final MailboxApiImpl api = new MailboxApiImpl(httpClientProvider); // We aren't using a real onion address, so use the given address verbatim
private final UrlConverter urlConverter = onion -> onion;
private final MailboxApiImpl api = new MailboxApiImpl(httpClientProvider,
urlConverter);
private final MailboxAuthToken token = new MailboxAuthToken(getRandomId()); private final MailboxAuthToken token = new MailboxAuthToken(getRandomId());
private final MailboxAuthToken token2 = new MailboxAuthToken(getRandomId()); private final MailboxAuthToken token2 = new MailboxAuthToken(getRandomId());

View File

@@ -49,8 +49,8 @@ public class MailboxIntegrationTest extends BrambleTestCase {
@Rule @Rule
public TemporaryFolder folder = new TemporaryFolder(); public TemporaryFolder folder = new TemporaryFolder();
private final static String URL_BASE = "http://127.0.0.1:8000"; private static final String URL_BASE = "http://127.0.0.1:8000";
private final static MailboxAuthToken SETUP_TOKEN; private static final MailboxAuthToken SETUP_TOKEN;
static { static {
try { try {
@@ -74,8 +74,10 @@ public class MailboxIntegrationTest extends BrambleTestCase {
return client; return client;
} }
}; };
private final static MailboxApiImpl api = // We aren't using a real onion address, so use the given address verbatim
new MailboxApiImpl(httpClientProvider); private static final UrlConverter urlConverter = onion -> onion;
private static final MailboxApiImpl api =
new MailboxApiImpl(httpClientProvider, urlConverter);
// needs to be static to keep values across different tests // needs to be static to keep values across different tests
private static MailboxProperties ownerProperties; private static MailboxProperties ownerProperties;
@@ -121,7 +123,7 @@ public class MailboxIntegrationTest extends BrambleTestCase {
ContactId contactId = new ContactId(1); ContactId contactId = new ContactId(1);
MailboxContact contact = getMailboxContact(contactId); MailboxContact contact = getMailboxContact(contactId);
MailboxProperties contactProperties = new MailboxProperties( MailboxProperties contactProperties = new MailboxProperties(
ownerProperties.getBaseUrl(), contact.token, ownerProperties.getOnion(), contact.token,
new ArrayList<>(), contact.inboxId, contact.outboxId); new ArrayList<>(), contact.inboxId, contact.outboxId);
api.addContact(ownerProperties, contact); api.addContact(ownerProperties, contact);
@@ -167,7 +169,7 @@ public class MailboxIntegrationTest extends BrambleTestCase {
ContactId contactId = new ContactId(1); ContactId contactId = new ContactId(1);
MailboxContact contact = getMailboxContact(contactId); MailboxContact contact = getMailboxContact(contactId);
MailboxProperties contactProperties = new MailboxProperties( MailboxProperties contactProperties = new MailboxProperties(
ownerProperties.getBaseUrl(), contact.token, ownerProperties.getOnion(), contact.token,
new ArrayList<>(), contact.inboxId, contact.outboxId); new ArrayList<>(), contact.inboxId, contact.outboxId);
api.addContact(ownerProperties, contact); api.addContact(ownerProperties, contact);

View File

@@ -55,7 +55,6 @@ public class MailboxPairingTaskImplTest extends BrambleMockTestCase {
private final String onion = getRandomString(56); private final String onion = getRandomString(56);
private final byte[] onionBytes = getRandomBytes(32); private final byte[] onionBytes = getRandomBytes(32);
private final String baseUrl = "http://" + onion + ".onion"; // TODO
private final MailboxAuthToken setupToken = private final MailboxAuthToken setupToken =
new MailboxAuthToken(getRandomId()); new MailboxAuthToken(getRandomId());
private final MailboxAuthToken ownerToken = private final MailboxAuthToken ownerToken =
@@ -63,9 +62,9 @@ public class MailboxPairingTaskImplTest extends BrambleMockTestCase {
private final String validPayload = getValidPayload(); private final String validPayload = getValidPayload();
private final long time = System.currentTimeMillis(); private final long time = System.currentTimeMillis();
private final MailboxProperties setupProperties = new MailboxProperties( private final MailboxProperties setupProperties = new MailboxProperties(
baseUrl, setupToken, new ArrayList<>()); onion, setupToken, new ArrayList<>());
private final MailboxProperties ownerProperties = new MailboxProperties( private final MailboxProperties ownerProperties = new MailboxProperties(
baseUrl, ownerToken, new ArrayList<>()); onion, ownerToken, new ArrayList<>());
@Test @Test
public void testInitialQrCodeReceivedState() { public void testInitialQrCodeReceivedState() {
@@ -207,7 +206,7 @@ public class MailboxPairingTaskImplTest extends BrambleMockTestCase {
private PredicateMatcher<MailboxProperties> matches(MailboxProperties p2) { private PredicateMatcher<MailboxProperties> matches(MailboxProperties p2) {
return new PredicateMatcher<>(MailboxProperties.class, p1 -> return new PredicateMatcher<>(MailboxProperties.class, p1 ->
p1.getAuthToken().equals(p2.getAuthToken()) && p1.getAuthToken().equals(p2.getAuthToken()) &&
p1.getBaseUrl().equals(p2.getBaseUrl()) && p1.getOnion().equals(p2.getOnion()) &&
p1.isOwner() == p2.isOwner() && p1.isOwner() == p2.isOwner() &&
p1.getServerSupports().equals(p2.getServerSupports())); p1.getServerSupports().equals(p2.getServerSupports()));
} }

View File

@@ -84,7 +84,7 @@ public class MailboxSettingsManagerImplTest extends BrambleMockTestCase {
MailboxProperties properties = manager.getOwnMailboxProperties(txn); MailboxProperties properties = manager.getOwnMailboxProperties(txn);
assertNotNull(properties); assertNotNull(properties);
assertEquals(onion, properties.getBaseUrl()); assertEquals(onion, properties.getOnion());
assertEquals(token, properties.getAuthToken()); assertEquals(token, properties.getAuthToken());
assertEquals(serverSupports, properties.getServerSupports()); assertEquals(serverSupports, properties.getServerSupports());
assertTrue(properties.isOwner()); assertTrue(properties.isOwner());

View File

@@ -109,7 +109,7 @@ public class MailboxUpdateManagerImplTest extends BrambleMockTestCase {
updateNoMailbox = new MailboxUpdate(someClientSupportsList); updateNoMailbox = new MailboxUpdate(someClientSupportsList);
updateProps = getMailboxProperties(false, someServerSupportsList); updateProps = getMailboxProperties(false, someServerSupportsList);
ownProps = new MailboxProperties(updateProps.getBaseUrl(), ownProps = new MailboxProperties(updateProps.getOnion(),
updateProps.getAuthToken(), someServerSupportsList); updateProps.getAuthToken(), someServerSupportsList);
updateWithMailbox = new MailboxUpdateWithMailbox(someClientSupportsList, updateWithMailbox = new MailboxUpdateWithMailbox(someClientSupportsList,
updateProps); updateProps);
@@ -170,7 +170,7 @@ public class MailboxUpdateManagerImplTest extends BrambleMockTestCase {
contactGroup.getId()); contactGroup.getId());
will(returnValue(messageMetadata)); will(returnValue(messageMetadata));
expectStoreMessage(txn, contactGroup.getId(), 1, someClientSupports, expectStoreMessage(txn, contactGroup.getId(), 1, someClientSupports,
emptyServerSupports, emptyPropsDict, true); emptyServerSupports, emptyPropsDict);
oneOf(clientHelper).mergeGroupMetadata(txn, localGroup.getId(), oneOf(clientHelper).mergeGroupMetadata(txn, localGroup.getId(),
sentDict); sentDict);
@@ -225,7 +225,7 @@ public class MailboxUpdateManagerImplTest extends BrambleMockTestCase {
contactGroup.getId()); contactGroup.getId());
will(returnValue(messageMetadata)); will(returnValue(messageMetadata));
expectStoreMessage(txn, contactGroup.getId(), 1, someClientSupports, expectStoreMessage(txn, contactGroup.getId(), 1, someClientSupports,
someServerSupports, propsDict, true); someServerSupports, propsDict);
oneOf(clientHelper).mergeGroupMetadata(txn, localGroup.getId(), oneOf(clientHelper).mergeGroupMetadata(txn, localGroup.getId(),
sentDict); sentDict);
@@ -276,7 +276,7 @@ public class MailboxUpdateManagerImplTest extends BrambleMockTestCase {
contactGroup.getId()); contactGroup.getId());
will(returnValue(emptyMessageMetadata)); will(returnValue(emptyMessageMetadata));
expectStoreMessage(txn, contactGroup.getId(), 1, someClientSupports, expectStoreMessage(txn, contactGroup.getId(), 1, someClientSupports,
emptyServerSupports, emptyPropsDict, true); emptyServerSupports, emptyPropsDict);
oneOf(clientHelper).mergeGroupMetadata(txn, localGroup.getId(), oneOf(clientHelper).mergeGroupMetadata(txn, localGroup.getId(),
sentDict); sentDict);
@@ -341,7 +341,7 @@ public class MailboxUpdateManagerImplTest extends BrambleMockTestCase {
contactGroup.getId()); contactGroup.getId());
will(returnValue(emptyMessageMetadata)); will(returnValue(emptyMessageMetadata));
expectStoreMessage(txn, contactGroup.getId(), 1, someClientSupports, expectStoreMessage(txn, contactGroup.getId(), 1, someClientSupports,
emptyServerSupports, emptyPropsDict, true); emptyServerSupports, emptyPropsDict);
oneOf(clientHelper).mergeGroupMetadata(txn, localGroup.getId(), oneOf(clientHelper).mergeGroupMetadata(txn, localGroup.getId(),
sentDict); sentDict);
@@ -400,7 +400,7 @@ public class MailboxUpdateManagerImplTest extends BrambleMockTestCase {
contactGroup.getId()); contactGroup.getId());
will(returnValue(messageMetadata)); will(returnValue(messageMetadata));
expectStoreMessage(txn, contactGroup.getId(), 2, expectStoreMessage(txn, contactGroup.getId(), 2,
newerClientSupports, someServerSupports, propsDict, true); newerClientSupports, someServerSupports, propsDict);
oneOf(db).removeMessage(txn, messageId); oneOf(db).removeMessage(txn, messageId);
oneOf(clientHelper).mergeGroupMetadata(txn, localGroup.getId(), oneOf(clientHelper).mergeGroupMetadata(txn, localGroup.getId(),
@@ -441,7 +441,7 @@ public class MailboxUpdateManagerImplTest extends BrambleMockTestCase {
contactGroup.getId()); contactGroup.getId());
will(returnValue(messageMetadata)); will(returnValue(messageMetadata));
expectStoreMessage(txn, contactGroup.getId(), 1, someClientSupports, expectStoreMessage(txn, contactGroup.getId(), 1, someClientSupports,
emptyServerSupports, emptyPropsDict, true); emptyServerSupports, emptyPropsDict);
}}); }});
MailboxUpdateManagerImpl t = createInstance(someClientSupportsList); MailboxUpdateManagerImpl t = createInstance(someClientSupportsList);
@@ -484,7 +484,7 @@ public class MailboxUpdateManagerImplTest extends BrambleMockTestCase {
contactGroup.getId()); contactGroup.getId());
will(returnValue(messageMetadata)); will(returnValue(messageMetadata));
expectStoreMessage(txn, contactGroup.getId(), 1, someClientSupports, expectStoreMessage(txn, contactGroup.getId(), 1, someClientSupports,
someServerSupports, propsDict, true); someServerSupports, propsDict);
}}); }});
MailboxUpdateManagerImpl t = createInstance(someClientSupportsList); MailboxUpdateManagerImpl t = createInstance(someClientSupportsList);
@@ -674,7 +674,7 @@ public class MailboxUpdateManagerImplTest extends BrambleMockTestCase {
contactGroup.getId()); contactGroup.getId());
will(returnValue(messageMetadata)); will(returnValue(messageMetadata));
expectStoreMessage(txn, contactGroup.getId(), 2, someClientSupports, expectStoreMessage(txn, contactGroup.getId(), 2, someClientSupports,
someServerSupports, propsDict, true); someServerSupports, propsDict);
oneOf(db).removeMessage(txn, latestId); oneOf(db).removeMessage(txn, latestId);
}}); }});
@@ -712,7 +712,7 @@ public class MailboxUpdateManagerImplTest extends BrambleMockTestCase {
contactGroup.getId()); contactGroup.getId());
will(returnValue(messageMetadata)); will(returnValue(messageMetadata));
expectStoreMessage(txn, contactGroup.getId(), 2, someClientSupports, expectStoreMessage(txn, contactGroup.getId(), 2, someClientSupports,
emptyServerSupports, emptyPropsDict, true); emptyServerSupports, emptyPropsDict);
oneOf(db).removeMessage(txn, latestId); oneOf(db).removeMessage(txn, latestId);
}}); }});
@@ -890,15 +890,14 @@ public class MailboxUpdateManagerImplTest extends BrambleMockTestCase {
private void expectStoreMessage(Transaction txn, GroupId g, private void expectStoreMessage(Transaction txn, GroupId g,
long version, BdfList clientSupports, BdfList serverSupports, long version, BdfList clientSupports, BdfList serverSupports,
BdfDictionary properties, boolean local) BdfDictionary properties) throws Exception {
throws Exception {
BdfList body = BdfList.of(version, clientSupports, serverSupports, BdfList body = BdfList.of(version, clientSupports, serverSupports,
properties); properties);
Message message = getMessage(g); Message message = getMessage(g);
long timestamp = message.getTimestamp(); long timestamp = message.getTimestamp();
BdfDictionary meta = BdfDictionary.of( BdfDictionary meta = BdfDictionary.of(
new BdfEntry(MSG_KEY_VERSION, version), new BdfEntry(MSG_KEY_VERSION, version),
new BdfEntry(MSG_KEY_LOCAL, local) new BdfEntry(MSG_KEY_LOCAL, true)
); );
context.checking(new Expectations() {{ context.checking(new Expectations() {{