Skip to content

Commit 8cf57be

Browse files
committed
Update integration tests error code for invalid fid target
1 parent e3f510b commit 8cf57be

1 file changed

Lines changed: 41 additions & 4 deletions

File tree

src/test/java/com/google/firebase/messaging/FirebaseMessagingIT.java

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ public void testSendFidError() throws InterruptedException {
113113
fail("No exception thrown for invalid FID");
114114
} catch (ExecutionException e) {
115115
FirebaseMessagingException cause = (FirebaseMessagingException) e.getCause();
116-
assertEquals(ErrorCode.INVALID_ARGUMENT, cause.getErrorCode());
117-
assertEquals(MessagingErrorCode.INVALID_ARGUMENT, cause.getMessagingErrorCode());
116+
assertEquals(ErrorCode.NOT_FOUND, cause.getErrorCode());
117+
assertEquals(MessagingErrorCode.UNREGISTERED, cause.getMessagingErrorCode());
118118
assertNotNull(cause.getHttpResponse());
119119
assertTrue(cause.getCause() instanceof HttpResponseException);
120120
}
@@ -238,13 +238,50 @@ public void testSendEachForMulticastFidsError() throws Exception {
238238
assertFalse(sendResponse.isSuccessful());
239239
assertNull(sendResponse.getMessageId());
240240
assertNotNull(sendResponse.getException());
241-
assertEquals(ErrorCode.INVALID_ARGUMENT,
241+
assertEquals(ErrorCode.NOT_FOUND,
242242
sendResponse.getException().getErrorCode());
243-
assertEquals(MessagingErrorCode.INVALID_ARGUMENT,
243+
assertEquals(MessagingErrorCode.UNREGISTERED,
244244
sendResponse.getException().getMessagingErrorCode());
245245
}
246246
}
247247

248+
@Test
249+
public void testSendEachForMulticastMixedError() throws Exception {
250+
MulticastMessage multicastMessage = MulticastMessage.builder()
251+
.setNotification(Notification.builder()
252+
.setTitle("Title")
253+
.setBody("Body")
254+
.build())
255+
.addToken("not-a-token")
256+
.addFid("not-a-fid")
257+
.build();
258+
259+
BatchResponse response = FirebaseMessaging.getInstance().sendEachForMulticast(
260+
multicastMessage, true);
261+
262+
assertEquals(0, response.getSuccessCount());
263+
assertEquals(2, response.getFailureCount());
264+
assertEquals(2, response.getResponses().size());
265+
266+
SendResponse response1 = response.getResponses().get(0);
267+
assertFalse(response1.isSuccessful());
268+
assertNull(response1.getMessageId());
269+
assertNotNull(response1.getException());
270+
assertEquals(ErrorCode.INVALID_ARGUMENT, response1.getException().getErrorCode());
271+
assertEquals(
272+
MessagingErrorCode.INVALID_ARGUMENT,
273+
response1.getException().getMessagingErrorCode());
274+
275+
SendResponse response2 = response.getResponses().get(1);
276+
assertFalse(response2.isSuccessful());
277+
assertNull(response2.getMessageId());
278+
assertNotNull(response2.getException());
279+
assertEquals(ErrorCode.NOT_FOUND, response2.getException().getErrorCode());
280+
assertEquals(
281+
MessagingErrorCode.UNREGISTERED,
282+
response2.getException().getMessagingErrorCode());
283+
}
284+
248285
@Test
249286
public void testSubscribe() throws Exception {
250287
FirebaseMessaging messaging = FirebaseMessaging.getInstance();

0 commit comments

Comments
 (0)