urbanairship-core/src/test/java/com/urbanairship/push/PushManagerJobHandlerTest.java
@Test
    public void testCreateChannel200() {
        // Set up channel response
        Response response = mock(Response.class);
        when(response.getStatus()).thenReturn(HttpURLConnection.HTTP_OK);
        when(response.getResponseBody()).thenReturn(fakeResponseBody);
        when(response.getResponseHeader(CHANNEL_LOCATION_KEY)).thenReturn(fakeChannelLocation);

        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 match in preferences", fakeChannelId, pushManager.getChannelId());
        assertEquals("Channel location should match in preferences", fakeChannelLocation,
                pushManager.getChannelLocation());

        // Verify we update the user
        verify(richPushInbox.getUser()).update(true);
    }
/**
     * Test creating channel accepts a 200
     */
Test creating channel accepts a 200
Test creating channel accepts a 200
@Test
    public void testCreateChannel200() {
        Response response = mock(Response.class);
        when(response.getStatus()).thenReturn(HttpURLConnection.HTTP_OK);
        when(response.getResponseBody()).thenReturn(fakeResponseBody);
        when(response.getResponseHeader(CHANNEL_LOCATION_KEY)).thenReturn(fakeChannelLocation);
        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 match in preferences", fakeChannelId, pushManager.getChannelId());
        assertEquals("Channel location should match in preferences", fakeChannelLocation,
                pushManager.getChannelLocation());
        verify(richPushInbox.getUser()).update(true);
    }
@ Test public void testCreateChannel200 ( ) { Response response = mock ( Response . class ) ; when ( response . getStatus ( ) ) . thenReturn ( HttpURLConnection . HTTP_OK ) ; when ( response . getResponseBody ( ) ) . thenReturn ( fakeResponseBody ) ; when ( response . getResponseHeader ( CHANNEL_LOCATION_KEY ) ) . thenReturn ( fakeChannelLocation ) ; 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 match in preferences" , fakeChannelId , pushManager . getChannelId ( ) ) ; assertEquals ( "Channel location should match in preferences" , fakeChannelLocation , pushManager . getChannelLocation ( ) ) ; verify ( richPushInbox . getUser ( ) ) . update ( true ) ; }
Test creating channel accepts a 200
Test creating channel accepts a 200
// Set up channel response // Return the response // Verify we update the user