@Test public void getByNameReturnsNullWhenDocumentNotLoaded() throws Exception { when(this.getByNameQuery.execute()).thenReturn(Collections.singletonList(PERSON_DOCNAME)); when(this.dab.getDocument(PERSON_REFERENCE)).thenReturn(null); Person result = this.manager.getByName(PERSON_NAME); Assert.assertNull(result); }
@Override public E getByName(String name) { try { Query q = this.qm.createQuery( "select doc.fullName from Document doc, doc.object(" + this.localSerializer.serialize(getEntityXClassReference()) + ") as entity where doc.space = :space and doc.title = :name", Query.XWQL).bindValue("space", this.getDataSpace().getName()).bindValue("name", name); List<String> docNames = q.execute(); for (String docName : docNames) { return get(docName); } } catch (QueryException ex) { this.logger.warn("Failed to retrieve the entity named [{}]: {}", name, ex.getMessage()); } return null; }
AbstractPrimaryEntityManager implements PrimaryEntityManager<E> { @Override public E getByName(String name) { try { Query q = this.qm.createQuery( "select doc.fullName from Document doc, doc.object(" + this.localSerializer.serialize(getEntityXClassReference()) + ") as entity where doc.space = :space and doc.title = :name", Query.XWQL).bindValue("space", this.getDataSpace().getName()).bindValue("name", name); List<String> docNames = q.execute(); for (String docName : docNames) { return get(docName); } } catch (QueryException ex) { this.logger.warn("Failed to retrieve the entity named [{}]: {}", name, ex.getMessage()); } return null; } }
AbstractPrimaryEntityManager implements PrimaryEntityManager<E> { @Override public E getByName(String name) { try { Query q = this.qm.createQuery( "select doc.fullName from Document doc, doc.object(" + this.localSerializer.serialize(getEntityXClassReference()) + ") as entity where doc.space = :space and doc.title = :name", Query.XWQL).bindValue("space", this.getDataSpace().getName()).bindValue("name", name); List<String> docNames = q.execute(); for (String docName : docNames) { return get(docName); } } catch (QueryException ex) { this.logger.warn("Failed to retrieve the entity named [{}]: {}", name, ex.getMessage()); } return null; }  }
AbstractPrimaryEntityManager implements PrimaryEntityManager<E> { @Override public E getByName(String name) { try { Query q = this.qm.createQuery( "select doc.fullName from Document doc, doc.object(" + this.localSerializer.serialize(getEntityXClassReference()) + ") as entity where doc.space = :space and doc.title = :name", Query.XWQL).bindValue("space", this.getDataSpace().getName()).bindValue("name", name); List<String> docNames = q.execute(); for (String docName : docNames) { return get(docName); } } catch (QueryException ex) { this.logger.warn("Failed to retrieve the entity named [{}]: {}", name, ex.getMessage()); } return null; }  @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 getByName(String name) { try { Query q = this.qm.createQuery( "select doc.fullName from Document doc, doc.object(" + this.localSerializer.serialize(getEntityXClassReference()) + ") as entity where doc.space = :space and doc.title = :name", Query.XWQL).bindValue("space", this.getDataSpace().getName()).bindValue("name", name); List<String> docNames = q.execute(); for (String docName : docNames) { return get(docName); } } catch (QueryException ex) { this.logger.warn("Failed to retrieve the entity named [{}]: {}", name, ex.getMessage()); } return null; }  @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();  }