@Test
@SuppressWarnings( { "nls", "null", "unused", "unchecked" })
public void testImport_Labels_Order_ExistingLabels_Merge() throws Exception {
IFolder root = DynamicDAO.save(Owl.getModelFactory().createFolder(null, null, "Root"));
ILabel laterLabel = Owl.getModelFactory().createLabel(null, "Later");
laterLabel.setOrder(1);
ILabel personalLabel = Owl.getModelFactory().createLabel(null, "Personal");
personalLabel.setOrder(0);
DynamicDAO.save(laterLabel);
DynamicDAO.save(personalLabel);
/* Import */
List<? extends IEntity> elements = Owl.getInterpreter().importFrom(getClass().getResourceAsStream("/data/importer/labels.opml"));
assertEquals(5, elements.size());
assertEquals(5, count(Label.class.getName(), elements));
ImportUtils.doImport(null, elements, false);
for (IEntity entity : elements) {
ILabel label = (ILabel) entity;
if ("Later".equals(label.getName()))
assertEquals(0, label.getOrder());
else if ("Personal".equals(label.getName()))
assertEquals(1, label.getOrder());
else if ("Important".equals(label.getName()))
assertEquals(2, label.getOrder());
else if ("Work".equals(label.getName()))
assertEquals(3, label.getOrder());
else if ("To Do".equals(label.getName()))
assertEquals(4, label.getOrder());
}
}