### Question:
Xsd2UmlLinker { public static Model link(final Model model, final Xsd2UmlHostedPlugin plugin) { final ModelIndex indexedModel = new DefaultModelIndex(model); final Map<String, Identifier> nameToClassTypeId = makeNameToClassTypeId(indexedModel.getClassTypes().values()); final Map<Type, Map<String, AssociationEnd>> navigations = new HashMap<Type, Map<String, AssociationEnd>>(); final List<NamespaceOwnedElement> ownedElements = new LinkedList<NamespaceOwnedElement>(); for (final NamespaceOwnedElement ownedElement : model.getOwnedElements()) { if (ownedElement instanceof ClassType) { final ClassType classType = (ClassType) ownedElement; ownedElements.add(cleanUpClassType(classType, plugin, indexedModel, nameToClassTypeId, navigations)); } else { ownedElements.add(ownedElement); } } final Xsd2UmlPluginHost host = new Xsd2UmlPluginHostAdapter(indexedModel); ownedElements.addAll(makeAssociations(navigations, indexedModel, plugin, host)); return new Model(Identifier.random(), model.getName(), model.getTaggedValues(), ownedElements); }  static Model link(final Model model, final Xsd2UmlHostedPlugin plugin);  }### Answer:
@Test public void testLink() throws Exception { Assert.assertNotNull(Xsd2UmlLinker.link(model, plugin)); }
@Test(expected = IllegalStateException.class) public void testInvalidAssociationEnd() throws Exception { when(plugin.isAssociationEnd(Mockito.any(ClassType.class), Mockito.any(Attribute.class), Mockito.any(Xsd2UmlPluginHost.class))).thenReturn(true); when(plugin.getAssociationEndTypeName(Mockito.any(ClassType.class), Mockito.any(Attribute.class), Mockito.any(Xsd2UmlPluginHost.class))).thenReturn("test"); Assert.assertNotNull(Xsd2UmlLinker.link(model, plugin)); }
@Test(expected = IllegalArgumentException.class) public void testValidAssociationEnd() throws Exception { when(plugin.isAssociationEnd(Mockito.any(ClassType.class), Mockito.any(Attribute.class), Mockito.any(Xsd2UmlPluginHost.class))).thenReturn(true); when(plugin.getAssociationEndTypeName(Mockito.any(ClassType.class), Mockito.any(Attribute.class), Mockito.any(Xsd2UmlPluginHost.class))).thenReturn("classTypeName"); Assert.assertNotNull(Xsd2UmlLinker.link(model, plugin)); }