/** create a new Personality copying this one; the _types_ state is copied, not shared. */ public Personality<T> copy() { return new Personality<>( this ); }
/** create a new Personality copying this one; the _types_ state is copied, not shared. */ public Personality<T> copy() { return new Personality<>( this ); }
public void testNullPointerTrapInCanSupport() { EnhGraph eg = new EnhGraph( Factory.createGraphMem(), new Personality<RDFNode>() ); Node n = NodeCreateUtils.create( "eh:something" ); EnhNode en = new EnhNode( n, eg ); assertFalse( en.canAs( Property.class ) ); }
public void testNullPointerTrapInCanSupport() { EnhGraph eg = new EnhGraph( Factory.createGraphMem(), new Personality<RDFNode>() ); Node n = NodeCreateUtils.create( "eh:something" ); EnhNode en = new EnhNode( n, eg ); assertFalse( en.canAs( Property.class ) ); }
/** Test that an attempt to polymorph an enhanced node into a class that isn't supported by the enhanced graph generates an UnsupportedPolymorphism exception. */ public void testNullPointerTrap() { EnhGraph eg = new EnhGraph( Factory.createGraphMem(), new Personality<RDFNode>() ); Node n = NodeCreateUtils.create( "eh:something" ); EnhNode en = new EnhNode( n, eg ); try { en.as( Property.class ); fail( "oops" ); } catch (UnsupportedPolymorphismException e) { assertEquals( en, e.getBadNode() ); assertTrue( "exception should have cuplprit graph", eg == ((EnhNode)e.getBadNode()).getGraph() ); assertSame( "exception should have culprit class", Property.class, e.getBadClass() ); } }
/** Test that an attempt to polymorph an enhanced node into a class that isn't supported by the enhanced graph generates an UnsupportedPolymorphism exception. */ public void testNullPointerTrap() { EnhGraph eg = new EnhGraph( Factory.createGraphMem(), new Personality<RDFNode>() ); Node n = NodeCreateUtils.create( "eh:something" ); EnhNode en = new EnhNode( n, eg ); try { en.as( Property.class ); fail( "oops" ); } catch (UnsupportedPolymorphismException e) { assertEquals( en, e.getBadNode() ); assertTrue( "exception should have cuplprit graph", eg == ((EnhNode)e.getBadNode()).getGraph() ); assertSame( "exception should have culprit class", Property.class, e.getBadClass() ); } }