@Test public void testWriteLinkNode() throws JSONException, RepositoryException, IOException { Session session = mock(Session.class); ByteArrayOutputStream baos = new ByteArrayOutputStream(); Writer w = new PrintWriter(baos); JSONWriter write = new JSONWriter(w); SiteService siteService = mock(SiteService.class); Node node = new MockNode("/path/to/link"); node.setProperty(FilesConstants.SAKAI_LINK, "uuid"); node.setProperty("foo", "bar"); Node fileNode = createFileNode(); when(session.getNodeByIdentifier("uuid")).thenReturn(fileNode); FileUtils.writeLinkNode(node, session, write, siteService); w.flush(); String s = baos.toString("UTF-8"); JSONObject j = new JSONObject(s); assertEquals("/path/to/link", j.getString("jcr:path")); assertEquals("bar", j.getString("foo")); assertFileNodeInfo(j.getJSONObject("file")); }