@Test public void testFindByTitle() throws Exception { IPictogram pictogram = new Pictogram(); pictogram.setTitle("testFindByTitle"); pictogram.setFileIdentifier("test.txt"); repository.save(pictogram); IPictogram testPictogram = repository.findByTitle(pictogram.getTitle()); assertEquals(pictogram.getId(), testPictogram.getId()); // return null for non-existing entities testPictogram = repository.findByTitle("NON-EXIST"); assertEquals(null, testPictogram); }
@Test public void testConvertToEntity() throws Exception { ODocument document = new ODocument("Pictogram") .field("title", "title") .field("titleasc", "title") .field("fileIdentifier", "test.txt") .field("created", 1L) .field("modified", 2L); // persist to database to create id document.save(); IPictogram pictogram = repository.convertToEntity(document); assertEquals("title", pictogram.getTitle()); assertEquals("test.txt", pictogram.getFileIdentifier()); assertEquals(new Long(1L), pictogram.getCreated()); assertEquals(new Long(2L), pictogram.getModified()); assertEquals(document.getIdentity().toString(), pictogram.getId()); }