Ejemplo n.º 1
0
 /**
  * Test method TaxonomyService.removeCategory() Input: Remove categories of Article node Expect:
  * Return empty list
  *
  * @throws RepositoryException
  * @throws TaxonomyNodeAlreadyExistsException
  * @throws TaxonomyAlreadyExistsException
  */
 public void testRemoveCategory()
     throws RepositoryException, TaxonomyNodeAlreadyExistsException,
         TaxonomyAlreadyExistsException {
   session.getRootNode().addNode("MyDocuments");
   Node article = session.getRootNode().addNode("Article");
   session.save();
   taxonomyService.addTaxonomyNode(COLLABORATION_WS, "/MyDocuments", "Education", "root");
   taxonomyService.addTaxonomyNode(COLLABORATION_WS, "/MyDocuments", "News", "root");
   taxonomyService.addTaxonomyNode(COLLABORATION_WS, "/MyDocuments/Education", "Language", "root");
   taxonomyService.addTaxonomyNode(COLLABORATION_WS, "/MyDocuments/News", "Weather", "root");
   Node rootTree1 = (Node) session.getItem("/MyDocuments/Education");
   taxonomyService.addTaxonomyTree(rootTree1);
   Node rootTree2 = (Node) session.getItem("/MyDocuments/News");
   taxonomyService.addTaxonomyTree(rootTree2);
   taxonomyService.addCategory(article, "Education", "Language", true);
   taxonomyService.addCategory(article, "News", "Weather", true);
   List<Node> lstNode = mockTaxonomyService.getAllCategories(article, true);
   assertEquals(2, lstNode.size());
   taxonomyService.removeCategory(article, "Education", "Language", true);
   lstNode = mockTaxonomyService.getAllCategories(article, true);
   assertEquals(1, lstNode.size());
   taxonomyService.removeCategory(article, "News", "Weather", true);
   lstNode = mockTaxonomyService.getAllCategories(article, true);
   assertEquals(0, lstNode.size());
 }
Ejemplo n.º 2
0
 /**
  * Test method TaxonomyService.getAllCategories() Input: Add 3 categories to node Expect: return 3
  * categories
  *
  * @throws RepositoryException
  * @throws TaxonomyNodeAlreadyExistsException
  * @throws TaxonomyAlreadyExistsException
  */
 public void testGetAllCategories()
     throws RepositoryException, TaxonomyNodeAlreadyExistsException,
         TaxonomyAlreadyExistsException {
   session.getRootNode().addNode("MyDocuments");
   Node article = session.getRootNode().addNode("Article");
   session.save();
   taxonomyService.addTaxonomyNode(COLLABORATION_WS, "/MyDocuments", "Culture", "root");
   taxonomyService.addTaxonomyNode(COLLABORATION_WS, "/MyDocuments", "News", "root");
   taxonomyService.addTaxonomyNode(COLLABORATION_WS, "/MyDocuments/News", "Politics", "root");
   taxonomyService.addTaxonomyNode(COLLABORATION_WS, "/MyDocuments/Culture", "Foods", "root");
   taxonomyService.addTaxonomyNode(COLLABORATION_WS, "/MyDocuments/Culture", "Art", "root");
   Node rootTree1 = (Node) session.getItem("/MyDocuments/Culture");
   Node rootTree2 = (Node) session.getItem("/MyDocuments/News");
   taxonomyService.addTaxonomyTree(rootTree1);
   taxonomyService.addTaxonomyTree(rootTree2);
   taxonomyService.addCategories(article, "Culture", new String[] {"Foods", "Art"}, true);
   taxonomyService.addCategory(article, "News", "Politics", true);
   List<Node> lstNode = mockTaxonomyService.getAllCategories(article, true);
   Node taxoLink1 = (Node) session.getItem("/MyDocuments/Culture/Foods");
   Node taxoLink2 = (Node) session.getItem("/MyDocuments/Culture/Art");
   Node taxoLink3 = (Node) session.getItem("/MyDocuments/News/Politics");
   assertEquals(3, lstNode.size());
   assertTrue(lstNode.contains(taxoLink1));
   assertTrue(lstNode.contains(taxoLink2));
   assertTrue(lstNode.contains(taxoLink3));
 }