@Test public void loadSetsUnknownUserWhenAuthorIsNull() throws ComponentLookupException { doReturn(null).when(this.doc).getAuthorReference(); PatientData<String> result = this.mocker.getComponentUnderTest().load(this.patient); Assert.assertEquals(UNKNOWN_USER, result.get(AUTHOR)); }
@Override public PatientData<String> load(Patient patient) { try { XWikiDocument doc = patient.getXDocument(); Map<String, String> result = new LinkedHashMap<>(); DateTimeFormatter dateFormatter = ISODateTimeFormat.dateTime().withZone(DateTimeZone.UTC); result.put(DOCUMENT_NAME, doc.getDocumentReference().getName()); result.put(CREATION_DATE, dateFormatter.print(new DateTime(doc.getCreationDate()))); result.put(AUTHOR, (doc.getAuthorReference() != null) ? doc.getAuthorReference().getName() : UNKNOWN_USER); result.put(DATE, dateFormatter.print(new DateTime(doc.getDate()))); return new DictionaryPatientData<>(getName(), result); } catch (Exception e) { this.logger.error(ERROR_MESSAGE_LOAD_FAILED, e.getMessage()); } return null; }
MetaDataController extends AbstractSimpleController implements PatientDataController<String> { @Override public PatientData<String> load(Patient patient) { try { XWikiDocument doc = patient.getXDocument(); Map<String, String> result = new LinkedHashMap<>(); DateTimeFormatter dateFormatter = ISODateTimeFormat.dateTime().withZone(DateTimeZone.UTC); result.put(DOCUMENT_NAME, doc.getDocumentReference().getName()); result.put(CREATION_DATE, dateFormatter.print(new DateTime(doc.getCreationDate()))); result.put(AUTHOR, (doc.getAuthorReference() != null) ? doc.getAuthorReference().getName() : UNKNOWN_USER); result.put(DATE, dateFormatter.print(new DateTime(doc.getDate()))); return new DictionaryPatientData<>(getName(), result); } catch (Exception e) { this.logger.error(ERROR_MESSAGE_LOAD_FAILED, e.getMessage()); } return null; } }
MetaDataController extends AbstractSimpleController implements PatientDataController<String> { @Override public PatientData<String> load(Patient patient) { try { XWikiDocument doc = patient.getXDocument(); Map<String, String> result = new LinkedHashMap<>(); DateTimeFormatter dateFormatter = ISODateTimeFormat.dateTime().withZone(DateTimeZone.UTC); result.put(DOCUMENT_NAME, doc.getDocumentReference().getName()); result.put(CREATION_DATE, dateFormatter.print(new DateTime(doc.getCreationDate()))); result.put(AUTHOR, (doc.getAuthorReference() != null) ? doc.getAuthorReference().getName() : UNKNOWN_USER); result.put(DATE, dateFormatter.print(new DateTime(doc.getDate()))); return new DictionaryPatientData<>(getName(), result); } catch (Exception e) { this.logger.error(ERROR_MESSAGE_LOAD_FAILED, e.getMessage()); } return null; }  }
MetaDataController extends AbstractSimpleController implements PatientDataController<String> { @Override public PatientData<String> load(Patient patient) { try { XWikiDocument doc = patient.getXDocument(); Map<String, String> result = new LinkedHashMap<>(); DateTimeFormatter dateFormatter = ISODateTimeFormat.dateTime().withZone(DateTimeZone.UTC); result.put(DOCUMENT_NAME, doc.getDocumentReference().getName()); result.put(CREATION_DATE, dateFormatter.print(new DateTime(doc.getCreationDate()))); result.put(AUTHOR, (doc.getAuthorReference() != null) ? doc.getAuthorReference().getName() : UNKNOWN_USER); result.put(DATE, dateFormatter.print(new DateTime(doc.getDate()))); return new DictionaryPatientData<>(getName(), result); } catch (Exception e) { this.logger.error(ERROR_MESSAGE_LOAD_FAILED, e.getMessage()); } return null; }  @Override PatientData<String> load(Patient patient); @Override void writeJSON(Patient patient, JSONObject json, Collection<String> selectedFieldNames); @Override String getName(); }
MetaDataController extends AbstractSimpleController implements PatientDataController<String> { @Override public PatientData<String> load(Patient patient) { try { XWikiDocument doc = patient.getXDocument(); Map<String, String> result = new LinkedHashMap<>(); DateTimeFormatter dateFormatter = ISODateTimeFormat.dateTime().withZone(DateTimeZone.UTC); result.put(DOCUMENT_NAME, doc.getDocumentReference().getName()); result.put(CREATION_DATE, dateFormatter.print(new DateTime(doc.getCreationDate()))); result.put(AUTHOR, (doc.getAuthorReference() != null) ? doc.getAuthorReference().getName() : UNKNOWN_USER); result.put(DATE, dateFormatter.print(new DateTime(doc.getDate()))); return new DictionaryPatientData<>(getName(), result); } catch (Exception e) { this.logger.error(ERROR_MESSAGE_LOAD_FAILED, e.getMessage()); } return null; }  @Override PatientData<String> load(Patient patient); @Override void writeJSON(Patient patient, JSONObject json, Collection<String> selectedFieldNames); @Override String getName();  }