public void testForCyclicFalse() { ComplexTypeDescriptor a = new ComplexTypeDescriptor(); a.setName("a"); a.setType("person"); ComplexTypeDescriptor b = new ComplexTypeDescriptor(); b.setName("b"); b.setType("name"); ComplexTypeDescriptor c = new ComplexTypeDescriptor(); c.setName("c"); c.setType("age"); a.getElements().add(b); a.getElements().add(c); assertFalse("should be not identified as cyclic", TypeDescriptor .isCyclic(a)); }
public void testForCyclicTrue() { ComplexTypeDescriptor a = new ComplexTypeDescriptor(); a.setName("a"); a.setType("outertype"); ComplexTypeDescriptor b = new ComplexTypeDescriptor(); b.setName("b"); b.setType("middletype"); ComplexTypeDescriptor c = new ComplexTypeDescriptor(); c.setName("c"); c.setType("innertype"); a.getElements().add(b); b.getElements().add(c); c.getElements().add(a); assertTrue("should be identified as cyclic", TypeDescriptor.isCyclic(a)); }
@Test public void testCyclicToElement() throws Exception { ComplexTypeDescriptor a = new ComplexTypeDescriptor(); a.setName("a"); a.setType("typename"); a.setQnameFromString("{namespace}typename"); ComplexTypeDescriptor b = new ComplexTypeDescriptor(); b.setName("b"); b.setType("typename2"); b.setQnameFromString("{namespace}typename2"); a.getElements().add(b); b.getElements().add(a); Element el = XMLSplitterSerialisationHelper .typeDescriptorToExtensionXML(a); String xml = new XMLOutputter().outputString(el); assertEquals( "unexpected xml", "<s:extensions xmlns:s=\"http://org.embl.ebi.escience/xscufl/0.1alpha\"><s:complextype optional=\"false\" unbounded=\"false\" typename=\"typename\" name=\"a\" qname=\"{namespace}typename\"><s:elements><s:complextype optional=\"false\" unbounded=\"false\" typename=\"typename2\" name=\"b\" qname=\"{namespace}typename2\"><s:elements><s:complextype id=\"{namespace}typename\" optional=\"false\" unbounded=\"false\" typename=\"typename\" name=\"a\" /></s:elements></s:complextype></s:elements></s:complextype></s:extensions>", xml); }
public void testForCyclicTrueWithArray() { ComplexTypeDescriptor a = new ComplexTypeDescriptor(); a.setName("a"); a.setType("outertype"); ArrayTypeDescriptor b = new ArrayTypeDescriptor(); b.setName("b"); b.setType("arraytype"); ComplexTypeDescriptor c = new ComplexTypeDescriptor(); c.setName("c"); c.setType("innertype"); a.getElements().add(b); b.setElementType(c); c.getElements().add(a); assertTrue("should be identified as cyclic", TypeDescriptor.isCyclic(a)); }
@Test public void testCyclicToElement2() throws Exception { ComplexTypeDescriptor a = new ComplexTypeDescriptor(); a.setName("a"); a.setType("typename"); a.setQnameFromString("{namespace}typename"); a.getElements().add(a); Element el = XMLSplitterSerialisationHelper .typeDescriptorToExtensionXML(a); String xml = new XMLOutputter().outputString(el); assertEquals( "unexpected xml", "<s:extensions xmlns:s=\"http://org.embl.ebi.escience/xscufl/0.1alpha\"><s:complextype optional=\"false\" unbounded=\"false\" typename=\"typename\" name=\"a\" qname=\"{namespace}typename\"><s:elements><s:complextype id=\"{namespace}typename\" optional=\"false\" unbounded=\"false\" typename=\"typename\" name=\"a\" /></s:elements></s:complextype></s:extensions>", xml); }
public void testRetrieveSignitureForArrayDescriptor2() { ArrayTypeDescriptor desc = new ArrayTypeDescriptor(); desc.setName("AnArray"); desc.setType("complextype"); ComplexTypeDescriptor complex = new ComplexTypeDescriptor(); complex.setName("complex"); complex.setType("complextype"); desc.setElementType(complex); String[] names = new String[1]; Class<?>[] types = new Class[1]; List<TypeDescriptor> params = new ArrayList<TypeDescriptor>(); params.add(desc); TypeDescriptor.retrieveSignature(params, names, types); assertEquals("AnArray", names[0]); assertEquals(org.w3c.dom.Element.class, types[0]); }