Don’t throw exceptions from ReportMessageManager#store()

This commit is contained in:
Chris Eager
2021-05-13 18:20:54 -05:00
committed by Chris Eager
parent 10c6f885fd
commit df01be2dca
2 changed files with 21 additions and 4 deletions

View File

@@ -1,10 +1,12 @@
package org.whispersystems.textsecuregcm.storage;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;
import io.micrometer.core.instrument.Counter;
@@ -26,11 +28,18 @@ class ReportMessageManagerTest {
final UUID messageGuid = UUID.randomUUID();
final String number = "+15105551111";
assertThrows(NullPointerException.class, () -> reportMessageManager.store(null, messageGuid));
assertDoesNotThrow(() -> reportMessageManager.store(null, messageGuid));
verifyZeroInteractions(reportMessageDynamoDb);
reportMessageManager.store(number, messageGuid);
verify(reportMessageDynamoDb).store(any());
doThrow(RuntimeException.class)
.when(reportMessageDynamoDb).store(any());
assertDoesNotThrow(() -> reportMessageManager.store(number, messageGuid));
}
@Test