/** * Return a Set of ClassDescriptors for all classes that directly extend or implement this class * or interface. * * @return set of subclass ClassDescriptors * @throws IllegalStateException if the set of subclasses has not been set */ public Set<ClassDescriptor> getSubDescriptors() { checkModel(); return model.getDirectSubs(this); }
public void testSetClassDescriptorNull() throws Exception { FieldDescriptor fd = new TestFieldDescriptor("name"); try { fd.setClassDescriptor(null); fail("Expected NullPointerException"); } catch (NullPointerException e) { } }
public void testSetClassDescriptorValid() throws Exception { FieldDescriptor fd = new TestFieldDescriptor("name"); ClassDescriptor cld = makeClass("Class1"); try { fd.setClassDescriptor(cld); } catch (IllegalStateException e) { fail("Unable to set ClassDescriptor"); } }
public void testRelationTypeManyToOne() throws Exception { CollectionDescriptor col = new CollectionDescriptor("col1", "package.name.Class1", null); ReferenceDescriptor ref = new ReferenceDescriptor("ref1", "package.name.Class1", "col1"); Set<CollectionDescriptor> cols = Collections.singleton(col); Set<ReferenceDescriptor> refs = Collections.singleton(ref); ClassDescriptor cld = new ClassDescriptor("package.name.Class1", null, false, ClassDescriptorFactory.NO_ATTRS, refs, cols); new Model("model1", "package.name", Collections.singleton(cld)); assertEquals(FieldDescriptor.N_ONE_RELATION, ref.relationType()); }
public void testRelationTypeOneToMany() throws Exception { CollectionDescriptor col = new CollectionDescriptor("col1", "package.name.Class1", "ref1"); ReferenceDescriptor ref = new ReferenceDescriptor("ref1", "package.name.Class1", null); Set<CollectionDescriptor> cols = Collections.singleton(col); Set<ReferenceDescriptor> refs = Collections.singleton(ref); ClassDescriptor cld = new ClassDescriptor("package.name.Class1", null, false, noAttrs, refs, cols); new Model("model1", "package.name", Collections.singleton(cld)); assertEquals(FieldDescriptor.ONE_N_RELATION, col.relationType()); }
public void testFieldDescriptorByName() throws Exception { ClassDescriptor cld = new ClassDescriptor( "package.name.Class1", null, false, getAttributes(), getReferences(), getCollections()); cld.setAllFieldDescriptors(); assertNotNull(cld.getFieldDescriptorByName("atd1")); assertNotNull(cld.getFieldDescriptorByName("atd2")); assertNotNull(cld.getFieldDescriptorByName("rfd1")); assertNotNull(cld.getFieldDescriptorByName("rfd2")); assertNotNull(cld.getFieldDescriptorByName("cld1")); assertNotNull(cld.getFieldDescriptorByName("cld2")); }
public void testConstructorNullType() throws Exception { try { new AttributeDescriptor("name", null); fail("Expected: IllegalArgumentException"); } catch (IllegalArgumentException e) { } }
public void testEquals() throws Exception { AttributeDescriptor attr1 = new AttributeDescriptor("name1", "int"); AttributeDescriptor attr2 = new AttributeDescriptor("name1", "int"); AttributeDescriptor attr3 = new AttributeDescriptor("name2", "int"); AttributeDescriptor attr4 = new AttributeDescriptor("name1", "float"); assertEquals(attr1, attr2); assertEquals(attr1.hashCode(), attr2.hashCode()); assertFalse(attr1.equals(attr3)); assertFalse(attr1.equals(attr4)); }
public void testEquals() throws Exception { ReferenceDescriptor ref1 = new ReferenceDescriptor("rfd1", "Class2", "rfd1"); ReferenceDescriptor ref2 = new ReferenceDescriptor("rfd1", "Class2", "rfd1"); ReferenceDescriptor ref3 = new ReferenceDescriptor("rfd2", "Class2", "rfd1"); ReferenceDescriptor ref5 = new ReferenceDescriptor("rfd1", "Class3", "rfd1"); ReferenceDescriptor ref6 = new ReferenceDescriptor("rfd1", "Class2", "rfd2"); assertEquals(ref1, ref2); assertEquals(ref1.hashCode(), ref2.hashCode()); assertFalse(ref1.equals(ref3)); assertFalse(ref1.equals(ref5)); assertFalse(ref1.equals(ref6)); }
public void testToString() throws Exception { CollectionDescriptor col = new CollectionDescriptor("ref", "package.name.Class1", null); String expected = "<collection name=\"ref\" referenced-type=\"Class1\"/>"; assertEquals(col.toString(), expected); col = new CollectionDescriptor("ref", "package.name.Class1", "reverseRef"); expected = "<collection name=\"ref\" referenced-type=\"Class1\" reverse-reference=\"reverseRef\"/>"; assertEquals(col.toString(), expected); } }
public void testConstructNameNull() { try { new ClassDescriptor("", null, false, noAttrs, noRefs, noColls); fail("Expected: IllegalArgumentException"); } catch (IllegalArgumentException e) { } }
public void testCapitalise() throws Exception { assertEquals("A", StringUtil.capitalise("a")); assertEquals("A", StringUtil.capitalise("A")); assertEquals("Aaaa", StringUtil.capitalise("aaaa")); assertEquals("AaaaBbbb", StringUtil.capitalise("aaaaBbbb")); assertEquals("", StringUtil.capitalise("")); assertNull(StringUtil.capitalise(null)); }
public void testReverseCapitalisation() throws Exception { assertEquals("a", StringUtil.reverseCapitalisation("A")); assertEquals("A", StringUtil.reverseCapitalisation("a")); assertEquals("aa", StringUtil.reverseCapitalisation("Aa")); assertEquals("AA", StringUtil.reverseCapitalisation("aA")); assertEquals("", StringUtil.reverseCapitalisation("")); assertNull(StringUtil.reverseCapitalisation(null)); }
public void testConstructorNull() throws Exception { try { new PrimaryKey("key", null, null); fail("Expected NullPointerException"); } catch (NullPointerException e) { } }
public void testCountOccurancesNullStr() throws Exception { try { StringUtil.countOccurances(null, "A test string"); fail("Expected: NullPointerException"); } catch (NullPointerException e) { } }
public void testIndefiniteArticle() throws Exception { assertEquals("a", StringUtil.indefiniteArticle("monkey")); assertEquals("an", StringUtil.indefiniteArticle("emu")); assertEquals("a", StringUtil.indefiniteArticle("TLA")); assertEquals("an", StringUtil.indefiniteArticle("O")); assertEquals("an", StringUtil.indefiniteArticle("IMP")); }
public void testConstructorEmptyType() throws Exception { try { new AttributeDescriptor("name", ""); fail("Expected: IllegalArgumentException"); } catch (IllegalArgumentException e) { } }
public void testSetClassDescriptorTwice() throws Exception { FieldDescriptor fd = new TestFieldDescriptor("name"); ClassDescriptor cld = makeClass("Class1"); fd.setClassDescriptor(cld); try { fd.setClassDescriptor(cld); fail("Expected IllegalStateException"); } catch (IllegalStateException e) { } }
public void testConstructorNullName() throws Exception { try { new AttributeDescriptor(null, "int"); fail("Expected IllegalArgumentException"); } catch (IllegalArgumentException e) { } }
public void testConstructorEmptyName() throws Exception { try { new AttributeDescriptor("", "int"); fail("Expected IllegalArgumentException"); } catch (IllegalArgumentException e) { } }