mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-22 08:48:05 +01:00
Convert incoming/outgoing message entities to records
This commit is contained in:
committed by
Jon Chambers
parent
c4c5397b44
commit
3d875f1ce5
@@ -391,19 +391,19 @@ class MessageControllerTest {
|
||||
.accept(MediaType.APPLICATION_JSON_TYPE)
|
||||
.get(OutgoingMessageEntityList.class);
|
||||
|
||||
assertEquals(response.getMessages().size(), 2);
|
||||
assertEquals(response.messages().size(), 2);
|
||||
|
||||
assertEquals(response.getMessages().get(0).getTimestamp(), timestampOne);
|
||||
assertEquals(response.getMessages().get(1).getTimestamp(), timestampTwo);
|
||||
assertEquals(response.messages().get(0).timestamp(), timestampOne);
|
||||
assertEquals(response.messages().get(1).timestamp(), timestampTwo);
|
||||
|
||||
assertEquals(response.getMessages().get(0).getGuid(), messageGuidOne);
|
||||
assertNull(response.getMessages().get(1).getGuid());
|
||||
assertEquals(response.messages().get(0).guid(), messageGuidOne);
|
||||
assertNull(response.messages().get(1).guid());
|
||||
|
||||
assertEquals(response.getMessages().get(0).getSourceUuid(), sourceUuid);
|
||||
assertEquals(response.getMessages().get(1).getSourceUuid(), sourceUuid);
|
||||
assertEquals(response.messages().get(0).sourceUuid(), sourceUuid);
|
||||
assertEquals(response.messages().get(1).sourceUuid(), sourceUuid);
|
||||
|
||||
assertEquals(updatedPniOne, response.getMessages().get(0).getUpdatedPni());
|
||||
assertNull(response.getMessages().get(1).getUpdatedPni());
|
||||
assertEquals(updatedPniOne, response.messages().get(0).updatedPni());
|
||||
assertNull(response.messages().get(1).updatedPni());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -116,8 +116,8 @@ public class ChangeNumberManagerTest {
|
||||
final Map<Long, Integer> registrationIds = Map.of(1L, 17, 2L, 19);
|
||||
|
||||
final IncomingMessage msg = mock(IncomingMessage.class);
|
||||
when(msg.getDestinationDeviceId()).thenReturn(2L);
|
||||
when(msg.getContent()).thenReturn(Base64.encodeBase64String(new byte[]{1}));
|
||||
when(msg.destinationDeviceId()).thenReturn(2L);
|
||||
when(msg.content()).thenReturn(Base64.encodeBase64String(new byte[]{1}));
|
||||
|
||||
changeNumberManager.changeNumber(account, changedE164, pniIdentityKey, prekeys, List.of(msg), registrationIds);
|
||||
|
||||
|
||||
@@ -194,15 +194,15 @@ class MessagesDynamoDbTest {
|
||||
}
|
||||
|
||||
private static void verify(OutgoingMessageEntity retrieved, MessageProtos.Envelope inserted) {
|
||||
assertThat(retrieved.getTimestamp()).isEqualTo(inserted.getTimestamp());
|
||||
assertThat(retrieved.getSource()).isEqualTo(inserted.hasSource() ? inserted.getSource() : null);
|
||||
assertThat(retrieved.getSourceUuid()).isEqualTo(inserted.hasSourceUuid() ? UUID.fromString(inserted.getSourceUuid()) : null);
|
||||
assertThat(retrieved.getSourceDevice()).isEqualTo(inserted.getSourceDevice());
|
||||
assertThat(retrieved.getType()).isEqualTo(inserted.getType().getNumber());
|
||||
assertThat(retrieved.getContent()).isEqualTo(inserted.hasContent() ? inserted.getContent().toByteArray() : null);
|
||||
assertThat(retrieved.getServerTimestamp()).isEqualTo(inserted.getServerTimestamp());
|
||||
assertThat(retrieved.getGuid()).isEqualTo(UUID.fromString(inserted.getServerGuid()));
|
||||
assertThat(retrieved.getDestinationUuid()).isEqualTo(UUID.fromString(inserted.getDestinationUuid()));
|
||||
assertThat(retrieved.timestamp()).isEqualTo(inserted.getTimestamp());
|
||||
assertThat(retrieved.source()).isEqualTo(inserted.hasSource() ? inserted.getSource() : null);
|
||||
assertThat(retrieved.sourceUuid()).isEqualTo(inserted.hasSourceUuid() ? UUID.fromString(inserted.getSourceUuid()) : null);
|
||||
assertThat(retrieved.sourceDevice()).isEqualTo(inserted.getSourceDevice());
|
||||
assertThat(retrieved.type()).isEqualTo(inserted.getType().getNumber());
|
||||
assertThat(retrieved.content()).isEqualTo(inserted.hasContent() ? inserted.getContent().toByteArray() : null);
|
||||
assertThat(retrieved.serverTimestamp()).isEqualTo(inserted.getServerTimestamp());
|
||||
assertThat(retrieved.guid()).isEqualTo(UUID.fromString(inserted.getServerGuid()));
|
||||
assertThat(retrieved.destinationUuid()).isEqualTo(UUID.fromString(inserted.getDestinationUuid()));
|
||||
}
|
||||
|
||||
private static VerifyMessage verify(MessageProtos.Envelope expected) {
|
||||
|
||||
@@ -64,7 +64,6 @@ import org.whispersystems.websocket.WebSocketClient;
|
||||
import org.whispersystems.websocket.auth.WebSocketAuthenticator.AuthenticationResult;
|
||||
import org.whispersystems.websocket.messages.WebSocketResponseMessage;
|
||||
import org.whispersystems.websocket.session.WebSocketSessionContext;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
class WebSocketConnectionTest {
|
||||
|
||||
@@ -208,7 +207,7 @@ class WebSocketConnectionTest {
|
||||
futures.get(0).completeExceptionally(new IOException());
|
||||
futures.get(2).completeExceptionally(new IOException());
|
||||
|
||||
verify(storedMessages, times(1)).delete(eq(accountUuid), eq(2L), eq(outgoingMessages.get(1).getGuid()), eq(outgoingMessages.get(1).getServerTimestamp()));
|
||||
verify(storedMessages, times(1)).delete(eq(accountUuid), eq(2L), eq(outgoingMessages.get(1).guid()), eq(outgoingMessages.get(1).serverTimestamp()));
|
||||
verify(receiptSender, times(1)).sendReceipt(eq(auth), eq(senderOneUuid), eq(2222L));
|
||||
|
||||
connection.stop();
|
||||
|
||||
Reference in New Issue
Block a user