@Test(groups = {"wso2.greg"}) public void EditComment() throws Exception { Resource r1 = registry.newResource(); byte[] r1content = "R1 content".getBytes(); r1.setContent(r1content); r1.setDescription("this is a resource to edit comment"); registry.put("/c101/c11/r1", r1); Comment c1 = new Comment(); c1.setResourcePath("/c10/c11/r1"); c1.setText("This is default comment "); c1.setUser("admin"); registry.addComment("/c101/c11/r1", c1); Comment[] comments = registry.getComments("/c101/c11/r1"); boolean commentFound = false; for (Comment comment : comments) { if (comment.getText().equals(c1.getText())) { commentFound = true; // //System.out.println(comment.getText()); // //System.out.println(comment.getResourcePath()); // //System.out.println(comment.getUser()); // //System.out.println(comment.getTime()); // //System.out.println("\n"); // break; } } assertTrue( commentFound, "comment:" + c1.getText() + " is not associated with the artifact /c101/c11/r1"); try { Resource commentsResource = registry.get("/c101/c11/r1;comments"); assertTrue(commentsResource instanceof Collection, "Comment resource should be a directory."); comments = (Comment[]) commentsResource.getContent(); List commentTexts = new ArrayList(); for (Comment comment : comments) { Resource commentResource = registry.get(comment.getPath()); commentTexts.add(new String((byte[]) commentResource.getContent())); } assertTrue( commentTexts.contains(c1.getText()), c1.getText() + " is not associated for resource /c101/c11/r1."); registry.editComment(comments[0].getPath(), "This is the edited comment"); comments = registry.getComments("/c101/c11/r1"); // System.out.println(comments); Resource resource = registry.get(comments[0].getPath()); assertEquals(new String((byte[]) resource.getContent()), "This is the edited comment"); } catch (RegistryException e) { e.printStackTrace(); fail("Failed to get comments form URL:/c101/c11/r1;comments"); } /*Edit comment goes here*/ registry.editComment("/c101/c11/r1", "This is the edited comment"); }