### Question:
SmackGcmUpstreamMessageListener implements PacketListener { protected void handleNackReceipt(Map<String, Object> jsonObject) { String messageId = (String) jsonObject.get("message_id"); String error = (String) jsonObject.get("error"); GcmErrorCode errorCode = GcmErrorCode.valueOf(error); Notification notification = Notification.fromJsonString(messageId); logger.info("Failed to deliver GCM message due to " + error + " message:" + notification.toString()); upstreamResponder.handleError(notification, !errorCode.isTerminalError, error); if (errorCode == GcmErrorCode.DEVICE_UNREGISTERED) { String from = (String) jsonObject.get("from"); upstreamResponder.handleDeviceUnregistered(NotificationMethod.GCM, from); } } SmackGcmUpstreamMessageListener(UpstreamNotificationResponder errorResponder); @SuppressWarnings("unchecked") @Override void processPacket(Packet packet); boolean isConnectionDraining();  }### Answer:
@Test public void shouldHandleInvalidTokenError() throws Exception { Mockito.when(jsonObject.get("message_id")).thenReturn((String)"{\"customMessage\":\"This is a Test\"}"); Mockito.when(jsonObject.get("error")).thenReturn((String)"DEVICE_UNREGISTERED"); Mockito.when(jsonObject.get("from")).thenReturn(notificationToken); smackGcmUpstreamMessageListener.handleNackReceipt(jsonObject); Mockito.verify(errorResponder).handleDeviceUnregistered(NotificationMethod.GCM, notificationToken); }