@Override public String getNewBagType() throws IncompatibleTypes { try { return DescriptorUtils.findSumType(getClasses()).getUnqualifiedName(); } catch (MetaDataException e) { throw new IncompatibleTypes(e); } }
@Override public String getNewBagType() throws IncompatibleTypes { try { return DescriptorUtils.findSumType(getClasses()).getUnqualifiedName(); } catch (MetaDataException e) { throw new IncompatibleTypes(e); } }
@Override public String getNewBagType() throws IncompatibleTypes { try { return DescriptorUtils.findSumType(getClasses()).getUnqualifiedName(); } catch (MetaDataException e) { throw new IncompatibleTypes(e); } }
@Override public String getNewBagType() throws IncompatibleTypes { try { return DescriptorUtils.findSumType(getClasses()).getUnqualifiedName(); } catch (MetaDataException e) { throw new IncompatibleTypes(e); } }
break; ClassDescriptor nextCommonSuperType = findSumType(copyOfClasses); isLineage = nextCommonSuperType != lastCommonType; lastCommonType = nextCommonSuperType;
break; ClassDescriptor nextCommonSuperType = findSumType(copyOfClasses); isLineage = nextCommonSuperType != lastCommonType; lastCommonType = nextCommonSuperType;
@Test public void testEmptySet() { try { DescriptorUtils.findSumType(classes); fail("No exception thrown"); } catch (MetaDataException e) { // Expected behaviour. } }
@Test public void testNull() throws MetaDataException { classes = null; try { DescriptorUtils.findSumType(classes); fail("No exception thrown"); } catch (IllegalArgumentException e) { // Expected behaviour. } }
@Override public String getNewBagType() throws IncompatibleTypes { try { ClassDescriptor leftType = findSumType(getClasses()); // We have to check these individually, because of multiple inheritance on the // left. We could, for example have Employees on the left, and subtract Things and // HasAddresses from them, even though there is no common type of Thing and // HasAddress. for (InterMineBag bag: excluded) { // Just check that it makes sense to subtract the rights from the lefts, // ie. that there is some kind of common type here at all. findIntersectionType(asList(leftType, model.getClassDescriptorByName(bag.getType()))); } // But in all cases, the final type is the left type. return leftType.getUnqualifiedName(); } catch (MetaDataException e) { throw new IncompatibleTypes(e); } }
@Override public String getNewBagType() throws IncompatibleTypes { try { ClassDescriptor leftType = findSumType(getClasses()); // We have to check these individually, because of multiple inheritance on the // left. We could, for example have Employees on the left, and subtract Things and // HasAddresses from them, even though there is no common type of Thing and // HasAddress. for (InterMineBag bag: excluded) { // Just check that it makes sense to subtract the rights from the lefts, // ie. that there is some kind of common type here at all. findIntersectionType(asList(leftType, model.getClassDescriptorByName(bag.getType()))); } // But in all cases, the final type is the left type. return leftType.getUnqualifiedName(); } catch (MetaDataException e) { throw new IncompatibleTypes(e); } }
@Test public void testSingleMember() throws MetaDataException { withClass("Employee"); String common = DescriptorUtils.findSumType(classes).getUnqualifiedName(); assertEquals(common, "Employee"); }
/** * Test that the common type of parent and child is * the ancestor. * * ie: * <pre> * [A] * \ * B * </pre> */ @Test public void testDirectSubclass() throws MetaDataException { withClasses("Employee", "Address"); String common = DescriptorUtils.findSumType(classes).getUnqualifiedName(); assertEquals(common, "Thing"); }
/** * Test that the common type of cousins is the grandparent * * ie: * <pre> * [?] * / \ * B C * </pre> */ @Test public void testCommonCousins() throws MetaDataException { withClasses("Employable", "Address"); String common = DescriptorUtils.findSumType(classes).getUnqualifiedName(); assertEquals(common, "Thing"); }
/** * Test that the common type of grandparent and grand-child is * the ancestor. * * ie: * <pre> * [A] * \ * ? * \ * C * </pre> */ @Test public void testDistantSubclass() throws MetaDataException { withClasses("Employable", "Manager"); String common = DescriptorUtils.findSumType(classes).getUnqualifiedName(); assertEquals(common, "Employable"); }
/** * Test that exceptions are thrown for unconnected types. * * ie: * <pre> * {BOOM} * | | * A B * </pre> */ @Test public void testIncompatibleTypes() { withClasses("Employee", "SimpleObject"); try { String common = DescriptorUtils.findSumType(classes).getUnqualifiedName(); fail("No exception thrown: " + common); } catch (MetaDataException e) { // Expected behaviour. } }