Package org.locationtech.udig.issues.internal

Examples of org.locationtech.udig.issues.internal.IssuesManager


    /*
     * Test method for 'org.locationtech.udig.project.ui.internal.IssuesManager.removeIssues(String)'
     */
    @Test
    public void testRemoveIssues() {
        IssuesManager m = new IssuesManager();
        IIssuesList issueslist = m.getIssuesList();
        for( int i = 0; i < 10; i++ ) {
            issueslist.add(new DummyIssue(i, i < 6 ? "toRemove" : "g" + i)); //$NON-NLS-1$ //$NON-NLS-2$
        }
        DummyListener l = new DummyListener();
        m.addIssuesListListener(l);

        assertEquals(10, issueslist.size());
        m.removeIssues("toRemove"); //$NON-NLS-1$
        assertEquals("All the issues with groupId \"toRemove\"" + //$NON-NLS-1$
                " should be gone leaving 4 items", 4, issueslist.size()); //$NON-NLS-1$
        for( IIssue issue : issueslist ) {
            assertFalse("Item has groupId \"toRemove\"", issue.getGroupId().equals("toRemove")); //$NON-NLS-1$ //$NON-NLS-2$
        }
        assertEquals(6, l.changes);
        assertEquals(1, l.timesCalled);
        l.changes = 0;
        l.timesCalled = 0;
        m.removeIssues("hello"); //$NON-NLS-1$
        assertEquals(0, l.changes);
        assertEquals(0, l.timesCalled);
        assertEquals(4, issueslist.size());
    }
View Full Code Here


        assertEquals(4, issueslist.size());
    }

    @Test
    public void testSetIssuesList() throws Exception {
        IssuesManager m = new IssuesManager();
        IIssuesList issuesList = new IssuesList();
        m.setIssuesList(issuesList);

        final AtomicBoolean addedListener = new AtomicBoolean(false);
        final AtomicBoolean removedListener = new AtomicBoolean(false);
        DummyIssue dummyIssue = new DummyIssue(3){
            @Override
            public void addIssueListener( IIssueListener listener ) {
                addedListener.set(true);
            }

            @Override
            public void removeIssueListener( IIssueListener listener ) {
                removedListener.set(true);
            }
        };
        issuesList.add(dummyIssue);
        assertTrue(addedListener.get());
        assertFalse(removedListener.get());

        addedListener.set(false);

        m.setIssuesList(new IssuesList());

        assertFalse(addedListener.get());
        assertTrue(removedListener.get());

        removedListener.set(false);

        m.setIssuesList(issuesList);

        assertTrue(addedListener.get());
        assertFalse(removedListener.get());
    }
View Full Code Here

    }

    @Test
    public void testListeners() throws Exception {

        IssuesManager m = new IssuesManager();
        final IssuesListEvent[] listEvent = new IssuesListEvent[1];
        m.addIssuesListListener(new IIssuesListListener(){

            public void notifyChange( IssuesListEvent event ) {
                listEvent[0] = event;
            }

        });

        final IssuesManagerEvent[] managerEvent = new IssuesManagerEvent[1];

        m.addListener(new IIssuesManagerListener(){

            public void notifyChange( IssuesManagerEvent event ) {
                managerEvent[0] = event;
            }

        });

        m.getIssuesList().add(new DummyIssue(0));

        assertNotNull(listEvent[0]);
        assertNull(managerEvent[0]);

        listEvent[0] = null;

        m.setIssuesList(new IssuesList());

        assertEquals(IssuesManagerEventType.ISSUES_LIST_CHANGE, managerEvent[0].getType());
        assertNull(listEvent[0]);

        managerEvent[0] = null;

        m.getIssuesList().add(new DummyIssue(0));

        assertNotNull(listEvent[0]);
        assertNull(managerEvent[0]);

    }
View Full Code Here

    }

    @Test
    public void testDirtyEvents() throws Exception {
            IssuesManager m = new IssuesManager();
            m.setIssuesList(IssuesListTestHelper.createInMemoryDatastoreIssuesList(null, null));

            FeatureIssue createFeatureIssue = IssuesListTestHelper.createFeatureIssue("newFeature"); //$NON-NLS-1$
            m.getIssuesList().add(createFeatureIssue);

            final IssuesManagerEvent[] managerEvent = new IssuesManagerEvent[1];

            m.addListener(new IIssuesManagerListener(){

                public void notifyChange( IssuesManagerEvent event ) {
                    managerEvent[0] = event;
                }

            });

            createFeatureIssue.setPriority(Priority.CRITICAL);

            assertEquals(IssuesManagerEventType.DIRTY_ISSUE, managerEvent[0].getType());
            assertEquals(Boolean.TRUE, managerEvent[0].getNewValue());
            managerEvent[0] = null;

            m.save(new NullProgressMonitor());

            assertEquals(IssuesManagerEventType.SAVE, managerEvent[0].getType());
            assertNull(managerEvent[0].getNewValue());
            assertEquals(createFeatureIssue, ((Collection) managerEvent[0].getOldValue())
                    .iterator().next());
View Full Code Here

                    .iterator().next());
    }

    @Test
    public void testSaveIssuesList() throws Exception {
        IssuesManager m = new IssuesManager();
        IIssuesList issuesList = new IssuesList();
        m.setIssuesList(issuesList);
        issuesList.add(IssuesListTestHelper.createFeatureIssue("1")); //$NON-NLS-1$

        // no exception happens, and nothing else.
        assertFalse(m.save(new NullProgressMonitor()));

        DataStore[] store = new DataStore[1];
        SimpleFeatureType[] featureType = new SimpleFeatureType[1];
        issuesList = IssuesListTestHelper.createInMemoryDatastoreIssuesList(store, featureType);
        m.setIssuesList(issuesList);

        FeatureIssue createIssue = IssuesListTestHelper.createFeatureIssue("2"); //$NON-NLS-1$
        issuesList.add(createIssue);
        issuesList.add(IssuesListTestHelper.createFeatureIssue("3")); //$NON-NLS-1$
        assertFalse(m.save(new NullProgressMonitor()));

        createIssue.setPriority(Priority.TRIVIAL);

        class Listener implements IIssuesListListener {

            private Collection< ? extends IIssue> saved;

            public void notifyChange( IssuesListEvent event ) {

                if (event.getType() == IssuesListEventType.SAVE)
                    saved = event.getChanged();
            }

        };

        Listener listener = new Listener();
        issuesList.addListener(listener);

        assertTrue(m.save(new NullProgressMonitor()));
        assertEquals(1, listener.saved.size());
        assertEquals(createIssue.getId(), listener.saved.iterator().next().getId());
    }
View Full Code Here

TOP

Related Classes of org.locationtech.udig.issues.internal.IssuesManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.