urbanairship-core/src/test/java/com/urbanairship/push/NamedUserJobHandlerTest.java
@Test
    public void testDisassociateNamedUserFailedRetry() {
        when(pushManager.getChannelId()).thenReturn("channelID");
        when(namedUser.getId()).thenReturn(null);

        // Set up a 500 response
        Response response = Mockito.mock(Response.class);
        when(response.getStatus()).thenReturn(HttpURLConnection.HTTP_INTERNAL_ERROR);
        when(namedUserClient.disassociate("channelID")).thenReturn(response);

        // Perform the update
        JobInfo jobInfo = JobInfo.newBuilder().setAction(NamedUserJobHandler.ACTION_UPDATE_NAMED_USER).build();
        Assert.assertEquals(JobInfo.JOB_RETRY, jobHandler.performJob(jobInfo));

        // Verify the update was performed
        verify(namedUserClient).disassociate("channelID");

        // Verify the last change token was not updated
        assertNotEquals(changeToken, dataStore.getString(NamedUserJobHandler.LAST_UPDATED_TOKEN_KEY, null));
    }
/**
     * Test associate named user fails if the status is 500
     */
Test associate named user fails if the status is 500
Test associate named user fails if the status is 500
@Test
    public void testDisassociateNamedUserFailedRetry() {
        when(pushManager.getChannelId()).thenReturn("channelID");
        when(namedUser.getId()).thenReturn(null);
        Response response = Mockito.mock(Response.class);
        when(response.getStatus()).thenReturn(HttpURLConnection.HTTP_INTERNAL_ERROR);
        when(namedUserClient.disassociate("channelID")).thenReturn(response);
        JobInfo jobInfo = JobInfo.newBuilder().setAction(NamedUserJobHandler.ACTION_UPDATE_NAMED_USER).build();
        Assert.assertEquals(JobInfo.JOB_RETRY, jobHandler.performJob(jobInfo));
        verify(namedUserClient).disassociate("channelID");
        assertNotEquals(changeToken, dataStore.getString(NamedUserJobHandler.LAST_UPDATED_TOKEN_KEY, null));
    }
@ Test public void testDisassociateNamedUserFailedRetry ( ) { when ( pushManager . getChannelId ( ) ) . thenReturn ( "channelID" ) ; when ( namedUser . getId ( ) ) . thenReturn ( null ) ; Response response = Mockito . mock ( Response . class ) ; when ( response . getStatus ( ) ) . thenReturn ( HttpURLConnection . HTTP_INTERNAL_ERROR ) ; when ( namedUserClient . disassociate ( "channelID" ) ) . thenReturn ( response ) ; JobInfo jobInfo = JobInfo . newBuilder ( ) . setAction ( NamedUserJobHandler . ACTION_UPDATE_NAMED_USER ) . build ( ) ; Assert . assertEquals ( JobInfo . JOB_RETRY , jobHandler . performJob ( jobInfo ) ) ; verify ( namedUserClient ) . disassociate ( "channelID" ) ; assertNotEquals ( changeToken , dataStore . getString ( NamedUserJobHandler . LAST_UPDATED_TOKEN_KEY , null ) ) ; }
Test associate named user fails if the status is 500
Test associate named user fails if the status is 500
// Set up a 500 response // Perform the update // Verify the update was performed // Verify the last change token was not updated