sample/src/androidTest/java/com/urbanairship/sample/SampleTest.java
@Test
    public void testPush() throws Exception {
        UAirship.shared().getNamedUser().setId(TEST_NAMED_USER_STRING);
        UAirship.shared().getPushManager().editTags().addTag(TEST_TAG_STRING).apply();

        // Wait for registration updates
        Thread.sleep(TimeUnit.SECONDS.toMillis(10));

        PushPayload channelPayload = PushPayload.newChannelPushBuilder(channelId)
                                                .setAlert(UUID.randomUUID().toString())
                                                .build();
        pushSender.send(channelPayload);

        PushPayload tagPayload = PushPayload.newTagPushBuilder(TEST_TAG_STRING)
                                            .setAlert(UUID.randomUUID().toString())
                                            .build();
        pushSender.send(tagPayload);

        PushPayload namedUserPayload = PushPayload.newNamedUserPushBuilder(TEST_NAMED_USER_STRING)
                                                  .setAlert(UUID.randomUUID().toString())
                                                  .build();
        pushSender.send(namedUserPayload);

        Map<String, String> expectedAlerts = new HashMap<>();
        expectedAlerts.put(channelPayload.getAlert(), "channel");
        expectedAlerts.put(tagPayload.getAlert(), "tag");
        expectedAlerts.put(namedUserPayload.getAlert(), "named user");

        for (int i = 0; i < 4; i++) {
            String postedAlert = airshipReceiver.postedAlerts.poll(15, TimeUnit.SECONDS);
            if (postedAlert == null) {
                break;
            }
            expectedAlerts.remove(postedAlert);
        }

        assertTrue("Failed to receive alert types: " + expectedAlerts.values(), expectedAlerts.isEmpty());
    }
/**
     * Test setting named user, tag and pushes to them, including broadcast and channel pushes.
     */
Test setting named user, tag and pushes to them, including broadcast and channel pushes.
Test setting named user tag and pushes to them including broadcast and channel pushes .
@Test
    public void testPush() throws Exception {
        UAirship.shared().getNamedUser().setId(TEST_NAMED_USER_STRING);
        UAirship.shared().getPushManager().editTags().addTag(TEST_TAG_STRING).apply();
        Thread.sleep(TimeUnit.SECONDS.toMillis(10));
        PushPayload channelPayload = PushPayload.newChannelPushBuilder(channelId)
                                                .setAlert(UUID.randomUUID().toString())
                                                .build();
        pushSender.send(channelPayload);
        PushPayload tagPayload = PushPayload.newTagPushBuilder(TEST_TAG_STRING)
                                            .setAlert(UUID.randomUUID().toString())
                                            .build();
        pushSender.send(tagPayload);
        PushPayload namedUserPayload = PushPayload.newNamedUserPushBuilder(TEST_NAMED_USER_STRING)
                                                  .setAlert(UUID.randomUUID().toString())
                                                  .build();
        pushSender.send(namedUserPayload);
        Map<String, String> expectedAlerts = new HashMap<>();
        expectedAlerts.put(channelPayload.getAlert(), "channel");
        expectedAlerts.put(tagPayload.getAlert(), "tag");
        expectedAlerts.put(namedUserPayload.getAlert(), "named user");
        for (int i = 0; i < 4; i++) {
            String postedAlert = airshipReceiver.postedAlerts.poll(15, TimeUnit.SECONDS);
            if (postedAlert == null) {
                break;
            }
            expectedAlerts.remove(postedAlert);
        }
        assertTrue("Failed to receive alert types: " + expectedAlerts.values(), expectedAlerts.isEmpty());
    }
@ Test public void testPush ( ) throws Exception { UAirship . shared ( ) . getNamedUser ( ) . setId ( TEST_NAMED_USER_STRING ) ; UAirship . shared ( ) . getPushManager ( ) . editTags ( ) . addTag ( TEST_TAG_STRING ) . apply ( ) ; Thread . sleep ( TimeUnit . SECONDS . toMillis ( 10 ) ) ; PushPayload channelPayload = PushPayload . newChannelPushBuilder ( channelId ) . setAlert ( UUID . randomUUID ( ) . toString ( ) ) . build ( ) ; pushSender . send ( channelPayload ) ; PushPayload tagPayload = PushPayload . newTagPushBuilder ( TEST_TAG_STRING ) . setAlert ( UUID . randomUUID ( ) . toString ( ) ) . build ( ) ; pushSender . send ( tagPayload ) ; PushPayload namedUserPayload = PushPayload . newNamedUserPushBuilder ( TEST_NAMED_USER_STRING ) . setAlert ( UUID . randomUUID ( ) . toString ( ) ) . build ( ) ; pushSender . send ( namedUserPayload ) ; Map < String , String > expectedAlerts = new HashMap < > ( ) ; expectedAlerts . put ( channelPayload . getAlert ( ) , "channel" ) ; expectedAlerts . put ( tagPayload . getAlert ( ) , "tag" ) ; expectedAlerts . put ( namedUserPayload . getAlert ( ) , "named user" ) ; for ( int i = 0 ; i < 4 ; i ++ ) { String postedAlert = airshipReceiver . postedAlerts . poll ( 15 , TimeUnit . SECONDS ) ; if ( postedAlert == null ) { break ; } expectedAlerts . remove ( postedAlert ) ; } assertTrue ( "Failed to receive alert types: " + expectedAlerts . values ( ) , expectedAlerts . isEmpty ( ) ) ; }
Test setting named user, tag and pushes to them, including broadcast and channel pushes.
Test setting named user tag and pushes to them including broadcast and channel pushes .
// Wait for registration updates