# # Copyright (c) 2003 by Benja Fallenstein # # This file is part of Gzz. # # Gzz is free software; you can redistribute it and/or modify it under # the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # Gzz is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General # Public License for more details. # # You should have received a copy of the GNU Lesser General # Public License along with Gzz; if not, write to the Free # Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA # import gzz, java import jarray from test.tools.gfx import getvs from com.hp.hpl.mesa.rdf import jena model = jena.mem.ModelMem() p = model.createProperty("http://fenfire.org/2003/02/test#", "test-property") n = [model.createResource() for i in range(10)] n[0].addProperty(p, n[1]) n[1].addProperty(p, n[2]) for i in range(3,10): n[2].addProperty(p, n[i]) class Cmp(java.util.Comparator): def compare(self, r1, r2): return n.index(r1) - n.index(r2) c = gzz.loom.Cursor(Cmp()) def list(set): l = []; i = set.iterator() while i.hasNext(): l.append(i.next()) return l def testGetPoswardConnections(): c.set(n[0], n[1]) assert list(c.getPoswardConnections()) == [n[1]] c.set(n[1], n[2]) assert list(c.getPoswardConnections()) == [n[2]] c.set(n[2], n[3]) assert list(c.getPoswardConnections()) == n[3:] def testRotate(): c.set(n[2], n[5]) c.rotate(1) assert c.focus == n[2] and c.rotation == n[6] c.rotate(1) assert c.focus == n[2] and c.rotation == n[7] c.rotate(-1) assert c.focus == n[2] and c.rotation == n[6] c.set(n[2], n[9]) c.rotate(1) assert c.focus == n[2] and c.rotation == n[9] c.rotate(-1) assert c.focus == n[2] and c.rotation == n[8] c.rotate(1) assert c.focus == n[2] and c.rotation == n[9] c.rotate(1) assert c.focus == n[2] and c.rotation == n[9] c.set(n[2], n[3]) c.rotate(-1) assert c.focus == n[2] and c.rotation == n[3]