@Before public void baseline() throws Exception { map = MapTests.createDefaultMap("FTName", 4, true, new Dimension(500, 500)); // $NON-NLS-1$ Folder folder = ProjectFactory.eINSTANCE.createFolder(); folder.setName("Folder"); folder.setShown(true); map.getLegend().add(folder); Layer layer = map.getLayersInternal().get(0); LayerLegendItem layerItem = ProjectFactory.eINSTANCE.createLayerLegendItem(); layerItem.setName("Layer 0"); layerItem.setLayer(layer); folder.getItems().add(layerItem); layer = ProjectFactory.eINSTANCE.createLayer(); map.getLayersInternal().add(layer); layerItem = ProjectFactory.eINSTANCE.createLayerLegendItem(); layerItem.setName("Layer 1"); layerItem.setLayer(layer); folder.getItems().add(layerItem); layer = ProjectFactory.eINSTANCE.createLayer(); map.getLayersInternal().add(layer); layerItem = ProjectFactory.eINSTANCE.createLayerLegendItem(); layerItem.setName("Layer 2"); layerItem.setLayer(layer); map.getLegend().add(layerItem); layer = ProjectFactory.eINSTANCE.createLayer(); map.getLayersInternal().add(layer); layerItem = ProjectFactory.eINSTANCE.createLayerLegendItem(); layerItem.setName("Layer 3"); layerItem.setLayer(layer); map.getLegend().add(layerItem); }
@Test public void testAddFoldersWithConstructor1() { Folder folder = new Folder(); folder.setName("Home"); folder.setVisibility(Visibility.PUBLIC); folder.setVisibilityInCascade(true); Folder folder1 = new Folder(); folder1.setName("Docs"); folder1.setVisibility(Visibility.PUBLIC); folder1.setVisibilityInCascade(true); folder.add(folder1); Assert.assertEquals("Docs", folder.getFolders().iterator().next().getName()); }
@Test public void createFolder() { // Creation of the root folder Folder root = new Folder(); root.setName("Root"); root.setIdUser("*****@*****.**"); // Creation of a child folder Folder child = new Folder(); child.setName("Child"); child.setIdUser("*****@*****.**"); child.setParentFolder(root); // Adding the child folder to its parent folder (the root folder9 List<Folder> childFolders = new ArrayList(); childFolders.add(child); root.setChildFolders(childFolders); // Creation of a document Document doc = new Document(); doc.setName("Invoices July"); doc.setOriginalFilename("test.pdf"); doc.setDocumentDate(new Date()); doc.setFolder(child); doc.setIdUser("*****@*****.**"); doc.setPath("myPath"); doc.setSize(1200); doc.setType("PDF"); List<Document> docs = new ArrayList(); docs.add(doc); // Adding the document to the child folder child.setDocuments(docs); tx.begin(); // We persist just the root folder because we have the annotation cascade ALL em.persist(root); tx.commit(); Assert.assertNotNull("IDFolder must no be empty", root.getId()); Assert.assertNotNull("Root Folder has no child folder", root.getChildFolders()); Assert.assertEquals("Root folder should have 1 child", root.getChildFolders().size(), 1); }
@Test public void getNameTest() { folder.setName("Входящие"); Assert.assertEquals("Входящие", folder.getName()); }