/** * test method addFavourite. Input: /testAddFavourite node tested action: add favorite for 3 users * 'root', 'demo', 'james' to the node above. Expected value : 1 for favorite node list size of * each user /testAddFavourite node) * * @throws Exception */ public void testAddFavorite() throws Exception { Node rootNode = session.getRootNode(); Node testAddFavouriteNode = rootNode.addNode("testAddFavorite"); session.save(); favoriteService.addFavorite(testAddFavouriteNode, "root"); favoriteService.addFavorite(testAddFavouriteNode, "demo"); favoriteService.addFavorite(testAddFavouriteNode, "james"); int rootFav = favoriteService .getAllFavoriteNodesByUser(session.getWorkspace().getName(), REPO_NAME, "root") .size(); int demoFav = favoriteService .getAllFavoriteNodesByUser(session.getWorkspace().getName(), REPO_NAME, "demo") .size(); int jamesFav = favoriteService .getAllFavoriteNodesByUser(session.getWorkspace().getName(), REPO_NAME, "james") .size(); assertEquals("testAddFavorite failed!", 1, rootFav); assertEquals("testAddFavorite failed!", 1, demoFav); assertEquals("testAddFavorite failed!", 1, jamesFav); testAddFavouriteNode.remove(); session.save(); }
/** * test method getAllFavouriteNodesByUser. Input: /node0 /node1 /node2 /node3 /node3/node4. Tested * action: add favorite for 'root' to node0, node2, node4; add favorite for 'demo' to property of * node1, * * <p>expectedValue : 4 ( number of favorite nodes by 'root') * * @throws Exception */ public void testGetAllFavouriteNodesByUser() throws Exception { Node rootNode = session.getRootNode(); Node testNode = rootNode.addNode("testNode"); session.save(); Node node0 = testNode.addNode("node0"); Node node1 = testNode.addNode("node1"); Node node2 = testNode.addNode("node2"); Node node3 = testNode.addNode("node3"); Node node4 = node3.addNode("node4"); favoriteService.addFavorite(node0, "root"); favoriteService.addFavorite(node1, "demo"); favoriteService.addFavorite(node2, "root"); favoriteService.addFavorite(node3, "root"); favoriteService.addFavorite(node4, "root"); assertEquals( "testGetAllFavouriteNodesByUser failed!", 4, favoriteService .getAllFavoriteNodesByUser( rootNode.getSession().getWorkspace().getName(), "repository", "root") .size()); testNode.remove(); session.save(); }