@Test public void getOwnerWithMissingDocument() { when(this.entity.getDocumentReference()).thenReturn(null); Assert.assertNull(this.component.getOwner(this.entity)); }
@Nullable @Override public Owner getOwner(@Nullable final PrimaryEntity entity) { if (entity == null || entity.getDocumentReference() == null) { return null; } final DocumentReference entityRef = entity.getDocumentReference(); final DocumentReference classReference = this.partialEntityResolver.resolve(Owner.CLASS_REFERENCE, entityRef); final String owner = this.helper.getStringProperty(entity.getXDocument(), classReference, OWNER); if (StringUtils.isNotBlank(owner) && !NULL_STR.equals(owner)) { return new DefaultOwner(this.stringEntityResolver.resolve(owner, entityRef), this.helper); } return new DefaultOwner(null, this.helper); }
DefaultEntityAccessManager implements EntityAccessManager { @Nullable @Override public Owner getOwner(@Nullable final PrimaryEntity entity) { if (entity == null || entity.getDocumentReference() == null) { return null; } final DocumentReference entityRef = entity.getDocumentReference(); final DocumentReference classReference = this.partialEntityResolver.resolve(Owner.CLASS_REFERENCE, entityRef); final String owner = this.helper.getStringProperty(entity.getXDocument(), classReference, OWNER); if (StringUtils.isNotBlank(owner) && !NULL_STR.equals(owner)) { return new DefaultOwner(this.stringEntityResolver.resolve(owner, entityRef), this.helper); } return new DefaultOwner(null, this.helper); } }
DefaultEntityAccessManager implements EntityAccessManager { @Nullable @Override public Owner getOwner(@Nullable final PrimaryEntity entity) { if (entity == null || entity.getDocumentReference() == null) { return null; } final DocumentReference entityRef = entity.getDocumentReference(); final DocumentReference classReference = this.partialEntityResolver.resolve(Owner.CLASS_REFERENCE, entityRef); final String owner = this.helper.getStringProperty(entity.getXDocument(), classReference, OWNER); if (StringUtils.isNotBlank(owner) && !NULL_STR.equals(owner)) { return new DefaultOwner(this.stringEntityResolver.resolve(owner, entityRef), this.helper); } return new DefaultOwner(null, this.helper); }  }
DefaultEntityAccessManager implements EntityAccessManager { @Nullable @Override public Owner getOwner(@Nullable final PrimaryEntity entity) { if (entity == null || entity.getDocumentReference() == null) { return null; } final DocumentReference entityRef = entity.getDocumentReference(); final DocumentReference classReference = this.partialEntityResolver.resolve(Owner.CLASS_REFERENCE, entityRef); final String owner = this.helper.getStringProperty(entity.getXDocument(), classReference, OWNER); if (StringUtils.isNotBlank(owner) && !NULL_STR.equals(owner)) { return new DefaultOwner(this.stringEntityResolver.resolve(owner, entityRef), this.helper); } return new DefaultOwner(null, this.helper); }  @Nonnull @Override Collection<AccessLevel> listAccessLevels(); @Nonnull @Override Collection<AccessLevel> listAllAccessLevels(); @Nonnull @Override AccessLevel resolveAccessLevel(@Nullable final String name); @Nonnull @Override AccessLevel getAccessLevel(@Nullable final PrimaryEntity entity, @Nullable final EntityReference userOrGroup); @Override boolean isAdministrator(@Nullable final PrimaryEntity entity); @Override boolean isAdministrator(@Nullable final PrimaryEntity entity, @Nullable final DocumentReference user); @Nullable @Override Owner getOwner(@Nullable final PrimaryEntity entity); @Override boolean setOwner(@Nullable final PrimaryEntity entity, @Nullable final EntityReference userOrGroup); @Nonnull @Override Collection<Collaborator> getCollaborators(@Nullable final PrimaryEntity entity); @Override boolean setCollaborators(
        @Nullable final PrimaryEntity entity,
        @Nullable final Collection<Collaborator> newCollaborators); @Override boolean addCollaborator(@Nullable final PrimaryEntity entity, @Nullable final Collaborator collaborator); @Override boolean removeCollaborator(@Nullable final PrimaryEntity entity, @Nullable final Collaborator collaborator); }
DefaultEntityAccessManager implements EntityAccessManager { @Nullable @Override public Owner getOwner(@Nullable final PrimaryEntity entity) { if (entity == null || entity.getDocumentReference() == null) { return null; } final DocumentReference entityRef = entity.getDocumentReference(); final DocumentReference classReference = this.partialEntityResolver.resolve(Owner.CLASS_REFERENCE, entityRef); final String owner = this.helper.getStringProperty(entity.getXDocument(), classReference, OWNER); if (StringUtils.isNotBlank(owner) && !NULL_STR.equals(owner)) { return new DefaultOwner(this.stringEntityResolver.resolve(owner, entityRef), this.helper); } return new DefaultOwner(null, this.helper); }  @Nonnull @Override Collection<AccessLevel> listAccessLevels(); @Nonnull @Override Collection<AccessLevel> listAllAccessLevels(); @Nonnull @Override AccessLevel resolveAccessLevel(@Nullable final String name); @Nonnull @Override AccessLevel getAccessLevel(@Nullable final PrimaryEntity entity, @Nullable final EntityReference userOrGroup); @Override boolean isAdministrator(@Nullable final PrimaryEntity entity); @Override boolean isAdministrator(@Nullable final PrimaryEntity entity, @Nullable final DocumentReference user); @Nullable @Override Owner getOwner(@Nullable final PrimaryEntity entity); @Override boolean setOwner(@Nullable final PrimaryEntity entity, @Nullable final EntityReference userOrGroup); @Nonnull @Override Collection<Collaborator> getCollaborators(@Nullable final PrimaryEntity entity); @Override boolean setCollaborators(
        @Nullable final PrimaryEntity entity,
        @Nullable final Collection<Collaborator> newCollaborators); @Override boolean addCollaborator(@Nullable final PrimaryEntity entity, @Nullable final Collaborator collaborator); @Override boolean removeCollaborator(@Nullable final PrimaryEntity entity, @Nullable final Collaborator collaborator);  }