@Test
public void testGetReferences() throws Exception {

	Playlist playlist1 = new Playlist("d1");
	playlist1 = playlistService.createPlaylist(playlist1);
	Playlist playlist2 = new Playlist("d2");
	playlist2 = playlistService.createPlaylist(playlist2);
	Playlist playlist3 = new Playlist("d3");
	playlist3 = playlistService.createPlaylist(playlist3);
	playlist3 = playlistService.addPlaylist(playlist3.getId(), playlist2);
	Playlist playlist4 = new Playlist("d4");
	playlist4 = playlistService.createPlaylist(playlist4);
	playlist4 = playlistService.addPlaylist(playlist4.getId(), playlist2);
	// an unreferenced playlist
	Playlist playlist5 = new Playlist("d5");
	playlist5 = playlistService.createPlaylist(playlist5);
	screenService.createScreen(new Screen("s1", playlist1));
	screenService.createScreen(new Screen("s2", playlist2));
	screenService.createScreen(new Screen("s3", playlist2));
	Screen screen4 = screenService.createScreen(new Screen("s4", playlist1));
	screenService.createScreen(new Screen("s5"));
	// one screen where user is not owner
	screen4.getOwners().clear();
	screen4 = ScreenDAO.save(screen4);
	// one playlist where user is not owner
	playlist4.getOwners().clear();
	playlist4 = PlaylistDAO.save(playlist4);
	PlaylistReferences refs = playlistService.getReferences(playlist1.getId());
	assertEquals(1, refs.getUserScreens().size());
	assertEquals(1, refs.getForeignScreens());
	assertEquals(0, refs.getUserPlaylists().size());
	assertEquals(0, refs.getForeignPlaylists());
	refs = playlistService.getReferences(playlist2.getId());
	assertEquals(2, refs.getUserScreens().size());
	assertEquals(0, refs.getForeignScreens());
	assertEquals(1, refs.getUserPlaylists().size());
	assertEquals(1, refs.getForeignPlaylists());
	refs = playlistService.getReferences(playlist5.getId());
	assertEquals(0, refs.getUserScreens().size());
	assertEquals(0, refs.getForeignScreens());
	assertEquals(0, refs.getUserPlaylists().size());
	assertEquals(0, refs.getForeignPlaylists());
}