@Test public void testWriteAssociation() throws Exception { final ClassType mockClass = Mockito.mock(ClassType.class); final List<TaggedValue> mockTaggedValues = new ArrayList<TaggedValue>(); final Identifier id = Identifier.random(); final Identifier testId = Identifier.fromString("1234"); mockTaggedValues.add(new TaggedValue("true", id)); final Multiplicity mult = new Multiplicity(new Range(Occurs.ZERO, Occurs.ONE)); final AssociationEnd mockEnd = new AssociationEnd(mult, "test", false, mockTaggedValues, testId, "test"); final ModelIndex mockIndex = Mockito.mock(ModelIndex.class); final Uml2XsdPluginWriter mockWriter = Mockito.mock(Uml2XsdPluginWriter.class); final TagDefinition mockTagDef = new TagDefinition(Identifier.random(), "mongo.navigable", mult); final Type mockType = Mockito.mock(Type.class); Mockito.when(mockIndex.getTagDefinition(id)).thenReturn(mockTagDef); Mockito.when(mockIndex.getType(testId)).thenReturn(mockType); Mockito.when(mockType.getName()).thenReturn("test name"); pluginForMongo.writeAssociation(mockClass, mockEnd, mockIndex, mockWriter); Mockito.verify(mockWriter).element(); Mockito.verify(mockWriter).annotation(); Mockito.verify(mockWriter).begin("sli", SliMongoConstants.SLI_REFERENCE_TYPE.getLocalPart(), SliMongoConstants.SLI_REFERENCE_TYPE.getNamespaceURI()); }
@Override public void writeAssociation(final ClassType complexType, final AssociationEnd end, final ModelIndex model, final Uml2XsdPluginWriter xsw) { if (PluginHelpers.isMongoNavigable(end, model)) { final Type type = model.getType(end.getType()); xsw.element(); try { if (PluginHelpers.hasMongoName(end, model)) { xsw.elementName(new QName(PluginHelpers.getMongoName(end, model))); } else { xsw.elementName(new QName(getName(end, model))); } xsw.type(getTypeName(MONGO_REFERENCE_TYPE)); xsw.minOccurs(end.getMultiplicity().getRange().getLower()); xsw.maxOccurs(end.getMultiplicity().getRange().getUpper()); xsw.annotation(); PluginHelpers.writeDocumentation(end, model, xsw); xsw.appinfo(); xsw.begin("sli", SliMongoConstants.SLI_REFERENCE_TYPE.getLocalPart(), SliMongoConstants.SLI_REFERENCE_TYPE.getNamespaceURI()); xsw.characters(getTypeName(type.getName()).getLocalPart()); xsw.end(); xsw.end(); xsw.end(); } finally { xsw.end(); } } }
PluginForMongo implements Uml2XsdPlugin { @Override public void writeAssociation(final ClassType complexType, final AssociationEnd end, final ModelIndex model, final Uml2XsdPluginWriter xsw) { if (PluginHelpers.isMongoNavigable(end, model)) { final Type type = model.getType(end.getType()); xsw.element(); try { if (PluginHelpers.hasMongoName(end, model)) { xsw.elementName(new QName(PluginHelpers.getMongoName(end, model))); } else { xsw.elementName(new QName(getName(end, model))); } xsw.type(getTypeName(MONGO_REFERENCE_TYPE)); xsw.minOccurs(end.getMultiplicity().getRange().getLower()); xsw.maxOccurs(end.getMultiplicity().getRange().getUpper()); xsw.annotation(); PluginHelpers.writeDocumentation(end, model, xsw); xsw.appinfo(); xsw.begin("sli", SliMongoConstants.SLI_REFERENCE_TYPE.getLocalPart(), SliMongoConstants.SLI_REFERENCE_TYPE.getNamespaceURI()); xsw.characters(getTypeName(type.getName()).getLocalPart()); xsw.end(); xsw.end(); xsw.end(); } finally { xsw.end(); } } } }
PluginForMongo implements Uml2XsdPlugin { @Override public void writeAssociation(final ClassType complexType, final AssociationEnd end, final ModelIndex model, final Uml2XsdPluginWriter xsw) { if (PluginHelpers.isMongoNavigable(end, model)) { final Type type = model.getType(end.getType()); xsw.element(); try { if (PluginHelpers.hasMongoName(end, model)) { xsw.elementName(new QName(PluginHelpers.getMongoName(end, model))); } else { xsw.elementName(new QName(getName(end, model))); } xsw.type(getTypeName(MONGO_REFERENCE_TYPE)); xsw.minOccurs(end.getMultiplicity().getRange().getLower()); xsw.maxOccurs(end.getMultiplicity().getRange().getUpper()); xsw.annotation(); PluginHelpers.writeDocumentation(end, model, xsw); xsw.appinfo(); xsw.begin("sli", SliMongoConstants.SLI_REFERENCE_TYPE.getLocalPart(), SliMongoConstants.SLI_REFERENCE_TYPE.getNamespaceURI()); xsw.characters(getTypeName(type.getName()).getLocalPart()); xsw.end(); xsw.end(); xsw.end(); } finally { xsw.end(); } } }  }
PluginForMongo implements Uml2XsdPlugin { @Override public void writeAssociation(final ClassType complexType, final AssociationEnd end, final ModelIndex model, final Uml2XsdPluginWriter xsw) { if (PluginHelpers.isMongoNavigable(end, model)) { final Type type = model.getType(end.getType()); xsw.element(); try { if (PluginHelpers.hasMongoName(end, model)) { xsw.elementName(new QName(PluginHelpers.getMongoName(end, model))); } else { xsw.elementName(new QName(getName(end, model))); } xsw.type(getTypeName(MONGO_REFERENCE_TYPE)); xsw.minOccurs(end.getMultiplicity().getRange().getLower()); xsw.maxOccurs(end.getMultiplicity().getRange().getUpper()); xsw.annotation(); PluginHelpers.writeDocumentation(end, model, xsw); xsw.appinfo(); xsw.begin("sli", SliMongoConstants.SLI_REFERENCE_TYPE.getLocalPart(), SliMongoConstants.SLI_REFERENCE_TYPE.getNamespaceURI()); xsw.characters(getTypeName(type.getName()).getLocalPart()); xsw.end(); xsw.end(); xsw.end(); } finally { xsw.end(); } } }  static final boolean isUnbounded(final Occurs occurs); @Override Map<String, String> declarePrefixMappings(); @Override QName getElementName(final String name, final boolean isReference); @Override QName getElementType(final String name, final boolean isAssociation); @Override QName getGraphAssociationEndName(final PsmDocument<Type> classType); @Override QName getElementName(final PsmDocument<Type> classType); @Override String getTargetNamespace(); @Override QName getTypeName(final String name); @Override boolean isAttributeFormDefaultQualified(); @Override boolean isElementFormDefaultQualified(); @Override boolean isEnabled(final QName name); @Override void writeAppInfo(final TaggedValue taggedValue, final ModelIndex lookup, final Uml2XsdPluginWriter xsw); @Override void writeAssociation(final ClassType complexType, final AssociationEnd end, final ModelIndex model,
            final Uml2XsdPluginWriter xsw); @Override void writeTopLevelElement(PsmDocument<Type> classType, ModelIndex model, Uml2XsdPluginWriter xsw); }
PluginForMongo implements Uml2XsdPlugin { @Override public void writeAssociation(final ClassType complexType, final AssociationEnd end, final ModelIndex model, final Uml2XsdPluginWriter xsw) { if (PluginHelpers.isMongoNavigable(end, model)) { final Type type = model.getType(end.getType()); xsw.element(); try { if (PluginHelpers.hasMongoName(end, model)) { xsw.elementName(new QName(PluginHelpers.getMongoName(end, model))); } else { xsw.elementName(new QName(getName(end, model))); } xsw.type(getTypeName(MONGO_REFERENCE_TYPE)); xsw.minOccurs(end.getMultiplicity().getRange().getLower()); xsw.maxOccurs(end.getMultiplicity().getRange().getUpper()); xsw.annotation(); PluginHelpers.writeDocumentation(end, model, xsw); xsw.appinfo(); xsw.begin("sli", SliMongoConstants.SLI_REFERENCE_TYPE.getLocalPart(), SliMongoConstants.SLI_REFERENCE_TYPE.getNamespaceURI()); xsw.characters(getTypeName(type.getName()).getLocalPart()); xsw.end(); xsw.end(); xsw.end(); } finally { xsw.end(); } } }  static final boolean isUnbounded(final Occurs occurs); @Override Map<String, String> declarePrefixMappings(); @Override QName getElementName(final String name, final boolean isReference); @Override QName getElementType(final String name, final boolean isAssociation); @Override QName getGraphAssociationEndName(final PsmDocument<Type> classType); @Override QName getElementName(final PsmDocument<Type> classType); @Override String getTargetNamespace(); @Override QName getTypeName(final String name); @Override boolean isAttributeFormDefaultQualified(); @Override boolean isElementFormDefaultQualified(); @Override boolean isEnabled(final QName name); @Override void writeAppInfo(final TaggedValue taggedValue, final ModelIndex lookup, final Uml2XsdPluginWriter xsw); @Override void writeAssociation(final ClassType complexType, final AssociationEnd end, final ModelIndex model,
            final Uml2XsdPluginWriter xsw); @Override void writeTopLevelElement(PsmDocument<Type> classType, ModelIndex model, Uml2XsdPluginWriter xsw);  }