urbanairship-core/src/test/java/com/urbanairship/push/PushManagerTest.java
@Test
    public void testEditTagsClear() {
        Set<String> tags = new HashSet<>();
        tags.add("existing_tag");
        tags.add("another_existing_tag");

        // Set some existing tags first
        pushManager.setTags(tags);

        pushManager.editTags()
                   .addTag("hi")
                   .clear()
                   .apply();

        // Verify the new tags
        tags = pushManager.getTags();
        assertEquals(1, tags.size());
        assertTrue(tags.contains("hi"));


        verify(mockDispatcher, atLeastOnce()).dispatch(Mockito.argThat(new ArgumentMatcher<JobInfo>() {
            @Override
            public boolean matches(JobInfo jobInfo) {
                return jobInfo.getAction().equals(PushManagerJobHandler.ACTION_UPDATE_CHANNEL_REGISTRATION);
            }
        }));
    }
/**
     * Test edit tags with clear set, clears the tags first before
     * doing any adds.
     */
Test edit tags with clear set, clears the tags first before
doing any adds.
Test edit tags with clear set clears the tags first before doing any adds .
@Test
    public void testEditTagsClear() {
        Set<String> tags = new HashSet<>();
        tags.add("existing_tag");
        tags.add("another_existing_tag");
        pushManager.setTags(tags);
        pushManager.editTags()
                   .addTag("hi")
                   .clear()
                   .apply();
        tags = pushManager.getTags();
        assertEquals(1, tags.size());
        assertTrue(tags.contains("hi"));
        verify(mockDispatcher, atLeastOnce()).dispatch(Mockito.argThat(new ArgumentMatcher<JobInfo>() {
            @Override
            public boolean matches(JobInfo jobInfo) {
                return jobInfo.getAction().equals(PushManagerJobHandler.ACTION_UPDATE_CHANNEL_REGISTRATION);
            }
        }));
    }
@ Test public void testEditTagsClear ( ) { Set < String > tags = new HashSet < > ( ) ; tags . add ( "existing_tag" ) ; tags . add ( "another_existing_tag" ) ; pushManager . setTags ( tags ) ; pushManager . editTags ( ) . addTag ( "hi" ) . clear ( ) . apply ( ) ; tags = pushManager . getTags ( ) ; assertEquals ( 1 , tags . size ( ) ) ; assertTrue ( tags . contains ( "hi" ) ) ; verify ( mockDispatcher , atLeastOnce ( ) ) . dispatch ( Mockito . argThat ( new ArgumentMatcher < JobInfo > ( ) { @ Override public boolean matches ( JobInfo jobInfo ) { return jobInfo . getAction ( ) . equals ( PushManagerJobHandler . ACTION_UPDATE_CHANNEL_REGISTRATION ) ; } } ) ) ; }
Test edit tags with clear set, clears the tags first before
 doing any adds.
Test edit tags with clear set clears the tags first before doing any adds .
// Set some existing tags first // Verify the new tags