if (source.getAcceptedUnicastNotifications() != null) { sync.setAcceptedUnicastNotifications(new ArrayList<>( source.getAcceptedUnicastNotifications()));
Mockito.verify(clientState, Mockito.times(1)).updateTopicSubscriptionInfo(Mockito.eq(topicId1), Mockito.eq(6)); Assert.assertEquals("uid", transport.createNotificationRequest().getAcceptedUnicastNotifications().get(0));
@Test public void testAcceptedUnicastNotification() throws Exception { KaaClientState clientState = Mockito.mock(KaaClientState.class); NotificationProcessor notificationProcessor = Mockito.mock(NotificationProcessor.class); NotificationSyncResponse response1 = new NotificationSyncResponse(); response1.setResponseStatus(SyncResponseStatus.DELTA); KaaChannelManager channelManagerMock = Mockito.mock(KaaChannelManager.class); NotificationTransport transport = new DefaultNotificationTransport(); transport.setChannelManager(channelManagerMock); transport.setNotificationProcessor(notificationProcessor); transport.setClientState(clientState); Notification nf1 = new Notification(1l, NotificationType.CUSTOM, "uid_1", 5, ByteBuffer.wrap(new byte[]{1, 2, 3})); Notification nf2 = new Notification(2l, NotificationType.CUSTOM, "uid_2", 3, ByteBuffer.wrap(new byte[]{1, 2, 3})); Notification nf3 = new Notification(3l, NotificationType.CUSTOM, "uid_2", 5, ByteBuffer.wrap(new byte[]{1, 2, 3})); response1.setNotifications(Arrays.asList(nf1, nf2, nf3)); transport.onNotificationResponse(response1); NotificationSyncRequest request1 = transport.createNotificationRequest(); Assert.assertTrue(request1.getAcceptedUnicastNotifications().size() == 2); NotificationSyncResponse response2 = new NotificationSyncResponse(); response2.setResponseStatus(SyncResponseStatus.NO_DELTA); transport.onNotificationResponse(response2); NotificationSyncRequest request2 = transport.createNotificationRequest(); Assert.assertNull(request2.getAcceptedUnicastNotifications()); }
@Test public void testCreateEmptyRequest() { NotificationTransport transport1 = new DefaultNotificationTransport(); Assert.assertNull(transport1.createEmptyNotificationRequest()); KaaClientState clientState = Mockito.mock(KaaClientState.class); NotificationTransport transport2 = new DefaultNotificationTransport(); Assert.assertNull(transport2.createEmptyNotificationRequest()); transport2.setClientState(clientState); NotificationSyncRequest request = transport2.createEmptyNotificationRequest(); Assert.assertNull(request.getAcceptedUnicastNotifications()); Assert.assertNull(request.getSubscriptionCommands()); Assert.assertEquals(TopicListHashCalculator.NULL_LIST_HASH, request.getTopicListHash()); }