urbanairship-core/src/test/java/com/urbanairship/push/PushManagerJobHandlerTest.java
@Test
    public void testUpdateRegistrationCreateChannelAmazon() {
        TestApplication.getApplication().setPlatform(UAirship.AMAZON_PLATFORM);

        // Verify channel doesn't exist in preferences
        assertNull("Channel ID should be null in preferences", pushManager.getChannelId());
        assertNull("Channel location should be null in preferences", pushManager.getChannelLocation());

        // Set up channel response
        Response response = mock(Response.class);
        when(response.getStatus()).thenReturn(HttpURLConnection.HTTP_CREATED);
        when(response.getResponseBody()).thenReturn(fakeResponseBody);
        when(response.getResponseHeader(CHANNEL_LOCATION_KEY)).thenReturn(fakeChannelLocation);

        // Ensure payload is different, so we don't get a null payload
        pushManager.setAlias("someAlias");
        ChannelRegistrationPayload payload = pushManager.getNextChannelRegistrationPayload();

        // Return the response
        when(client.createChannelWithPayload(payload)).thenReturn(response);

        JobInfo jobInfo = JobInfo.newBuilder()
                                 .setAction(PushManagerJobHandler.ACTION_UPDATE_CHANNEL_REGISTRATION)
                                 .build();

        assertEquals(JobInfo.JOB_FINISHED, jobHandler.performJob(jobInfo));

        assertEquals("Channel ID should exist in preferences", fakeChannelId, pushManager.getChannelId());
        assertEquals("Channel location should exist in preferences", fakeChannelLocation,
                pushManager.getChannelLocation());
    }
/**
     * Test update registration will create a new channel for Amazon platform
     */
Test update registration will create a new channel for Amazon platform
Test update registration will create a new channel for Amazon platform
@Test
    public void testUpdateRegistrationCreateChannelAmazon() {
        TestApplication.getApplication().setPlatform(UAirship.AMAZON_PLATFORM);
        assertNull("Channel ID should be null in preferences", pushManager.getChannelId());
        assertNull("Channel location should be null in preferences", pushManager.getChannelLocation());
        Response response = mock(Response.class);
        when(response.getStatus()).thenReturn(HttpURLConnection.HTTP_CREATED);
        when(response.getResponseBody()).thenReturn(fakeResponseBody);
        when(response.getResponseHeader(CHANNEL_LOCATION_KEY)).thenReturn(fakeChannelLocation);
        pushManager.setAlias("someAlias");
        ChannelRegistrationPayload payload = pushManager.getNextChannelRegistrationPayload();
        when(client.createChannelWithPayload(payload)).thenReturn(response);
        JobInfo jobInfo = JobInfo.newBuilder()
                                 .setAction(PushManagerJobHandler.ACTION_UPDATE_CHANNEL_REGISTRATION)
                                 .build();
        assertEquals(JobInfo.JOB_FINISHED, jobHandler.performJob(jobInfo));
        assertEquals("Channel ID should exist in preferences", fakeChannelId, pushManager.getChannelId());
        assertEquals("Channel location should exist in preferences", fakeChannelLocation,
                pushManager.getChannelLocation());
    }
@ Test public void testUpdateRegistrationCreateChannelAmazon ( ) { TestApplication . getApplication ( ) . setPlatform ( UAirship . AMAZON_PLATFORM ) ; assertNull ( "Channel ID should be null in preferences" , pushManager . getChannelId ( ) ) ; assertNull ( "Channel location should be null in preferences" , pushManager . getChannelLocation ( ) ) ; Response response = mock ( Response . class ) ; when ( response . getStatus ( ) ) . thenReturn ( HttpURLConnection . HTTP_CREATED ) ; when ( response . getResponseBody ( ) ) . thenReturn ( fakeResponseBody ) ; when ( response . getResponseHeader ( CHANNEL_LOCATION_KEY ) ) . thenReturn ( fakeChannelLocation ) ; pushManager . setAlias ( "someAlias" ) ; ChannelRegistrationPayload payload = pushManager . getNextChannelRegistrationPayload ( ) ; when ( client . createChannelWithPayload ( payload ) ) . thenReturn ( response ) ; JobInfo jobInfo = JobInfo . newBuilder ( ) . setAction ( PushManagerJobHandler . ACTION_UPDATE_CHANNEL_REGISTRATION ) . build ( ) ; assertEquals ( JobInfo . JOB_FINISHED , jobHandler . performJob ( jobInfo ) ) ; assertEquals ( "Channel ID should exist in preferences" , fakeChannelId , pushManager . getChannelId ( ) ) ; assertEquals ( "Channel location should exist in preferences" , fakeChannelLocation , pushManager . getChannelLocation ( ) ) ; }
Test update registration will create a new channel for Amazon platform
Test update registration will create a new channel for Amazon platform
// Verify channel doesn't exist in preferences // Set up channel response // Ensure payload is different, so we don't get a null payload // Return the response