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

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

        // Verify associate not called when channel ID doesn't exist
        verifyZeroInteractions(namedUserClient);

        // Verify the last change token was not updated
        assertNotEquals(changeToken, dataStore.getString(NamedUserJobHandler.LAST_UPDATED_TOKEN_KEY, null));
    }
/**
     * Test associate without channel fails.
     */
Test associate without channel fails.
Test associate without channel fails .
@Test
    public void testAssociateNamedUserFailedNoChannel() {
        when(pushManager.getChannelId()).thenReturn(null);
        when(namedUser.getId()).thenReturn("namedUserID");
        JobInfo jobInfo = JobInfo.newBuilder().setAction(NamedUserJobHandler.ACTION_UPDATE_NAMED_USER).build();
        Assert.assertEquals(JobInfo.JOB_FINISHED, jobHandler.performJob(jobInfo));
        verifyZeroInteractions(namedUserClient);
        assertNotEquals(changeToken, dataStore.getString(NamedUserJobHandler.LAST_UPDATED_TOKEN_KEY, null));
    }
@ Test public void testAssociateNamedUserFailedNoChannel ( ) { when ( pushManager . getChannelId ( ) ) . thenReturn ( null ) ; when ( namedUser . getId ( ) ) . thenReturn ( "namedUserID" ) ; JobInfo jobInfo = JobInfo . newBuilder ( ) . setAction ( NamedUserJobHandler . ACTION_UPDATE_NAMED_USER ) . build ( ) ; Assert . assertEquals ( JobInfo . JOB_FINISHED , jobHandler . performJob ( jobInfo ) ) ; verifyZeroInteractions ( namedUserClient ) ; assertNotEquals ( changeToken , dataStore . getString ( NamedUserJobHandler . LAST_UPDATED_TOKEN_KEY , null ) ) ; }
Test associate without channel fails.
Test associate without channel fails .
// Perform the update // Verify associate not called when channel ID doesn't exist // Verify the last change token was not updated