urbanairship-core/src/test/java/com/urbanairship/push/PushManagerJobHandlerTest.java
@Test
    public void testUpdateRegistrationTooManyRequests() {
        // 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(Response.HTTP_TOO_MANY_REQUESTS);

        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_RETRY, jobHandler.performJob(jobInfo));
    }
/**
     * Test update registration returns a retry when the status is 429.
     */
Test update registration returns a retry when the status is 429.
Test update registration returns a retry when the status is 429 .
@Test
    public void testUpdateRegistrationTooManyRequests() {
        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(Response.HTTP_TOO_MANY_REQUESTS);
        ChannelRegistrationPayload payload = pushManager.getNextChannelRegistrationPayload();
        when(client.createChannelWithPayload(payload)).thenReturn(response);
        JobInfo jobInfo = JobInfo.newBuilder().setAction(PushManagerJobHandler.ACTION_UPDATE_CHANNEL_REGISTRATION).build();
        assertEquals(JobInfo.JOB_RETRY, jobHandler.performJob(jobInfo));
    }
@ Test public void testUpdateRegistrationTooManyRequests ( ) { 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 ( Response . HTTP_TOO_MANY_REQUESTS ) ; ChannelRegistrationPayload payload = pushManager . getNextChannelRegistrationPayload ( ) ; when ( client . createChannelWithPayload ( payload ) ) . thenReturn ( response ) ; JobInfo jobInfo = JobInfo . newBuilder ( ) . setAction ( PushManagerJobHandler . ACTION_UPDATE_CHANNEL_REGISTRATION ) . build ( ) ; assertEquals ( JobInfo . JOB_RETRY , jobHandler . performJob ( jobInfo ) ) ; }
Test update registration returns a retry when the status is 429.
Test update registration returns a retry when the status is 429 .
// Verify channel doesn't exist in preferences // Set up channel response // Return the response