Update and refactor storage service syncing.

Switched to proto3, updated protos, and generally refactored things to
make it easier to add new storage record types.
This commit is contained in:
Greyson Parrelli
2020-02-28 13:03:06 -05:00
parent 40d9d663ec
commit 5f7075d39a
25 changed files with 1484 additions and 1387 deletions

View File

@@ -0,0 +1,54 @@
package org.thoughtcrime.securesms.testutil;
import com.annimon.stream.Stream;
import com.google.common.collect.Sets;
import org.thoughtcrime.securesms.util.Conversions;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import static junit.framework.TestCase.assertTrue;
import static org.junit.Assert.assertEquals;
public final class TestHelpers {
private TestHelpers() {}
public static byte[] byteArray(int a) {
return Conversions.intToByteArray(a);
}
public static List<byte[]> byteListOf(int... vals) {
List<byte[]> list = new ArrayList<>(vals.length);
for (int i = 0; i < vals.length; i++) {
list.add(Conversions.intToByteArray(vals[i]));
}
return list;
}
@SafeVarargs
public static <E> Set<E> setOf(E... values) {
return Sets.newHashSet(values);
}
public static void assertByteListEquals(List<byte[]> a, List<byte[]> b) {
assertEquals(a.size(), b.size());
List<ByteBuffer> aBuffer = Stream.of(a).map(ByteBuffer::wrap).toList();
List<ByteBuffer> bBuffer = Stream.of(b).map(ByteBuffer::wrap).toList();
assertTrue(aBuffer.containsAll(bBuffer));
}
public static <E> void assertContentsEqual(Collection<E> a, Collection<E> b) {
assertEquals(a.size(), b.size());
assertTrue(a.containsAll(b));
}
}