@@ -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