### Question:
XMLSave { protected void saveElementID(EObject o) { String id = helper.getID(o); if (null == id && o instanceof BaseElement) { String eId = ((BaseElement) o).getId(); if (null == eId && isIdNeeded(o)) { id = EcoreUtil.generateUUID(); ((BaseElement) o).setId(id); } } if (id != null) { if (!toDOM) { doc.addAttribute(idAttributeName, id); } else { Attr attr = getGwtDOMHandler().createAttributeNS(idAttributeNS, idAttributeName); attr.setNodeValue(id); getGwtDOMHandler().setAttributeNodeNS(currentNode, attr); handler.recordValues(attr, o, null, o); } } saveFeatures(o); } XMLSave(XMLHelper helper);  XMLSave(Map<?, ?> options, XMLHelper helper, String encoding);  XMLSave(Map<?, ?> options, XMLHelper helper, String encoding, String xmlVersion); Document save(XMLResource resource, Document doc, Map<?, ?> options, XMLDOMHandler handler); void traverse(List<? extends EObject> contents); boolean isDuplicateURI(String nsURI); char[] toChar();  }### Answer:
@Test public void testSaveElementID() { BaseElementImpl obj = mock(BaseElementImpl.class); FormalExpression expression = mock(FormalExpression.class); when(currentNode.getParentNode()).thenReturn(currentNode); when(xmlHelper.getID(any(EObject.class))).thenReturn(null); Attr attr = mock(Attr.class); when(gwtDOMHandler.createAttributeNS(anyString(), anyString())).thenReturn(attr); tested.saveElementID(obj); tested.saveElementID(expression); ArgumentCaptor<String> idCaptor = ArgumentCaptor.forClass(String.class); verify(obj, times(1)).setId(idCaptor.capture()); String id = idCaptor.getValue(); verify(attr, times(1)).setNodeValue(eq(id)); verify(gwtDOMHandler, times(1)).setAttributeNodeNS(eq(currentNode), eq(attr)); verify(xmldomHandler, times(1)).recordValues(eq(attr), eq(obj), eq(null), eq(obj)); }