@Test public void createSkipsExistingDocuments() throws Exception { DocumentReference ref = new DocumentReference("main", "Persons", "P0000005"); when(this.referenceResolver .resolve(new EntityReference("P0000005", EntityType.DOCUMENT, this.manager.getDataSpace()))) .thenReturn(ref); when(this.dab.exists(ref)).thenReturn(true); ref = new DocumentReference("main", "Persons", "P0000006"); when(this.referenceResolver .resolve(new EntityReference("P0000006", EntityType.DOCUMENT, this.manager.getDataSpace()))) .thenReturn(ref); when(this.dab.exists(ref)).thenReturn(false); when(this.dab.getDocument(ref)).thenReturn(this.doc); when(this.doc.getDocumentReference()).thenReturn(ref); Person result = this.manager.create(); Assert.assertNotNull(result); Assert.assertEquals("P0000006", result.getId()); Mockito.verify(this.xwiki).saveDocument(this.doc, this.xcontext); }
@Override public E create() { return create(this.bridge.getCurrentUserReference()); }
AbstractPrimaryEntityManager implements PrimaryEntityManager<E> { @Override public E create() { return create(this.bridge.getCurrentUserReference()); } }
AbstractPrimaryEntityManager implements PrimaryEntityManager<E> { @Override public E create() { return create(this.bridge.getCurrentUserReference()); }  }
AbstractPrimaryEntityManager implements PrimaryEntityManager<E> { @Override public E create() { return create(this.bridge.getCurrentUserReference()); }  @Override E create(); @Override synchronized E create(DocumentReference creator); @Override E get(String id); @Override E get(DocumentReference reference); @Override E getByName(String name); @Override Iterator<E> getAll(); @Override boolean delete(E entity); @Override E load(DocumentModelBridge document); @Override String getIdPrefix(); @Override EntityReference getEntityType(); }
AbstractPrimaryEntityManager implements PrimaryEntityManager<E> { @Override public E create() { return create(this.bridge.getCurrentUserReference()); }  @Override E create(); @Override synchronized E create(DocumentReference creator); @Override E get(String id); @Override E get(DocumentReference reference); @Override E getByName(String name); @Override Iterator<E> getAll(); @Override boolean delete(E entity); @Override E load(DocumentModelBridge document); @Override String getIdPrefix(); @Override EntityReference getEntityType();  }