@Test public void updateDocument() { when(this.wikiDescriptorManager.getMainWikiId()).thenReturn("mainwiki"); XWikiDocument document = new XWikiDocument(new DocumentReference("mainwiki", "Mail", "MailConfig")); XWikiContext xcontext = mock(XWikiContext.class); XWiki xwiki = mock(XWiki.class); when(this.xcontextProvider.get()).thenReturn(xcontext); when(xcontext.getWiki()).thenReturn(xwiki); this.initializer.updateDocument(document); assertEquals("mainwiki:XWiki.superadmin", document.getCreatorReference().toString()); assertEquals("mainwiki:XWiki.superadmin", document.getAuthorReference().toString()); assertTrue(document.isHidden()); assertEquals("Mail Configuration", document.getTitle()); BaseObject sendMailConfigObject = document.getXObject(new LocalDocumentReference("Mail", "SendMailConfigClass")); assertNotNull(sendMailConfigObject); assertNotNull(document.getXObject(new LocalDocumentReference("Mail", "GeneralMailConfigClass"))); }
@Override public boolean updateDocument(XWikiDocument document) { boolean needsUpdate = false; if (updateReferences(document)) { needsUpdate = true; } if (!document.isHidden()) { document.setHidden(true); needsUpdate = true; } if (document.getTitle().isEmpty()) { document.setTitle("Mail Configuration"); needsUpdate = true; } if (addGeneralMailConfigClassXObject(document)) { needsUpdate = true; } if (addSendMailConfigClassXObject(document)) { needsUpdate = true; } if (removeConfigurableClass(document)) { needsUpdate = true; } return needsUpdate; }
MailConfigMandatoryDocumentInitializer implements MandatoryDocumentInitializer { @Override public boolean updateDocument(XWikiDocument document) { boolean needsUpdate = false; if (updateReferences(document)) { needsUpdate = true; } if (!document.isHidden()) { document.setHidden(true); needsUpdate = true; } if (document.getTitle().isEmpty()) { document.setTitle("Mail Configuration"); needsUpdate = true; } if (addGeneralMailConfigClassXObject(document)) { needsUpdate = true; } if (addSendMailConfigClassXObject(document)) { needsUpdate = true; } if (removeConfigurableClass(document)) { needsUpdate = true; } return needsUpdate; } }
MailConfigMandatoryDocumentInitializer implements MandatoryDocumentInitializer { @Override public boolean updateDocument(XWikiDocument document) { boolean needsUpdate = false; if (updateReferences(document)) { needsUpdate = true; } if (!document.isHidden()) { document.setHidden(true); needsUpdate = true; } if (document.getTitle().isEmpty()) { document.setTitle("Mail Configuration"); needsUpdate = true; } if (addGeneralMailConfigClassXObject(document)) { needsUpdate = true; } if (addSendMailConfigClassXObject(document)) { needsUpdate = true; } if (removeConfigurableClass(document)) { needsUpdate = true; } return needsUpdate; }  }
MailConfigMandatoryDocumentInitializer implements MandatoryDocumentInitializer { @Override public boolean updateDocument(XWikiDocument document) { boolean needsUpdate = false; if (updateReferences(document)) { needsUpdate = true; } if (!document.isHidden()) { document.setHidden(true); needsUpdate = true; } if (document.getTitle().isEmpty()) { document.setTitle("Mail Configuration"); needsUpdate = true; } if (addGeneralMailConfigClassXObject(document)) { needsUpdate = true; } if (addSendMailConfigClassXObject(document)) { needsUpdate = true; } if (removeConfigurableClass(document)) { needsUpdate = true; } return needsUpdate; }  @Override EntityReference getDocumentReference(); @Override boolean updateDocument(XWikiDocument document); }
MailConfigMandatoryDocumentInitializer implements MandatoryDocumentInitializer { @Override public boolean updateDocument(XWikiDocument document) { boolean needsUpdate = false; if (updateReferences(document)) { needsUpdate = true; } if (!document.isHidden()) { document.setHidden(true); needsUpdate = true; } if (document.getTitle().isEmpty()) { document.setTitle("Mail Configuration"); needsUpdate = true; } if (addGeneralMailConfigClassXObject(document)) { needsUpdate = true; } if (addSendMailConfigClassXObject(document)) { needsUpdate = true; } if (removeConfigurableClass(document)) { needsUpdate = true; } return needsUpdate; }  @Override EntityReference getDocumentReference(); @Override boolean updateDocument(XWikiDocument document);  }