@Test public void nameIsTrimmedFirstName() { final DocumentReference specialUserProfile = new DocumentReference("xwiki", "XWiki", "aaaa"); this.user = new WikiUser(specialUserProfile, this.serializer, this.bridgeMock, this.resolver); when(this.bridgeMock.getProperty(same(specialUserProfile), any(DocumentReference.class), same("first_name"))) .thenReturn("Anonymous"); when(this.bridgeMock.getProperty(same(specialUserProfile), any(DocumentReference.class), same("last_name"))) .thenReturn(" "); Assert.assertEquals("Anonymous", this.user.getName()); }
@Override public String getName() { if (this.profileReference == null) { return ""; } String firstName = String.valueOf(this.bridge.getProperty(this.profileReference, this.classReference, "first_name")); String lastName = String.valueOf(this.bridge.getProperty(this.profileReference, this.classReference, "last_name")); String result = StringUtils.trim(firstName) + " " + StringUtils.trim(lastName); if (StringUtils.isBlank(result)) { result = getUsername(); } return result.trim(); }
WikiUser extends AbstractUser { @Override public String getName() { if (this.profileReference == null) { return ""; } String firstName = String.valueOf(this.bridge.getProperty(this.profileReference, this.classReference, "first_name")); String lastName = String.valueOf(this.bridge.getProperty(this.profileReference, this.classReference, "last_name")); String result = StringUtils.trim(firstName) + " " + StringUtils.trim(lastName); if (StringUtils.isBlank(result)) { result = getUsername(); } return result.trim(); } }
WikiUser extends AbstractUser { @Override public String getName() { if (this.profileReference == null) { return ""; } String firstName = String.valueOf(this.bridge.getProperty(this.profileReference, this.classReference, "first_name")); String lastName = String.valueOf(this.bridge.getProperty(this.profileReference, this.classReference, "last_name")); String result = StringUtils.trim(firstName) + " " + StringUtils.trim(lastName); if (StringUtils.isBlank(result)) { result = getUsername(); } return result.trim(); } WikiUser(DocumentReference reference, EntityReferenceSerializer<String> serializer,
        DocumentAccessBridge bridge, EntityReferenceResolver<EntityReference> resolver); }
WikiUser extends AbstractUser { @Override public String getName() { if (this.profileReference == null) { return ""; } String firstName = String.valueOf(this.bridge.getProperty(this.profileReference, this.classReference, "first_name")); String lastName = String.valueOf(this.bridge.getProperty(this.profileReference, this.classReference, "last_name")); String result = StringUtils.trim(firstName) + " " + StringUtils.trim(lastName); if (StringUtils.isBlank(result)) { result = getUsername(); } return result.trim(); } WikiUser(DocumentReference reference, EntityReferenceSerializer<String> serializer,
        DocumentAccessBridge bridge, EntityReferenceResolver<EntityReference> resolver); @Override boolean exists(); @Override String getName(); @Override Object getAttribute(String attributeName); @Override URI getProfileURI(); }
WikiUser extends AbstractUser { @Override public String getName() { if (this.profileReference == null) { return ""; } String firstName = String.valueOf(this.bridge.getProperty(this.profileReference, this.classReference, "first_name")); String lastName = String.valueOf(this.bridge.getProperty(this.profileReference, this.classReference, "last_name")); String result = StringUtils.trim(firstName) + " " + StringUtils.trim(lastName); if (StringUtils.isBlank(result)) { result = getUsername(); } return result.trim(); } WikiUser(DocumentReference reference, EntityReferenceSerializer<String> serializer,
        DocumentAccessBridge bridge, EntityReferenceResolver<EntityReference> resolver); @Override boolean exists(); @Override String getName(); @Override Object getAttribute(String attributeName); @Override URI getProfileURI();  }