urbanairship-core/src/test/java/com/urbanairship/push/PushManagerJobHandlerTest.java
@Test
    public void testChannelConflict() throws MalformedURLException {
        // Set Channel ID and channel location
        pushManager.setChannel(fakeChannelId, fakeChannelLocation);

        // Set up a conflict response
        Response conflictResponse = mock(Response.class);
        when(conflictResponse.getStatus()).thenReturn(HttpURLConnection.HTTP_CONFLICT);
        when(client.updateChannelWithPayload(Mockito.eq(new URL(fakeChannelLocation)), Mockito.any(ChannelRegistrationPayload.class))).thenReturn(conflictResponse);

        JobInfo jobInfo = JobInfo.newBuilder().setAction(PushManagerJobHandler.ACTION_UPDATE_CHANNEL_REGISTRATION).build();
        assertEquals(JobInfo.JOB_RETRY, jobHandler.performJob(jobInfo));

        // Verify update was called
        Mockito.verify(client).updateChannelWithPayload(Mockito.eq(new URL(fakeChannelLocation)), Mockito.any(ChannelRegistrationPayload.class));

        // Verify the channel was cleared
        assertNull("Channel ID should be null", pushManager.getChannelId());
        assertNull("Channel location should be null", pushManager.getChannelLocation());
    }
/**
     * Test updating channel returns a 409 recreates the channel.
     */
Test updating channel returns a 409 recreates the channel.
Test updating channel returns a 409 recreates the channel .
@Test
    public void testChannelConflict() throws MalformedURLException {
        pushManager.setChannel(fakeChannelId, fakeChannelLocation);
        Response conflictResponse = mock(Response.class);
        when(conflictResponse.getStatus()).thenReturn(HttpURLConnection.HTTP_CONFLICT);
        when(client.updateChannelWithPayload(Mockito.eq(new URL(fakeChannelLocation)), Mockito.any(ChannelRegistrationPayload.class))).thenReturn(conflictResponse);
        JobInfo jobInfo = JobInfo.newBuilder().setAction(PushManagerJobHandler.ACTION_UPDATE_CHANNEL_REGISTRATION).build();
        assertEquals(JobInfo.JOB_RETRY, jobHandler.performJob(jobInfo));
        Mockito.verify(client).updateChannelWithPayload(Mockito.eq(new URL(fakeChannelLocation)), Mockito.any(ChannelRegistrationPayload.class));
        assertNull("Channel ID should be null", pushManager.getChannelId());
        assertNull("Channel location should be null", pushManager.getChannelLocation());
    }
@ Test public void testChannelConflict ( ) throws MalformedURLException { pushManager . setChannel ( fakeChannelId , fakeChannelLocation ) ; Response conflictResponse = mock ( Response . class ) ; when ( conflictResponse . getStatus ( ) ) . thenReturn ( HttpURLConnection . HTTP_CONFLICT ) ; when ( client . updateChannelWithPayload ( Mockito . eq ( new URL ( fakeChannelLocation ) ) , Mockito . any ( ChannelRegistrationPayload . class ) ) ) . thenReturn ( conflictResponse ) ; JobInfo jobInfo = JobInfo . newBuilder ( ) . setAction ( PushManagerJobHandler . ACTION_UPDATE_CHANNEL_REGISTRATION ) . build ( ) ; assertEquals ( JobInfo . JOB_RETRY , jobHandler . performJob ( jobInfo ) ) ; Mockito . verify ( client ) . updateChannelWithPayload ( Mockito . eq ( new URL ( fakeChannelLocation ) ) , Mockito . any ( ChannelRegistrationPayload . class ) ) ; assertNull ( "Channel ID should be null" , pushManager . getChannelId ( ) ) ; assertNull ( "Channel location should be null" , pushManager . getChannelLocation ( ) ) ; }
Test updating channel returns a 409 recreates the channel.
Test updating channel returns a 409 recreates the channel .
// Set Channel ID and channel location // Set up a conflict response // Verify update was called // Verify the channel was cleared