Reduce and centralize message-sending metrics

This commit is contained in:
Jon Chambers
2025-04-07 11:08:53 -04:00
committed by GitHub
parent 6013d00654
commit ffa98e5b34
3 changed files with 152 additions and 282 deletions

View File

@@ -18,7 +18,6 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoInteractions;
import static org.mockito.Mockito.when;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@@ -254,41 +253,6 @@ class MessageSenderTest {
mismatchedDevicesException.getMismatchedDevicesByServiceIdentifier());
}
@ParameterizedTest
@MethodSource
void getDeliveryChannelName(final Device device, final String expectedChannelName) {
assertEquals(expectedChannelName, MessageSender.getDeliveryChannelName(device));
}
private static List<Arguments> getDeliveryChannelName() {
final List<Arguments> arguments = new ArrayList<>();
{
final Device apnDevice = mock(Device.class);
when(apnDevice.getApnId()).thenReturn("apns-token");
arguments.add(Arguments.of(apnDevice, "apn"));
}
{
final Device fcmDevice = mock(Device.class);
when(fcmDevice.getGcmId()).thenReturn("fcm-token");
arguments.add(Arguments.of(fcmDevice, "gcm"));
}
{
final Device fetchesMessagesDevice = mock(Device.class);
when(fetchesMessagesDevice.getFetchesMessages()).thenReturn(true);
arguments.add(Arguments.of(fetchesMessagesDevice, "websocket"));
}
arguments.add(Arguments.of(mock(Device.class), "none"));
return arguments;
}
@Test
void validateContentLength() {
assertThrows(MessageTooLargeException.class, () ->