@Test public void testAddMany() throws Exception { List<IIssue> newIssues = new ArrayList<IIssue>(); newIssues.add(IssuesListTestHelper.createFeatureIssue("new1")); // $NON-NLS-1$ newIssues.add(IssuesListTestHelper.createFeatureIssue("new2")); // $NON-NLS-1$ list.addAll(newIssues); list.refresh(); assertEquals(6, list.size()); }
@Before public void setUp() throws Exception { FeatureIssue.setTesting(true); DataStore[] ds = new DataStore[1]; SimpleFeatureType[] ft = new SimpleFeatureType[1]; list = IssuesListTestHelper.createInMemoryDatastoreIssuesList(ds, ft); featureType = ft[0]; store = ds[0]; IssuesListTestHelper.addFeatures(ds[0], ft[0]); list.refresh(); }
@Test public void testModifyIssue() throws Exception { String newDescription = "new modified description"; // $NON-NLS-1$ list.clear(); list.add(IssuesListTestHelper.createFeatureIssue("test")); // $NON-NLS-1$ list.refresh(); assertEquals(1, list.size()); IIssue issue = list.get(0); issue.setDescription(newDescription); ((IRemoteIssuesList) list).save(issue); FilterFactory factory = CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints()); Expression expr2 = factory.literal(issue.getId()); Expression expr1 = factory.property(IssuesListTestHelper.ISSUE_ID_ATTR); Filter filter = factory.equals(expr1, expr2); SimpleFeature next = store .getFeatureSource(featureType.getName().getLocalPart()) .getFeatures(filter) .features() .next(); assertEquals(newDescription, next.getAttribute(IssuesListTestHelper.DESCRIPTION_ATTR)); }
@Test public void testAddIIssue() throws Exception { FeatureIssue issue = IssuesListTestHelper.createFeatureIssue("new"); // $NON-NLS-1$ list.add(issue); assertEquals(5, list.size()); assertEquals("new", list.get(4).getId()); // $NON-NLS-1$ list.refresh(); assertEquals(5, list.size()); assertEquals("new", list.get(4).getId()); // $NON-NLS-1$ assertEquals("groupID", list.get(4).getGroupId()); // $NON-NLS-1$ assertEquals("test description", list.get(4).getDescription()); // $NON-NLS-1$ assertEquals( 5, store.getFeatureSource(featureType.getName().getLocalPart()).getCount(Query.ALL)); }
@Test public void testNullID() throws Exception { list.clear(); list.add(IssuesListTestHelper.createFeatureIssue(null)); assertNotNull(list.get(0).getId()); SimpleFeature next = this.store .getFeatureSource(this.featureType.getName().getLocalPart()) .getFeatures() .features() .next(); Object id = next.getAttribute("id"); // $NON-NLS-1$ assertNotNull(id); }
@Test public void testBackendAddedIssue() throws Exception { IssuesListTestHelper.createFeature( "new", //$NON-NLS-1$ Resolution.IN_PROGRESS, Priority.CRITICAL, new ReferencedEnvelope(0, 10, 0, 10, crs), store.getFeatureWriterAppend( featureType.getName().getLocalPart(), Transaction.AUTO_COMMIT)); final IssuesListEvent[] change = new IssuesListEvent[1]; list.addListener( new IIssuesListListener() { public void notifyChange(IssuesListEvent event) { change[0] = event; } }); list.refresh(); assertEquals(5, list.size()); assertEquals("new", list.get(4).getId()); // $NON-NLS-1$ assertEquals(IssuesListEventType.REFRESH, change[0].getType()); }
@Test public void testAddIssueWithBounds() throws Exception { list.add(IssuesListTestHelper.createFeatureIssue("id")); // $NON-NLS-1$ // no exception? good. }