public void testRevereseReferenceNotReciprocal() throws Exception { // rfd1 points to Class2 but has reverse-reference that points to another field in Class1 ReferenceDescriptor rfd1 = new ReferenceDescriptor("rfd1", "package.name.Class2", "rfd2"); ReferenceDescriptor rfdOther1 = new ReferenceDescriptor("rfdOther1", "package.name.Class2", "rfd2"); ReferenceDescriptor rfd2 = new ReferenceDescriptor("rfd2", "package.name.Class1", "rfdOther1"); Set<ReferenceDescriptor> refs1 = new HashSet<ReferenceDescriptor>(Arrays.asList(rfd1, rfdOther1)); Set<ReferenceDescriptor> refs2 = Collections.singleton(rfd2); ClassDescriptor cld1 = new ClassDescriptor("package.name.Class1", null, false, ClassDescriptorFactory.NO_ATTRS, refs1, ClassDescriptorFactory.NO_COLLS); ClassDescriptor cld2 = new ClassDescriptor("package.name.Class2", null, false, ClassDescriptorFactory.NO_ATTRS, refs2, ClassDescriptorFactory.NO_COLLS); Model model = new Model("model", "package.name", Arrays.asList(cld1, cld2)); // this no longer throws an exception , instead creates the model but adds a problem assertEquals(1, model.getProblems().size()); }
if (newModel.hasProblems()) { throw new ModelMergerException("There were problems merging the model: " + newModel.getProblems());
public void testRevereseReferenceWrongType() throws Exception { // rfd1 points to Class2 but has reverse-reference rfd2 which exists but is a refernece to Class3 ReferenceDescriptor rfd1 = new ReferenceDescriptor("rfd1", "package.name.Class2", "rfd2"); ReferenceDescriptor rfd2 = new ReferenceDescriptor("rfd2", "package.name.Class3", "rfd1"); ReferenceDescriptor rfd3 = new ReferenceDescriptor("rfd1", "package.name.Class2", "rfd2"); //ReferenceDescriptor rfdOther2 = new ReferenceDescriptor("rfdOther2", "package.name.Class1", "rfd2"); Set<ReferenceDescriptor> refs1 = Collections.singleton(rfd1); Set<ReferenceDescriptor> refs2 = Collections.singleton(rfd2); Set<ReferenceDescriptor> refs3 = Collections.singleton(rfd3); ClassDescriptor cld1 = new ClassDescriptor("package.name.Class1", null, false, ClassDescriptorFactory.NO_ATTRS, refs1, ClassDescriptorFactory.NO_COLLS); ClassDescriptor cld2 = new ClassDescriptor("package.name.Class2", null, false, ClassDescriptorFactory.NO_ATTRS, refs2, ClassDescriptorFactory.NO_COLLS); ClassDescriptor cld3 = new ClassDescriptor("package.name.Class3", null, false, ClassDescriptorFactory.NO_ATTRS, refs3, ClassDescriptorFactory.NO_COLLS); Model model = new Model("model", "package.name", Arrays.asList(cld1, cld2, cld3)); assertEquals(1, model.getProblems().size()); }
if (newModel.hasProblems()) { throw new ModelMergerException("There were problems merging the model: " + newModel.getProblems());