diff --git a/src/main/java/com/celements/ajax/AjaxAction.java b/src/main/java/com/celements/ajax/AjaxAction.java index dbd527cac..4749f0a0f 100644 --- a/src/main/java/com/celements/ajax/AjaxAction.java +++ b/src/main/java/com/celements/ajax/AjaxAction.java @@ -64,12 +64,10 @@ public String render(XWikiContext context) throws XWikiException { } private Optional getAjaxScript(XWikiContext context) { - List pathParts = parseRequestPath(context) - .limit(3).collect(toImmutableList()); + List pathParts = parseRequestPath(context).limit(3).collect(toImmutableList()); if ((pathParts.size() > 2) && pathParts.get(0).equals(AJAX_SCRIPT_ACTION)) { - String celAjaxScript = "/" + Stream.concat( - Stream.of(CEL_AJAX_SCRIPT_DIR_PROPERTY), - parseRequestPath(context).skip(1)) + String celAjaxScript = "/" + Stream + .concat(Stream.of(CEL_AJAX_SCRIPT_DIR_PROPERTY), parseRequestPath(context).skip(1)) .collect(joining("/")); LOGGER.debug("ajax: found script path '{}'", celAjaxScript); return Optional.of(celAjaxScript); @@ -78,8 +76,7 @@ private Optional getAjaxScript(XWikiContext context) { } private Stream parseRequestPath(XWikiContext context) { - return Splitter.on('/') - .splitToStream(context.getRequest().getPathInfo()) + return Splitter.on('/').splitToStream(context.getRequest().getPathInfo()) .filter(not(String::isEmpty)); } diff --git a/src/main/java/com/celements/appScript/AppScriptService.java b/src/main/java/com/celements/appScript/AppScriptService.java index 038941af8..b25310709 100644 --- a/src/main/java/com/celements/appScript/AppScriptService.java +++ b/src/main/java/com/celements/appScript/AppScriptService.java @@ -52,16 +52,10 @@ public class AppScriptService implements IAppScriptService { private final ConfigurationSource xwikiConfigSource; @Inject - public AppScriptService( - IEmptyCheckRole emptyCheck, - Execution execution, - EntityReferenceValueProvider defaultEntityReferenceValueProvider, - XWikiProvider wikiProvider, - IModelAccessFacade modelAccess, - ModelUtils modelUtils, - ModelContext mContext, - UrlService urlService, - @Named(XWikiConfigSource.NAME) ConfigurationSource xwikiConfigSource) { + public AppScriptService(IEmptyCheckRole emptyCheck, Execution execution, + EntityReferenceValueProvider defaultEntityReferenceValueProvider, XWikiProvider wikiProvider, + IModelAccessFacade modelAccess, ModelUtils modelUtils, ModelContext mContext, + UrlService urlService, @Named(XWikiConfigSource.NAME) ConfigurationSource xwikiConfigSource) { this.emptyCheck = emptyCheck; this.execution = execution; this.defaultEntityReferenceValueProvider = defaultEntityReferenceValueProvider; @@ -140,8 +134,7 @@ public Optional getAppScriptDocRef(String scriptName) { @Override public Optional getAppRecursiveScriptDocRef(String scriptName) { return findAppScriptRecursivly(scriptName, - sn -> hasLocalAppRecursiveScript(sn) - || hasCentralAppRecursiveScript(sn), + sn -> hasLocalAppRecursiveScript(sn) || hasCentralAppRecursiveScript(sn), sn -> sn.lastIndexOf("/") > 0).flatMap(scriptNameFound -> { if (hasLocalAppRecursiveScript(scriptNameFound)) { return getLocalAppRecursiveScriptDocRef(scriptNameFound); @@ -197,27 +190,25 @@ public boolean isAppScriptAvailable(String scriptName) { @Override public Optional getAppRecursiveScript(String scriptName) { - return findAppScriptRecursivly(scriptName, - sn -> isAppScriptAvailable(sn + "++"), - sn -> sn.lastIndexOf("/") > 0) - .map(sNT -> sNT + "++") + return findAppScriptRecursivly(scriptName, sn -> isAppScriptAvailable(sn + "++"), + sn -> sn.lastIndexOf("/") > 0).map(sNT -> sNT + "++") .filter(sNT -> !Strings.isNullOrEmpty(sNT) && isAppScriptAvailable(sNT)); } @Override public Optional getAppRecursiveSetupScript(String scriptName) { - return getAppRecursiveScript(scriptName) - .filter(script -> script.endsWith("++")) + return getAppRecursiveScript(scriptName).filter(script -> script.endsWith("++")) .map(script -> script.substring(0, script.length() - 2) + "_setup++") .filter(this::isAppScriptAvailable); } - private Optional findAppScriptRecursivly(String scriptName, - Predicate hasFound, Predicate hasMore) { + private Optional findAppScriptRecursivly(String scriptName, Predicate hasFound, + Predicate hasMore) { String scriptNameTest = scriptName; do { scriptNameTest = reduceOneDirectory(scriptNameTest); - } while (scriptNameTest != null && !hasFound.test(scriptNameTest) && hasMore.test(scriptNameTest)); + } while (scriptNameTest != null && !hasFound.test(scriptNameTest) + && hasMore.test(scriptNameTest)); if (scriptNameTest != null && hasFound.test(scriptNameTest)) { return Optional.of(scriptNameTest); } @@ -248,8 +239,8 @@ public String getAppScriptURL(String scriptName, String queryString) { queryString = "xpage=" + IAppScriptService.APP_SCRIPT_XPAGE + "&s=" + scriptName + queryString; if (scriptName.split("/").length <= 2) { return urlService.getURL( - modelUtils.resolveRef(scriptName.replace("/", "."), DocumentReference.class), - "view", queryString); + modelUtils.resolveRef(scriptName.replace("/", "."), DocumentReference.class), "view", + queryString); } else { return Util.escapeURL("/app/" + scriptName + "?" + queryString); } @@ -318,8 +309,7 @@ private boolean isAppScriptActionRequest() { private boolean isAppScriptSpaceRequest() { return "view".equals(getContext().getAction()) - && mContext.getDocRef().orElseThrow().getSpaceReferences().contains( - getCurrentSpaceRef()); + && mContext.getDocRef().orElseThrow().getSpaceReferences().contains(getCurrentSpaceRef()); } private SpaceReference getCurrentSpaceRef() { @@ -340,8 +330,8 @@ String getAppScriptNameFromRequestURL() { if (path.startsWith(getContext().getAction())) { path = path.replaceAll("^" + getContext().getAction() + "/+", ""); } - path = path.replaceFirst("^" + defaultEntityReferenceValueProvider.getDefaultValue( - EntityType.SPACE) + "/", ""); + path = path.replaceFirst( + "^" + defaultEntityReferenceValueProvider.getDefaultValue(EntityType.SPACE) + "/", ""); if ("".equals(path)) { path = defaultEntityReferenceValueProvider.getDefaultValue(EntityType.DOCUMENT); } else if (path.endsWith("/")) { diff --git a/src/main/java/com/celements/auth/classes/RemoteLoginClass.java b/src/main/java/com/celements/auth/classes/RemoteLoginClass.java index c1c6a1122..4294ec740 100644 --- a/src/main/java/com/celements/auth/classes/RemoteLoginClass.java +++ b/src/main/java/com/celements/auth/classes/RemoteLoginClass.java @@ -20,8 +20,8 @@ public class RemoteLoginClass extends AbstractClassDefinition implements AuthCla public static final String CLASS_NAME = "RemoteLoginClass"; public static final String CLASS_DEF_HINT = AuthClass.CLASS_SPACE + "." + CLASS_NAME; - public static final ClassField FIELD_URL = new StringField.Builder(CLASS_DEF_HINT, - "url").size(30).build(); + public static final ClassField FIELD_URL = new StringField.Builder(CLASS_DEF_HINT, "url") + .size(30).build(); public static final ClassField FIELD_TIMEOUT = new IntField.Builder(CLASS_DEF_HINT, "timeout").size(30).build(); diff --git a/src/main/java/com/celements/captcha/CaptchaService.java b/src/main/java/com/celements/captcha/CaptchaService.java index 88d806183..3a173e64c 100644 --- a/src/main/java/com/celements/captcha/CaptchaService.java +++ b/src/main/java/com/celements/captcha/CaptchaService.java @@ -49,12 +49,12 @@ public boolean checkCaptcha() { String answer = getContext().getRequest().get("captcha_answer"); if ((answer != null) && (answer.length() > 0)) { try { - LOGGER.info("Checking answer for user id '" + getCaptchaVerifier().getUserId( - getContext().getRequest()) + "'"); + LOGGER.info("Checking answer for user id '" + + getCaptchaVerifier().getUserId(getContext().getRequest()) + "'"); String anwserCacheKey = "captcha_" + getCaptchaType() + "_anwserCache"; if (!getContext().containsKey(anwserCacheKey)) { - Boolean isAnswerCorrect = getCaptchaVerifier().isAnswerCorrect( - getContext().getRequest().get("captcha_id"), answer); + Boolean isAnswerCorrect = getCaptchaVerifier() + .isAnswerCorrect(getContext().getRequest().get("captcha_id"), answer); getContext().put(anwserCacheKey, isAnswerCorrect); } return (Boolean) getContext().get(anwserCacheKey); diff --git a/src/main/java/com/celements/cells/AbstractRenderStrategy.java b/src/main/java/com/celements/cells/AbstractRenderStrategy.java index ec9343a4d..b4e23f817 100644 --- a/src/main/java/com/celements/cells/AbstractRenderStrategy.java +++ b/src/main/java/com/celements/cells/AbstractRenderStrategy.java @@ -122,13 +122,12 @@ public final Contextualiser getContextualiser(@Nullable TreeNode node) { LOGGER.trace("getContextualiser: cell [{}]", node.getDocumentReference()); Optional scopeKey = getRenderScopeKey(node.getDocumentReference()); scopeKey.map(key -> key + EXEC_CTX_KEY_DOC_SUFFIX) - .map(LogUtils.logF(execution.getContext()::getProperty) - .debug(LOGGER).msg("getContextualiser")) - .flatMap(doc -> tryCast(doc, XWikiDocument.class)) - .ifPresent(contextualiser::withDoc); + .map(LogUtils.logF(execution.getContext()::getProperty).debug(LOGGER) + .msg("getContextualiser")) + .flatMap(doc -> tryCast(doc, XWikiDocument.class)).ifPresent(contextualiser::withDoc); scopeKey.map(key -> key + EXEC_CTX_KEY_OBJ_NB_SUFFIX) - .map(LogUtils.logF(execution.getContext()::getProperty) - .debug(LOGGER).msg("getContextualiser")) + .map(LogUtils.logF(execution.getContext()::getProperty).debug(LOGGER) + .msg("getContextualiser")) .ifPresent(nb -> contextualiser.withExecContext(EXEC_CTX_KEY_OBJ_NB, nb)); } return contextualiser; @@ -136,10 +135,8 @@ public final Contextualiser getContextualiser(@Nullable TreeNode node) { private Optional getRenderScopeKey(DocumentReference cellDocRef) { return XWikiObjectFetcher.on(modelAccess.getOrCreateDocument(cellDocRef)) - .filter(KeyValueClass.FIELD_KEY, "cell-render-scope") - .fetchField(KeyValueClass.FIELD_VALUE) - .stream().findFirst() - .map(scope -> EXEC_CTX_KEY + "." + scope); + .filter(KeyValueClass.FIELD_KEY, "cell-render-scope").fetchField(KeyValueClass.FIELD_VALUE) + .stream().findFirst().map(scope -> EXEC_CTX_KEY + "." + scope); } @Override @@ -153,13 +150,12 @@ public void startRenderCell(@NotNull TreeNode node, boolean isFirstItem, boolean DocumentReference cellDocRef = node.getDocumentReference(); LOGGER.debug("startRenderCell: cellDocRef [{}]", cellDocRef); collectCellAttributes(cellDocRef, attrBuilder); - getCellTypeConfig(cellDocRef).ifPresent(cellTypeConfig -> cellTypeConfig - .collectAttributes(attrBuilder, cellDocRef)); + getCellTypeConfig(cellDocRef) + .ifPresent(cellTypeConfig -> cellTypeConfig.collectAttributes(attrBuilder, cellDocRef)); cellWriter.openLevel(getTagName(cellDocRef).orElse(null), attrBuilder.build()); } - private void collectCellAttributes(DocumentReference cellDocRef, - AttributeBuilder attrBuilder) { + private void collectCellAttributes(DocumentReference cellDocRef, AttributeBuilder attrBuilder) { try { XWikiDocument cellDoc = modelAccess.getDocument(cellDocRef); XWikiObjectFetcher fetcher = XWikiObjectFetcher.on(cellDoc).filter(CellClass.CLASS_REF); @@ -197,10 +193,8 @@ private Optional collectId(DocumentReference cellDocRef, XWikiObjectFetc .orElseGet(() -> "cell:" + modelUtils.serializeRef(cellDocRef, COMPACT).replace(":", "..")) + Stream.of(EXEC_CTX_KEY_OBJ_NB, EXEC_CTX_KEY_GLOBAL_OBJ_NB) .map(execution.getContext()::getProperty) - .map(val -> Ints.tryParse(Objects.toString(val))) - .filter(Objects::nonNull) - .map(nb -> "_" + nb) - .findFirst().orElse(""); + .map(val -> Ints.tryParse(Objects.toString(val))).filter(Objects::nonNull) + .map(nb -> "_" + nb).findFirst().orElse(""); Set ids = execution.getContext().computeIfAbsent(EXEC_CTX_KEY + ".ids", HashSet::new); if (ids.contains(id)) { LOGGER.warn("collectId - cell id [{}] generated multiple times for [{}]", id, cellDocRef); diff --git a/src/main/java/com/celements/cells/AbstractWriter.java b/src/main/java/com/celements/cells/AbstractWriter.java index 91676b220..d1b37ef47 100644 --- a/src/main/java/com/celements/cells/AbstractWriter.java +++ b/src/main/java/com/celements/cells/AbstractWriter.java @@ -44,8 +44,7 @@ protected Optional> getCurrentLevel() { } protected Optional hasLevelContentOptional() { - return getCurrentLevel() - .map(Entry::getValue); + return getCurrentLevel().map(Entry::getValue); } @Override diff --git a/src/main/java/com/celements/cells/CellsClasses.java b/src/main/java/com/celements/cells/CellsClasses.java index 3d0b2053c..77584b2f7 100644 --- a/src/main/java/com/celements/cells/CellsClasses.java +++ b/src/main/java/com/celements/cells/CellsClasses.java @@ -221,10 +221,10 @@ public void getTranslationBoxCellConfigClass() throws XWikiException { doc = modelAccess.getOrCreateDocument(translationBoxCellConfigClassRef); BaseClass bclass = doc.getXClass(); bclass.setXClassReference(translationBoxCellConfigClassRef); - needsUpdate |= bclass.addTextField("page_exceptions", "Page Exceptions (FullNames" - + " comma separated)", 30); - needsUpdate |= bclass.addTextField("pagetype_exceptions", "Page Type Exceptions" - + " (FullNames comma separated)", 30); + needsUpdate |= bclass.addTextField("page_exceptions", + "Page Exceptions (FullNames" + " comma separated)", 30); + needsUpdate |= bclass.addTextField("pagetype_exceptions", + "Page Type Exceptions" + " (FullNames comma separated)", 30); setContentAndSaveClassDocument(doc, needsUpdate); } diff --git a/src/main/java/com/celements/cells/CellsScriptService.java b/src/main/java/com/celements/cells/CellsScriptService.java index 66666db00..64bdd4dcf 100644 --- a/src/main/java/com/celements/cells/CellsScriptService.java +++ b/src/main/java/com/celements/cells/CellsScriptService.java @@ -66,8 +66,8 @@ public DocumentReference getPageDependentDocRef(DocumentReference currentPageRef public Document getPageDependentTranslatedDocument(Document currentDoc, DocumentReference cellDocRef) { try { - return getPageDepDocRefCmd().getTranslatedDocument(getCurrentXWikiDoc(currentDoc), - cellDocRef).newDocument(getContext()); + return getPageDepDocRefCmd().getTranslatedDocument(getCurrentXWikiDoc(currentDoc), cellDocRef) + .newDocument(getContext()); } catch (XWikiException exp) { LOGGER.error("Failed to get xwiki document for [" + currentDoc.getDocumentReference() + "].", exp); diff --git a/src/main/java/com/celements/cells/ICellsClassConfig.java b/src/main/java/com/celements/cells/ICellsClassConfig.java index 7dad87aa6..34004c077 100644 --- a/src/main/java/com/celements/cells/ICellsClassConfig.java +++ b/src/main/java/com/celements/cells/ICellsClassConfig.java @@ -27,8 +27,7 @@ public interface ICellsClassConfig { @Deprecated String CELEMENTS_CELL_CLASS_NAME = "CellClass"; @Deprecated - String CELEMENTS_CELL_CLASS = CELEMENTS_CELL_CLASS_SPACE + "." - + CELEMENTS_CELL_CLASS_NAME; + String CELEMENTS_CELL_CLASS = CELEMENTS_CELL_CLASS_SPACE + "." + CELEMENTS_CELL_CLASS_NAME; @Deprecated String CELLCLASS_TAGNAME_FIELD = CellClass.FIELD_TAG_NAME.getName(); @Deprecated diff --git a/src/main/java/com/celements/cells/RenderingEngine.java b/src/main/java/com/celements/cells/RenderingEngine.java index bee06240f..bfd437074 100644 --- a/src/main/java/com/celements/cells/RenderingEngine.java +++ b/src/main/java/com/celements/cells/RenderingEngine.java @@ -95,9 +95,8 @@ void renderCell(TreeNode node, boolean isFirstItem, boolean isLastItem) { if (renderStrategy.isRenderCell(node)) { renderStrategy.getContextualiser(node).execute(() -> { renderStrategy.startRenderCell(node, isFirstItem, isLastItem); - renderSubCells(node, Optional.ofNullable(node) - .map(TreeNode::getDocumentReference) - .orElse(null)); + renderSubCells(node, + Optional.ofNullable(node).map(TreeNode::getDocumentReference).orElse(null)); renderStrategy.endRenderCell(node, isFirstItem, isLastItem); }); } @@ -107,8 +106,8 @@ void renderSubCells(TreeNode parentNode, EntityReference parentRef) { if (renderStrategy.isRenderSubCells(parentRef)) { List children = treeNodeService.getSubNodesForParent(parentRef, renderStrategy.getMenuPart(parentNode)); - LOGGER.debug("internal_renderSubCells: for parent [{}] render [{}] children [{}].", - parentRef, children.size(), children); + LOGGER.debug("internal_renderSubCells: for parent [{}] render [{}] children [{}].", parentRef, + children.size(), children); if (!children.isEmpty()) { renderStrategy.startRenderChildren(parentRef); boolean isFirstItem = true; diff --git a/src/main/java/com/celements/cells/attribute/DefaultAttributeBuilder.java b/src/main/java/com/celements/cells/attribute/DefaultAttributeBuilder.java index 6cc46263f..39e474bbf 100644 --- a/src/main/java/com/celements/cells/attribute/DefaultAttributeBuilder.java +++ b/src/main/java/com/celements/cells/attribute/DefaultAttributeBuilder.java @@ -17,8 +17,8 @@ @NotThreadSafe public class DefaultAttributeBuilder implements AttributeBuilder { - private static final Splitter CSS_CLASS_SPLITTER = Splitter.on( - " ").trimResults().omitEmptyStrings(); + private static final Splitter CSS_CLASS_SPLITTER = Splitter.on(" ").trimResults() + .omitEmptyStrings(); private final Map attributeMap = new LinkedHashMap<>(); diff --git a/src/main/java/com/celements/cells/classes/CellAttributeClass.java b/src/main/java/com/celements/cells/classes/CellAttributeClass.java index 575abcc37..61191d9fb 100644 --- a/src/main/java/com/celements/cells/classes/CellAttributeClass.java +++ b/src/main/java/com/celements/cells/classes/CellAttributeClass.java @@ -41,11 +41,11 @@ public class CellAttributeClass extends AbstractClassDefinition public static final String CLASS_DEF_HINT = CelementsClassDefinition.SPACE_NAME + "." + DOC_NAME; public static final ClassReference CLASS_REF = new ClassReference(SPACE_NAME, DOC_NAME); - public static final ClassField FIELD_NAME = new StringField.Builder(CLASS_REF, - "name").prettyName("name").build(); + public static final ClassField FIELD_NAME = new StringField.Builder(CLASS_REF, "name") + .prettyName("name").build(); - public static final ClassField FIELD_VALUE = new LargeStringField.Builder( - CLASS_REF, "value").rows(5).prettyName("value (velocity interpreted)").build(); + public static final ClassField FIELD_VALUE = new LargeStringField.Builder(CLASS_REF, + "value").rows(5).prettyName("value (velocity interpreted)").build(); public CellAttributeClass() { super(CLASS_REF); diff --git a/src/main/java/com/celements/cells/classes/CellClass.java b/src/main/java/com/celements/cells/classes/CellClass.java index 3f1f40e28..22b82df5d 100644 --- a/src/main/java/com/celements/cells/classes/CellClass.java +++ b/src/main/java/com/celements/cells/classes/CellClass.java @@ -55,7 +55,7 @@ public class CellClass extends AbstractClassDefinition public static final ClassField FIELD_EVENT_DATA_ATTR = new LargeStringField.Builder( CLASS_REF, "event_data_attr").rows(20).size(15).prettyName("celEventJS data attribute") - .build(); + .build(); public CellClass() { super(CLASS_REF); diff --git a/src/main/java/com/celements/cells/classes/GroupCellClass.java b/src/main/java/com/celements/cells/classes/GroupCellClass.java index 8cf54d774..7fdc7849f 100644 --- a/src/main/java/com/celements/cells/classes/GroupCellClass.java +++ b/src/main/java/com/celements/cells/classes/GroupCellClass.java @@ -13,8 +13,7 @@ @Singleton @Immutable @Component(GroupCellClass.CLASS_DEF_HINT) -public class GroupCellClass extends AbstractClassDefinition - implements CellsClassDefinition { +public class GroupCellClass extends AbstractClassDefinition implements CellsClassDefinition { public static final String DOC_NAME = "GroupCellClass"; public static final String SPACE_NAME = "Celements"; @@ -22,10 +21,7 @@ public class GroupCellClass extends AbstractClassDefinition public static final ClassReference CLASS_REF = new ClassReference(SPACE_NAME, DOC_NAME); public static final ClassField FIELD_RENDER_LAYOUT = new StringField.Builder(CLASS_REF, - "render_layout") - .prettyName("Render Layout") - .size(30) - .build(); + "render_layout").prettyName("Render Layout").size(30).build(); public GroupCellClass() { super(CLASS_REF); diff --git a/src/main/java/com/celements/cells/classes/PageDepCellConfigClass.java b/src/main/java/com/celements/cells/classes/PageDepCellConfigClass.java index 7ff7cfadf..a401b47ae 100644 --- a/src/main/java/com/celements/cells/classes/PageDepCellConfigClass.java +++ b/src/main/java/com/celements/cells/classes/PageDepCellConfigClass.java @@ -23,16 +23,10 @@ public class PageDepCellConfigClass extends AbstractClassDefinition public static final ClassReference CLASS_REF = new ClassReference(SPACE_NAME, DOC_NAME); public static final ClassField FIELD_SPACE_NAME = new StringField.Builder(CLASS_REF, - "space_name") - .prettyName("Space Name") - .size(30) - .build(); + "space_name").prettyName("Space Name").size(30).build(); public static final ClassField FIELD_IS_ACTIVE = new BooleanField.Builder(CLASS_REF, - "is_inheritable") - .displayType("yesno") - .prettyName("is inheritable") - .build(); + "is_inheritable").displayType("yesno").prettyName("is inheritable").build(); public PageDepCellConfigClass() { super(CLASS_REF); diff --git a/src/main/java/com/celements/cells/classes/PageLayoutPropertiesClass.java b/src/main/java/com/celements/cells/classes/PageLayoutPropertiesClass.java index f7c0bcede..69c12c0e6 100644 --- a/src/main/java/com/celements/cells/classes/PageLayoutPropertiesClass.java +++ b/src/main/java/com/celements/cells/classes/PageLayoutPropertiesClass.java @@ -31,53 +31,32 @@ public class PageLayoutPropertiesClass extends AbstractClassDefinition public static final String PAGE_LAYOUT_VALUE = "pageLayout"; public static final ClassField FIELD_PRETTYNAME = new StringField.Builder(CLASS_REF, - "prettyname") - .prettyName("Layout Pretty Name") - .size(30) - .build(); + "prettyname").prettyName("Layout Pretty Name").size(30).build(); public static final ClassField FIELD_IS_ACTIVE = new BooleanField.Builder(CLASS_REF, - "isActive") - .displayType("yesno") - .prettyName("is active") - .build(); + "isActive").displayType("yesno").prettyName("is active").build(); public static final ClassField FIELD_AUTHORS = new StringField.Builder(CLASS_REF, - "authors") - .prettyName("Authors") - .size(30) - .build(); + "authors").prettyName("Authors").size(30).build(); public static final ClassField FIELD_LICENSE = new LargeStringField.Builder(CLASS_REF, - "license") - .rows(30) - .size(15) - .prettyName("License") - .build(); + "license").rows(30).size(15).prettyName("License").build(); public static final ClassField FIELD_VERSION = new StringField.Builder(CLASS_REF, - "version") - .prettyName("Version") - .size(30) - .build(); + "version").prettyName("Version").size(30).build(); public static final ClassField FIELD_LAYOUT_DOCTYPE = new StringSingleListField.Builder( - CLASS_REF, "doctype") - .size(1) - .displayType(DisplayType.select) - .values(ImmutableList.of(HtmlDoctype.XHTML.toString(), HtmlDoctype.HTML5.toString())) - .prettyName("Doctype") - /* .relationalStorage(true) */ - .build(); + CLASS_REF, "doctype").size(1).displayType(DisplayType.select) + .values(ImmutableList.of(HtmlDoctype.XHTML.toString(), HtmlDoctype.HTML5.toString())) + .prettyName("Doctype") + /* .relationalStorage(true) */ + .build(); public static final ClassField FIELD_LAYOUT_TYPE = new StringSingleListField.Builder( - CLASS_REF, "layout_type") - .size(1) - .displayType(DisplayType.select) - .values(ImmutableList.of(PAGE_LAYOUT_VALUE, EDITOR_LAYOUT_VALUE)) - .prettyName("Layout Type") - /* .relationalStorage(true) */ - .build(); + CLASS_REF, "layout_type").size(1).displayType(DisplayType.select) + .values(ImmutableList.of(PAGE_LAYOUT_VALUE, EDITOR_LAYOUT_VALUE)).prettyName("Layout Type") + /* .relationalStorage(true) */ + .build(); public PageLayoutPropertiesClass() { super(CLASS_REF); diff --git a/src/main/java/com/celements/cells/classes/TranslationBoxCellConfigClass.java b/src/main/java/com/celements/cells/classes/TranslationBoxCellConfigClass.java index fde76d4ab..90622325d 100644 --- a/src/main/java/com/celements/cells/classes/TranslationBoxCellConfigClass.java +++ b/src/main/java/com/celements/cells/classes/TranslationBoxCellConfigClass.java @@ -22,16 +22,11 @@ public class TranslationBoxCellConfigClass extends AbstractClassDefinition public static final ClassReference CLASS_REF = new ClassReference(SPACE_NAME, DOC_NAME); public static final ClassField FIELD_PAGE_EXCEPTIONS = new StringField.Builder(CLASS_REF, - "page_exceptions") - .prettyName("Page Exceptions (FullNames comma separated)") - .size(30) - .build(); + "page_exceptions").prettyName("Page Exceptions (FullNames comma separated)").size(30).build(); public static final ClassField FIELD_PAGETYPE_EXCEPTIONS = new StringField.Builder( CLASS_REF, "pagetype_exceptions") - .prettyName("Page Type Exceptions (FullNames comma separated)") - .size(30) - .build(); + .prettyName("Page Type Exceptions (FullNames comma separated)").size(30).build(); public TranslationBoxCellConfigClass() { super(CLASS_REF); diff --git a/src/main/java/com/celements/cells/cmd/PageDependentDocumentReferenceCommand.java b/src/main/java/com/celements/cells/cmd/PageDependentDocumentReferenceCommand.java index f6fdc1016..13f3a1784 100644 --- a/src/main/java/com/celements/cells/cmd/PageDependentDocumentReferenceCommand.java +++ b/src/main/java/com/celements/cells/cmd/PageDependentDocumentReferenceCommand.java @@ -73,8 +73,8 @@ public class PageDependentDocumentReferenceCommand { @Deprecated public static final String PROPNAME_IS_INHERITABLE = "is_inheritable"; - private static final Logger LOGGER = LoggerFactory.getLogger( - PageDependentDocumentReferenceCommand.class); + private static final Logger LOGGER = LoggerFactory + .getLogger(PageDependentDocumentReferenceCommand.class); PageLayoutCommand pageLayoutCmd; @@ -168,12 +168,12 @@ public XWikiDocument getTranslatedDocument(XWikiDocument document, DocumentRefer public XWikiDocument getTranslatedDocument(XWikiDocument document, DocumentReference cellDocRef) throws XWikiException { - LOGGER.debug("getTranslatedDocument: document [" + document.getDocumentReference() - + "] cellDocRef [" + cellDocRef + "] context language [" + getContext().getLanguage() - + "]."); + LOGGER.debug( + "getTranslatedDocument: document [" + document.getDocumentReference() + "] cellDocRef [" + + cellDocRef + "] context language [" + getContext().getLanguage() + "]."); if (!isCurrentDocument(cellDocRef)) { - XWikiDocument tdoc = getDocument(document, cellDocRef).getTranslatedDocument( - getContext().getLanguage(), getContext()); + XWikiDocument tdoc = getDocument(document, cellDocRef) + .getTranslatedDocument(getContext().getLanguage(), getContext()); LOGGER.trace("getTranslatedDocument returning tdoc [" + tdoc.getDocumentReference() + "] lang [" + tdoc.getLanguage() + "," + tdoc.getDefaultLanguage() + "]."); return tdoc; @@ -199,8 +199,8 @@ DocumentReference getDependentDocumentReference(DocumentReference docRef, } else { LOGGER.info("getDependentDocumentReference: inheritable for '{}'. ", docRef); } - XWikiDocument pageDepDoc = new InheritorFactory().getContentInheritor(depDocList, - getContext()).getDocument(); + XWikiDocument pageDepDoc = new InheritorFactory() + .getContentInheritor(depDocList, getContext()).getDocument(); if (pageDepDoc != null) { return pageDepDoc.getDocumentReference(); } else { @@ -231,8 +231,8 @@ public DocumentReference getDependentDefaultDocumentReference(DocumentReference } else { LOGGER.trace("getDependentDefaultDocumentReference: no current layout reference found."); } - XWikiDocument pageDepDoc = new InheritorFactory().getContentInheritor(depDefaultDocList, - getContext()).getDocument(); + XWikiDocument pageDepDoc = new InheritorFactory() + .getContentInheritor(depDefaultDocList, getContext()).getDocument(); if (pageDepDoc != null) { LOGGER.debug("getDependentDefaultDocumentReference: docList '{}', pageDepDoc '{}'", depDefaultDocList, pageDepDoc.getDocumentReference()); @@ -268,8 +268,9 @@ public DocumentReference getLayoutDefaultDocRef(SpaceReference currLayoutRef, public DocumentReference getLayoutDefaultDocRef(SpaceReference currLayoutRef, String depCellSpace) { if ((depCellSpace != null) && (!"".equals(depCellSpace))) { - return new DocumentReference(depCellSpace + "-" - + PageDependentDocumentReferenceCommand.PDC_DEFAULT_CONTENT_NAME, currLayoutRef); + return new DocumentReference( + depCellSpace + "-" + PageDependentDocumentReferenceCommand.PDC_DEFAULT_CONTENT_NAME, + currLayoutRef); } return null; } @@ -312,8 +313,7 @@ public SpaceReference getDependentDocumentSpaceRef(DocumentReference docRef, (WikiReference) curSpaceRef.getParent()); } else { LOGGER.warn("getDependentDocumentSpace: fallback to currentDocument. Please" - + " check with isCurrentDocument method before calling" - + " getDependentDocumentSpace!"); + + " check with isCurrentDocument method before calling" + " getDependentDocumentSpace!"); spaceRef = getCurrentDocumentSpaceRef(docRef); } return spaceRef; @@ -326,8 +326,7 @@ public SpaceReference getDependentWikiSpaceRef(DocumentReference docRef, spaceRef = getDependentWikiSpaceRef(depCellSpace); if (spaceRef == null) { LOGGER.warn("getDependentDocumentSpace: fallback to currentDocument. Please" - + " check with isCurrentDocument method before calling" - + " getDependentDocumentSpace!"); + + " check with isCurrentDocument method before calling" + " getDependentDocumentSpace!"); spaceRef = getCurrentDocumentSpaceRef(docRef); } return spaceRef; @@ -379,9 +378,7 @@ public boolean isInheritable(DocumentReference cellDocRef) { private Optional getDepCellValue(DocumentReference cellDocRef, ClassField field) { return XWikiObjectFetcher.on(getModelAccess().getOrCreateDocument(cellDocRef)) - .filter(PageDepCellConfigClass.CLASS_REF) - .fetchField(field) - .stream().findFirst(); + .filter(PageDepCellConfigClass.CLASS_REF).fetchField(field).stream().findFirst(); } /** @@ -415,8 +412,8 @@ private IWebUtilsService getWebUtilsService() { } private XWikiContext getContext() { - return (XWikiContext) Utils.getComponent(Execution.class).getContext().getProperty( - XWikiContext.EXECUTIONCONTEXT_KEY); + return (XWikiContext) Utils.getComponent(Execution.class).getContext() + .getProperty(XWikiContext.EXECUTIONCONTEXT_KEY); } private EntityReferenceValueProvider getConfigProvider() { diff --git a/src/main/java/com/celements/cells/div/DivWriter.java b/src/main/java/com/celements/cells/div/DivWriter.java index f3b1d0641..e22a55c2c 100644 --- a/src/main/java/com/celements/cells/div/DivWriter.java +++ b/src/main/java/com/celements/cells/div/DivWriter.java @@ -85,15 +85,13 @@ public void openLevel(@Nullable String tagName, @NotNull List att @Override public boolean hasLevelContent() { - return hasLevelContentOptional() - .orElse(out.length() > 0); + return hasLevelContentOptional().orElse(out.length() > 0); } @Override public DivWriter appendContent(@Nullable String content) { final String con = Objects.toString(content, "").trim(); - if (!con.isEmpty() && !getOpenLevels().findFirst() - .map(VOID_ELEMENTS::contains).orElse(false)) { + if (!con.isEmpty() && !getOpenLevels().findFirst().map(VOID_ELEMENTS::contains).orElse(false)) { getCurrentLevel().ifPresent(e -> e.setValue(true)); out.append(con); } diff --git a/src/main/java/com/celements/cells/json/JsonWriter.java b/src/main/java/com/celements/cells/json/JsonWriter.java index 66ce19933..68f002cd7 100644 --- a/src/main/java/com/celements/cells/json/JsonWriter.java +++ b/src/main/java/com/celements/cells/json/JsonWriter.java @@ -54,11 +54,9 @@ public void openLevel(@Nullable String tagName, @NotNull List att jsonBuilder.openDictionary(); jsonBuilder.addPropertyNonEmpty("tagName", tagName); jsonBuilder.openDictionary("attributes"); - attributes.stream() - .filter(attribute -> attribute.getValue().isPresent()) - .forEach( - attribute -> jsonBuilder.addPropertyNonEmpty(attribute.getName(), - attribute.getValue().get())); + attributes.stream().filter(attribute -> attribute.getValue().isPresent()) + .forEach(attribute -> jsonBuilder.addPropertyNonEmpty(attribute.getName(), + attribute.getValue().get())); jsonBuilder.closeDictionary(); jsonBuilder.openArray("subnodes"); } diff --git a/src/main/java/com/celements/collections/CollectionsService.java b/src/main/java/com/celements/collections/CollectionsService.java index 488934c93..c7611976c 100644 --- a/src/main/java/com/celements/collections/CollectionsService.java +++ b/src/main/java/com/celements/collections/CollectionsService.java @@ -32,11 +32,7 @@ public List getObjectsOrdered(XWikiDocument doc, DocumentReference c if (doc == null) { return new ArrayList<>(); } - return XWikiObjectEditor - .on(doc) - .filter(new ClassReference(classRef)) - .fetch() - .stream() + return XWikiObjectEditor.on(doc).filter(new ClassReference(classRef)).fetch().stream() .sorted(BaseObjectComparator.create(orderField1, asc1) .thenComparing(BaseObjectComparator.create(orderField2, asc2))) .collect(toList()); diff --git a/src/main/java/com/celements/collections/service/DateScriptService.java b/src/main/java/com/celements/collections/service/DateScriptService.java index cfe716f76..928503b1f 100644 --- a/src/main/java/com/celements/collections/service/DateScriptService.java +++ b/src/main/java/com/celements/collections/service/DateScriptService.java @@ -76,8 +76,7 @@ public ZonedDateTime atZone(Date date, String zone) { public ZonedDateTime atZone(Date date, ZoneId zone) { return guard(date).map(Date::toInstant) - .map(instant -> instant.atZone(guard(zone).orElseGet(this::getZone))) - .orElse(null); + .map(instant -> instant.atZone(guard(zone).orElseGet(this::getZone))).orElse(null); } public LocalDate getLocalDate(int year, int month, int dayOfMonth) { @@ -100,8 +99,7 @@ public Duration getDuration(long amount, String unit) { public ChronoUnit getChronoUnit(String unit) { String name = Strings.nullToEmpty(unit).toUpperCase(); return Enums.getIfPresent(ChronoUnit.class, name) - .or(() -> Enums.getIfPresent(ChronoUnit.class, name + "S") - .orNull()); + .or(() -> Enums.getIfPresent(ChronoUnit.class, name + "S").orNull()); } public Date toDate(Temporal temporal) { @@ -120,11 +118,9 @@ public String format(String pattern, Temporal temporal) { public String format(String pattern, Temporal temporal, Locale locale) { try { - return guard(temporal) - .map(guard(pattern) - .map(p -> DateFormat.formatter(p, guard(locale).orElseGet(Locale::getDefault))) - .orElseGet(() -> (t -> null))) - .orElse(null); + return guard(temporal).map(guard(pattern) + .map(p -> DateFormat.formatter(p, guard(locale).orElseGet(Locale::getDefault))) + .orElseGet(() -> (t -> null))).orElse(null); } catch (DateTimeException exc) { LOGGER.info("format - failed for [{}] with pattern [{}] and locale [{}]", temporal, pattern, locale, exc); diff --git a/src/main/java/com/celements/collections/service/StreamScriptService.java b/src/main/java/com/celements/collections/service/StreamScriptService.java index f729f70f0..e2d753f19 100644 --- a/src/main/java/com/celements/collections/service/StreamScriptService.java +++ b/src/main/java/com/celements/collections/service/StreamScriptService.java @@ -18,9 +18,7 @@ public class StreamScriptService implements ScriptService { public Stream of(Object... values) { - return (values != null) - ? Stream.of(values).filter(Objects::nonNull) - : Stream.empty(); + return (values != null) ? Stream.of(values).filter(Objects::nonNull) : Stream.empty(); } public Stream concat(Stream... streams) { diff --git a/src/main/java/com/celements/common/cache/AbstractDocumentReferenceCache.java b/src/main/java/com/celements/common/cache/AbstractDocumentReferenceCache.java index cf2db2549..6caf7d4a9 100644 --- a/src/main/java/com/celements/common/cache/AbstractDocumentReferenceCache.java +++ b/src/main/java/com/celements/common/cache/AbstractDocumentReferenceCache.java @@ -98,8 +98,8 @@ private synchronized Map> getCache(WikiReference wikiR return cache.get(wikiRef); } - private Map> loadCache(WikiReference wikiRef) throws QueryException, - XWikiException { + private Map> loadCache(WikiReference wikiRef) + throws QueryException, XWikiException { getLogger().debug("loadCache: start for wiki '{}'", wikiRef); Map> cache = new HashMap<>(); for (DocumentReference docRef : executeXWQL(wikiRef)) { diff --git a/src/main/java/com/celements/common/classes/listener/XWikiPreferencesClassActivationListener.java b/src/main/java/com/celements/common/classes/listener/XWikiPreferencesClassActivationListener.java index 7d2410ca3..95b02b30a 100644 --- a/src/main/java/com/celements/common/classes/listener/XWikiPreferencesClassActivationListener.java +++ b/src/main/java/com/celements/common/classes/listener/XWikiPreferencesClassActivationListener.java @@ -41,15 +41,14 @@ public class XWikiPreferencesClassActivationListener implements EventListener { public static final String NAME = "celements.classes.XWikiPreferencesClassActivationListener"; - private static final Logger LOGGER = LoggerFactory.getLogger( - XWikiPreferencesClassActivationListener.class); + private static final Logger LOGGER = LoggerFactory + .getLogger(XWikiPreferencesClassActivationListener.class); private final IClassesCompositorComponent classesCompositor; private final Execution execution; @Inject - public XWikiPreferencesClassActivationListener( - IClassesCompositorComponent classesCompositor, + public XWikiPreferencesClassActivationListener(IClassesCompositorComponent classesCompositor, Execution execution) { this.classesCompositor = classesCompositor; this.execution = execution; diff --git a/src/main/java/com/celements/common/collections/ListUtils.java b/src/main/java/com/celements/common/collections/ListUtils.java index 52afd8ff8..f5c8c3f24 100644 --- a/src/main/java/com/celements/common/collections/ListUtils.java +++ b/src/main/java/com/celements/common/collections/ListUtils.java @@ -23,8 +23,7 @@ public class ListUtils { - private ListUtils() { - } + private ListUtils() {} /** * Provides a type safe substract for Lists. diff --git a/src/main/java/com/celements/common/observation/listener/AbstractDocumentListener.java b/src/main/java/com/celements/common/observation/listener/AbstractDocumentListener.java index c473e7654..b4fc9a0a1 100644 --- a/src/main/java/com/celements/common/observation/listener/AbstractDocumentListener.java +++ b/src/main/java/com/celements/common/observation/listener/AbstractDocumentListener.java @@ -16,8 +16,8 @@ import com.xpn.xwiki.doc.XWikiDocument; import com.xpn.xwiki.objects.BaseObject; -public abstract class AbstractDocumentListener extends - AbstractLocalEventListener { +public abstract class AbstractDocumentListener + extends AbstractLocalEventListener { @Override protected void onEventInternal(Event event, XWikiDocument doc, Object data) { diff --git a/src/main/java/com/celements/common/observation/listener/AbstractDocumentUpdateListener.java b/src/main/java/com/celements/common/observation/listener/AbstractDocumentUpdateListener.java index d1c6ed032..8782ed882 100644 --- a/src/main/java/com/celements/common/observation/listener/AbstractDocumentUpdateListener.java +++ b/src/main/java/com/celements/common/observation/listener/AbstractDocumentUpdateListener.java @@ -51,8 +51,8 @@ protected Event getNotifyEvent(Event event, XWikiDocument doc) { notifyEvent = getCreateEvent(event, doc.getDocumentReference()); } else if ((bObj == null) && (origBObj != null)) { notifyEvent = getDeleteEvent(event, doc.getDocumentReference()); - } else if ((bObj != null) && (origBObj != null) && (copyDocService.checkObject(bObj, origBObj) - || checkDocFields(doc))) { + } else if ((bObj != null) && (origBObj != null) + && (copyDocService.checkObject(bObj, origBObj) || checkDocFields(doc))) { notifyEvent = getUpdateEvent(event, doc.getDocumentReference()); } return notifyEvent; diff --git a/src/main/java/com/celements/common/observation/listener/AbstractEventListener.java b/src/main/java/com/celements/common/observation/listener/AbstractEventListener.java index 47b900c12..b85f592b6 100644 --- a/src/main/java/com/celements/common/observation/listener/AbstractEventListener.java +++ b/src/main/java/com/celements/common/observation/listener/AbstractEventListener.java @@ -57,8 +57,8 @@ protected ObservationManager getObservationManager() { try { this.observationManager = webUtilsService.lookup(ObservationManager.class); } catch (ComponentLookupException exc) { - throw new RuntimeException("Cound not retrieve an Observation Manager against " - + "the component manager", exc); + throw new RuntimeException( + "Cound not retrieve an Observation Manager against " + "the component manager", exc); } } return this.observationManager; @@ -73,8 +73,8 @@ protected XWikiContext getContext() { } public synchronized boolean isDisabled() { - return disabled || ConfigSourceUtils.getStringListProperty(configSrc, CFG_SRC_KEY).contains( - getName()); + return disabled + || ConfigSourceUtils.getStringListProperty(configSrc, CFG_SRC_KEY).contains(getName()); } public synchronized void enable() { diff --git a/src/main/java/com/celements/copydoc/CopyDocumentService.java b/src/main/java/com/celements/copydoc/CopyDocumentService.java index 72d436f39..fa26014c8 100644 --- a/src/main/java/com/celements/copydoc/CopyDocumentService.java +++ b/src/main/java/com/celements/copydoc/CopyDocumentService.java @@ -146,8 +146,8 @@ boolean copyObjects(XWikiDocument srcDoc, XWikiDocument trgDoc, Predicate srcObjs = getXObjects(srcDoc, xObjFilter); List trgObjs = new ArrayList<>(getXObjects(trgDoc, xObjFilter)); hasChanged |= createOrUpdateObjects(trgDoc, srcObjs, trgObjs, set); - hasChanged |= (set && modelAccess.removeXObjects(trgDoc, trgObjs)) || (!set - && !trgObjs.isEmpty()); + hasChanged |= (set && modelAccess.removeXObjects(trgDoc, trgObjs)) + || (!set && !trgObjs.isEmpty()); return hasChanged; } diff --git a/src/main/java/com/celements/docform/DocFormCommand.java b/src/main/java/com/celements/docform/DocFormCommand.java index eabcba7b8..b06217d75 100644 --- a/src/main/java/com/celements/docform/DocFormCommand.java +++ b/src/main/java/com/celements/docform/DocFormCommand.java @@ -120,8 +120,7 @@ public class DocFormCommand implements IDocForm { public DocFormCommand() { responseMap = new EnumMap<>(ResponseState.class); - Stream.of(ResponseState.values()) - .forEach(state -> responseMap.put(state, new HashSet<>())); + Stream.of(ResponseState.values()).forEach(state -> responseMap.put(state, new HashSet<>())); changedObjects = new HashMap<>(); defaultDocRef = Optional.empty(); isCreateAllowed = false; @@ -157,13 +156,10 @@ private void updateDoc(DocumentReference docRef, List reque // apply template for request document changedDocs.add(xdoc); } - requestParams.stream() - .filter(param -> param.getDocRef().equals(docRef)) - .map(param -> updateDocFromParam(xdoc, tdoc, param)) - .filter(Objects::nonNull) + requestParams.stream().filter(param -> param.getDocRef().equals(docRef)) + .map(param -> updateDocFromParam(xdoc, tdoc, param)).filter(Objects::nonNull) .forEach(changedDocs::add); - changedDocs.stream() - .forEach(this::trySaveDoc); + changedDocs.stream().forEach(this::trySaveDoc); // TODO [CELDEV-900] release lock on docRef } @@ -207,19 +203,17 @@ XWikiDocument updateDocFromParam(XWikiDocument xdoc, XWikiDocument tdoc, private XWikiDocument setDocField(XWikiDocument tdoc, DocFormRequestParam param) { DocFormRequestKey key = param.getKey(); - Predicate> setter = field -> xDocFieldAccessor.set( - tdoc, field, param.getValuesAsString()); + Predicate> setter = field -> xDocFieldAccessor.set(tdoc, field, + param.getValuesAsString()); return xDocClassDef.getField(key.getFieldName(), String.class) .filter(log(setter).debug(LOGGER).msg(() -> format("setDocField - [{0}]", param))) - .map(field -> tdoc) - .orElse(null); + .map(field -> tdoc).orElse(null); } private XWikiDocument setObjField(XWikiDocument xdoc, DocFormRequestParam param) { DocFormRequestKey key = param.getKey(); int actualObjNb = getChangedObjects().getOrDefault(key.getObjHash(), key.getObjNb()); - XWikiObjectEditor editor = XWikiObjectEditor.on(xdoc) - .filter(key.getClassRef()) + XWikiObjectEditor editor = XWikiObjectEditor.on(xdoc).filter(key.getClassRef()) .filter(actualObjNb); if ((key.getObjNb() >= 0) && !editor.fetch().exists()) { // XXX [CELDEV-901] disable object creation from non-negative numbers @@ -256,8 +250,7 @@ private boolean setObjField(BaseObject obj, DocFormRequestParam param) { } private XWikiDocument removeObj(XWikiDocument xdoc, DocFormRequestKey key) { - XWikiObjectEditor editor = XWikiObjectEditor.on(xdoc) - .filter(key.getClassRef()) + XWikiObjectEditor editor = XWikiObjectEditor.on(xdoc).filter(key.getClassRef()) .filter(key.getObjNb()); if (!editor.delete().isEmpty()) { LOGGER.debug("removeObj: removed obj for [{}]", key); @@ -280,12 +273,12 @@ private void trySaveDoc(XWikiDocument doc) { } else { try { modelAccess.saveDocument(doc, "updateAndSaveDocFormRequest"); - LOGGER.info("saved doc [{}], lang [{}]", - serialize(doc.getDocumentReference()), doc.getLanguage()); + LOGGER.info("saved doc [{}], lang [{}]", serialize(doc.getDocumentReference()), + doc.getLanguage()); state = ResponseState.successful; } catch (DocumentSaveException dse) { - LOGGER.error("failed saving [{}], lang [{}]", - serialize(doc.getDocumentReference()), doc.getLanguage(), dse); + LOGGER.error("failed saving [{}], lang [{}]", serialize(doc.getDocumentReference()), + doc.getLanguage(), dse); state = ResponseState.failed; } } @@ -295,13 +288,14 @@ private void trySaveDoc(XWikiDocument doc) { @Override public Map> getResponseMap( List requestParams) { - Stream.concat(defaultDocRef.map(Stream::of).orElseGet(Stream::empty), - requestParams.stream().map(DocFormRequestParam::getDocRef)) + Stream + .concat(defaultDocRef.map(Stream::of).orElseGet(Stream::empty), + requestParams.stream().map(DocFormRequestParam::getDocRef)) .filter(not(responseMap.get(ResponseState.successful)::contains)) .filter(not(responseMap.get(ResponseState.failed)::contains)) .forEach(responseMap.get(ResponseState.unchanged)::add); - return responseMap.entrySet().stream().collect(toImmutableMap(Entry::getKey, - entry -> ImmutableSet.copyOf(entry.getValue()))); + return responseMap.entrySet().stream() + .collect(toImmutableMap(Entry::getKey, entry -> ImmutableSet.copyOf(entry.getValue()))); } private XWikiDocument getTranslatedDoc(XWikiDocument xdoc) { @@ -309,8 +303,8 @@ private XWikiDocument getTranslatedDoc(XWikiDocument xdoc) { try { XWikiDocument tdoc = getAddTranslationCommand().getTranslatedDoc(xdoc, lang); LOGGER.debug("getTranslatedDoc - [{}], [{}]: lang [{}], defaultLang [{}], isSameAsMain [{}]", - serialize(xdoc.getDocumentReference()), lang, - tdoc.getLanguage(), tdoc.getDefaultLanguage(), xdoc == tdoc); + serialize(xdoc.getDocumentReference()), lang, tdoc.getLanguage(), + tdoc.getDefaultLanguage(), xdoc == tdoc); return tdoc; } catch (XWikiException xwe) { LOGGER.warn("getTranslatedDoc: failed for [{}]", serialize(xdoc.getDocumentReference()), xwe); @@ -328,8 +322,7 @@ private Supplier serialize(EntityReference ref) { AddTranslationCommand addTranslationCmd; private AddTranslationCommand getAddTranslationCommand() { - return Optional.ofNullable(addTranslationCmd) - .orElseGet(AddTranslationCommand::new); + return Optional.ofNullable(addTranslationCmd).orElseGet(AddTranslationCommand::new); } } diff --git a/src/main/java/com/celements/docform/DocFormRequestKey.java b/src/main/java/com/celements/docform/DocFormRequestKey.java index 03f254ecf..96abe107f 100644 --- a/src/main/java/com/celements/docform/DocFormRequestKey.java +++ b/src/main/java/com/celements/docform/DocFormRequestKey.java @@ -18,7 +18,9 @@ public class DocFormRequestKey implements Comparable { public enum Type { - DOC_FIELD, OBJ_FIELD, OBJ_REMOVE; + DOC_FIELD, + OBJ_FIELD, + OBJ_REMOVE; } private final String keyString; @@ -29,28 +31,26 @@ public enum Type { private final boolean remove; private final String fieldName; - public static DocFormRequestKey createDocFieldKey(String key, - DocumentReference docRef, String fieldName) { + public static DocFormRequestKey createDocFieldKey(String key, DocumentReference docRef, + String fieldName) { checkArgument(emptyToNull(fieldName) != null, key); return new DocFormRequestKey(key, Type.DOC_FIELD, docRef, null, 0, false, fieldName); } - public static DocFormRequestKey createObjFieldKey(String key, - DocumentReference docRef, ClassReference classRef, Integer objNb, String fieldName) { + public static DocFormRequestKey createObjFieldKey(String key, DocumentReference docRef, + ClassReference classRef, Integer objNb, String fieldName) { checkArgument(classRef != null, key); checkArgument(objNb != null, key); checkArgument(emptyToNull(fieldName) != null, key); - return new DocFormRequestKey(key, Type.OBJ_FIELD, docRef, classRef, objNb, - false, fieldName); + return new DocFormRequestKey(key, Type.OBJ_FIELD, docRef, classRef, objNb, false, fieldName); } - public static DocFormRequestKey createObjRemoveKey(String key, - DocumentReference docRef, ClassReference classRef, Integer objNb) { + public static DocFormRequestKey createObjRemoveKey(String key, DocumentReference docRef, + ClassReference classRef, Integer objNb) { checkArgument(classRef != null, key); checkArgument(objNb != null, key); checkArgument(objNb >= 0, key); - return new DocFormRequestKey(key, Type.OBJ_REMOVE, docRef, classRef, - objNb, true, null); + return new DocFormRequestKey(key, Type.OBJ_REMOVE, docRef, classRef, objNb, true, null); } private DocFormRequestKey(String key, Type type, DocumentReference docRef, @@ -108,8 +108,7 @@ public boolean equals(Object obj) { } else if (obj instanceof DocFormRequestKey) { DocFormRequestKey that = (DocFormRequestKey) obj; return Objects.equals(this.docRef, that.docRef) - && Objects.equals(this.classRef, that.classRef) - && Objects.equals(this.objNb, that.objNb) + && Objects.equals(this.classRef, that.classRef) && Objects.equals(this.objNb, that.objNb) && Objects.equals(this.remove, that.remove) && Objects.equals(this.fieldName, that.fieldName); } @@ -126,8 +125,7 @@ public int compareTo(DocFormRequestKey that) { // positive numbers first sorted asc, then negativ desc .compare(this.objNb, that.objNb, new ObjNbComparator()) // remove come last - .compareFalseFirst(this.remove, that.remove) - .compare(this.fieldName, that.fieldName) + .compareFalseFirst(this.remove, that.remove).compare(this.fieldName, that.fieldName) .result(); } @@ -152,9 +150,9 @@ public int compare(Integer i1, Integer i2) { @Override public String toString() { - return "DocFormRequestKey [keyString=" + keyString + ", type=" + type - + ", docRef=" + docRef + ", classRef=" + classRef + ", objNb=" + objNb - + ", remove=" + remove + ", fieldName=" + fieldName + "]"; + return "DocFormRequestKey [keyString=" + keyString + ", type=" + type + ", docRef=" + docRef + + ", classRef=" + classRef + ", objNb=" + objNb + ", remove=" + remove + ", fieldName=" + + fieldName + "]"; } } diff --git a/src/main/java/com/celements/docform/DocFormRequestKeyParser.java b/src/main/java/com/celements/docform/DocFormRequestKeyParser.java index 8174b562f..adea96cf7 100644 --- a/src/main/java/com/celements/docform/DocFormRequestKeyParser.java +++ b/src/main/java/com/celements/docform/DocFormRequestKeyParser.java @@ -55,18 +55,15 @@ public DocFormRequestKeyParser(DocumentReference defaultDocRef) { * Parses given map to {@link DocFormRequestParam} objects. See {@link #parse(String)}. */ public List parseParameterMap(Map map) { - return map.keySet().stream() - .filter(key -> !nullToEmpty(key).trim().isEmpty()) - .map(key -> { - try { - return parse(key).orElse(null); - } catch (DocFormRequestParseException exc) { - LOGGER.warn("unable to parse {}", key, exc); - return null; - } - }).filter(Objects::nonNull) - .map(key -> new DocFormRequestParam(key, map.get(key.getKeyString()))) - .sorted() + return map.keySet().stream().filter(key -> !nullToEmpty(key).trim().isEmpty()).map(key -> { + try { + return parse(key).orElse(null); + } catch (DocFormRequestParseException exc) { + LOGGER.warn("unable to parse {}", key, exc); + return null; + } + }).filter(Objects::nonNull) + .map(key -> new DocFormRequestParam(key, map.get(key.getKeyString()))).sorted() .collect(toImmutableList()); } @@ -82,8 +79,8 @@ public List parseParameterMap(Map map) { * if the key matches the expected pattern but cannot be parsed */ public Optional parse(String key) throws DocFormRequestParseException { - List keyParts = new ArrayList<>(Splitter.on(KEY_DELIM) - .trimResults().omitEmptyStrings().splitToList(key)); + List keyParts = new ArrayList<>( + Splitter.on(KEY_DELIM).trimResults().omitEmptyStrings().splitToList(key)); try { DocumentReference docRef = parseDocRefIfPresent(keyParts).orElse(defaultDocRef); if (isAllowedDocField(asFieldName(keyParts))) { @@ -95,8 +92,8 @@ public Optional parse(String key) throws DocFormRequestParseE if (objNbKeyPart.startsWith("^")) { return Optional.of(createObjRemoveKey(key, docRef, classRef, objNb)); } else { - return Optional.of(createObjFieldKey(key, docRef, classRef, objNb, - asFieldName(keyParts))); + return Optional + .of(createObjFieldKey(key, docRef, classRef, objNb, asFieldName(keyParts))); } } else { LOGGER.info("parse: skip key [{}]", key); @@ -122,16 +119,14 @@ private Optional parseDocRefIfPresent(List keyParts) private boolean isAllowedDocField(String key) { if (allowedDocFields == null) { allowedDocFields = getXDocClassDef().getFields().stream() - .filter(ImmutableSet.of(FIELD_TITLE, FIELD_CONTENT)::contains) - .map(ClassField::getName) + .filter(ImmutableSet.of(FIELD_TITLE, FIELD_CONTENT)::contains).map(ClassField::getName) .collect(toImmutableSet()); } return allowedDocFields.contains(key); } private boolean isObjKey(List keyParts) { - return (keyParts.size() > 1) - && PATTERN_FULLNAME.matcher(keyParts.get(0)).matches() + return (keyParts.size() > 1) && PATTERN_FULLNAME.matcher(keyParts.get(0)).matches() && PATTERN_OBJNB.matcher(keyParts.get(1)).matches(); } diff --git a/src/main/java/com/celements/docform/DocFormRequestParam.java b/src/main/java/com/celements/docform/DocFormRequestParam.java index e83aa921a..c69acd864 100644 --- a/src/main/java/com/celements/docform/DocFormRequestParam.java +++ b/src/main/java/com/celements/docform/DocFormRequestParam.java @@ -24,9 +24,7 @@ public class DocFormRequestParam implements Comparable { public DocFormRequestParam(DocFormRequestKey key, List values) { this.key = checkNotNull(key); - this.values = values.stream() - .map(s -> nullToEmpty(s).trim()) - .filter(not(String::isEmpty)) + this.values = values.stream().map(s -> nullToEmpty(s).trim()).filter(not(String::isEmpty)) .collect(toImmutableList()); } diff --git a/src/main/java/com/celements/docform/DocFormScriptService.java b/src/main/java/com/celements/docform/DocFormScriptService.java index b75b981f7..d5f01cb8a 100644 --- a/src/main/java/com/celements/docform/DocFormScriptService.java +++ b/src/main/java/com/celements/docform/DocFormScriptService.java @@ -59,8 +59,8 @@ public List parseRequestParams() { return parseParams(context.getDocRef().orElse(null), getRequestParameterMap()); } - public Map> updateAndSaveDocFromMap( - DocumentReference docRef, Map map) { + public Map> updateAndSaveDocFromMap(DocumentReference docRef, + Map map) { return updateAndSaveDoc(docRef, parseParams(docRef, map)); } @@ -80,8 +80,7 @@ public Map> updateAndSaveDoc(DocumentReference do if (hasEditOnAllDocs(requestParams)) { docForm.updateDocs(requestParams); } - return docForm.getResponseMap(requestParams) - .entrySet().stream() + return docForm.getResponseMap(requestParams).entrySet().stream() .collect(toImmutableMap(entry -> entry.getKey().name(), Entry::getValue)); } catch (Exception exc) { LOGGER.error("updateAndSaveDocFromMap: failed for map [{}]", requestParams, exc); @@ -98,14 +97,11 @@ public Map> updateAndSaveDocFromRequest(DocumentR } private Map getRequestParameterMap() { - return context.request().map(XWikiRequest::getParameterMap) - .orElseGet(Collections::emptyMap); + return context.request().map(XWikiRequest::getParameterMap).orElseGet(Collections::emptyMap); } boolean hasEditOnAllDocs(List requestParams) { - return requestParams.stream() - .map(DocFormRequestParam::getDocRef) - .distinct() + return requestParams.stream().map(DocFormRequestParam::getDocRef).distinct() .filter(docRef -> modelAccess.exists(docRef) || isCreateAllowed()) .allMatch(docRef -> rightsAccess.hasAccessLevel(docRef, EAccessLevel.EDIT)); } @@ -115,9 +111,9 @@ public boolean isCreateAllowed() { } private IDocForm getDocFormCommand(DocumentReference docRef) { - return (IDocForm) getContext().computeIfAbsent(DOC_FORM_COMMAND_CTX_KEY + "_" + - modelUtils.serializeRef(docRef, ReferenceSerializationMode.GLOBAL), - key -> Utils.getComponent(IDocForm.class) - .initialize(docRef, isCreateAllowed())); + return (IDocForm) getContext().computeIfAbsent( + DOC_FORM_COMMAND_CTX_KEY + "_" + + modelUtils.serializeRef(docRef, ReferenceSerializationMode.GLOBAL), + key -> Utils.getComponent(IDocForm.class).initialize(docRef, isCreateAllowed())); } } diff --git a/src/main/java/com/celements/docform/IDocForm.java b/src/main/java/com/celements/docform/IDocForm.java index 46af89569..691ed27ce 100644 --- a/src/main/java/com/celements/docform/IDocForm.java +++ b/src/main/java/com/celements/docform/IDocForm.java @@ -13,7 +13,9 @@ public interface IDocForm { public enum ResponseState { - successful, failed, unchanged; + successful, + failed, + unchanged; } IDocForm initialize(DocumentReference defaultDocRef, boolean isCreateAllowed); diff --git a/src/main/java/com/celements/dom4j/Dom4JParser.java b/src/main/java/com/celements/dom4j/Dom4JParser.java index f848d13a2..ec155e6f4 100644 --- a/src/main/java/com/celements/dom4j/Dom4JParser.java +++ b/src/main/java/com/celements/dom4j/Dom4JParser.java @@ -64,8 +64,8 @@ public OutputFormat getOutputFormat() { } public D readDocument(String xml) throws IOException { - try (ByteArrayInputStream in = new ByteArrayInputStream( - xml.getBytes(outFormat.getEncoding()))) { + try ( + ByteArrayInputStream in = new ByteArrayInputStream(xml.getBytes(outFormat.getEncoding()))) { SAXReader reader = new SAXReader(factory); reader.setEntityResolver(new DefaultEntityResolver()); reader.setFeature("http://apache.org/xml/features/disallow-doctype-decl", disableDTDs); @@ -87,11 +87,10 @@ public String writeXML(Stream nodes) throws IOException { } } - public Optional readAndExecute(String xml, - Function> executable) throws IOException { + public Optional readAndExecute(String xml, Function> executable) + throws IOException { D document = readDocument(xml); - return Optional.of(writeXML(executable.apply(document))) - .filter(not(String::isEmpty)); + return Optional.of(writeXML(executable.apply(document))).filter(not(String::isEmpty)); } } diff --git a/src/main/java/com/celements/emptycheck/internal/DefaultEmptyDocStrategy.java b/src/main/java/com/celements/emptycheck/internal/DefaultEmptyDocStrategy.java index d20842dd9..27bf35bea 100644 --- a/src/main/java/com/celements/emptycheck/internal/DefaultEmptyDocStrategy.java +++ b/src/main/java/com/celements/emptycheck/internal/DefaultEmptyDocStrategy.java @@ -37,8 +37,8 @@ @Component("default") @Singleton -public class DefaultEmptyDocStrategy implements IEmptyDocStrategyRole, - IDefaultEmptyDocStrategyRole { +public class DefaultEmptyDocStrategy + implements IEmptyDocStrategyRole, IDefaultEmptyDocStrategyRole { private static final Logger LOGGER = LoggerFactory.getLogger(DefaultEmptyDocStrategy.class); @@ -79,8 +79,8 @@ public boolean isEmptyRTEDocumentDefault(DocumentReference docRef) { @Override public boolean isEmptyRTEDocumentTranslated(DocumentReference docRef) { try { - return isEmptyRTEDocument(getContext().getWiki().getDocument(docRef, - getContext()).getTranslatedDocument(getContext().getLanguage(), getContext())); + return isEmptyRTEDocument(getContext().getWiki().getDocument(docRef, getContext()) + .getTranslatedDocument(getContext().getLanguage(), getContext())); } catch (XWikiException exp) { LOGGER.error("isEmptyRTEDocumentTranslated failed getting document. ", exp); } @@ -95,8 +95,8 @@ public boolean isEmptyRTEDocument(XWikiDocument localdoc) { @Override public boolean isEmptyRTEString(String rteContent) { checkNotNull(rteContent); - return "".equals(rteContent.replaceAll( - "(

)?()?(\\s*( |))*\\s*()?(

)?", "").trim()); + return "".equals(rteContent + .replaceAll("(

)?()?(\\s*( |))*\\s*()?(

)?", "").trim()); } @Override @@ -112,8 +112,8 @@ public boolean isEmptyDocumentDefault(DocumentReference docRef) { @Override public boolean isEmptyDocumentTranslated(DocumentReference docRef) { try { - return isEmptyDocument(getContext().getWiki().getDocument(docRef, - getContext()).getTranslatedDocument(getContext().getLanguage(), getContext())); + return isEmptyDocument(getContext().getWiki().getDocument(docRef, getContext()) + .getTranslatedDocument(getContext().getLanguage(), getContext())); } catch (XWikiException exp) { LOGGER.error("isEmptyDocumentTranslated failed getting document", exp); } diff --git a/src/main/java/com/celements/emptycheck/internal/NextNonEmptyChildrenCommand.java b/src/main/java/com/celements/emptycheck/internal/NextNonEmptyChildrenCommand.java index ac60b6bec..95bda63d4 100644 --- a/src/main/java/com/celements/emptycheck/internal/NextNonEmptyChildrenCommand.java +++ b/src/main/java/com/celements/emptycheck/internal/NextNonEmptyChildrenCommand.java @@ -15,8 +15,7 @@ public class NextNonEmptyChildrenCommand { - private static final Logger LOGGER = LoggerFactory.getLogger( - NextNonEmptyChildrenCommand.class); + private static final Logger LOGGER = LoggerFactory.getLogger(NextNonEmptyChildrenCommand.class); private Set visitedDocRefs; @@ -32,8 +31,8 @@ public DocumentReference getNextNonEmptyChildren(DocumentReference documentRef) return result; } } else { - LOGGER.warn("getNextNonEmptyChildren_internal: recursion detected on [" + nextChild - + "]."); + LOGGER + .warn("getNextNonEmptyChildren_internal: recursion detected on [" + nextChild + "]."); } } return null; diff --git a/src/main/java/com/celements/emptycheck/service/EmptyCheckService.java b/src/main/java/com/celements/emptycheck/service/EmptyCheckService.java index acf64aec9..f6eae6561 100644 --- a/src/main/java/com/celements/emptycheck/service/EmptyCheckService.java +++ b/src/main/java/com/celements/emptycheck/service/EmptyCheckService.java @@ -34,8 +34,8 @@ private XWikiContext getContext() { @Override public DocumentReference getNextNonEmptyChildren(DocumentReference documentRef) { - DocumentReference nonEmptyChildRef = new NextNonEmptyChildrenCommand().getNextNonEmptyChildren( - documentRef); + DocumentReference nonEmptyChildRef = new NextNonEmptyChildrenCommand() + .getNextNonEmptyChildren(documentRef); if (nonEmptyChildRef != null) { return nonEmptyChildRef; } diff --git a/src/main/java/com/celements/form/classes/FormConfigClass.java b/src/main/java/com/celements/form/classes/FormConfigClass.java index 73e08ff29..b9dd917f1 100644 --- a/src/main/java/com/celements/form/classes/FormConfigClass.java +++ b/src/main/java/com/celements/form/classes/FormConfigClass.java @@ -19,19 +19,18 @@ public class FormConfigClass extends AbstractClassDefinition implements FormClas public static final String CLASS_DEF_HINT = FormClass.CLASS_SPACE + "." + CLASS_NAME; public static final ClassReference CLASS_REF = new ClassReference(CLASS_SPACE, CLASS_NAME); - public static final ClassField FIELD_FORM_LAYOUT = new StringField.Builder( - CLASS_REF, "formLayout").size(30).prettyName("Formular Layout Name").build(); + public static final ClassField FIELD_FORM_LAYOUT = new StringField.Builder(CLASS_REF, + "formLayout").size(30).prettyName("Formular Layout Name").build(); - public static final ClassField FIELD_SUCCESSFULPAGE = new StringField.Builder( - CLASS_REF, "successfulpage").size(30).build(); + public static final ClassField FIELD_SUCCESSFULPAGE = new StringField.Builder(CLASS_REF, + "successfulpage").size(30).build(); - public static final ClassField FIELD_FAILEDPAGE = new StringField.Builder( - CLASS_REF, "failedpage").size(30).build(); + public static final ClassField FIELD_FAILEDPAGE = new StringField.Builder(CLASS_REF, + "failedpage").size(30).build(); public static final ClassField FIELD_EXCLUDE_FORM_IS_FILLED = new StringField.Builder( CLASS_REF, "excludeFromIsFilledCheck").size(30) - .prettyName("Exclude fields from 'isFilled' check. (separator: ',')") - .build(); + .prettyName("Exclude fields from 'isFilled' check. (separator: ',')").build(); public FormConfigClass() { super(CLASS_REF); diff --git a/src/main/java/com/celements/ftpclient/CelFTPClient.java b/src/main/java/com/celements/ftpclient/CelFTPClient.java index a406a629d..37c1fd326 100644 --- a/src/main/java/com/celements/ftpclient/CelFTPClient.java +++ b/src/main/java/com/celements/ftpclient/CelFTPClient.java @@ -47,8 +47,8 @@ public boolean connectAndLogin(String host, Integer port, String userName, Strin /** A convenience method for connecting and logging in */ @Override - public boolean connectAndLogin(String host, String userName, String password) throws IOException, - UnknownHostException, FTPConnectionClosedException { + public boolean connectAndLogin(String host, String userName, String password) + throws IOException, UnknownHostException, FTPConnectionClosedException { return connectAndLogin(host, null, userName, password); } @@ -81,8 +81,8 @@ public boolean binary() throws IOException { /** Download a file from the server, and save it to the specified local file */ @Override - public boolean downloadFile(String serverFile, String localFile) throws IOException, - FTPConnectionClosedException { + public boolean downloadFile(String serverFile, String localFile) + throws IOException, FTPConnectionClosedException { FileOutputStream out = new FileOutputStream(localFile); boolean result = retrieveFile(serverFile, out); out.close(); @@ -91,8 +91,8 @@ public boolean downloadFile(String serverFile, String localFile) throws IOExcept /** Upload a file to the server */ @Override - public boolean uploadFile(String localFile, String serverFile) throws IOException, - FTPConnectionClosedException { + public boolean uploadFile(String localFile, String serverFile) + throws IOException, FTPConnectionClosedException { FileInputStream in = new FileInputStream(localFile); boolean result = storeFile(serverFile, in); in.close(); diff --git a/src/main/java/com/celements/ftpclient/ICelFTPClient.java b/src/main/java/com/celements/ftpclient/ICelFTPClient.java index 9fb63c803..0f3e7fe2a 100644 --- a/src/main/java/com/celements/ftpclient/ICelFTPClient.java +++ b/src/main/java/com/celements/ftpclient/ICelFTPClient.java @@ -21,8 +21,8 @@ public interface ICelFTPClient { public List listFileNames() throws IOException, FTPConnectionClosedException; - public boolean connectAndLogin(String host, String userName, String password) throws IOException, - UnknownHostException, FTPConnectionClosedException; + public boolean connectAndLogin(String host, String userName, String password) + throws IOException, UnknownHostException, FTPConnectionClosedException; public boolean connectAndLogin(String host, Integer port, String userName, String password) throws IOException, UnknownHostException, FTPConnectionClosedException; @@ -242,11 +242,11 @@ public FTPListParseEngine initiateListParsing(String parserKey, String pathname) public boolean getAutodetectUTF8(); - public boolean downloadFile(String serverFile, String localFile) throws IOException, - FTPConnectionClosedException; + public boolean downloadFile(String serverFile, String localFile) + throws IOException, FTPConnectionClosedException; - public boolean uploadFile(String localFile, String serverFile) throws IOException, - FTPConnectionClosedException; + public boolean uploadFile(String localFile, String serverFile) + throws IOException, FTPConnectionClosedException; public List listSubdirNames() throws IOException, FTPConnectionClosedException; diff --git a/src/main/java/com/celements/inheritor/ContentInheritor.java b/src/main/java/com/celements/inheritor/ContentInheritor.java index 9f6bc71cc..4f1a29f6e 100644 --- a/src/main/java/com/celements/inheritor/ContentInheritor.java +++ b/src/main/java/com/celements/inheritor/ContentInheritor.java @@ -37,8 +37,7 @@ public class ContentInheritor { private IEmptyDocumentChecker _emptyDocumentChecker; private String _language; - public ContentInheritor() { - } + public ContentInheritor() {} public void setIteratorFactory(IIteratorFactory iteratorFactory) { _iteratorFactory = iteratorFactory; @@ -154,8 +153,8 @@ IEmptyDocumentChecker getEmptyDocumentChecker() { } private XWikiContext getContext() { - return (XWikiContext) Utils.getComponent(Execution.class).getContext().getProperty( - "xwikicontext"); + return (XWikiContext) Utils.getComponent(Execution.class).getContext() + .getProperty("xwikicontext"); } } diff --git a/src/main/java/com/celements/inheritor/DefaultEmptyFieldChecker.java b/src/main/java/com/celements/inheritor/DefaultEmptyFieldChecker.java index 1162b607c..c86d07ef1 100644 --- a/src/main/java/com/celements/inheritor/DefaultEmptyFieldChecker.java +++ b/src/main/java/com/celements/inheritor/DefaultEmptyFieldChecker.java @@ -53,8 +53,8 @@ public boolean isEmptyString(BaseStringProperty property) { @Override public boolean isEmptyNumber(NumberProperty property) { - return (property.getValue().toString().equals("0") || property.getValue().toString().equals( - "0.0")); + return (property.getValue().toString().equals("0") + || property.getValue().toString().equals("0.0")); } @Override diff --git a/src/main/java/com/celements/inheritor/DefaultTemplatePathTransformationConfiguration.java b/src/main/java/com/celements/inheritor/DefaultTemplatePathTransformationConfiguration.java index dbe5263df..887e6d0d6 100644 --- a/src/main/java/com/celements/inheritor/DefaultTemplatePathTransformationConfiguration.java +++ b/src/main/java/com/celements/inheritor/DefaultTemplatePathTransformationConfiguration.java @@ -32,8 +32,8 @@ * disk based on inheritance. */ @Component -public class DefaultTemplatePathTransformationConfiguration implements - TemplatePathTransformationConfiguration, Initializable { +public class DefaultTemplatePathTransformationConfiguration + implements TemplatePathTransformationConfiguration, Initializable { /** * Prefix for configuration keys for the Icon transformation module. diff --git a/src/main/java/com/celements/inheritor/InheritorFactory.java b/src/main/java/com/celements/inheritor/InheritorFactory.java index 5343fed25..f16f32a3a 100644 --- a/src/main/java/com/celements/inheritor/InheritorFactory.java +++ b/src/main/java/com/celements/inheritor/InheritorFactory.java @@ -125,8 +125,9 @@ private PageLayoutCommand getPageLayoutCmd() { } public FieldInheritor getPageLayoutInheritor(String fullName, XWikiContext context) { - return getFieldInheritor("Celements2.PageType", Arrays.asList(fullName, - getSpacePreferencesFullName(fullName), "XWiki.XWikiPreferences"), context); + return getFieldInheritor("Celements2.PageType", + Arrays.asList(fullName, getSpacePreferencesFullName(fullName), "XWiki.XWikiPreferences"), + context); } /** @@ -145,9 +146,9 @@ public FieldInheritor getConfigFieldInheritor(DocumentReference classDocRef, public FieldInheritor getConfigFieldInheritor(ClassReference classRef, EntityReference reference) { checkArgument(isAbsoluteRef(reference)); - Iterable docRefs = FluentIterable.of(extractRef(reference, - DocumentReference.class).orNull(), getSpacePrefDocRef(reference), getXWikiPrefDocRef( - reference)) + Iterable docRefs = FluentIterable + .of(extractRef(reference, DocumentReference.class).orNull(), getSpacePrefDocRef(reference), + getXWikiPrefDocRef(reference)) .filter(Predicates.notNull()); return getFieldInheritor(classRef, docRefs); } @@ -163,8 +164,8 @@ DocumentReference getSpacePrefDocRef(EntityReference reference) { private DocumentReference getXWikiPrefDocRef(EntityReference reference) { Optional wikiRef = extractRef(reference, WikiReference.class); if (wikiRef.isPresent()) { - return create(DocumentReference.class, "XWikiPreferences", create(SpaceReference.class, - "XWiki", wikiRef.get())); + return create(DocumentReference.class, "XWikiPreferences", + create(SpaceReference.class, "XWiki", wikiRef.get())); } return null; } diff --git a/src/main/java/com/celements/iterator/DocumentIterator.java b/src/main/java/com/celements/iterator/DocumentIterator.java index 298c2e926..d14809cd0 100644 --- a/src/main/java/com/celements/iterator/DocumentIterator.java +++ b/src/main/java/com/celements/iterator/DocumentIterator.java @@ -49,8 +49,7 @@ public class DocumentIterator implements Iterator, Iterable getObjectsForCurrentDoc() { if (getCurrentDoc() == null) { return Collections.emptyList(); } - List objs = getCurrentDoc().getXObjects( - getWebUtilsService().resolveDocumentReference(_xwikiClassName)); + List objs = getCurrentDoc() + .getXObjects(getWebUtilsService().resolveDocumentReference(_xwikiClassName)); if (objs != null) { return objs; } else { diff --git a/src/main/java/com/celements/javascript/FrontendResourceIncludeCssListener.java b/src/main/java/com/celements/javascript/FrontendResourceIncludeCssListener.java index 60a344784..8ca6cce9a 100644 --- a/src/main/java/com/celements/javascript/FrontendResourceIncludeCssListener.java +++ b/src/main/java/com/celements/javascript/FrontendResourceIncludeCssListener.java @@ -15,8 +15,7 @@ public class FrontendResourceIncludeCssListener implements IExtJSFilesListener { private final FrontendResourceResolver resolver; @Inject - public FrontendResourceIncludeCssListener( - CssCommand cssCommand, + public FrontendResourceIncludeCssListener(CssCommand cssCommand, FrontendResourceResolver resolver) { this.cssCommand = cssCommand; this.resolver = resolver; @@ -26,8 +25,7 @@ public FrontendResourceIncludeCssListener( public void beforeAllExtFinish(ExternalJavaScriptFilesCommand jsCommand) { // Include frontend entry sources. CSSEngine treats :frontend/... values as manifest keys and // expands them to the CSS assets emitted for that entrypoint. - jsCommand.streamExtJsFiles() - .filter(resolver::isFrontendSource) + jsCommand.streamExtJsFiles().filter(resolver::isFrontendSource) .forEach(cssCommand::includeCSSPage); } } diff --git a/src/main/java/com/celements/javascript/FrontendResourceResolver.java b/src/main/java/com/celements/javascript/FrontendResourceResolver.java index b392a65c5..3f68916da 100644 --- a/src/main/java/com/celements/javascript/FrontendResourceResolver.java +++ b/src/main/java/com/celements/javascript/FrontendResourceResolver.java @@ -33,7 +33,6 @@ /** * Resolves frontend JavaScript & CSS resources based on the vite manifest file. - * * The manifest file is generated by vite during the build process and contains mappings from source * files to their corresponding production files with hashed names. * @@ -54,13 +53,11 @@ public class FrontendResourceResolver { private final ObjectMapper objectMapper; // ":frontend/file.ts" -> ("dist/file.a8b3.mjs", ["dist/assets/file.a8b3.css"]) - private final Supplier> manifest = Suppliers.memoize( - this::readManifestFiles); + private final Supplier> manifest = Suppliers + .memoize(this::readManifestFiles); @Inject - public FrontendResourceResolver( - Environment springEnv, - ResourcePatternResolver resourceLoader) { + public FrontendResourceResolver(Environment springEnv, ResourcePatternResolver resourceLoader) { this.resourceLoader = resourceLoader; this.springEnv = springEnv; this.objectMapper = new ObjectMapper(); @@ -83,7 +80,6 @@ public Map getManifest() { * * @param sourcePath * e.g. ":frontend/file.ts" - * * @return The resolved frontend resource with JS and CSS dist paths, e.g. * "dist/file.a8b3.mjs" and ["dist/assets/file.a8b3.css"] */ @@ -102,11 +98,16 @@ private Map readManifestFiles() { } catch (IOException e) { throw new IllegalStateException("Failed loading frontend manifest files", e); } - var map = StreamEx.of(resources) - .filter(Resource::exists) - .flatMap(this::readJson) - .flatMapToEntry(json -> new ViteManifest(json).frontendResources()) - .toImmutableMap(); // ISE on duplicate keys, we expect unique source files + var map = StreamEx.of(resources).filter(Resource::exists).flatMap(this::readJson) + .flatMapToEntry(json -> new ViteManifest(json).frontendResources()).toImmutableMap(); // ISE + // on + // duplicate + // keys, + // we + // expect + // unique + // source + // files LOGGER.info("readManifest - {}", map); return map; } @@ -120,7 +121,8 @@ private Stream readJson(Resource resource) { } } - public record FrontendResource(String jsPath, List cssPaths) {} + public record FrontendResource(String jsPath, List cssPaths) { + } static final class ViteManifest { @@ -131,11 +133,9 @@ static final class ViteManifest { } Map frontendResources() { - return EntryStream.of(manifest.fields()) - .mapToValue(ViteManifestEntry::new) - .mapToKeyPartial((key, entry) -> entry.sourcePath()) - .mapToValuePartial((sourcePath, entry) -> entry.jsPath() - .map(jsPath -> toFrontendResource(jsPath, entry))) + return EntryStream.of(manifest.fields()).mapToValue(ViteManifestEntry::new) + .mapToKeyPartial((key, entry) -> entry.sourcePath()).mapToValuePartial((sourcePath, + entry) -> entry.jsPath().map(jsPath -> toFrontendResource(jsPath, entry))) .toImmutableMap(); } @@ -152,15 +152,13 @@ private Stream collectCssPaths(ViteManifestEntry entry, Set visi if (!visited.add(entry.key())) { return Stream.empty(); } - return StreamEx.of(entry.imports() - .flatMap(k -> entry(k).stream()) - .flatMap(e -> collectCssPaths(e, visited))) + return StreamEx.of( + entry.imports().flatMap(k -> entry(k).stream()).flatMap(e -> collectCssPaths(e, visited))) .append(entry.cssPaths()); } private Optional entry(String key) { - return Optional.ofNullable(manifest.get(key)) - .map(json -> new ViteManifestEntry(key, json)); + return Optional.ofNullable(manifest.get(key)).map(json -> new ViteManifestEntry(key, json)); } } @@ -171,8 +169,7 @@ record ViteManifestEntry(String key, JsonNode json) { private static final String FIELD_IMPORTS = "imports"; Optional sourcePath() { - return Optional.ofNullable(key) - .filter(k -> k.startsWith(MANIFEST_KEY_PREFIX)) + return Optional.ofNullable(key).filter(k -> k.startsWith(MANIFEST_KEY_PREFIX)) .map(k -> k.replaceFirst(MANIFEST_KEY_PREFIX, SOURCE_PREFIX)); } @@ -193,19 +190,13 @@ private Optional getNode(String name) { } private Stream getArray(String fieldName) { - return getNode(fieldName) - .filter(JsonNode::isArray) - .stream() - .map(JsonNode::elements) + return getNode(fieldName).filter(JsonNode::isArray).stream().map(JsonNode::elements) .flatMap(StreamEx::of); } private String toTargetPath(JsonNode node) { - return Optional.ofNullable(node) - .map(JsonNode::asText) - .filter(not(String::isEmpty)) - .map(file -> TARGET_DIR + file) - .orElse(null); + return Optional.ofNullable(node).map(JsonNode::asText).filter(not(String::isEmpty)) + .map(file -> TARGET_DIR + file).orElse(null); } } } diff --git a/src/main/java/com/celements/javascript/JSScriptService.java b/src/main/java/com/celements/javascript/JSScriptService.java index 2a8486b3b..ceb200874 100644 --- a/src/main/java/com/celements/javascript/JSScriptService.java +++ b/src/main/java/com/celements/javascript/JSScriptService.java @@ -38,8 +38,7 @@ public String getAllExternalJavaScriptFiles() { public List getRteContentJsFiles() { return getExtJavaScriptFileCmd().getAllRteContentJsFiles().stream() - .map(JsFileEntry::getFilepath) - .collect(Collectors.toList()); + .map(JsFileEntry::getFilepath).collect(Collectors.toList()); } /** @@ -93,14 +92,13 @@ public ExtJsFileParameter.Builder createExtJSParam() { } public ExtJsFileParameter.Builder createDefaultExtJSParam() { - return createExtJSParam() - .setAction("file") + return createExtJSParam().setAction("file") .setLoadMode(isJSDeferActive() ? JsLoadMode.DEFER : null); } private boolean isJSDeferActive() { - return 1 == xwiki.get().orElseThrow().getXWikiPreferenceAsInt( - "cel_activate_jsdefer", 0, getContext()); + return 1 == xwiki.get().orElseThrow().getXWikiPreferenceAsInt("cel_activate_jsdefer", 0, + getContext()); } public String includeExtJsFile(@Nullable ExtJsFileParameter.Builder extJsFileParams) { @@ -168,8 +166,8 @@ public String addLazyExtJSfile(@Nullable String jsFile, @Nullable String action, private ExternalJavaScriptFilesCommand getExtJavaScriptFileCmd() { if (getContext().get(JAVA_SCRIPT_FILES_COMMAND_KEY) == null) { - getContext().put(JAVA_SCRIPT_FILES_COMMAND_KEY, getSpringContext() - .getBean(ExternalJavaScriptFilesCommand.class)); + getContext().put(JAVA_SCRIPT_FILES_COMMAND_KEY, + getSpringContext().getBean(ExternalJavaScriptFilesCommand.class)); } return (ExternalJavaScriptFilesCommand) getContext().get(JAVA_SCRIPT_FILES_COMMAND_KEY); } diff --git a/src/main/java/com/celements/javascript/JsFileEntry.java b/src/main/java/com/celements/javascript/JsFileEntry.java index cc9418642..a4d3f488c 100644 --- a/src/main/java/com/celements/javascript/JsFileEntry.java +++ b/src/main/java/com/celements/javascript/JsFileEntry.java @@ -97,9 +97,11 @@ public boolean isValid() { public boolean isModule() { var filepath = getFilePathOnly(); - return filepath.endsWith(".mjs") - || filepath.endsWith(".mts") - || filepath.endsWith(".ts"); // are transpiled to mjs + return filepath.endsWith(".mjs") || isTranspiledToMjs(filepath); + } + + private static boolean isTranspiledToMjs(String filepath) { + return filepath.endsWith(".mts") || filepath.endsWith(".ts"); } @Override @@ -115,8 +117,8 @@ public boolean equals(@Nullable Object obj) { @Override public String toString() { - return "JsFileEntry [jsFileUrl=" + jsFileUrl + ", loadMode=" + loadMode - + ", isRteContent=" + isRteContent + ", " + super.toString() + "]"; + return "JsFileEntry [jsFileUrl=" + jsFileUrl + ", loadMode=" + loadMode + ", isRteContent=" + + isRteContent + ", " + super.toString() + "]"; } } diff --git a/src/main/java/com/celements/javascript/JsLoadMode.java b/src/main/java/com/celements/javascript/JsLoadMode.java index 23c5d4004..3a019431a 100644 --- a/src/main/java/com/celements/javascript/JsLoadMode.java +++ b/src/main/java/com/celements/javascript/JsLoadMode.java @@ -2,6 +2,8 @@ public enum JsLoadMode { - SYNC, DEFER, ASYNC; + SYNC, + DEFER, + ASYNC; } diff --git a/src/main/java/com/celements/lastChanged/DocumentChangesListener.java b/src/main/java/com/celements/lastChanged/DocumentChangesListener.java index e1512091c..a56161de1 100644 --- a/src/main/java/com/celements/lastChanged/DocumentChangesListener.java +++ b/src/main/java/com/celements/lastChanged/DocumentChangesListener.java @@ -40,8 +40,8 @@ public void onEvent(Event event, Object source, Object data) { if ((source != null) && (source instanceof XWikiDocument)) { XWikiDocument doc = (XWikiDocument) source; DocumentReference docRef = doc.getDocumentReference(); - ((LastChangedService) lastChangedSrv).invalidateCacheForSpaceRef( - docRef.getLastSpaceReference()); + ((LastChangedService) lastChangedSrv) + .invalidateCacheForSpaceRef(docRef.getLastSpaceReference()); } else { LOGGER.error("onEvent failed docref '{}'", source); } diff --git a/src/main/java/com/celements/lastChanged/LastChangedService.java b/src/main/java/com/celements/lastChanged/LastChangedService.java index 3762b6ea9..8c08b916a 100644 --- a/src/main/java/com/celements/lastChanged/LastChangedService.java +++ b/src/main/java/com/celements/lastChanged/LastChangedService.java @@ -95,8 +95,8 @@ Date internal_getLastChangeDate(SpaceReference spaceRef) { if (firstRow[1] != null) { lastChangedDocLang = firstRow[1].toString(); } - DocumentReference lastChangedDocRef = webUtilsService.resolveDocumentReference( - lastChangedDocFN); + DocumentReference lastChangedDocRef = webUtilsService + .resolveDocumentReference(lastChangedDocFN); XWikiDocument lastChangedDoc; try { if (Strings.isNullOrEmpty(lastChangedDocLang)) { diff --git a/src/main/java/com/celements/mandatory/FileBaseTag0.java b/src/main/java/com/celements/mandatory/FileBaseTag0.java index 858e43b2e..12e1a8cb4 100644 --- a/src/main/java/com/celements/mandatory/FileBaseTag0.java +++ b/src/main/java/com/celements/mandatory/FileBaseTag0.java @@ -163,8 +163,8 @@ boolean checkMenuName(XWikiDocument fileBaseTag0Doc, String lang, String menunam } boolean checkPageType(XWikiDocument fileBaseTag0Doc) throws XWikiException { - DocumentReference pageTypeClassRef = getPageTypeClasses().getPageTypeClassRef( - getContext().getDatabase()); + DocumentReference pageTypeClassRef = getPageTypeClasses() + .getPageTypeClassRef(getContext().getDatabase()); BaseObject pageTypeObj = fileBaseTag0Doc.getXObject(pageTypeClassRef, false, getContext()); if (pageTypeObj == null) { pageTypeObj = fileBaseTag0Doc.newXObject(pageTypeClassRef, getContext()); diff --git a/src/main/java/com/celements/mandatory/FileBaseTag1.java b/src/main/java/com/celements/mandatory/FileBaseTag1.java index d3c792e91..1073c6493 100644 --- a/src/main/java/com/celements/mandatory/FileBaseTag1.java +++ b/src/main/java/com/celements/mandatory/FileBaseTag1.java @@ -163,8 +163,8 @@ boolean checkMenuName(XWikiDocument fileBaseTag1Doc, String lang, String menunam } boolean checkPageType(XWikiDocument fileBaseTag1Doc) throws XWikiException { - DocumentReference pageTypeClassRef = getPageTypeClasses().getPageTypeClassRef( - getContext().getDatabase()); + DocumentReference pageTypeClassRef = getPageTypeClasses() + .getPageTypeClassRef(getContext().getDatabase()); BaseObject pageTypeObj = fileBaseTag1Doc.getXObject(pageTypeClassRef, false, getContext()); if (pageTypeObj == null) { pageTypeObj = fileBaseTag1Doc.newXObject(pageTypeClassRef, getContext()); diff --git a/src/main/java/com/celements/mandatory/HTMLWebPreferences.java b/src/main/java/com/celements/mandatory/HTMLWebPreferences.java index da236cda5..10156f163 100644 --- a/src/main/java/com/celements/mandatory/HTMLWebPreferences.java +++ b/src/main/java/com/celements/mandatory/HTMLWebPreferences.java @@ -81,10 +81,10 @@ public void checkDocuments() throws XWikiException { } boolean isSkipCelementsHTMLwebPreferences() { - boolean isSkip = getContext().getWiki().ParamAsLong( - "celements.mandatory.skipHTMLwebPreferences", 0) == 1L; - LOGGER.trace("skipCelementsHTMLwebPreferences for [{}]: [{}]", - getContext().getDatabase(), isSkip); + boolean isSkip = getContext().getWiki() + .ParamAsLong("celements.mandatory.skipHTMLwebPreferences", 0) == 1L; + LOGGER.trace("skipCelementsHTMLwebPreferences for [{}]: [{}]", getContext().getDatabase(), + isSkip); return isSkip; } @@ -121,8 +121,8 @@ boolean checkHTMLwebPreferences(XWikiDocument wikiPrefDoc) throws XWikiException } boolean checkPageType(XWikiDocument wikiPrefDoc) throws XWikiException { - DocumentReference pageTypeClassRef = getPageTypeClasses().getPageTypeClassRef( - getContext().getDatabase()); + DocumentReference pageTypeClassRef = getPageTypeClasses() + .getPageTypeClassRef(getContext().getDatabase()); BaseObject pageTypeObj = wikiPrefDoc.getXObject(pageTypeClassRef, false, getContext()); if (pageTypeObj == null) { pageTypeObj = wikiPrefDoc.newXObject(pageTypeClassRef, getContext()); diff --git a/src/main/java/com/celements/mandatory/Robots_TXT.java b/src/main/java/com/celements/mandatory/Robots_TXT.java index 3ab18dfe7..b2e535a56 100644 --- a/src/main/java/com/celements/mandatory/Robots_TXT.java +++ b/src/main/java/com/celements/mandatory/Robots_TXT.java @@ -117,8 +117,8 @@ boolean checkRobots_txt(XWikiDocument robotsTxtDoc) { } boolean checkPageType(XWikiDocument robotsTxtDoc) throws XWikiException { - DocumentReference pageTypeClassRef = getPageTypeClasses().getPageTypeClassRef( - getContext().getDatabase()); + DocumentReference pageTypeClassRef = getPageTypeClasses() + .getPageTypeClassRef(getContext().getDatabase()); BaseObject pageTypeObj = robotsTxtDoc.getXObject(pageTypeClassRef, false, getContext()); if (pageTypeObj == null) { pageTypeObj = robotsTxtDoc.newXObject(pageTypeClassRef, getContext()); diff --git a/src/main/java/com/celements/mandatory/XWikiXWikiPreferences.java b/src/main/java/com/celements/mandatory/XWikiXWikiPreferences.java index 964d5b3c7..23d2949a1 100644 --- a/src/main/java/com/celements/mandatory/XWikiXWikiPreferences.java +++ b/src/main/java/com/celements/mandatory/XWikiXWikiPreferences.java @@ -66,10 +66,8 @@ public String getName() { @Override protected DocumentReference getDocRef() { - return new RefBuilder().with(modelContext.getWikiRef()) - .space(XWikiConstant.XWIKI_SPACE) - .doc(XWikiConstant.XWIKI_PREF_DOC_NAME) - .build(DocumentReference.class); + return new RefBuilder().with(modelContext.getWikiRef()).space(XWikiConstant.XWIKI_SPACE) + .doc(XWikiConstant.XWIKI_PREF_DOC_NAME).build(DocumentReference.class); } @Override @@ -103,8 +101,7 @@ private boolean checkWikiPreferences(XWikiDocument wikiPrefDoc, if (isNullOrEmpty(wikiPrefDoc.getDefaultLanguage())) { wikiPrefDoc.setDefaultLanguage(defaultLang); } - BaseObject prefsObj = XWikiObjectEditor.on(wikiPrefDoc) - .filter(new ClassReference(getDocRef())) + BaseObject prefsObj = XWikiObjectEditor.on(wikiPrefDoc).filter(new ClassReference(getDocRef())) .createFirstIfNotExists(); boolean dirty = false; dirty |= additionalChecks.test(prefsObj); @@ -125,8 +122,8 @@ private boolean checkWikiPreferences(XWikiDocument wikiPrefDoc) { return checkWikiPreferences(wikiPrefDoc, (prefsObj) -> { boolean dirty = false; String documentBundles = prefsObj.getStringValue("documentBundles"); - if (isNullOrEmpty(documentBundles) || !documentBundles.contains( - "celements2web:Celements2.Dictionary")) { + if (isNullOrEmpty(documentBundles) + || !documentBundles.contains("celements2web:Celements2.Dictionary")) { if (isNullOrEmpty(documentBundles)) { documentBundles = "celements2web:Celements2.Dictionary"; } else { diff --git a/src/main/java/com/celements/mandatory/XWikiXWikiRights.java b/src/main/java/com/celements/mandatory/XWikiXWikiRights.java index 62a0fe942..7097754fc 100644 --- a/src/main/java/com/celements/mandatory/XWikiXWikiRights.java +++ b/src/main/java/com/celements/mandatory/XWikiXWikiRights.java @@ -53,10 +53,8 @@ public String getName() { @Override protected DocumentReference getDocRef() { - return new RefBuilder().with(modelContext.getWikiRef()) - .space(XWikiConstant.XWIKI_SPACE) - .doc(XWikiConstant.XWIKI_PREF_DOC_NAME) - .build(DocumentReference.class); + return new RefBuilder().with(modelContext.getWikiRef()).space(XWikiConstant.XWIKI_SPACE) + .doc(XWikiConstant.XWIKI_PREF_DOC_NAME).build(DocumentReference.class); } @Override @@ -85,13 +83,11 @@ boolean checkAccessRightObjs(XWikiDocument wikiPrefDoc) { protected boolean checkGlobalRightObj(XWikiDocument doc, String group, List levels) { - var editor = XWikiObjectEditor.on(doc) - .filter(XWikiGlobalRightsClass.CLASS_REF) + var editor = XWikiObjectEditor.on(doc).filter(XWikiGlobalRightsClass.CLASS_REF) .filter(XWikiGlobalRightsClass.FIELD_GROUPS, List.of(group)) .filter(XWikiGlobalRightsClass.FIELD_ALLOW, true); if (!editor.fetch().exists()) { - editor.filter(XWikiGlobalRightsClass.FIELD_LEVELS, levels) - .createFirstIfNotExists(); + editor.filter(XWikiGlobalRightsClass.FIELD_LEVELS, levels).createFirstIfNotExists(); return true; } return false; diff --git a/src/main/java/com/celements/menu/MenuService.java b/src/main/java/com/celements/menu/MenuService.java index e59bfa4f8..9ec6385e4 100644 --- a/src/main/java/com/celements/menu/MenuService.java +++ b/src/main/java/com/celements/menu/MenuService.java @@ -74,8 +74,8 @@ public List getMenuHeaders() { ArrayList resultList = new ArrayList<>(); resultList.addAll(menuHeadersMap.values()); if (LOGGER.isTraceEnabled()) { - LOGGER.trace("getMenuHeaders_internal returning: " + Arrays.deepToString( - resultList.toArray())); + LOGGER + .trace("getMenuHeaders_internal returning: " + Arrays.deepToString(resultList.toArray())); } LOGGER.debug("getMenuHeaders_internal end"); return resultList; @@ -152,8 +152,8 @@ public List getSubMenuItems(Integer headerId) { ArrayList resultList = new ArrayList<>(); resultList.addAll(menuItemsMap.values()); if (LOGGER.isTraceEnabled()) { - LOGGER.trace("getSubMenuItems_internal returning: " + Arrays.deepToString( - resultList.toArray())); + LOGGER.trace( + "getSubMenuItems_internal returning: " + Arrays.deepToString(resultList.toArray())); } LOGGER.debug("getSubMenuItems_internal end"); return resultList; @@ -161,8 +161,8 @@ public List getSubMenuItems(Integer headerId) { private void addMenuItems(TreeMap menuItemsMap, Integer headerId) { try { - List result = queryManager.createQuery(getSubItemsXWQL(), Query.XWQL).bindValue( - "headerId", headerId).execute(); + List result = queryManager.createQuery(getSubItemsXWQL(), Query.XWQL) + .bindValue("headerId", headerId).execute(); if (LOGGER.isTraceEnabled()) { LOGGER.trace("addMenuItems received for " + getContext().getDatabase() + ": " + Arrays.deepToString(result.toArray())); diff --git a/src/main/java/com/celements/menu/access/DefaultMenuAccessProvider.java b/src/main/java/com/celements/menu/access/DefaultMenuAccessProvider.java index dac60b884..c0b7f5d14 100644 --- a/src/main/java/com/celements/menu/access/DefaultMenuAccessProvider.java +++ b/src/main/java/com/celements/menu/access/DefaultMenuAccessProvider.java @@ -28,18 +28,18 @@ private XWikiContext getContext() { } @Override - public boolean hasview(DocumentReference menuBarDocRef) throws NoAccessDefinedException, - XWikiException { + public boolean hasview(DocumentReference menuBarDocRef) + throws NoAccessDefinedException, XWikiException { String database = getContext().getDatabase(); try { getContext().setDatabase(getContext().getOriginalDatabase()); - if (webUtilsService.getRefDefaultSerializer().serialize(menuBarDocRef).endsWith( - "Celements2.AdminMenu")) { + if (webUtilsService.getRefDefaultSerializer().serialize(menuBarDocRef) + .endsWith("Celements2.AdminMenu")) { LOGGER.debug("hasview: AdminMenu [" + getContext().getUser() + "] isAdvancedAdmin [" + webUtilsService.isAdvancedAdmin() + "]."); return webUtilsService.isAdvancedAdmin(); - } else if (webUtilsService.getRefDefaultSerializer().serialize(menuBarDocRef).endsWith( - "Celements2.LayoutMenu")) { + } else if (webUtilsService.getRefDefaultSerializer().serialize(menuBarDocRef) + .endsWith("Celements2.LayoutMenu")) { LOGGER.debug("hasview: LayoutMenu [" + getContext().getUser() + "] isLayoutEditor [" + webUtilsService.isLayoutEditor() + "] isAdvancedAdmin [" + webUtilsService.isAdvancedAdmin() + "]."); @@ -61,8 +61,8 @@ private boolean hasCentralAndLocalView(DocumentReference menuBarDocRef) throws X getContext().setDatabase("celements2web"); DocumentReference menuBar2webDocRef = new DocumentReference("celements2web", menuBarDocRef.getLastSpaceReference().getName(), menuBarDocRef.getName()); - String menuBar2webFullName = webUtilsService.getRefDefaultSerializer().serialize( - menuBar2webDocRef); + String menuBar2webFullName = webUtilsService.getRefDefaultSerializer() + .serialize(menuBar2webDocRef); boolean centralView = !getContext().getWiki().exists(menuBar2webDocRef, getContext()) || getContext().getWiki().getRightService().hasAccessLevel("view", getContext().getUser(), menuBar2webFullName, getContext()); @@ -71,23 +71,23 @@ private boolean hasCentralAndLocalView(DocumentReference menuBarDocRef) throws X getContext().setDatabase(getContext().getOriginalDatabase()); DocumentReference menuBarLocalDocRef = new DocumentReference(getContext().getOriginalDatabase(), menuBarDocRef.getLastSpaceReference().getName(), menuBarDocRef.getName()); - String menuBarFullName = webUtilsService.getRefDefaultSerializer().serialize( - menuBarLocalDocRef); + String menuBarFullName = webUtilsService.getRefDefaultSerializer() + .serialize(menuBarLocalDocRef); boolean localView = true; if (getContext().getWiki().exists(menuBarLocalDocRef, getContext())) { localView = getContext().getWiki().getRightService().hasAccessLevel("view", getContext().getUser(), menuBarFullName, getContext()); } else if (XWikiRightService.GUEST_USER_FULLNAME.equals(getContext().getUser())) { - String menuBarLocalFullName = webUtilsService.getRefLocalSerializer().serialize( - menuBarLocalDocRef); + String menuBarLocalFullName = webUtilsService.getRefLocalSerializer() + .serialize(menuBarLocalDocRef); String prefParamName = "CelMenuBar-" + menuBarLocalFullName; String cfgFallbackName = "celements.menubar.guestview." + menuBarLocalFullName; localView = (getContext().getWiki().getXWikiPreferenceAsInt(prefParamName, cfgFallbackName, 0, getContext()) == 1); - LOGGER.info("hasview: localView default for quest on [" + menuBarFullName + "] -> [" - + localView + "] on database [" + getContext().getDatabase() - + "]. Checked prefParamName [" + prefParamName + "] and cfgFallbackName [" - + cfgFallbackName + "]."); + LOGGER + .info("hasview: localView default for quest on [" + menuBarFullName + "] -> [" + localView + + "] on database [" + getContext().getDatabase() + "]. Checked prefParamName [" + + prefParamName + "] and cfgFallbackName [" + cfgFallbackName + "]."); } LOGGER.debug("hasview: localView [" + menuBarFullName + "] for [" + getContext().getUser() + "] -> [" + localView + "] on database [" + getContext().getDatabase() + "]."); diff --git a/src/main/java/com/celements/menu/access/IMenuAccessProviderRole.java b/src/main/java/com/celements/menu/access/IMenuAccessProviderRole.java index cae2c8c6f..b665f4105 100644 --- a/src/main/java/com/celements/menu/access/IMenuAccessProviderRole.java +++ b/src/main/java/com/celements/menu/access/IMenuAccessProviderRole.java @@ -8,8 +8,8 @@ @ComponentRole public interface IMenuAccessProviderRole { - public boolean hasview(DocumentReference menuBarDocRef) throws NoAccessDefinedException, - XWikiException; + public boolean hasview(DocumentReference menuBarDocRef) + throws NoAccessDefinedException, XWikiException; public boolean denyView(DocumentReference menuBarDocRef); diff --git a/src/main/java/com/celements/menu/access/MenuAccessService.java b/src/main/java/com/celements/menu/access/MenuAccessService.java index b35915b23..b62c7158e 100644 --- a/src/main/java/com/celements/menu/access/MenuAccessService.java +++ b/src/main/java/com/celements/menu/access/MenuAccessService.java @@ -33,9 +33,9 @@ public boolean hasview(DocumentReference menuBarDocRef) { boolean hasview = false; boolean allowForDeny = true; for (IMenuAccessProviderRole accessProvider : accessProviderMap.values()) { - LOGGER.trace("start accessProvider [" + accessProvider.getClass() - + "] check for menuBarDocRef [" + menuBarDocRef + "] current database [" - + getContext().getDatabase() + "]."); + LOGGER.trace( + "start accessProvider [" + accessProvider.getClass() + "] check for menuBarDocRef [" + + menuBarDocRef + "] current database [" + getContext().getDatabase() + "]."); try { boolean newHasView = accessProvider.hasview(menuBarDocRef); LOGGER.debug("check has view for [" + getContext().getUser() + "] on [" + menuBarDocRef diff --git a/src/main/java/com/celements/metatag/BaseObjectMetaTagProvider.java b/src/main/java/com/celements/metatag/BaseObjectMetaTagProvider.java index 05e170b7d..ebaab6013 100644 --- a/src/main/java/com/celements/metatag/BaseObjectMetaTagProvider.java +++ b/src/main/java/com/celements/metatag/BaseObjectMetaTagProvider.java @@ -76,16 +76,15 @@ public void initialize() throws InitializationException { public List getHeaderMetaTags() { SortedMap> tags = new TreeMap<>(); addMetaTagsFromList(getMetaTagsForDoc(context.getXWikiPreferenceDoc()), tags); - addMetaTagsFromList(getMetaTagsForDoc(context.getSpacePreferenceDoc(context - .getCurrentSpaceRefOrDefault())), tags); + addMetaTagsFromList( + getMetaTagsForDoc(context.getSpacePreferenceDoc(context.getCurrentSpaceRefOrDefault())), + tags); Optional doc = context.getCurrentDoc().toJavaUtil(); if (doc.isPresent()) { addMetaTagsFromList(getMetaTagsForDoc(doc.get()), tags); } - return ImmutableList.copyOf(tags.values().parallelStream() - .flatMap(applyOverride()) - .filter(Objects::nonNull) - .collect(Collectors.toList())); + return ImmutableList.copyOf(tags.values().parallelStream().flatMap(applyOverride()) + .filter(Objects::nonNull).collect(Collectors.toList())); } Function, Stream> applyOverride() { @@ -123,9 +122,8 @@ public void accept(List accu, MetaTag tag) { } else if (reductor.getOverridable()) { Collections.replaceAll(accu, reductor, tag); } else { - reductor.setValue(reductor.getValueOpt().orElse("") + "," + tag.getValueOpt() - .orElse( - "")); + reductor.setValue( + reductor.getValueOpt().orElse("") + "," + tag.getValueOpt().orElse("")); } } }; @@ -137,8 +135,8 @@ public BinaryOperator> combiner() { @Override public List apply(List list1, List list2) { - return Stream.of(list1, list2).flatMap(Collection::stream).collect(Collectors - .toList()); + return Stream.of(list1, list2).flatMap(Collection::stream) + .collect(Collectors.toList()); } }; } @@ -167,8 +165,8 @@ public Set characteristics() { void addMetaTagsFromList(List newTags, SortedMap> finalTags) { for (MetaTag tag : newTags) { Optional lang = tag.getLangOpt(); - if (!lang.isPresent() || lang.get().equals(context.getLanguage().orElse(null)) || lang.get() - .equals(context.getDefaultLanguage())) { + if (!lang.isPresent() || lang.get().equals(context.getLanguage().orElse(null)) + || lang.get().equals(context.getDefaultLanguage())) { String key = tag.getKeyOpt().orElse(""); if (!finalTags.containsKey(key)) { finalTags.put(key, new ArrayList()); @@ -180,17 +178,14 @@ void addMetaTagsFromList(List newTags, SortedMap> List getMetaTagsForDoc(XWikiDocument doc) { return XWikiObjectFetcher.on(doc).filter(metaTagClass).filterPresent(MetaTagClass.FIELD_KEY) - .list().stream().parallel() - .map( - new Function() { + .list().stream().parallel().map(new Function() { - @Override - public MetaTag apply(BaseObject obj) { - return (MetaTag) metaTagConverter.apply(obj); - } + @Override + public MetaTag apply(BaseObject obj) { + return (MetaTag) metaTagConverter.apply(obj); + } - }) - .collect(Collectors.toList()); + }).collect(Collectors.toList()); } @Override diff --git a/src/main/java/com/celements/metatag/MetaTagScriptService.java b/src/main/java/com/celements/metatag/MetaTagScriptService.java index 72f4dde03..4f5201590 100644 --- a/src/main/java/com/celements/metatag/MetaTagScriptService.java +++ b/src/main/java/com/celements/metatag/MetaTagScriptService.java @@ -50,8 +50,8 @@ public class MetaTagScriptService implements ScriptService { public void addMetaTagToCollector(@NotNull String attributeName, @NotNull String attributeValue, @Nullable String content) { - metaTag.addMetaTagToCollector(new MetaTag(attributeName, attributeValue, Strings.nullToEmpty( - content))); + metaTag.addMetaTagToCollector( + new MetaTag(attributeName, attributeValue, Strings.nullToEmpty(content))); } public void addMetaTagToCollector(@NotNull Map attributes, diff --git a/src/main/java/com/celements/migrator/MenuBar_SubMenuItemsClassMigrator.java b/src/main/java/com/celements/migrator/MenuBar_SubMenuItemsClassMigrator.java index 8c6bcf6a1..f0acbcf69 100644 --- a/src/main/java/com/celements/migrator/MenuBar_SubMenuItemsClassMigrator.java +++ b/src/main/java/com/celements/migrator/MenuBar_SubMenuItemsClassMigrator.java @@ -41,11 +41,10 @@ import com.xpn.xwiki.store.migration.XWikiDBVersion; @Component("MenuBar_SubMenuItemsClass") -public class MenuBar_SubMenuItemsClassMigrator - extends AbstractCelementsHibernateMigrator { +public class MenuBar_SubMenuItemsClassMigrator extends AbstractCelementsHibernateMigrator { - private static final Logger LOGGER = LoggerFactory.getLogger( - MenuBar_SubMenuItemsClassMigrator.class); + private static final Logger LOGGER = LoggerFactory + .getLogger(MenuBar_SubMenuItemsClassMigrator.class); @Requirement IMenuService menuService; @@ -60,7 +59,7 @@ public class MenuBar_SubMenuItemsClassMigrator IWebUtilsService webUtilsService; private XWikiContext getContext() { - return (XWikiContext)execution.getContext().getProperty("xwikicontext"); + return (XWikiContext) execution.getContext().getProperty("xwikicontext"); } @Override @@ -73,17 +72,16 @@ private MenuClasses getMenuClasses() { } @Override - public void migrate(SubSystemHibernateMigrationManager manager, XWikiContext context - ) throws XWikiException { + public void migrate(SubSystemHibernateMigrationManager manager, XWikiContext context) + throws XWikiException { getMenuClasses().runUpdate(getContext()); - List result = context.getWiki().search( - "select distinct o.name from BaseObject o" + List result = context.getWiki().search("select distinct o.name from BaseObject o" + " where o.className = 'Celements2.MenuBarSubItem'", context); - LOGGER.info("found [" + ((result != null) ? result.size() : result) - + "] documents to migrate."); + LOGGER + .info("found [" + ((result != null) ? result.size() : result) + "] documents to migrate."); for (Object fullName : result) { - XWikiDocument doc = context.getWiki().getDocument( - webUtilsService.resolveDocumentReference(fullName.toString()), context); + XWikiDocument doc = context.getWiki() + .getDocument(webUtilsService.resolveDocumentReference(fullName.toString()), context); XObjectIterator menuBarSubItemIterator = new XObjectIterator(getContext()); menuBarSubItemIterator.setClassName("Celements2.MenuBarSubItem"); menuBarSubItemIterator.setDocList(Arrays.asList(fullName.toString())); @@ -97,8 +95,7 @@ public void migrate(SubSystemHibernateMigrationManager manager, XWikiContext con } } - private void migrateSubItem(BaseObject oldSubItemObj, XWikiDocument doc - ) throws XWikiException { + private void migrateSubItem(BaseObject oldSubItemObj, XWikiDocument doc) throws XWikiException { BaseObject newSubItemObj = doc.newXObject(menuService.getMenuBarSubItemClassRef(), getContext()); newSubItemObj.setStringValue("name", oldSubItemObj.getStringValue("name")); diff --git a/src/main/java/com/celements/migrator/MenuNameMappingCelements2_8.java b/src/main/java/com/celements/migrator/MenuNameMappingCelements2_8.java index 51801e1e3..9d334ca61 100644 --- a/src/main/java/com/celements/migrator/MenuNameMappingCelements2_8.java +++ b/src/main/java/com/celements/migrator/MenuNameMappingCelements2_8.java @@ -37,8 +37,7 @@ @Component("MenuNameMappingCelements2_8") public class MenuNameMappingCelements2_8 extends AbstractCelementsHibernateMigrator { - private static final Logger LOGGER = LoggerFactory.getLogger( - MenuNameMappingCelements2_8.class); + private static final Logger LOGGER = LoggerFactory.getLogger(MenuNameMappingCelements2_8.class); @Override public void migrate(SubSystemHibernateMigrationManager manager, XWikiContext context) @@ -49,15 +48,15 @@ public void migrate(SubSystemHibernateMigrationManager manager, XWikiContext con + " where o.className = 'Celements2.MenuName' and o.id = s.id" + " and s.name = 'menu_name'"; List result = context.getWiki().search(hql, context); - LOGGER.info("found [" + ((result != null) ? result.size() : result) - + "] documents to migrate."); + LOGGER + .info("found [" + ((result != null) ? result.size() : result) + "] documents to migrate."); for (Object fullName : result) { XWikiDocument doc = context.getWiki().getDocument(fullName.toString(), context); // we do not want a new history entry. Thus we cancel MetaData and Content Dirty flags doc.setMetaDataDirty(false); doc.setContentDirty(false); - LOGGER.debug("migrating MenuName on [" + doc.getFullName() + "] " - + doc.isMetaDataDirty() + ", " + doc.isContentDirty()); + LOGGER.debug("migrating MenuName on [" + doc.getFullName() + "] " + doc.isMetaDataDirty() + + ", " + doc.isContentDirty()); // save directly over store method to prevent observation manager executing events. context.getWiki().getStore().saveXWikiDoc(doc, context); } diff --git a/src/main/java/com/celements/migrator/TreeNodeRelativeParent_Database.java b/src/main/java/com/celements/migrator/TreeNodeRelativeParent_Database.java index b1de57e3a..59767ea3b 100644 --- a/src/main/java/com/celements/migrator/TreeNodeRelativeParent_Database.java +++ b/src/main/java/com/celements/migrator/TreeNodeRelativeParent_Database.java @@ -43,8 +43,8 @@ @Component("TreeNodeRelativeParent_Database") public class TreeNodeRelativeParent_Database extends AbstractCelementsHibernateMigrator { - private static final Logger LOGGER = LoggerFactory.getLogger( - TreeNodeRelativeParent_Database.class); + private static final Logger LOGGER = LoggerFactory + .getLogger(TreeNodeRelativeParent_Database.class); @Requirement private QueryManager queryManager; @@ -54,40 +54,38 @@ public class TreeNodeRelativeParent_Database extends AbstractCelementsHibernateM EntityReference getRelativeParentReference(String parentFN) { @SuppressWarnings("unchecked") - EntityReferenceResolver relativResolver = Utils.getComponent( - EntityReferenceResolver.class, "relative"); + EntityReferenceResolver relativResolver = Utils + .getComponent(EntityReferenceResolver.class, "relative"); return relativResolver.resolve(parentFN, EntityType.DOCUMENT); } @Override - public void migrate(SubSystemHibernateMigrationManager manager, XWikiContext context - ) throws XWikiException { + public void migrate(SubSystemHibernateMigrationManager manager, XWikiContext context) + throws XWikiException { Query theQuery; try { - theQuery = queryManager.createQuery("from doc.object(Celements2.MenuItem) as mItem" - + " where doc.parent like :buggyParent", Query.XWQL); + theQuery = queryManager.createQuery( + "from doc.object(Celements2.MenuItem) as mItem" + " where doc.parent like :buggyParent", + Query.XWQL); theQuery.bindValue("buggyParent", context.getDatabase() + ":%"); List result = theQuery.execute(); - LOGGER.info("found [" + ((result != null) ? result.size() : result) - + "] documents to migrate."); + LOGGER.info( + "found [" + ((result != null) ? result.size() : result) + "] documents to migrate."); for (String fullName : result) { - XWikiDocument doc = context.getWiki().getDocument( - webUtilsService.resolveDocumentReference(fullName), context); - String parentFN = webUtilsService.getRefLocalSerializer().serialize( - doc.getParentReference()); + XWikiDocument doc = context.getWiki() + .getDocument(webUtilsService.resolveDocumentReference(fullName), context); + String parentFN = webUtilsService.getRefLocalSerializer() + .serialize(doc.getParentReference()); doc.setParentReference(getRelativeParentReference(parentFN)); - LOGGER.debug("migrating TreeNodes parent on [" + fullName + "] " - + doc.isMetaDataDirty() + ", " + doc.isContentDirty()); + LOGGER.debug("migrating TreeNodes parent on [" + fullName + "] " + doc.isMetaDataDirty() + + ", " + doc.isContentDirty()); // save directly over store method to prevent observation manager executing events. - context.getWiki().saveDocument(doc, "TreeNodeRelativeParent_Database Migration", - context); + context.getWiki().saveDocument(doc, "TreeNodeRelativeParent_Database Migration", context); } } catch (QueryException exp) { - LOGGER.error("cannot create query for TreeNodeRelativeParent_Database Migration ", - exp); - throw new XWikiException(XWikiException.MODULE_XWIKI_APP, - XWikiException.MODULE_XWIKI, "Failed to execute migration" - + " TreeNodeRelativeParent_Database", exp); + LOGGER.error("cannot create query for TreeNodeRelativeParent_Database Migration ", exp); + throw new XWikiException(XWikiException.MODULE_XWIKI_APP, XWikiException.MODULE_XWIKI, + "Failed to execute migration" + " TreeNodeRelativeParent_Database", exp); } } diff --git a/src/main/java/com/celements/navigation/INavigationClassConfig.java b/src/main/java/com/celements/navigation/INavigationClassConfig.java index 7038c7365..1d79401d8 100644 --- a/src/main/java/com/celements/navigation/INavigationClassConfig.java +++ b/src/main/java/com/celements/navigation/INavigationClassConfig.java @@ -15,8 +15,8 @@ public interface INavigationClassConfig { public static final String MENU_NAME_IMAGE_FIELD = "image"; public static final String MENU_NAME_TOOLTIP_FIELD = "tooltip"; public static final String MENU_NAME_LANG_FIELD = "lang"; - public static final ClassReference MENU_NAME_CLASS_REF = new ClassReference( - MENU_NAME_CLASS_SPACE, MENU_NAME_CLASS_DOC); + public static final ClassReference MENU_NAME_CLASS_REF = new ClassReference(MENU_NAME_CLASS_SPACE, + MENU_NAME_CLASS_DOC); public static final String MAPPED_MENU_ITEM_CLASS_SPACE = "Classes"; public static final String MAPPED_MENU_ITEM_CLASS_DOC = "MenuItemClass"; @@ -49,8 +49,8 @@ public interface INavigationClassConfig { public static final String MENU_POSITION_FIELD = "menu_position"; public static final String PART_NAME_FIELD = "part_name"; public static final String TARGET_FIELD = "link_target"; - public static final ClassReference MENU_ITEM_CLASS_REF = new ClassReference( - MENU_ITEM_CLASS_SPACE, MENU_ITEM_CLASS_DOC); + public static final ClassReference MENU_ITEM_CLASS_REF = new ClassReference(MENU_ITEM_CLASS_SPACE, + MENU_ITEM_CLASS_DOC); @Deprecated public DocumentReference getMenuNameClassRef(String wikiName); diff --git a/src/main/java/com/celements/navigation/Navigation.java b/src/main/java/com/celements/navigation/Navigation.java index 24373ec1a..1ad0a3722 100644 --- a/src/main/java/com/celements/navigation/Navigation.java +++ b/src/main/java/com/celements/navigation/Navigation.java @@ -206,8 +206,8 @@ public void setPresentationType(String presentationTypeHint) { if (presentationTypeHint != null) { try { LOGGER.info("setPresentationType to [{}].", presentationTypeHint); - setPresentationType(Utils.getComponent(ComponentManager.class).lookup( - IPresentationTypeRole.class, presentationTypeHint)); + setPresentationType(Utils.getComponent(ComponentManager.class) + .lookup(IPresentationTypeRole.class, presentationTypeHint)); } catch (ComponentLookupException failedToLoadException) { LOGGER.error("setPresentationType failed to load IPresentationTypeRole for hint [{}].", presentationTypeHint, failedToLoadException); @@ -286,8 +286,8 @@ public String includeNavigation() { } return ""; } else { - throw new IllegalArgumentException("fromHierarchyLevel [" + fromHierarchyLevel - + "] must be greater than zero"); + throw new IllegalArgumentException( + "fromHierarchyLevel [" + fromHierarchyLevel + "] must be greater than zero"); } } @@ -330,8 +330,8 @@ public SpaceReference getNodeSpaceRef() { SpaceReference currentSpaceRef = getContext().getDoc().getDocumentReference() .getLastSpaceReference(); if (fromHierarchyLevel == 1) { - if (isEmptyMainMenu(currentSpaceRef) && getWebUtilsService().hasParentSpace( - currentSpaceRef.getName())) { + if (isEmptyMainMenu(currentSpaceRef) + && getWebUtilsService().hasParentSpace(currentSpaceRef.getName())) { // is main Menu and no mainMenuItem found ; user has edit rights nodeSpaceRef = getWebUtilsService().resolveSpaceReference( getWebUtilsService().getParentSpace(currentSpaceRef.getName())); @@ -407,30 +407,31 @@ void addNavigationForParent(StringBuilder outStream, EntityReference parentRef, for (TreeNode treeNode : currentMenuItems) { numItem = numItem + 1; DocumentReference nodeRef = treeNode.getDocumentReference(); - boolean isLastItem = (currentMenuItems.lastIndexOf(treeNode) == (currentMenuItems.size() - - 1)); + boolean isLastItem = (currentMenuItems + .lastIndexOf(treeNode) == (currentMenuItems.size() - 1)); writeMenuItemWithSubmenu(outStream, parent, numMoreLevels, nodeRef, isFirstItem, isLastItem, numItem); isFirstItem = false; } outStream.append(""); } else if ((getCurrentLevel(numMoreLevels) == 1) && hasedit()) { - LOGGER.trace("addNavigationForParent: empty navigation hint for parent [{}]" - + " numMoreLevels [{}], currentLevel [{}].", parentRef, numMoreLevels, - getCurrentLevel(numMoreLevels)); + LOGGER.trace( + "addNavigationForParent: empty navigation hint for parent [{}]" + + " numMoreLevels [{}], currentLevel [{}].", + parentRef, numMoreLevels, getCurrentLevel(numMoreLevels)); // is main Menu and no mainMenuItem found ; user has edit rights outStream.append("
    "); openMenuItemOut(outStream, null, true, true, false, 1); outStream.append("" - + getWebUtilsService().getAdminMessageTool().get(getEmptyDictKey()) - + ""); + + getWebUtilsService().getAdminMessageTool().get(getEmptyDictKey()) + ""); closeMenuItemOut(outStream); outStream.append("
"); } else { - LOGGER.debug("addNavigationForParent: empty output for parent [{}]" - + " numMoreLevels [{}], currentLevel [{}], hasEdit [{}].", parentRef, numMoreLevels, - getCurrentLevel(numMoreLevels), hasedit()); + LOGGER.debug( + "addNavigationForParent: empty output for parent [{}]" + + " numMoreLevels [{}], currentLevel [{}], hasEdit [{}].", + parentRef, numMoreLevels, getCurrentLevel(numMoreLevels), hasedit()); } } } @@ -556,8 +557,8 @@ private void closeMenuItemOut(StringBuilder outStream) { void openMenuItemOut(StringBuilder outStream, DocumentReference docRef, boolean isFirstItem, boolean isLastItem, boolean isLeaf, int numItem) { - outStream.append(""); + outStream.append( + ""); } @Override @@ -677,20 +678,20 @@ String getPageLayoutName(DocumentReference docRef) { } String getPageTypeConfigName(DocumentReference docRef) { - PageTypeReference pageTypeRef = getPageTypeResolverService().getPageTypeRefForDocWithDefault( - docRef); + PageTypeReference pageTypeRef = getPageTypeResolverService() + .getPageTypeRefForDocWithDefault(docRef); String getPageTypeConfigName = pageTypeRef.getConfigName(); return getPageTypeConfigName; } boolean isActiveMenuItem(DocumentReference docRef) { DocumentReference currentDocRef = getContext().getDoc().getDocumentReference(); - List docParentList = getWebUtilsService().getDocumentParentsList( - currentDocRef, true); + List docParentList = getWebUtilsService() + .getDocumentParentsList(currentDocRef, true); if (LOGGER.isDebugEnabled()) { - LOGGER.debug("isActiveMenuItem: for [" + docRef + "] with [" + docParentList.size() - + "] parents [" + Arrays.deepToString(docParentList.toArray(new DocumentReference[0])) - + "]."); + LOGGER.debug( + "isActiveMenuItem: for [" + docRef + "] with [" + docParentList.size() + "] parents [" + + Arrays.deepToString(docParentList.toArray(new DocumentReference[0])) + "]."); } return (docRef != null) && (docParentList.contains(docRef) || docRef.equals(currentDocRef)); } @@ -707,21 +708,17 @@ public String getMenuLink(DocumentReference docRef) { @Override public Optional getMenuLinkTarget(DocumentReference docRef) { - return Optional.ofNullable(docRef) - .filter(this::isMenuLinkTargetEnabled) + return Optional.ofNullable(docRef).filter(this::isMenuLinkTargetEnabled) .map(getModelAccess()::getOrCreateDocument) - .flatMap(doc -> XWikiObjectEditor.on(doc) - .filter(MENU_ITEM_CLASS_REF).fetch().stream().findFirst()) - .map(obj -> obj.getStringValue(TARGET_FIELD)) - .map(prop -> Objects.toString(prop, "").trim()) + .flatMap(doc -> XWikiObjectEditor.on(doc).filter(MENU_ITEM_CLASS_REF).fetch().stream() + .findFirst()) + .map(obj -> obj.getStringValue(TARGET_FIELD)).map(prop -> Objects.toString(prop, "").trim()) .filter(not(String::isEmpty)); } private boolean isMenuLinkTargetEnabled(DocumentReference docRef) { return ConfigSourceUtils.getStringProperty("navigation.linkTarget.enabled").toJavaUtil() - .map(String::toLowerCase) - .map(Boolean::parseBoolean) - .orElse(false); + .map(String::toLowerCase).map(Boolean::parseBoolean).orElse(false); } /** @@ -751,8 +748,8 @@ private static Long getNavCounterFromContext(ExecutionContext executionContext) if (navCounterObj instanceof Long) { return (Long) navCounterObj + 1; } else { - throw new IllegalArgumentException("Long object in context expected but got " - + navCounterObj.getClass()); + throw new IllegalArgumentException( + "Long object in context expected but got " + navCounterObj.getClass()); } } @@ -782,8 +779,8 @@ public List getMenuItemsForHierarchyLevel(int menuLeve public String getPrevMenuItemFullName(String fullName, XWikiContext context) { TreeNode prevTreeNode = null; try { - prevTreeNode = getTreeNodeService().getPrevMenuItem(getModelUtils() - .resolveRef(fullName, DocumentReference.class)); + prevTreeNode = getTreeNodeService() + .getPrevMenuItem(getModelUtils().resolveRef(fullName, DocumentReference.class)); } catch (XWikiException exp) { LOGGER.error("getPrevMenuItemFullName failed.", exp); } @@ -798,8 +795,8 @@ public String getPrevMenuItemFullName(String fullName, XWikiContext context) { public String getNextMenuItemFullName(String fullName, XWikiContext context) { TreeNode nextTreeNode = null; try { - nextTreeNode = getTreeNodeService().getNextMenuItem(getModelUtils() - .resolveRef(fullName, DocumentReference.class)); + nextTreeNode = getTreeNodeService() + .getNextMenuItem(getModelUtils().resolveRef(fullName, DocumentReference.class)); } catch (XWikiException exp) { LOGGER.error("getNextMenuItemFullName failed.", exp); } @@ -844,12 +841,12 @@ public void loadConfigFromObject(BaseObject prefObj) { showInactiveToLevel = prefObj.getIntValue("show_inactive_to_level", 0); menuPart = prefObj.getStringValue("menu_part"); setMenuSpace(prefObj.getStringValue("menu_space")); - if (!"".equals(prefObj.getStringValue("data_type")) && (prefObj.getStringValue( - "data_type") != null)) { + if (!"".equals(prefObj.getStringValue("data_type")) + && (prefObj.getStringValue("data_type") != null)) { dataType = prefObj.getStringValue("data_type"); } - if (!"".equals(prefObj.getStringValue("layout_type")) && (prefObj.getStringValue( - "layout_type") != null)) { + if (!"".equals(prefObj.getStringValue("layout_type")) + && (prefObj.getStringValue("layout_type") != null)) { try { setLayoutType(prefObj.getStringValue("layout_type")); } catch (UnknownLayoutTypeException exp) { @@ -860,8 +857,8 @@ public void loadConfigFromObject(BaseObject prefObj) { if (itemsPerPage > 0) { nrOfItemsPerPage = itemsPerPage; } - String presentationTypeStr = prefObj.getStringValue( - NavigationClasses.PRESENTATION_TYPE_FIELD); + String presentationTypeStr = prefObj + .getStringValue(NavigationClasses.PRESENTATION_TYPE_FIELD); if (!"".equals(presentationTypeStr)) { setPresentationType(presentationTypeStr); } @@ -905,8 +902,9 @@ private void generateLanguageMenu(INavigationBuilder navBuilder, XWikiContext co for (String language : langs) { navBuilder.openMenuItemOut(); boolean isLastItem = (langs.lastIndexOf(language) == (langs.size() - 1)); - navBuilder.appendMenuItemLink(language, "?language=" + language, getLanguageName(language, - context), language.equals(getNavLanguage()), isLastItem, cmCssClass); + navBuilder.appendMenuItemLink(language, "?language=" + language, + getLanguageName(language, context), language.equals(getNavLanguage()), isLastItem, + cmCssClass); navBuilder.closeMenuItemOut(); } navBuilder.closeLevel(); @@ -915,8 +913,8 @@ private void generateLanguageMenu(INavigationBuilder navBuilder, XWikiContext co private String getLanguageName(String lang, XWikiContext context) { XWikiMessageTool msg = context.getMessageTool(); String space = context.getDoc().getDocumentReference().getLastSpaceReference().getName(); - if (!msg.get("nav_cel_" + space + "_" + lang + "_" + lang).equals("nav_cel_" + space + "_" - + lang + "_" + lang)) { + if (!msg.get("nav_cel_" + space + "_" + lang + "_" + lang) + .equals("nav_cel_" + space + "_" + lang + "_" + lang)) { return msg.get("nav_cel_" + space + "_" + lang + "_" + lang); } else if (!msg.get("nav_cel_" + lang + "_" + lang).equals("nav_cel_" + lang + "_" + lang)) { return msg.get("nav_cel_" + lang + "_" + lang); @@ -1039,10 +1037,10 @@ public boolean hasMore() { parent = getWebUtilsService().getRefLocalSerializer().serialize(parentRef); } List currentMenuItems = getCurrentMenuItems(fromHierarchyLevel, parent); - LOGGER.debug("hasMore: parentRef [" + parentRef + "] currentMenuItems.size() [" - + currentMenuItems.size() + "] offset [" + offset + "]" + " nrOfItemsPerPage [" - + nrOfItemsPerPage + "] fromHierarchyLevel [" + fromHierarchyLevel + "] parent [" + parent - + "]"); + LOGGER.debug( + "hasMore: parentRef [" + parentRef + "] currentMenuItems.size() [" + currentMenuItems.size() + + "] offset [" + offset + "]" + " nrOfItemsPerPage [" + nrOfItemsPerPage + + "] fromHierarchyLevel [" + fromHierarchyLevel + "] parent [" + parent + "]"); return currentMenuItems.size() > 0; } diff --git a/src/main/java/com/celements/navigation/NavigationApi.java b/src/main/java/com/celements/navigation/NavigationApi.java index 4668b9586..2fb57e452 100644 --- a/src/main/java/com/celements/navigation/NavigationApi.java +++ b/src/main/java/com/celements/navigation/NavigationApi.java @@ -160,8 +160,8 @@ public boolean isNavigationEnabled() { } private DocumentReference getNavigationConfigClassRef(XWikiDocument doc) { - return getNavigationClasses().getNavigationConfigClassRef(getWebUtilsService().getWikiRef( - doc.getDocumentReference()).getName()); + return getNavigationClasses().getNavigationConfigClassRef( + getWebUtilsService().getWikiRef(doc.getDocumentReference()).getName()); } public void loadConfigByName(String configName) { @@ -199,8 +199,8 @@ private void loadConfig_internal(DocumentReference configDocRef, Integer objNum) XWikiDocument doc = context.getWiki().getDocument(configDocRef, context); BaseObject navConfigXobj = getNavigationConfigObject(doc, objNum); if (navConfigXobj != null) { - LOGGER.debug("loadConfig_internal: configName [" + navConfigXobj.getStringValue( - "menu_element_name") + "] , " + navConfigXobj); + LOGGER.debug("loadConfig_internal: configName [" + + navConfigXobj.getStringValue("menu_element_name") + "] , " + navConfigXobj); navigation.loadConfigFromObject(navConfigXobj); } else { LOGGER.warn("cannot load navigation config from doc [" + configDocRef + "]," diff --git a/src/main/java/com/celements/navigation/NavigationCache.java b/src/main/java/com/celements/navigation/NavigationCache.java index 7cbc24a32..3f2de7261 100644 --- a/src/main/java/com/celements/navigation/NavigationCache.java +++ b/src/main/java/com/celements/navigation/NavigationCache.java @@ -36,8 +36,8 @@ protected DocumentReference getCacheClassRef(WikiReference wikiRef) { @Override protected Collection getKeysForResult(DocumentReference docRef) throws XWikiException { Collection ret = new HashSet<>(); - List navConfObjs = getContext().getWiki().getDocument(docRef, - getContext()).getXObjects(getCacheClassRef(webUtils.getWikiRef(docRef))); + List navConfObjs = getContext().getWiki().getDocument(docRef, getContext()) + .getXObjects(getCacheClassRef(webUtils.getWikiRef(docRef))); if (navConfObjs != null) { for (BaseObject obj : navConfObjs) { String spaceName = getMenuSpaceName(obj); diff --git a/src/main/java/com/celements/navigation/NavigationClassConfig.java b/src/main/java/com/celements/navigation/NavigationClassConfig.java index 6bb81b770..20f6f86c4 100644 --- a/src/main/java/com/celements/navigation/NavigationClassConfig.java +++ b/src/main/java/com/celements/navigation/NavigationClassConfig.java @@ -26,8 +26,8 @@ public DocumentReference getMenuNameClassRef() { @Override public DocumentReference getMenuNameClassRef(WikiReference wikiRef) { - return new DocumentReference(MENU_NAME_CLASS_DOC, modelUtils.resolveRef(MENU_NAME_CLASS_SPACE, - SpaceReference.class, wikiRef)); + return new DocumentReference(MENU_NAME_CLASS_DOC, + modelUtils.resolveRef(MENU_NAME_CLASS_SPACE, SpaceReference.class, wikiRef)); } @Override @@ -42,8 +42,8 @@ public DocumentReference getNavigationConfigClassRef(String wikiName) { @Override public DocumentReference getNavigationConfigClassRef(WikiReference wikiRef) { - return new DocumentReference(NAVIGATION_CONFIG_CLASS_DOC, modelUtils.resolveRef( - NAVIGATION_CONFIG_CLASS_SPACE, SpaceReference.class, wikiRef)); + return new DocumentReference(NAVIGATION_CONFIG_CLASS_DOC, + modelUtils.resolveRef(NAVIGATION_CONFIG_CLASS_SPACE, SpaceReference.class, wikiRef)); } @Override @@ -58,8 +58,8 @@ public DocumentReference getMenuItemClassRef(String wikiName) { @Override public DocumentReference getMenuItemClassRef(WikiReference wikiRef) { - return new DocumentReference(MENU_ITEM_CLASS_DOC, modelUtils.resolveRef(MENU_ITEM_CLASS_SPACE, - SpaceReference.class, wikiRef)); + return new DocumentReference(MENU_ITEM_CLASS_DOC, + modelUtils.resolveRef(MENU_ITEM_CLASS_SPACE, SpaceReference.class, wikiRef)); } @Override diff --git a/src/main/java/com/celements/navigation/NavigationClasses.java b/src/main/java/com/celements/navigation/NavigationClasses.java index 990ff0dc5..50f6dfa9a 100644 --- a/src/main/java/com/celements/navigation/NavigationClasses.java +++ b/src/main/java/com/celements/navigation/NavigationClasses.java @@ -180,8 +180,8 @@ BaseClass getNavigationConfigClass() throws XWikiException { "integer"); needsUpdate |= bclass.addNumberField(SHOW_INACTIVE_TO_LEVEL_FIELD, "Always Show Inactive To Level", 30, "integer"); - needsUpdate |= bclass.addTextField(MENU_SPACE_FIELD, "Menu Space Name (leave empty" - + " for current space)", 30); + needsUpdate |= bclass.addTextField(MENU_SPACE_FIELD, + "Menu Space Name (leave empty" + " for current space)", 30); needsUpdate |= bclass.addTextField(MENU_PART_FIELD, "Menu Part Name", 30); needsUpdate |= bclass.addTextField(CM_CSS_CLASS_FIELD, "Context Menu CSS Class Name (empty for default)", 30); @@ -191,8 +191,8 @@ BaseClass getNavigationConfigClass() throws XWikiException { "Navigation Layout Type (empty for html list)", 30); needsUpdate |= bclass.addTextField(PRESENTATION_TYPE_FIELD, "Navigation Presentation Type (empty for menu name links)", 30); - needsUpdate |= bclass.addNumberField(INavigationClassConfig.ITEMS_PER_PAGE, "Number" - + " of items showed per page when using pageing", 30, "integer"); + needsUpdate |= bclass.addNumberField(INavigationClassConfig.ITEMS_PER_PAGE, + "Number" + " of items showed per page when using pageing", 30, "integer"); setContentAndSaveClassDocument(doc, needsUpdate); return bclass; @@ -250,8 +250,9 @@ BaseClass getNewMenuItemClass() throws XWikiException { try { doc = xwiki.getDocument(classRef, getContext()); } catch (XWikiException exp) { - LOGGER.error("Failed to get " + INavigationClassConfig.MAPPED_MENU_ITEM_CLASS - + " class document.", exp); + LOGGER.error( + "Failed to get " + INavigationClassConfig.MAPPED_MENU_ITEM_CLASS + " class document.", + exp); doc = new XWikiDocument(classRef); needsUpdate = true; } diff --git a/src/main/java/com/celements/navigation/NavigationConfig.java b/src/main/java/com/celements/navigation/NavigationConfig.java index 468fb2b6e..ccb8186f8 100644 --- a/src/main/java/com/celements/navigation/NavigationConfig.java +++ b/src/main/java/com/celements/navigation/NavigationConfig.java @@ -240,8 +240,8 @@ public Optional getPresentationType() { String thePresentationTypeHint = presentationTypeHint.or("default"); try { LOGGER.info("setPresentationType to [{}].", thePresentationTypeHint); - return Optional.of(Utils.getComponent(ComponentManager.class).lookup( - IPresentationTypeRole.class, thePresentationTypeHint)); + return Optional.of(Utils.getComponent(ComponentManager.class) + .lookup(IPresentationTypeRole.class, thePresentationTypeHint)); } catch (ComponentLookupException failedToLoadException) { LOGGER.error("setPresentationType failed to load IPresentationTypeRole for hint [{}].", thePresentationTypeHint, failedToLoadException); diff --git a/src/main/java/com/celements/navigation/cmd/EReorderLiteral.java b/src/main/java/com/celements/navigation/cmd/EReorderLiteral.java index f4c6aec11..8cdb8d9b7 100644 --- a/src/main/java/com/celements/navigation/cmd/EReorderLiteral.java +++ b/src/main/java/com/celements/navigation/cmd/EReorderLiteral.java @@ -26,6 +26,7 @@ import com.celements.sajson.IGenericLiteral; public enum EReorderLiteral implements IGenericLiteral { + ELEMENT_ID(ECommand.VALUE_COMMAND), ELEM_IDS_ARRAY(ECommand.ARRAY_COMMAND, ELEMENT_ID), PARENT_CHILDREN_PROPERTY(ECommand.PROPERTY_COMMAND, ELEM_IDS_ARRAY), diff --git a/src/main/java/com/celements/navigation/cmd/GetMappedMenuItemsForParentCommand.java b/src/main/java/com/celements/navigation/cmd/GetMappedMenuItemsForParentCommand.java index aa74a0d38..5426689a6 100644 --- a/src/main/java/com/celements/navigation/cmd/GetMappedMenuItemsForParentCommand.java +++ b/src/main/java/com/celements/navigation/cmd/GetMappedMenuItemsForParentCommand.java @@ -42,14 +42,14 @@ public class GetMappedMenuItemsForParentCommand { public final static String CELEMENTS_MAPPED_MENU_ITEMS_KEY = "com.celements.web.utils.GetMappedMenuItemsForParendCmd"; - private static final Logger LOGGER = LoggerFactory.getLogger( - GetMappedMenuItemsForParentCommand.class); + private static final Logger LOGGER = LoggerFactory + .getLogger(GetMappedMenuItemsForParentCommand.class); private boolean isActive; private XWikiContext getContext() { - return (XWikiContext) Utils.getComponent(Execution.class).getContext().getProperty( - "xwikicontext"); + return (XWikiContext) Utils.getComponent(Execution.class).getContext() + .getProperty("xwikicontext"); } public void setIsActive(boolean isActive) { diff --git a/src/main/java/com/celements/navigation/cmd/GetNotMappedMenuItemsForParentCommand.java b/src/main/java/com/celements/navigation/cmd/GetNotMappedMenuItemsForParentCommand.java index 756d57edc..ca6be8793 100644 --- a/src/main/java/com/celements/navigation/cmd/GetNotMappedMenuItemsForParentCommand.java +++ b/src/main/java/com/celements/navigation/cmd/GetNotMappedMenuItemsForParentCommand.java @@ -41,16 +41,16 @@ public class GetNotMappedMenuItemsForParentCommand { - private static final Logger LOGGER = LoggerFactory.getLogger( - GetNotMappedMenuItemsForParentCommand.class); + private static final Logger LOGGER = LoggerFactory + .getLogger(GetNotMappedMenuItemsForParentCommand.class); private final Map>> menuItems; private int queryCount = 0; private XWikiContext getContext() { - return (XWikiContext) Utils.getComponent(Execution.class).getContext().getProperty( - "xwikicontext"); + return (XWikiContext) Utils.getComponent(Execution.class).getContext() + .getProperty("xwikicontext"); } public GetNotMappedMenuItemsForParentCommand() { @@ -133,8 +133,8 @@ synchronized Map> loadMenuForWiki(String wikiName) { LOGGER.warn("loadMenuForWiki: skip [{}] because of null value!! " + "'{}', '{}', '{}'", fullName, wikiName, spaceName, fullName.split("\\.")[1]); } else { - DocumentReference docRef = new DocumentReference(wikiName, spaceName, fullName.split( - "\\.")[1]); + DocumentReference docRef = new DocumentReference(wikiName, spaceName, + fullName.split("\\.")[1]); TreeNode treeNode = new TreeNode(docRef, resolveParentRef(parentFN), (Integer) docData[3], strategy); menu.add(treeNode); diff --git a/src/main/java/com/celements/navigation/cmd/MenuItemObjectPartNameGetter.java b/src/main/java/com/celements/navigation/cmd/MenuItemObjectPartNameGetter.java index f95b60a85..1bfc4d4e7 100644 --- a/src/main/java/com/celements/navigation/cmd/MenuItemObjectPartNameGetter.java +++ b/src/main/java/com/celements/navigation/cmd/MenuItemObjectPartNameGetter.java @@ -41,9 +41,7 @@ public MenuItemObjectPartNameGetter() { @Override public String getPartName(DocumentReference docRef) { return XWikiObjectFetcher.on(modelAccess.getOrCreateDocument(docRef)) - .filter(INavigationClassConfig.MENU_ITEM_CLASS_REF) - .stream().findFirst() - .map(cobj -> cobj.getStringValue(INavigationClassConfig.PART_NAME_FIELD)) - .orElse(""); + .filter(INavigationClassConfig.MENU_ITEM_CLASS_REF).stream().findFirst() + .map(cobj -> cobj.getStringValue(INavigationClassConfig.PART_NAME_FIELD)).orElse(""); } } diff --git a/src/main/java/com/celements/navigation/cmd/MenuItemsUtils.java b/src/main/java/com/celements/navigation/cmd/MenuItemsUtils.java index 9518306b8..b6e3073c1 100644 --- a/src/main/java/com/celements/navigation/cmd/MenuItemsUtils.java +++ b/src/main/java/com/celements/navigation/cmd/MenuItemsUtils.java @@ -9,8 +9,7 @@ public class MenuItemsUtils { - private MenuItemsUtils() { - } + private MenuItemsUtils() {} public static EntityReference resolveParentRef(@NotNull String parentFN) { return (parentFN.isEmpty()) ? null : Utils.getComponent(ModelUtils.class).resolveRef(parentFN); diff --git a/src/main/java/com/celements/navigation/cmd/MultilingualMenuNameCommand.java b/src/main/java/com/celements/navigation/cmd/MultilingualMenuNameCommand.java index 9721b2de1..3a5706c7c 100644 --- a/src/main/java/com/celements/navigation/cmd/MultilingualMenuNameCommand.java +++ b/src/main/java/com/celements/navigation/cmd/MultilingualMenuNameCommand.java @@ -107,14 +107,12 @@ private String getMenuNameFromBaseObject(DocumentReference docRef, String langua menuName = menuNameObj.getStringValue("menu_name").trim(); } if (!allowEmptyMenuNames && menuName.isEmpty()) { - menuName = Stream.>>of( - () -> getModelAccess().getDocumentOpt(docRef, language), - () -> getModelAccess().getDocumentOpt(docRef)) - .map(Supplier::get).flatMap(Optional::stream) - .map(XWikiDocument::getTitle) - .filter(not(String::isBlank)) - .findFirst() - .orElseGet(() -> getFallbackMenuName(docRef)); + menuName = Stream + .>>of( + () -> getModelAccess().getDocumentOpt(docRef, language), + () -> getModelAccess().getDocumentOpt(docRef)) + .map(Supplier::get).flatMap(Optional::stream).map(XWikiDocument::getTitle) + .filter(not(String::isBlank)).findFirst().orElseGet(() -> getFallbackMenuName(docRef)); } LOGGER.info("getMenuNameFromBaseObject: for '{}' returning '{}'", docRef, menuName); return menuName; @@ -203,8 +201,8 @@ private XWiki getXWiki() { } private XWikiContext getContext() { - return Utils.getComponent(Execution.class).getContext() - .get(XWikiExecutionProp.XWIKI_CONTEXT).orElseThrow(); + return Utils.getComponent(Execution.class).getContext().get(XWikiExecutionProp.XWIKI_CONTEXT) + .orElseThrow(); } private IModelAccessFacade getModelAccess() { diff --git a/src/main/java/com/celements/navigation/cmd/ReorderSaveHandler.java b/src/main/java/com/celements/navigation/cmd/ReorderSaveHandler.java index a05af9176..9d851d37e 100644 --- a/src/main/java/com/celements/navigation/cmd/ReorderSaveHandler.java +++ b/src/main/java/com/celements/navigation/cmd/ReorderSaveHandler.java @@ -84,8 +84,8 @@ public void readPropertyKey(String key) { } currentPos = 0; } else { - throw new IllegalStateException("readPropertyKey: expecting ParentChildren but" + " found " - + currentCommand); + throw new IllegalStateException( + "readPropertyKey: expecting ParentChildren but" + " found " + currentCommand); } } @@ -157,10 +157,10 @@ public void stringEvent(String value) { updateNeeded = true; } BaseObject menuItemObj = XWikiObjectEditor.on(xdoc) - .filter(INavigationClassConfig.MENU_ITEM_CLASS_REF) - .fetch().stream().findFirst().orElse(null); - if ((menuItemObj != null) && (menuItemObj.getIntValue( - "menu_position") != getCurrentPos())) { + .filter(INavigationClassConfig.MENU_ITEM_CLASS_REF).fetch().stream().findFirst() + .orElse(null); + if ((menuItemObj != null) + && (menuItemObj.getIntValue("menu_position") != getCurrentPos())) { menuItemObj.setIntValue("menu_position", getCurrentPos()); markParentDirty(xdoc.getParentReference()); updateNeeded = true; diff --git a/src/main/java/com/celements/navigation/factories/XObjectNavigationFactory.java b/src/main/java/com/celements/navigation/factories/XObjectNavigationFactory.java index f1a01d153..58cf6d54c 100644 --- a/src/main/java/com/celements/navigation/factories/XObjectNavigationFactory.java +++ b/src/main/java/com/celements/navigation/factories/XObjectNavigationFactory.java @@ -60,8 +60,8 @@ protected DocumentReference getDefaultConfigReference() { @Override @NotNull public NavigationConfig getNavigationConfig(@NotNull DocumentReference configReference) { - return loadConfigFromObject(getConfigObjFetcher(configReference).stream() - .findFirst().orElse(null)); + return loadConfigFromObject( + getConfigObjFetcher(configReference).stream().findFirst().orElse(null)); } @Override @@ -94,9 +94,9 @@ NavigationConfig loadConfigFromObject(@Nullable BaseObject prefObj) { NavigationConfig.DEFAULT_MAX_LEVEL)); } if (isValueSet(prefObj, INavigationClassConfig.SHOW_INACTIVE_TO_LEVEL_FIELD)) { - b.showInactiveToLevel(prefObj.getIntValue( - INavigationClassConfig.SHOW_INACTIVE_TO_LEVEL_FIELD, NavigationConfig.DEFAULT_MIN_LEVEL - - 1)); + b.showInactiveToLevel( + prefObj.getIntValue(INavigationClassConfig.SHOW_INACTIVE_TO_LEVEL_FIELD, + NavigationConfig.DEFAULT_MIN_LEVEL - 1)); } String menuPart = prefObj.getStringValue(INavigationClassConfig.MENU_PART_FIELD); if (!Strings.isNullOrEmpty(menuPart)) { diff --git a/src/main/java/com/celements/navigation/filter/InternalRightsFilter.java b/src/main/java/com/celements/navigation/filter/InternalRightsFilter.java index 224f08b4c..37c162d3f 100644 --- a/src/main/java/com/celements/navigation/filter/InternalRightsFilter.java +++ b/src/main/java/com/celements/navigation/filter/InternalRightsFilter.java @@ -48,8 +48,8 @@ public String getMenuPart() { @Deprecated public boolean includeMenuItem(BaseObject baseObj, XWikiContext context) { return getRightsAccess().hasAccessLevel(baseObj.getDocumentReference(), EAccessLevel.VIEW, - context.getXWikiUser()) && (getMenuPart().isEmpty() || getMenuPart().equals( - baseObj.getStringValue("part_name"))); + context.getXWikiUser()) + && (getMenuPart().isEmpty() || getMenuPart().equals(baseObj.getStringValue("part_name"))); } @Override @@ -77,8 +77,8 @@ public boolean includeTreeNode(TreeNode node, XWikiContext context) { } private boolean checkMenuPart(TreeNode node, XWikiContext context) { - return (getMenuPart().isEmpty() || (node.isEmptyParentRef() && getMenuPart().equals( - node.getPartName()))); + return (getMenuPart().isEmpty() + || (node.isEmptyParentRef() && getMenuPart().equals(node.getPartName()))); } private IRightsAccessFacadeRole getRightsAccess() { diff --git a/src/main/java/com/celements/navigation/listener/NavigationCacheFlushingListener.java b/src/main/java/com/celements/navigation/listener/NavigationCacheFlushingListener.java index c8aaf9561..b5372b4e8 100644 --- a/src/main/java/com/celements/navigation/listener/NavigationCacheFlushingListener.java +++ b/src/main/java/com/celements/navigation/listener/NavigationCacheFlushingListener.java @@ -21,8 +21,8 @@ @Component(NavigationCache.NAME) public class NavigationCacheFlushingListener implements EventListener { - private static final Logger LOGGER = LoggerFactory.getLogger( - NavigationCacheFlushingListener.class); + private static final Logger LOGGER = LoggerFactory + .getLogger(NavigationCacheFlushingListener.class); @Requirement(NavigationCache.NAME) IDocumentReferenceCache navCache; diff --git a/src/main/java/com/celements/navigation/listener/TreeNodeDocumentCreatedListener.java b/src/main/java/com/celements/navigation/listener/TreeNodeDocumentCreatedListener.java index be76e105e..d2a2e5bae 100644 --- a/src/main/java/com/celements/navigation/listener/TreeNodeDocumentCreatedListener.java +++ b/src/main/java/com/celements/navigation/listener/TreeNodeDocumentCreatedListener.java @@ -41,10 +41,11 @@ import com.xpn.xwiki.objects.BaseObject; @Component("TreeNodeDocumentCreatedListener") -public class TreeNodeDocumentCreatedListener extends AbstractTreeNodeDocumentListener implements - EventListener { +public class TreeNodeDocumentCreatedListener extends AbstractTreeNodeDocumentListener + implements EventListener { - private static final Logger LOGGER = LoggerFactory.getLogger(TreeNodeDocumentCreatedListener.class); + private static final Logger LOGGER = LoggerFactory + .getLogger(TreeNodeDocumentCreatedListener.class); @Requirement private IWebUtilsService webUtilsService; @@ -82,8 +83,8 @@ public void onEvent(Event event, Object source, Object data) { if ((document != null) && !remoteObservationManagerContext.isRemoteState()) { LOGGER.debug("onEvent: got event for [" + event.getClass() + "] on document [" + document.getDocumentReference() + "]."); - BaseObject menuItemObj = document.getXObject(getNavClasses().getMenuItemClassRef( - getContext().getDatabase())); + BaseObject menuItemObj = document + .getXObject(getNavClasses().getMenuItemClassRef(getContext().getDatabase())); if (menuItemObj != null) { LOGGER.debug("TreeNodeDocumentCreatedListener checkMenuItemDiffs added to " + document.getDocumentReference() + "]"); diff --git a/src/main/java/com/celements/navigation/listener/TreeNodeDocumentDeletedListener.java b/src/main/java/com/celements/navigation/listener/TreeNodeDocumentDeletedListener.java index a2ccca629..041db7ca4 100644 --- a/src/main/java/com/celements/navigation/listener/TreeNodeDocumentDeletedListener.java +++ b/src/main/java/com/celements/navigation/listener/TreeNodeDocumentDeletedListener.java @@ -41,10 +41,11 @@ import com.xpn.xwiki.objects.BaseObject; @Component("TreeNodeDocumentDeletedListener") -public class TreeNodeDocumentDeletedListener extends AbstractTreeNodeDocumentListener implements - EventListener { +public class TreeNodeDocumentDeletedListener extends AbstractTreeNodeDocumentListener + implements EventListener { - private static final Logger LOGGER = LoggerFactory.getLogger(TreeNodeDocumentDeletedListener.class); + private static final Logger LOGGER = LoggerFactory + .getLogger(TreeNodeDocumentDeletedListener.class); @Requirement private IWebUtilsService webUtilsService; @@ -82,8 +83,8 @@ public void onEvent(Event event, Object source, Object data) { if ((document != null) && !remoteObservationManagerContext.isRemoteState()) { LOGGER.debug("onEvent: got event for [" + event.getClass() + "] on document [" + document.getDocumentReference() + "]."); - BaseObject menuItemObj = document.getXObject(getNavClasses().getMenuItemClassRef( - getContext().getDatabase())); + BaseObject menuItemObj = document + .getXObject(getNavClasses().getMenuItemClassRef(getContext().getDatabase())); if (menuItemObj != null) { LOGGER.debug("TreeNodeDocumentDeletedListener checkMenuItemDiffs deleted from " + document.getDocumentReference() + "]"); diff --git a/src/main/java/com/celements/navigation/listener/TreeNodeDocumentUpdatedListener.java b/src/main/java/com/celements/navigation/listener/TreeNodeDocumentUpdatedListener.java index e2e028f85..76604aa3f 100644 --- a/src/main/java/com/celements/navigation/listener/TreeNodeDocumentUpdatedListener.java +++ b/src/main/java/com/celements/navigation/listener/TreeNodeDocumentUpdatedListener.java @@ -45,10 +45,11 @@ import com.xpn.xwiki.objects.BaseObject; @Component("TreeNodeDocumentUpdatedListener") -public class TreeNodeDocumentUpdatedListener extends AbstractTreeNodeDocumentListener implements - EventListener { +public class TreeNodeDocumentUpdatedListener extends AbstractTreeNodeDocumentListener + implements EventListener { - private static final Logger LOGGER = LoggerFactory.getLogger(TreeNodeDocumentUpdatedListener.class); + private static final Logger LOGGER = LoggerFactory + .getLogger(TreeNodeDocumentUpdatedListener.class); @Requirement private IWebUtilsService webUtilsService; @@ -119,30 +120,30 @@ public void onEvent(Event event, Object source, Object data) { } boolean isMenuItemAdded(XWikiDocument document, XWikiDocument origDoc) { - BaseObject menuItemObj = document.getXObject(getNavClasses().getMenuItemClassRef( - getContext().getDatabase())); - BaseObject menuItemOrigObj = origDoc.getXObject(getNavClasses().getMenuItemClassRef( - getContext().getDatabase())); + BaseObject menuItemObj = document + .getXObject(getNavClasses().getMenuItemClassRef(getContext().getDatabase())); + BaseObject menuItemOrigObj = origDoc + .getXObject(getNavClasses().getMenuItemClassRef(getContext().getDatabase())); LOGGER.trace("checkMenuItemAdded checkMenuItemDiffs menuItemObj [" + menuItemObj + "], menuItemOrigObj [" + menuItemOrigObj + "]"); return ((menuItemObj != null) && (menuItemOrigObj == null)); } boolean isMenuItemDeleted(XWikiDocument document, XWikiDocument origDoc) { - BaseObject menuItemObj = document.getXObject(getNavClasses().getMenuItemClassRef( - getContext().getDatabase())); - BaseObject menuItemOrigObj = origDoc.getXObject(getNavClasses().getMenuItemClassRef( - getContext().getDatabase())); + BaseObject menuItemObj = document + .getXObject(getNavClasses().getMenuItemClassRef(getContext().getDatabase())); + BaseObject menuItemOrigObj = origDoc + .getXObject(getNavClasses().getMenuItemClassRef(getContext().getDatabase())); LOGGER.trace("checkMenuItemAdded checkMenuItemDiffs menuItemObj [" + menuItemObj + "], menuItemOrigObj [" + menuItemOrigObj + "]"); return ((menuItemObj == null) && (menuItemOrigObj != null)); } boolean isMenuItemUpdated(XWikiDocument document, XWikiDocument origDoc) { - BaseObject menuItemObj = document.getXObject(getNavClasses().getMenuItemClassRef( - getContext().getDatabase())); - BaseObject menuItemOrigObj = origDoc.getXObject(getNavClasses().getMenuItemClassRef( - getContext().getDatabase())); + BaseObject menuItemObj = document + .getXObject(getNavClasses().getMenuItemClassRef(getContext().getDatabase())); + BaseObject menuItemOrigObj = origDoc + .getXObject(getNavClasses().getMenuItemClassRef(getContext().getDatabase())); LOGGER.trace("TreeNodeDocumentUpdatedListener checkMenuItemDiffs menuItemObj [" + menuItemObj + "], menuItemOrigObj [" + menuItemOrigObj + "]"); if ((menuItemObj != null) && (menuItemOrigObj != null)) { diff --git a/src/main/java/com/celements/navigation/presentation/DefaultPresentationType.java b/src/main/java/com/celements/navigation/presentation/DefaultPresentationType.java index 39d750718..5b64e834f 100644 --- a/src/main/java/com/celements/navigation/presentation/DefaultPresentationType.java +++ b/src/main/java/com/celements/navigation/presentation/DefaultPresentationType.java @@ -68,8 +68,8 @@ protected void appendMenuItemLink(StringBuilder outStream, boolean isFirstItem, + nav.getMenuLinkTarget(docRef).map(target -> " target=\"" + target + "\"").orElse(""); } if (nav.useImagesForNavigation()) { - menuItemHTML += " " + menuNameCmd.addNavImageStyle(fullName, nav.getNavLanguage(), - getContext()); + menuItemHTML += " " + + menuNameCmd.addNavImageStyle(fullName, nav.getNavLanguage(), getContext()); } String tooltip = menuNameCmd.addToolTip(fullName, nav.getNavLanguage(), getContext()); if (!"".equals(tooltip)) { diff --git a/src/main/java/com/celements/navigation/presentation/LayoutEditorPresentationType.java b/src/main/java/com/celements/navigation/presentation/LayoutEditorPresentationType.java index e0c35e8be..9555cab97 100644 --- a/src/main/java/com/celements/navigation/presentation/LayoutEditorPresentationType.java +++ b/src/main/java/com/celements/navigation/presentation/LayoutEditorPresentationType.java @@ -19,8 +19,7 @@ @Component("layoutEditor") public class LayoutEditorPresentationType extends DefaultPresentationType { - private static final Logger LOGGER = LoggerFactory.getLogger( - LayoutEditorPresentationType.class); + private static final Logger LOGGER = LoggerFactory.getLogger(LayoutEditorPresentationType.class); private static final String _CEL_CM_CELLEDITOR_MENUITEM = "cel_cm_celleditor_menuitem"; @@ -64,8 +63,8 @@ protected void appendMenuItemLink(StringBuilder outStream, boolean isFirstItem, } if (nav.useImagesForNavigation()) { menuItemHTML.append(" "); - menuItemHTML.append(menuNameCmd.addNavImageStyle(fullName, nav.getNavLanguage(), - getContext())); + menuItemHTML + .append(menuNameCmd.addNavImageStyle(fullName, nav.getNavLanguage(), getContext())); } String tooltip = menuNameCmd.addToolTip(fullName, nav.getNavLanguage(), getContext()); if (!Strings.isNullOrEmpty(tooltip)) { diff --git a/src/main/java/com/celements/navigation/presentation/PresentationNodeData.java b/src/main/java/com/celements/navigation/presentation/PresentationNodeData.java index 6f9f39073..d24e48141 100644 --- a/src/main/java/com/celements/navigation/presentation/PresentationNodeData.java +++ b/src/main/java/com/celements/navigation/presentation/PresentationNodeData.java @@ -1,6 +1,5 @@ package com.celements.navigation.presentation; - public interface PresentationNodeData { } diff --git a/src/main/java/com/celements/navigation/presentation/RenderedContentDynLoadPresentationType.java b/src/main/java/com/celements/navigation/presentation/RenderedContentDynLoadPresentationType.java index 83cfa38cf..95eb2d1d3 100644 --- a/src/main/java/com/celements/navigation/presentation/RenderedContentDynLoadPresentationType.java +++ b/src/main/java/com/celements/navigation/presentation/RenderedContentDynLoadPresentationType.java @@ -52,13 +52,9 @@ protected void addRenderedContent(@NotNull StringBuilder outStream, } private @NotNull String getPassThroughParams() { - return mContext.request() - .map(r -> r.getParameterMap().entrySet()) - .orElse(Set.of()) - .stream() + return mContext.request().map(r -> r.getParameterMap().entrySet()).orElse(Set.of()).stream() .filter(entry1 -> !keyBlackList.contains(entry1.getKey())) - .flatMap(entry -> List.of(entry.getValue()).stream() - .map(v -> entry.getKey() + "=" + v)) + .flatMap(entry -> List.of(entry.getValue()).stream().map(v -> entry.getKey() + "=" + v)) .collect(() -> new StringJoiner("&", "&", "").setEmptyValue(""), StringJoiner::add, StringJoiner::merge) .toString(); diff --git a/src/main/java/com/celements/navigation/presentation/RenderedContentPresentationType.java b/src/main/java/com/celements/navigation/presentation/RenderedContentPresentationType.java index 91a6d4a82..0f35f37bf 100644 --- a/src/main/java/com/celements/navigation/presentation/RenderedContentPresentationType.java +++ b/src/main/java/com/celements/navigation/presentation/RenderedContentPresentationType.java @@ -34,8 +34,8 @@ public void writeNodeContent(StringBuilder outStream, boolean isFirstItem, boole DocumentReference docRef, boolean isLeaf, int numItem, INavigation nav) { LOGGER.debug("writeNodeContent for [{}].", docRef); outStream.append("
\n"); addRenderedContent(outStream, docRef); outStream.append("
\n"); diff --git a/src/main/java/com/celements/navigation/presentation/RenderedExtractPresentationType.java b/src/main/java/com/celements/navigation/presentation/RenderedExtractPresentationType.java index 9299092a8..b97d737fd 100644 --- a/src/main/java/com/celements/navigation/presentation/RenderedExtractPresentationType.java +++ b/src/main/java/com/celements/navigation/presentation/RenderedExtractPresentationType.java @@ -64,8 +64,8 @@ public void writeNodeContent(StringBuilder outStream, boolean isFirstItem, boole DocumentReference docRef, boolean isLeaf, int numItem, INavigation nav) { LOGGER.debug("writeNodeContent for [" + docRef + "]."); outStream.append("
\n"); try { outStream.append(getRenderedExtract(docRef)); @@ -99,14 +99,14 @@ private DocumentReference getTemplateRef() { private String getDocExtract(DocumentReference docRef) throws XWikiException { XWikiDocument contentDoc = getContext().getWiki().getDocument(docRef, getContext()); - DocumentReference documentExtractClassRef = getDocDetailsClasses().getDocumentExtractClassRef( - docRef.getLastSpaceReference().getParent().getName()); + DocumentReference documentExtractClassRef = getDocDetailsClasses() + .getDocumentExtractClassRef(docRef.getLastSpaceReference().getParent().getName()); BaseObject extractObj = contentDoc.getXObject(documentExtractClassRef, DocumentDetailsClasses.FIELD_DOC_EXTRACT_LANGUAGE, getContext().getLanguage(), false); if (extractObj == null) { extractObj = contentDoc.getXObject(documentExtractClassRef, - DocumentDetailsClasses.FIELD_DOC_EXTRACT_LANGUAGE, webUtilsService.getDefaultLanguage( - docRef.getLastSpaceReference()), false); + DocumentDetailsClasses.FIELD_DOC_EXTRACT_LANGUAGE, + webUtilsService.getDefaultLanguage(docRef.getLastSpaceReference()), false); } if (extractObj != null) { return extractObj.getStringValue(DocumentDetailsClasses.FIELD_DOC_EXTRACT_CONTENT); diff --git a/src/main/java/com/celements/navigation/presentation/SitemapPresentationType.java b/src/main/java/com/celements/navigation/presentation/SitemapPresentationType.java index 15a211476..638920f1e 100644 --- a/src/main/java/com/celements/navigation/presentation/SitemapPresentationType.java +++ b/src/main/java/com/celements/navigation/presentation/SitemapPresentationType.java @@ -46,8 +46,9 @@ void addLanguageLinks(StringBuilder outStream, DocumentReference docRef) { for (String lang : webUtilsService.getAllowedLanguages(spaceName)) { outStream.append(" parents = webUtilsService.getDocumentParentsList( - getContext().getDoc().getDocumentReference(), true); + List parents = webUtilsService + .getDocumentParentsList(getContext().getDoc().getDocumentReference(), true); if (parents.size() >= menuLevel) { return getMenuItemPos(parents.get(parents.size() - menuLevel), menuPart); } @@ -129,8 +129,8 @@ public boolean isTreeNode(DocumentReference docRef) { // TODO move to ITreeNodeProvider and integrate over all nodeProviders try { XWikiDocument document = getContext().getWiki().getDocument(docRef, getContext()); - List menuItems = document.getXObjects(navClassConfig.getMenuItemClassRef( - getContext().getDatabase())); + List menuItems = document + .getXObjects(navClassConfig.getMenuItemClassRef(getContext().getDatabase())); return ((menuItems != null) && !menuItems.isEmpty()); } catch (XWikiException exp) { LOGGER.error("Failed to get document for reference [{}].", docRef, exp); @@ -267,12 +267,12 @@ List fetchNodesForParent(EntityReference parentRef) { private List fetchNodesForParentKey(String parentKey) { long starttotal = System.currentTimeMillis(); long start = starttotal; - List notMappedmenuItems = treeNodeCache.getNotMappedMenuItemsForParentCmd().getTreeNodesForParentKey( - parentKey); + List notMappedmenuItems = treeNodeCache.getNotMappedMenuItemsForParentCmd() + .getTreeNodesForParentKey(parentKey); LOGGER.debug("fetchNodesForParentKey: time for getNotMappedMenuItemsFromDatabase: {}", (System.currentTimeMillis() - start)); - List mappedTreeNodes = treeNodeCache.getMappedMenuItemsForParentCmd().getTreeNodesForParentKey( - parentKey); + List mappedTreeNodes = treeNodeCache.getMappedMenuItemsForParentCmd() + .getTreeNodesForParentKey(parentKey); LOGGER.debug("fetchNodesForParentKey: time for getMappedMenuItemsForParentCmd: {}", (System.currentTimeMillis() - start)); start = System.currentTimeMillis(); @@ -407,8 +407,8 @@ public Integer getMaxConfiguredNavigationLevel() { int maxLevel = 0; for (BaseObject navObj : navConfigObjects) { if (navObj != null) { - maxLevel = Math.max(maxLevel, navObj.getIntValue( - INavigationClassConfig.TO_HIERARCHY_LEVEL_FIELD)); + maxLevel = Math.max(maxLevel, + navObj.getIntValue(INavigationClassConfig.TO_HIERARCHY_LEVEL_FIELD)); } } return maxLevel; @@ -429,8 +429,8 @@ List getNavObjectsFromLayout() { List subNodes = getSubNodesForParent(node.getDocumentReference(), ""); newSubNodes.addAll(subNodes); if (subNodes.isEmpty()) { - layoutCellList.add(webUtilsService.getRefDefaultSerializer().serialize( - node.getDocumentReference())); + layoutCellList.add( + webUtilsService.getRefDefaultSerializer().serialize(node.getDocumentReference())); } } subNodesForParent = newSubNodes; @@ -447,16 +447,17 @@ List getNavObjectsFromLayout() { private List getNavObjectsOnConfigDocs() { List navConfigObjects2 = Collections.emptyList(); try { - BaseCollection navConfigObj = getInheritorFactory().getConfigDocFieldInheritor( - INavigationClassConfig.NAVIGATION_CONFIG_CLASS, getParentKey( - getContext().getDoc().getDocumentReference(), false), getContext()).getObject( - "menu_element_name"); + BaseCollection navConfigObj = getInheritorFactory() + .getConfigDocFieldInheritor(INavigationClassConfig.NAVIGATION_CONFIG_CLASS, + getParentKey(getContext().getDoc().getDocumentReference(), false), getContext()) + .getObject("menu_element_name"); if (navConfigObj != null) { - XWikiDocument navConfigDoc = getContext().getWiki().getDocument( - navConfigObj.getDocumentReference(), getContext()); - String navConfigDocWikiName = navConfigDoc.getDocumentReference().getLastSpaceReference().getParent().getName(); - navConfigObjects2 = navConfigDoc.getXObjects(navClassConfig.getNavigationConfigClassRef( - navConfigDocWikiName)); + XWikiDocument navConfigDoc = getContext().getWiki() + .getDocument(navConfigObj.getDocumentReference(), getContext()); + String navConfigDocWikiName = navConfigDoc.getDocumentReference().getLastSpaceReference() + .getParent().getName(); + navConfigObjects2 = navConfigDoc + .getXObjects(navClassConfig.getNavigationConfigClassRef(navConfigDocWikiName)); } else { LOGGER.info("no config object found"); } @@ -482,8 +483,8 @@ TreeNode getSiblingMenuItem(DocumentReference docRef, boolean previous) throws X if (menuItem != null) { try { EntityReference parent = getParentEntityRef(docRef); - List subMenuItems = getSubNodesForParent(parent, menuItem.getStringValue( - "part_name")); + List subMenuItems = getSubNodesForParent(parent, + menuItem.getStringValue("part_name")); if (LOGGER.isDebugEnabled()) { LOGGER.debug("getPrevMenuItem: {} subMenuItems found for parent '{}'. {}", subMenuItems.size(), parent, Arrays.deepToString(subMenuItems.toArray())); @@ -494,14 +495,14 @@ TreeNode getSiblingMenuItem(DocumentReference docRef, boolean previous) throws X } else if (!previous && (pos < (subMenuItems.size() - 1))) { return subMenuItems.get(pos + 1); } - LOGGER.info("getPrevMenuItem: no previous MenuItem found for {}", getParentKey(docRef, - true)); + LOGGER.info("getPrevMenuItem: no previous MenuItem found for {}", + getParentKey(docRef, true)); } catch (XWikiException exp) { LOGGER.error("getSiblingMenuItem failed.", exp); } } else { - LOGGER.debug("getPrevMenuItem: no MenuItem Object found on doc {}", getParentKey(docRef, - true)); + LOGGER.debug("getPrevMenuItem: no MenuItem Object found on doc {}", + getParentKey(docRef, true)); } return null; } @@ -549,8 +550,8 @@ public EntityReference getParentReference(DocumentReference docRef) { */ @Override public EntityReference getParentEntityRef(DocumentReference docRef) throws XWikiException { - EntityReference parentRef = getContext().getWiki().getDocument(docRef, - getContext()).getParentReference(); + EntityReference parentRef = getContext().getWiki().getDocument(docRef, getContext()) + .getParentReference(); if ((parentRef == null) || (docRef.equals(parentRef))) { parentRef = docRef.getLastSpaceReference(); } @@ -614,8 +615,8 @@ public TreeNode getTreeNodeForDocRef(DocumentReference docRef) throws XWikiExcep EntityReference parentRef = getParentReference(docRef); TreeNode treeNode = null; XWikiDocument moveDoc = getContext().getWiki().getDocument(docRef, getContext()); - BaseObject menuItemObj = moveDoc.getXObject(navClassConfig.getMenuItemClassRef( - getContext().getDatabase())); + BaseObject menuItemObj = moveDoc + .getXObject(navClassConfig.getMenuItemClassRef(getContext().getDatabase())); if (menuItemObj != null) { int pos = menuItemObj.getIntValue(INavigationClassConfig.MENU_POSITION_FIELD, -1); if (parentRef instanceof SpaceReference) { @@ -649,15 +650,16 @@ public void storeOrder(List newTreeNodes, boolean isMinorEdit) { DocumentReference theDocRef = theNode.getDocumentReference(); try { XWikiDocument theDoc = wiki.getDocument(theDocRef, getContext()); - BaseObject menuItemObj = theDoc.getXObject(navClassConfig.getMenuItemClassRef( - getContext().getDatabase())); + BaseObject menuItemObj = theDoc + .getXObject(navClassConfig.getMenuItemClassRef(getContext().getDatabase())); if (menuItemObj != null) { pos++; int oldPos = menuItemObj.getIntValue(INavigationClassConfig.MENU_POSITION_FIELD, -1); if (oldPos != pos) { menuItemObj.setIntValue(INavigationClassConfig.MENU_POSITION_FIELD, pos); - wiki.saveDocument(theDoc, "changed menu position from '" + oldPos + "' to '" + pos - + "'.", isMinorEdit, getContext()); + wiki.saveDocument(theDoc, + "changed menu position from '" + oldPos + "' to '" + pos + "'.", isMinorEdit, + getContext()); } } else { LOGGER.error("storeOrder: failed to get menuItemObject of [{}].", theDocRef); @@ -699,8 +701,9 @@ public int hashCode() { public boolean equals(Object obj) { if (obj instanceof SubNodeCacheKey) { SubNodeCacheKey other = (SubNodeCacheKey) obj; - return Objects.equals(this.ref, other.ref) && Objects.equals(this.filterClass, - other.filterClass) && Objects.equals(this.menuPart, other.menuPart); + return Objects.equals(this.ref, other.ref) + && Objects.equals(this.filterClass, other.filterClass) + && Objects.equals(this.menuPart, other.menuPart); } return false; } diff --git a/src/main/java/com/celements/nextfreedoc/NextFreeDocService.java b/src/main/java/com/celements/nextfreedoc/NextFreeDocService.java index a2885d7b6..609822ccc 100644 --- a/src/main/java/com/celements/nextfreedoc/NextFreeDocService.java +++ b/src/main/java/com/celements/nextfreedoc/NextFreeDocService.java @@ -111,8 +111,8 @@ long getHighestNum(DocumentReference baseDocRef) { try { int offset = 0, limit = 8; List results; - while ((num == null) && ((results = getHighestNumQuery(baseDocRef, offset, - limit).execute()).size() > 0)) { + while ((num == null) + && ((results = getHighestNumQuery(baseDocRef, offset, limit).execute()).size() > 0)) { num = extractNumFromResults(baseDocRef.getName(), results); offset += results.size(); limit *= 2; diff --git a/src/main/java/com/celements/observation/save/SaveEvent.java b/src/main/java/com/celements/observation/save/SaveEvent.java index f3858b70f..972f5819d 100644 --- a/src/main/java/com/celements/observation/save/SaveEvent.java +++ b/src/main/java/com/celements/observation/save/SaveEvent.java @@ -36,8 +36,7 @@ public int hashCode() { @Override public boolean equals(Object obj) { return tryCast(obj, SaveEvent.class) - .map(other -> Objects.equals(this.getEventFilter(), other.getEventFilter())) - .orElse(false); + .map(other -> Objects.equals(this.getEventFilter(), other.getEventFilter())).orElse(false); } @Override diff --git a/src/main/java/com/celements/observation/save/SaveEventFilter.java b/src/main/java/com/celements/observation/save/SaveEventFilter.java index fddbabc2c..9f81fe890 100644 --- a/src/main/java/com/celements/observation/save/SaveEventFilter.java +++ b/src/main/java/com/celements/observation/save/SaveEventFilter.java @@ -53,10 +53,8 @@ public int hashCode() { @Override public boolean equals(Object obj) { - return tryCast(obj, SaveEventFilter.class) - .map(other -> (this.operation == other.operation) - && Objects.equals(this.identity, other.identity)) - .orElse(false); + return tryCast(obj, SaveEventFilter.class).map(other -> (this.operation == other.operation) + && Objects.equals(this.identity, other.identity)).orElse(false); } @Override diff --git a/src/main/java/com/celements/observation/save/SaveEventOperation.java b/src/main/java/com/celements/observation/save/SaveEventOperation.java index a10a226cf..96617382c 100644 --- a/src/main/java/com/celements/observation/save/SaveEventOperation.java +++ b/src/main/java/com/celements/observation/save/SaveEventOperation.java @@ -37,7 +37,8 @@ public boolean isDelete() { * A) if an original and new entity (doc, object, ...) exists * B) if the operation is before or after save. */ - public static Optional from(boolean origExists, boolean newExists, boolean beforeSave) { + public static Optional from(boolean origExists, boolean newExists, + boolean beforeSave) { int val = ((newExists ? 0 : 1) << 1) | (origExists ? 0 : 1); if (val < 3) { return Optional.of(values()[val + (beforeSave ? 0 : 3)]); @@ -48,7 +49,7 @@ public static Optional from(boolean origExists, boolean newE public static SaveEventOperation from(Event event) { String eventName = checkNotNull(event).getClass().getSimpleName().toUpperCase(); - return Arrays.stream(values()).filter(ops -> eventName.contains(ops.name())) - .findAny().orElseThrow(() -> new IllegalArgumentException("illegal save event: " + event)); + return Arrays.stream(values()).filter(ops -> eventName.contains(ops.name())).findAny() + .orElseThrow(() -> new IllegalArgumentException("illegal save event: " + event)); } } diff --git a/src/main/java/com/celements/observation/save/object/XObjectEventConverter.java b/src/main/java/com/celements/observation/save/object/XObjectEventConverter.java index 819a049d9..9a539d61e 100644 --- a/src/main/java/com/celements/observation/save/object/XObjectEventConverter.java +++ b/src/main/java/com/celements/observation/save/object/XObjectEventConverter.java @@ -43,12 +43,8 @@ public String getName() { @Override public List getEvents() { - return Arrays.asList( - new DocumentCreatingEvent(), - new DocumentUpdatingEvent(), - new DocumentDeletingEvent(), - new DocumentCreatedEvent(), - new DocumentUpdatedEvent(), + return Arrays.asList(new DocumentCreatingEvent(), new DocumentUpdatingEvent(), + new DocumentDeletingEvent(), new DocumentCreatedEvent(), new DocumentUpdatedEvent(), new DocumentDeletedEvent()); } @@ -56,7 +52,8 @@ public List getEvents() { protected void onEventInternal(Event sourceEvent, XWikiDocument doc, XWikiContext context) { if (doc.getTranslation() == 0) { Map newObjMap = getObjectMap(doc); - Map origObjMap = getObjectMap(doc.getOriginalDocument()); + Map origObjMap = getObjectMap( + doc.getOriginalDocument()); for (ImmutableObjectReference objRef : Sets.union(newObjMap.keySet(), origObjMap.keySet())) { BaseObject newObj = newObjMap.get(objRef); BaseObject origObj = origObjMap.get(objRef); diff --git a/src/main/java/com/celements/pagetype/PageType.java b/src/main/java/com/celements/pagetype/PageType.java index dbbaa9884..968cca1b5 100644 --- a/src/main/java/com/celements/pagetype/PageType.java +++ b/src/main/java/com/celements/pagetype/PageType.java @@ -148,10 +148,10 @@ String getRenderTemplateForRenderMode(String renderMode, XWikiContext context) // TODO check where to move to. RenderCommand or PageTypeTemplateResolver? public String resolveTemplatePath(String specView, XWikiContext context) { // TODO replace implementation with WebUtils getInheritedTemplatedPath - if ((specView != null) && (specView.trim().length() > 0) && !context.getWiki().exists(specView, - context)) { - if (!specView.startsWith("celements2web:") && context.getWiki().exists("celements2web:" - + specView, context)) { + if ((specView != null) && (specView.trim().length() > 0) + && !context.getWiki().exists(specView, context)) { + if (!specView.startsWith("celements2web:") + && context.getWiki().exists("celements2web:" + specView, context)) { specView = "celements2web:" + specView; } else { specView = ":" + specView.replaceAll("celements2web:", ""); diff --git a/src/main/java/com/celements/pagetype/PageTypeClassConfig.java b/src/main/java/com/celements/pagetype/PageTypeClassConfig.java index 5bb08759b..f5cd6a860 100644 --- a/src/main/java/com/celements/pagetype/PageTypeClassConfig.java +++ b/src/main/java/com/celements/pagetype/PageTypeClassConfig.java @@ -41,8 +41,8 @@ public class PageTypeClassConfig implements IPageTypeClassConfig { @Override public DocumentReference getPageTypePropertiesClassRef(WikiReference wikiRef) { - return new DocumentReference(PAGE_TYPE_PROPERTIES_CLASS_DOC, new SpaceReference( - PAGE_TYPE_PROPERTIES_CLASS_SPACE, wikiRef)); + return new DocumentReference(PAGE_TYPE_PROPERTIES_CLASS_DOC, + new SpaceReference(PAGE_TYPE_PROPERTIES_CLASS_SPACE, wikiRef)); } @Override @@ -52,8 +52,8 @@ public DocumentReference getPageTypeClassRef() { @Override public DocumentReference getPageTypeClassRef(WikiReference wikiRef) { - return new DocumentReference(PAGE_TYPE_CLASS_DOC, new SpaceReference(PAGE_TYPE_CLASS_SPACE, - wikiRef)); + return new DocumentReference(PAGE_TYPE_CLASS_DOC, + new SpaceReference(PAGE_TYPE_CLASS_SPACE, wikiRef)); } } diff --git a/src/main/java/com/celements/pagetype/PageTypeClasses.java b/src/main/java/com/celements/pagetype/PageTypeClasses.java index 341ed0e41..efe5582bb 100644 --- a/src/main/java/com/celements/pagetype/PageTypeClasses.java +++ b/src/main/java/com/celements/pagetype/PageTypeClasses.java @@ -132,8 +132,8 @@ public BaseClass getPageTypePropertiesClass() throws XWikiException { public BaseClass getPageTypeClass() throws XWikiException { boolean needsUpdate = false; - DocumentReference pageTypeClassRef = pageTypeClassConfig.getPageTypeClassRef( - modelContext.getWikiRef()); + DocumentReference pageTypeClassRef = pageTypeClassConfig + .getPageTypeClassRef(modelContext.getWikiRef()); XWikiDocument doc = modelAccess.getOrCreateDocument(pageTypeClassRef); BaseClass bclass = doc.getXClass(); diff --git a/src/main/java/com/celements/pagetype/PageTypeReference.java b/src/main/java/com/celements/pagetype/PageTypeReference.java index 398523339..2baeb448d 100644 --- a/src/main/java/com/celements/pagetype/PageTypeReference.java +++ b/src/main/java/com/celements/pagetype/PageTypeReference.java @@ -47,9 +47,7 @@ public PageTypeReference(String configName, String providerHint, List ca public PageTypeReference(String configName, String providerHint, Collection categories) { this.configName = configName; this.providerHint = providerHint; - this.categories = (categories != null) - ? ImmutableList.copyOf(categories) - : ImmutableList.of(); + this.categories = (categories != null) ? ImmutableList.copyOf(categories) : ImmutableList.of(); } public String getConfigName() { diff --git a/src/main/java/com/celements/pagetype/classes/PageTypePropertiesClass.java b/src/main/java/com/celements/pagetype/classes/PageTypePropertiesClass.java index 25eb4cc95..d90964f53 100644 --- a/src/main/java/com/celements/pagetype/classes/PageTypePropertiesClass.java +++ b/src/main/java/com/celements/pagetype/classes/PageTypePropertiesClass.java @@ -29,8 +29,8 @@ import com.celements.model.classes.fields.number.IntField; @Component(PageTypePropertiesClass.CLASS_DEF_HINT) -public class PageTypePropertiesClass extends AbstractClassDefinition implements - PageTypeClassDefinition { +public class PageTypePropertiesClass extends AbstractClassDefinition + implements PageTypeClassDefinition { public static final String SPACE_NAME = "Celements2"; public static final String DOC_NAME = "PageTypeProperties"; @@ -39,8 +39,8 @@ public class PageTypePropertiesClass extends AbstractClassDefinition implements public static final ClassField PAGETYPE_PROP_TYPE_NAME = new StringField.Builder( CLASS_REF, "type_name").size(30).prettyName("Type Pretty Name").build(); - public static final ClassField PAGETYPE_PROP_CATEGORY = new StringField.Builder( - CLASS_REF, "category").size(30).prettyName("Category").build(); + public static final ClassField PAGETYPE_PROP_CATEGORY = new StringField.Builder(CLASS_REF, + "category").size(30).prettyName("Category").build(); public static final ClassField PAGETYPE_PROP_PAGE_EDIT = new StringField.Builder( CLASS_REF, "page_edit").size(30).prettyName("Type Edit Template").build(); public static final ClassField PAGETYPE_PROP_PAGE_VIEW = new StringField.Builder( @@ -50,22 +50,20 @@ public class PageTypePropertiesClass extends AbstractClassDefinition implements public static final ClassField PAGETYPE_PROP_SHOW_FRAME = new BooleanField.Builder( CLASS_REF, "show_frame").prettyName("Show Frame").displayType("yesno").build(); public static final ClassField PAGETYPE_PROP_LOAD_RICHTEXT = new BooleanField.Builder( - CLASS_REF, "load_richtext").prettyName("Load Richtext Editor").displayType( - "yesno").build(); - public static final ClassField PAGETYPE_PROP_RTE_WIDTH = new IntField.Builder( - CLASS_REF, "rte_width").prettyName("Richtext Editor Width").size(30).build(); - public static final ClassField PAGETYPE_PROP_RTE_HEIGHT = new IntField.Builder( - CLASS_REF, "rte_height").prettyName("Richtext Editor Height").size(30).build(); + CLASS_REF, "load_richtext").prettyName("Load Richtext Editor").displayType("yesno").build(); + public static final ClassField PAGETYPE_PROP_RTE_WIDTH = new IntField.Builder(CLASS_REF, + "rte_width").prettyName("Richtext Editor Width").size(30).build(); + public static final ClassField PAGETYPE_PROP_RTE_HEIGHT = new IntField.Builder(CLASS_REF, + "rte_height").prettyName("Richtext Editor Height").size(30).build(); public static final ClassField PAGETYPE_PROP_HASPAGETITLE = new BooleanField.Builder( CLASS_REF, "haspagetitle").prettyName("Has Page Title").displayType("yesno").build(); public static final ClassField PAGETYPE_PROP_IS_UNCONNECTED_PARENT = new BooleanField.Builder( - CLASS_REF, "unconnected_parent").prettyName("Is Unconnected Parent").displayType( - "yesno").build(); - public static final ClassField PAGETYPE_PROP_TAG_NAME = new StringField.Builder( - CLASS_REF, "tag_name").size(30).prettyName("Tag Name").build(); + CLASS_REF, "unconnected_parent").prettyName("Is Unconnected Parent").displayType("yesno") + .build(); + public static final ClassField PAGETYPE_PROP_TAG_NAME = new StringField.Builder(CLASS_REF, + "tag_name").size(30).prettyName("Tag Name").build(); public static final ClassField PAGETYPE_PROP_INLINE_EDITOR_MODE = new BooleanField.Builder( - CLASS_REF, "inline_editor").prettyName("Use Inline Editor Mode").displayType( - "yesno").build(); + CLASS_REF, "inline_editor").prettyName("Use Inline Editor Mode").displayType("yesno").build(); public PageTypePropertiesClass() { super(CLASS_REF); diff --git a/src/main/java/com/celements/pagetype/cmd/PageTypeCommand.java b/src/main/java/com/celements/pagetype/cmd/PageTypeCommand.java index e0208452d..e29693e7a 100644 --- a/src/main/java/com/celements/pagetype/cmd/PageTypeCommand.java +++ b/src/main/java/com/celements/pagetype/cmd/PageTypeCommand.java @@ -78,8 +78,8 @@ public BaseObject getPageTypeObject(XWikiDocument doc, XWikiContext context) { if ((doc != null) && doc.isNew()) { doc = getTemplateDoc(doc, context); } - if ((doc != null) && (doc.getObjects(PAGE_TYPE_CLASSNAME) != null) && (doc.getObjects( - PAGE_TYPE_CLASSNAME).size() > 0)) { + if ((doc != null) && (doc.getObjects(PAGE_TYPE_CLASSNAME) != null) + && (doc.getObjects(PAGE_TYPE_CLASSNAME).size() > 0)) { return doc.getObject(PAGE_TYPE_CLASSNAME); } return null; @@ -108,8 +108,8 @@ public String getPageTypeWithDefault(XWikiDocument doc, String defaultPageType, XWikiDocument getTemplateDoc(XWikiDocument doc, XWikiContext context) { if (context.getRequest() != null) { String templName = context.getRequest().get("template"); - if ((templName != null) && !"".equals(templName.trim()) && context.getWiki().exists(templName, - context)) { + if ((templName != null) && !"".equals(templName.trim()) + && context.getWiki().exists(templName, context)) { try { doc = context.getWiki().getDocument(templName, context); } catch (XWikiException e) { diff --git a/src/main/java/com/celements/pagetype/java/AbstractJavaPageType.java b/src/main/java/com/celements/pagetype/java/AbstractJavaPageType.java index f0571b8ad..d5fe1b883 100644 --- a/src/main/java/com/celements/pagetype/java/AbstractJavaPageType.java +++ b/src/main/java/com/celements/pagetype/java/AbstractJavaPageType.java @@ -40,9 +40,7 @@ public Set getCategoryNames() { if (categories.isEmpty()) { categories.add(defaultCategory); } - return categories.stream() - .map(IPageTypeCategoryRole::getAllTypeNames) - .flatMap(Set::stream) + return categories.stream().map(IPageTypeCategoryRole::getAllTypeNames).flatMap(Set::stream) .collect(Collectors.toSet()); } diff --git a/src/main/java/com/celements/pagetype/java/JavaPageTypeProvider.java b/src/main/java/com/celements/pagetype/java/JavaPageTypeProvider.java index ad9d99059..e87374f02 100644 --- a/src/main/java/com/celements/pagetype/java/JavaPageTypeProvider.java +++ b/src/main/java/com/celements/pagetype/java/JavaPageTypeProvider.java @@ -52,8 +52,7 @@ public List getPageTypes() { Map buildTypeRefsMap() { return javaPageTypes.stream().collect(toImmutableMap( - pt -> new PageTypeReference(pt.getName(), PROVIDER_HINT, pt.getCategoryNames()), - pt -> pt)); + pt -> new PageTypeReference(pt.getName(), PROVIDER_HINT, pt.getCategoryNames()), pt -> pt)); } @Override diff --git a/src/main/java/com/celements/pagetype/service/PageTypeResolverService.java b/src/main/java/com/celements/pagetype/service/PageTypeResolverService.java index 96306792a..c46a790fc 100644 --- a/src/main/java/com/celements/pagetype/service/PageTypeResolverService.java +++ b/src/main/java/com/celements/pagetype/service/PageTypeResolverService.java @@ -149,14 +149,13 @@ public PageTypeReference resolveDefaultPageTypeReference(EntityReference referen } PageTypeReference getDefaultPageTypeReference() { - return pageTypeService.getPageTypeReference(RichTextPageType.NAME).toJavaUtil() - .orElseThrow(); + return pageTypeService.getPageTypeReference(RichTextPageType.NAME).toJavaUtil().orElseThrow(); } @Override public Optional resolvePageTypeReference(XWikiDocument doc) { - return pageTypeService.getPageTypeReference(getPageTypeFetcher(doc).fetchField( - PageTypeClass.FIELD_PAGE_TYPE).first().or("")); + return pageTypeService.getPageTypeReference( + getPageTypeFetcher(doc).fetchField(PageTypeClass.FIELD_PAGE_TYPE).first().or("")); } @Override @@ -183,8 +182,8 @@ private XWikiObjectFetcher getPageTypeFetcher(XWikiDocument doc) { if (useTemplateDoc(doc)) { doc = webUtilsService.getWikiTemplateDoc(); } - XWikiObjectFetcher fetcher = XWikiObjectFetcher.on((doc.getTranslation() == 0) ? doc - : new XWikiDocument(doc.getDocumentReference())) + XWikiObjectFetcher fetcher = XWikiObjectFetcher + .on((doc.getTranslation() == 0) ? doc : new XWikiDocument(doc.getDocumentReference())) .filter(pageTypeClassDef); if (LOGGER.isTraceEnabled() && fetcher.exists()) { LOGGER.trace("getPageTypeFetcher - for [{}] with object [{}] details: {}", doc, @@ -196,8 +195,8 @@ private XWikiObjectFetcher getPageTypeFetcher(XWikiDocument doc) { } private boolean useTemplateDoc(XWikiDocument doc) { - return doc.isNew() && (context.getDoc() != null) && doc.getDocumentReference().equals( - context.getDoc().getDocumentReference()) + return doc.isNew() && (context.getDoc() != null) + && doc.getDocumentReference().equals(context.getDoc().getDocumentReference()) && (webUtilsService.getWikiTemplateDocRef() != null); } diff --git a/src/main/java/com/celements/pagetype/service/PageTypeService.java b/src/main/java/com/celements/pagetype/service/PageTypeService.java index 523a043a5..5284a4b21 100644 --- a/src/main/java/com/celements/pagetype/service/PageTypeService.java +++ b/src/main/java/com/celements/pagetype/service/PageTypeService.java @@ -79,19 +79,21 @@ private void loadTypeNameCategoryMaps() { synchronized (typeNameToCatCache) { if (typeNameToCatCache.isEmpty()) { for (IPageTypeCategoryRole typeCategory : pageTypeCategoryList) { - IPageTypeCategoryRole beforeRegCat = typeNameToCatCache.putIfAbsent( - typeCategory.getTypeName(), typeCategory); + IPageTypeCategoryRole beforeRegCat = typeNameToCatCache + .putIfAbsent(typeCategory.getTypeName(), typeCategory); if (beforeRegCat != null) { - LOGGER.warn("Page type category collision on category name '{}' the colliding" - + " category '{}' is shadowed by '{}'.", typeCategory.getTypeName(), - typeCategory.getClass(), beforeRegCat.getClass()); + LOGGER.warn( + "Page type category collision on category name '{}' the colliding" + + " category '{}' is shadowed by '{}'.", + typeCategory.getTypeName(), typeCategory.getClass(), beforeRegCat.getClass()); } for (String deprecateName : typeCategory.getAllTypeNames()) { beforeRegCat = typeNameToCatCacheDeprecated.putIfAbsent(deprecateName, typeCategory); if (beforeRegCat != null) { - LOGGER.warn("Page type category collision on deprecated category name '{}' the " - + "colliding category '{}' is shadowed by '{}'.", deprecateName, - typeCategory.getClass(), beforeRegCat.getClass()); + LOGGER.warn( + "Page type category collision on deprecated category name '{}' the " + + "colliding category '{}' is shadowed by '{}'.", + deprecateName, typeCategory.getClass(), beforeRegCat.getClass()); } } } @@ -165,8 +167,8 @@ public List getPageTypesConfigNamesForCategories(Set catList, for (PageTypeReference pageTypeRef : getPageTypeRefsForCategories(catList, onlyVisible)) { pageTypeConfigNameList.add(pageTypeRef.getConfigName()); } - LOGGER.debug("getPageTypesConfigNamesForCategories: return " + Arrays.deepToString( - pageTypeConfigNameList.toArray())); + LOGGER.debug("getPageTypesConfigNamesForCategories: return " + + Arrays.deepToString(pageTypeConfigNameList.toArray())); return pageTypeConfigNameList; } @@ -180,9 +182,9 @@ public List getPageTypeRefsForCategories(Set catList, visiblePTSet.add(pageTypeRef); } } - LOGGER.debug("getPageTypeRefsForCategories: for catList [" + Arrays.deepToString( - catList.toArray()) + "] and onlyVisible [" + onlyVisible + "] return " - + Arrays.deepToString(visiblePTSet.toArray())); + LOGGER.debug("getPageTypeRefsForCategories: for catList [" + + Arrays.deepToString(catList.toArray()) + "] and onlyVisible [" + onlyVisible + + "] return " + Arrays.deepToString(visiblePTSet.toArray())); return new ArrayList<>(visiblePTSet); } else { return new ArrayList<>(getPageTypeRefsForCategories(catList)); @@ -231,8 +233,9 @@ Set getPageTypeRefsForCategories(Set catList) { } } } - LOGGER.debug("getPageTypeRefsForCategories: for catList [" + Arrays.deepToString( - catList.toArray()) + "] return " + Arrays.deepToString(filteredPTset.toArray())); + LOGGER.debug( + "getPageTypeRefsForCategories: for catList [" + Arrays.deepToString(catList.toArray()) + + "] return " + Arrays.deepToString(filteredPTset.toArray())); return filteredPTset; } @@ -242,8 +245,8 @@ public boolean setPageType(XWikiDocument doc, PageTypeReference ref) { checkNotNull(ref); try { BaseObject obj = modelAccess.getOrCreateXObject(doc, pageTypeClassConf.getPageTypeClassRef()); - boolean hasChanged = !ref.getConfigName().equals(modelAccess.getProperty(obj, - IPageTypeClassConfig.PAGE_TYPE_FIELD)); + boolean hasChanged = !ref.getConfigName() + .equals(modelAccess.getProperty(obj, IPageTypeClassConfig.PAGE_TYPE_FIELD)); if (hasChanged) { modelAccess.setProperty(obj, IPageTypeClassConfig.PAGE_TYPE_FIELD, ref.getConfigName()); } diff --git a/src/main/java/com/celements/pagetype/xobject/XObjectPageTypeCacheListener.java b/src/main/java/com/celements/pagetype/xobject/XObjectPageTypeCacheListener.java index 0754d68cf..e20368d42 100644 --- a/src/main/java/com/celements/pagetype/xobject/XObjectPageTypeCacheListener.java +++ b/src/main/java/com/celements/pagetype/xobject/XObjectPageTypeCacheListener.java @@ -37,8 +37,7 @@ @Component("XObjectPageTypeCacheListener") public class XObjectPageTypeCacheListener implements EventListener { - private static final Logger LOGGER = LoggerFactory.getLogger( - XObjectPageTypeCacheListener.class); + private static final Logger LOGGER = LoggerFactory.getLogger(XObjectPageTypeCacheListener.class); @Requirement IXObjectPageTypeCacheRole pageTypeCache; diff --git a/src/main/java/com/celements/pagetype/xobject/XObjectPageTypeConfig.java b/src/main/java/com/celements/pagetype/xobject/XObjectPageTypeConfig.java index 08432e9f9..26d68c6c8 100644 --- a/src/main/java/com/celements/pagetype/xobject/XObjectPageTypeConfig.java +++ b/src/main/java/com/celements/pagetype/xobject/XObjectPageTypeConfig.java @@ -76,8 +76,8 @@ public List getCategories() { LOGGER.debug("getCategories for [" + getName() + "] empty List found returning" + " [\"\"]."); return Arrays.asList(""); } else { - LOGGER.debug("getCategories for [" + getName() + "] returning [" + Arrays.deepToString( - categories.toArray()) + "]"); + LOGGER.debug("getCategories for [" + getName() + "] returning [" + + Arrays.deepToString(categories.toArray()) + "]"); return categories; } } @@ -106,8 +106,8 @@ public String getRenderTemplateForRenderMode(String renderMode) { try { return pageType.getRenderTemplate(renderMode, getContext()); } catch (XWikiException exp) { - LOGGER.error("Failed to get render template for pageType [" + pageType.getConfigName( - getContext()) + "] and renderMode [" + renderMode + "].", exp); + LOGGER.error("Failed to get render template for pageType [" + + pageType.getConfigName(getContext()) + "] and renderMode [" + renderMode + "].", exp); } return null; } @@ -125,8 +125,8 @@ public boolean isVisible() { public boolean isUnconnectedParent() { BaseObject pageTypePropertiesObj = pageType.getPageTypeProperties(getContext()); if (pageTypePropertiesObj != null) { - return (pageTypePropertiesObj.getIntValue( - IPageTypeClassConfig.PAGETYPE_PROP_IS_UNCONNECTED_PARENT, 0) > 0); + return (pageTypePropertiesObj + .getIntValue(IPageTypeClassConfig.PAGETYPE_PROP_IS_UNCONNECTED_PARENT, 0) > 0); } return false; } @@ -135,8 +135,8 @@ public boolean isUnconnectedParent() { public boolean useInlineEditorMode() { BaseObject pageTypePropertiesObj = pageType.getPageTypeProperties(getContext()); if (pageTypePropertiesObj != null) { - return (pageTypePropertiesObj.getIntValue( - IPageTypeClassConfig.PAGETYPE_PROP_INLINE_EDITOR_MODE, 0) > 0); + return (pageTypePropertiesObj + .getIntValue(IPageTypeClassConfig.PAGETYPE_PROP_INLINE_EDITOR_MODE, 0) > 0); } return false; } @@ -145,8 +145,8 @@ public boolean useInlineEditorMode() { public Optional defaultTagName() { BaseObject pageTypePropertiesObj = pageType.getPageTypeProperties(getContext()); if (pageTypePropertiesObj != null) { - return Optional.fromNullable(Strings.emptyToNull(pageTypePropertiesObj.getStringValue( - IPageTypeClassConfig.PAGETYPE_PROP_TAG_NAME))); + return Optional.fromNullable(Strings.emptyToNull( + pageTypePropertiesObj.getStringValue(IPageTypeClassConfig.PAGETYPE_PROP_TAG_NAME))); } return Optional.absent(); } diff --git a/src/main/java/com/celements/pagetype/xobject/XObjectPageTypeProvider.java b/src/main/java/com/celements/pagetype/xobject/XObjectPageTypeProvider.java index 59c16437d..94b4bc505 100644 --- a/src/main/java/com/celements/pagetype/xobject/XObjectPageTypeProvider.java +++ b/src/main/java/com/celements/pagetype/xobject/XObjectPageTypeProvider.java @@ -78,8 +78,8 @@ public List getPageTypes() { } count = count + 1; long startMillis = System.currentTimeMillis(); - List pageTypeList = xobjectPageTypeCache.getPageTypesRefsForWiki( - webUtilsService.getWikiRef()); + List pageTypeList = xobjectPageTypeCache + .getPageTypesRefsForWiki(webUtilsService.getWikiRef()); getExecContext().setProperty(_CEL_XOBJ_GETALLPAGETYPES_COUNTER, count); if (LOGGER.isInfoEnabled()) { long endMillis = System.currentTimeMillis(); diff --git a/src/main/java/com/celements/pagetype/xobject/XObjectPageTypeUtils.java b/src/main/java/com/celements/pagetype/xobject/XObjectPageTypeUtils.java index 7cce81d62..eadd9e5b3 100644 --- a/src/main/java/com/celements/pagetype/xobject/XObjectPageTypeUtils.java +++ b/src/main/java/com/celements/pagetype/xobject/XObjectPageTypeUtils.java @@ -40,8 +40,8 @@ public class XObjectPageTypeUtils implements XObjectPageTypeUtilsRole { @Override @NotNull public DocumentReference getDocRefForPageType(@NotNull String configName) { - DocumentReference pageTypeDocRef = new DocumentReference(configName, new SpaceReference( - DEFAULT_PAGE_TYPES_SPACE, webUtilsService.getWikiRef())); + DocumentReference pageTypeDocRef = new DocumentReference(configName, + new SpaceReference(DEFAULT_PAGE_TYPES_SPACE, webUtilsService.getWikiRef())); return pageTypeDocRef; } diff --git a/src/main/java/com/celements/pagetype/xobject/listener/XObjectPageTypeDocumentCreatedListener.java b/src/main/java/com/celements/pagetype/xobject/listener/XObjectPageTypeDocumentCreatedListener.java index 17e2071f4..e26746136 100644 --- a/src/main/java/com/celements/pagetype/xobject/listener/XObjectPageTypeDocumentCreatedListener.java +++ b/src/main/java/com/celements/pagetype/xobject/listener/XObjectPageTypeDocumentCreatedListener.java @@ -43,8 +43,8 @@ public class XObjectPageTypeDocumentCreatedListener extends AbstractXObjectPageT public static final String NAME = "XObjectPageTypeDocumentCreatedListener"; - private static final Logger LOGGER = LoggerFactory.getLogger( - XObjectPageTypeDocumentCreatedListener.class); + private static final Logger LOGGER = LoggerFactory + .getLogger(XObjectPageTypeDocumentCreatedListener.class); @Requirement RemoteObservationManagerContext remoteObservationManagerContext; diff --git a/src/main/java/com/celements/pagetype/xobject/listener/XObjectPageTypeDocumentDeletedListener.java b/src/main/java/com/celements/pagetype/xobject/listener/XObjectPageTypeDocumentDeletedListener.java index ddd45c8f1..4d2b3f99d 100644 --- a/src/main/java/com/celements/pagetype/xobject/listener/XObjectPageTypeDocumentDeletedListener.java +++ b/src/main/java/com/celements/pagetype/xobject/listener/XObjectPageTypeDocumentDeletedListener.java @@ -43,8 +43,8 @@ public class XObjectPageTypeDocumentDeletedListener extends AbstractXObjectPageT public static final String NAME = "XObjectPageTypeDocumentDeletedListener"; - private static final Logger LOGGER = LoggerFactory.getLogger( - XObjectPageTypeDocumentDeletedListener.class); + private static final Logger LOGGER = LoggerFactory + .getLogger(XObjectPageTypeDocumentDeletedListener.class); @Requirement RemoteObservationManagerContext remoteObservationManagerContext; diff --git a/src/main/java/com/celements/pagetype/xobject/listener/XObjectPageTypeDocumentUpdatedListener.java b/src/main/java/com/celements/pagetype/xobject/listener/XObjectPageTypeDocumentUpdatedListener.java index dfc564d7e..a9fc452c4 100644 --- a/src/main/java/com/celements/pagetype/xobject/listener/XObjectPageTypeDocumentUpdatedListener.java +++ b/src/main/java/com/celements/pagetype/xobject/listener/XObjectPageTypeDocumentUpdatedListener.java @@ -47,8 +47,8 @@ public class XObjectPageTypeDocumentUpdatedListener extends AbstractXObjectPageT public static final String NAME = "XObjectPageTypeDocumentUpdatedListener"; - private static final Logger LOGGER = LoggerFactory.getLogger( - XObjectPageTypeDocumentUpdatedListener.class); + private static final Logger LOGGER = LoggerFactory + .getLogger(XObjectPageTypeDocumentUpdatedListener.class); @Requirement RemoteObservationManagerContext remoteObservationManagerContext; diff --git a/src/main/java/com/celements/parents/DocumentParentsLister.java b/src/main/java/com/celements/parents/DocumentParentsLister.java index 4b8ed3232..06fb1cf77 100644 --- a/src/main/java/com/celements/parents/DocumentParentsLister.java +++ b/src/main/java/com/celements/parents/DocumentParentsLister.java @@ -111,8 +111,8 @@ private boolean setSecondaryParent(List parents) private List checkPageTypes(List parents) { List ret = new ArrayList<>(); for (DocumentReference parent : parents) { - IPageTypeConfig pageTypeConf = pageTypeProvider.getPageTypeByReference( - pageTypeResolver.getPageTypeRefForDocWithDefault(parent)); + IPageTypeConfig pageTypeConf = pageTypeProvider + .getPageTypeByReference(pageTypeResolver.getPageTypeRefForDocWithDefault(parent)); if (pageTypeConf.isUnconnectedParent()) { ret.add(parent); } diff --git a/src/main/java/com/celements/rendering/RenderCommand.java b/src/main/java/com/celements/rendering/RenderCommand.java index dc4a17252..9a631a18f 100644 --- a/src/main/java/com/celements/rendering/RenderCommand.java +++ b/src/main/java/com/celements/rendering/RenderCommand.java @@ -100,8 +100,8 @@ public String renderCelementsCell(DocumentReference elemDocRef) throws XWikiExce */ @Deprecated public String renderCelementsCell(String elementFullName) throws XWikiException { - XWikiDocument cellDoc = getModelAccess().getOrCreateDocument(getModelUtils() - .resolveRef(elementFullName, DocumentReference.class)); + XWikiDocument cellDoc = getModelAccess() + .getOrCreateDocument(getModelUtils().resolveRef(elementFullName, DocumentReference.class)); return renderCelementsDocument(cellDoc, "view"); } @@ -113,8 +113,7 @@ public String renderCelementsDocument(DocumentReference elemDocRef, String rende public String renderCelementsDocumentPreserveVelocityContext(DocumentReference elementDocRef, String lang, String renderMode) throws XWikiException { VelocityContext vContext = (VelocityContext) getVeloCtx().clone(); - return new Contextualiser() - .withXWikiContext("vcontext", vContext) + return new Contextualiser().withXWikiContext("vcontext", vContext) .withExecContext("velocityContext", vContext) .execute(rethrow(() -> renderCelementsDocument(elementDocRef, lang, renderMode))); } @@ -134,14 +133,12 @@ public String renderCelementsDocument(XWikiDocument cellDoc, String lang, String throws XWikiException { LOGGER.debug("renderCelementsDocument: cellDoc [{}] lang [{}] renderMode [{}].", cellDoc.getDocumentReference(), lang, renderMode); - String cellDocFN = getModelUtils().serializeRef( - cellDoc.getDocumentReference()); + String cellDocFN = getModelUtils().serializeRef(cellDoc.getDocumentReference()); if ((getContext() != null) && (getContext().get("vcontext") != null) && getContext().getWiki().getRightService().hasAccessLevel(renderMode, getContext().getUser(), cellDocFN, getContext())) { String template = getRenderTemplatePath(cellDoc, renderMode); - return new Contextualiser() - .withVeloContext("celldoc", cellDoc.newDocument(getContext())) + return new Contextualiser().withVeloContext("celldoc", cellDoc.newDocument(getContext())) .execute(rethrow(() -> renderTemplatePath(cellDoc, template, lang, ""))); } else { if ((getContext() == null) || (getContext().get("vcontext") == null)) { @@ -157,8 +154,8 @@ public String renderTemplatePath(String renderTemplatePath, String lang, String return renderTemplatePath(getContext().getDoc(), renderTemplatePath, lang, defLang); } - public String renderTemplatePath(XWikiDocument cellDoc, String renderTemplatePath, - String lang, String defLang) throws XWikiException { + public String renderTemplatePath(XWikiDocument cellDoc, String renderTemplatePath, String lang, + String defLang) throws XWikiException { String renderedContent = ""; String templateContent; Optional templateDoc = getTemplateDoc(renderTemplatePath); @@ -183,8 +180,8 @@ public String renderTemplatePath(XWikiDocument cellDoc, String renderTemplatePat private Optional getTemplateDoc(String renderTemplatePath) { if (!renderTemplatePath.startsWith(":")) { - return getModelAccess().getDocumentOpt(getModelUtils().resolveRef( - renderTemplatePath, DocumentReference.class)); + return getModelAccess() + .getDocumentOpt(getModelUtils().resolveRef(renderTemplatePath, DocumentReference.class)); } return Optional.empty(); } @@ -304,13 +301,12 @@ String getTemplatePathOnDisk(String renderTemplatePath, String lang) { String getRenderTemplatePath(XWikiDocument cellDoc, String renderMode) { String cellDocFN = getModelUtils().serializeRef(cellDoc.getDocumentReference()); - return Optional.ofNullable(getPageTypeResolver() - .resolvePageTypeReference(cellDoc).toJavaUtil() - .orElse(defaultPageTypeRef)) + return Optional + .ofNullable(getPageTypeResolver().resolvePageTypeReference(cellDoc).toJavaUtil() + .orElse(defaultPageTypeRef)) .map(getPageTypeService()::getPageTypeConfigForPageTypeRef) .map(cellType -> cellType.getRenderTemplateForRenderMode(renderMode)) - .filter(not(String::isEmpty)) - .orElse(cellDocFN); + .filter(not(String::isEmpty)).orElse(cellDocFN); } private VelocityContext getVeloCtx() { diff --git a/src/main/java/com/celements/rights/publication/PublicationService.java b/src/main/java/com/celements/rights/publication/PublicationService.java index 4ecbdcbf6..7ffc29ea4 100644 --- a/src/main/java/com/celements/rights/publication/PublicationService.java +++ b/src/main/java/com/celements/rights/publication/PublicationService.java @@ -113,9 +113,9 @@ DocumentReference getPublicationClassReference() { } DocumentReference getPublicationClassReference(EntityReference entityRef) { - return ((DocumentDetailsClasses) documentDetailsClasses).getDocumentPublicationClassRef( - References.extractRef(entityRef, WikiReference.class).or( - modelContext.getWikiRef()).getName()); + return ((DocumentDetailsClasses) documentDetailsClasses) + .getDocumentPublicationClassRef(References.extractRef(entityRef, WikiReference.class) + .or(modelContext.getWikiRef()).getName()); } @Override diff --git a/src/main/java/com/celements/sajson/AbstractEventHandler.java b/src/main/java/com/celements/sajson/AbstractEventHandler.java index d31146e1e..fdcfaaa8d 100644 --- a/src/main/java/com/celements/sajson/AbstractEventHandler.java +++ b/src/main/java/com/celements/sajson/AbstractEventHandler.java @@ -36,8 +36,8 @@ public void stringEvent(String value) { @Override public void booleanEvent(boolean value) { - throw new IllegalArgumentException("received unsupported booleanEvent (value: [" + value - + "]."); + throw new IllegalArgumentException( + "received unsupported booleanEvent (value: [" + value + "]."); } } diff --git a/src/main/java/com/celements/sajson/JsonBuilder.java b/src/main/java/com/celements/sajson/JsonBuilder.java index cc7db7dfb..dc98f6f78 100644 --- a/src/main/java/com/celements/sajson/JsonBuilder.java +++ b/src/main/java/com/celements/sajson/JsonBuilder.java @@ -41,11 +41,8 @@ public class JsonBuilder { private static final Map JSON_REPLACEMENTS = ImmutableMap.of( - Pattern.compile("\\\\"), "\\\\\\\\", - Pattern.compile("\""), "\\\\\"", - Pattern.compile("\n"), "\\\\n", - Pattern.compile("\r"), "\\\\r", - Pattern.compile("\t"), "\\\\t"); + Pattern.compile("\\\\"), "\\\\\\\\", Pattern.compile("\""), "\\\\\"", Pattern.compile("\n"), + "\\\\n", Pattern.compile("\r"), "\\\\r", Pattern.compile("\t"), "\\\\t"); private final Deque commandStack; private final StringBuilder json; @@ -140,8 +137,8 @@ public void closeDictionary() { } public void openProperty(String key) { - checkState(commandStack.peek() == DICTIONARY_COMMAND, format("cannot open property on {0}", - commandStack.peek())); + checkState(commandStack.peek() == DICTIONARY_COMMAND, + format("cannot open property on {0}", commandStack.peek())); commandStack.push(PROPERTY_COMMAND); addOpeningPart(toJsonString(key) + " : "); onFirstElement = true; @@ -198,9 +195,7 @@ String toJsonString(Object value) { } private boolean applyJsonReplacements(Object value) { - return (value != null) - && !(value instanceof Boolean) - && !(value instanceof Number) + return (value != null) && !(value instanceof Boolean) && !(value instanceof Number) && !(value instanceof JsonBuilder); } diff --git a/src/main/java/com/celements/sajson/LexicalParser.java b/src/main/java/com/celements/sajson/LexicalParser.java index 533c0692f..321696dd0 100644 --- a/src/main/java/com/celements/sajson/LexicalParser.java +++ b/src/main/java/com/celements/sajson/LexicalParser.java @@ -139,8 +139,8 @@ public void booleanEvent(boolean value) { @Override final public void finishEvent() { if (!workerStack.isEmpty()) { - throw new IllegalStateException("SyntaxError: finishEvent on nonempty" + " stack:" - + workerStack.peek()); + throw new IllegalStateException( + "SyntaxError: finishEvent on nonempty" + " stack:" + workerStack.peek()); } } @@ -151,9 +151,9 @@ final private void checkStackState(ECommand expectedCommand) { LOGGER.debug("reopen " + workerStack.peek() + " ; " + workerStack.peek().getCommand()); } if (workerStack.isEmpty() || (workerStack.peek().getCommand() != expectedCommand)) { - throw new IllegalStateException("Expecting: " + workerStack.peek().getCommand() + " for " - + workerStack.peek() + " but received " + expectedCommand + ". " + "Stack: " - + workerStack.toString()); + throw new IllegalStateException( + "Expecting: " + workerStack.peek().getCommand() + " for " + workerStack.peek() + + " but received " + expectedCommand + ". " + "Stack: " + workerStack.toString()); } } diff --git a/src/main/java/com/celements/validation/FormValidationService.java b/src/main/java/com/celements/validation/FormValidationService.java index 4ca573e39..4149a08ef 100644 --- a/src/main/java/com/celements/validation/FormValidationService.java +++ b/src/main/java/com/celements/validation/FormValidationService.java @@ -62,8 +62,7 @@ public class FormValidationService implements IFormValidationServiceRole { @Requirement private ModelContext context; - void injectValidationRules( - Map requestValidationRules, + void injectValidationRules(Map requestValidationRules, Map legacyRequestValidationRules, Map fieldValidationRules) { this.requestValidationRules = requestValidationRules; @@ -80,12 +79,11 @@ public Map>> validateRequest() { public Map>> validateMap( Map requestMap) { Map>> ret = new HashMap<>(); - DocFormRequestKeyParser parser = new DocFormRequestKeyParser(context.getDocRef() - .orElseThrow(IllegalStateException::new)); + DocFormRequestKeyParser parser = new DocFormRequestKeyParser( + context.getDocRef().orElseThrow(IllegalStateException::new)); for (ValidationResult v : validate(parser.parseParameterMap(requestMap))) { ret.computeIfAbsent(v.getName(), k -> new EnumMap<>(ValidationType.class)) - .computeIfAbsent(v.getType(), k -> new HashSet<>()) - .add(v.getMessage()); + .computeIfAbsent(v.getType(), k -> new HashSet<>()).add(v.getMessage()); } return ret; } @@ -102,16 +100,15 @@ public List validate(List params) { } private List validateLegacy(List params) { - Map paramMap = StreamEx.of(params).mapToEntry( - p -> RequestParameter.create(p.getKey().getKeyString()), - p -> p.getValues().toArray(new String[0])) - .filterKeys(Objects::nonNull) - .toImmutableMap(); + Map paramMap = StreamEx.of(params) + .mapToEntry(p -> RequestParameter.create(p.getKey().getKeyString()), + p -> p.getValues().toArray(new String[0])) + .filterKeys(Objects::nonNull).toImmutableMap(); List ret = new ArrayList<>(); for (IRequestValidationRuleRole validationRule : legacyRequestValidationRules.values()) { LOGGER.trace("validateLegacy - for rule: {}", validationRule); - validationRule.validateRequest(paramMap).forEach((name, x) -> x.forEach((type, msgs) -> msgs - .forEach(msg -> ret.add(new ValidationResult(type, name, msg))))); + validationRule.validateRequest(paramMap).forEach((name, x) -> x.forEach( + (type, msgs) -> msgs.forEach(msg -> ret.add(new ValidationResult(type, name, msg))))); } LOGGER.debug("validateLegacy - params [{}], result [{}]", paramMap, ret); return ret; diff --git a/src/main/java/com/celements/validation/IFormValidationServiceRole.java b/src/main/java/com/celements/validation/IFormValidationServiceRole.java index f1d9ddb92..75d1178f6 100644 --- a/src/main/java/com/celements/validation/IFormValidationServiceRole.java +++ b/src/main/java/com/celements/validation/IFormValidationServiceRole.java @@ -53,8 +53,7 @@ public interface IFormValidationServiceRole { * @return map [KEY = request field-name / VALUE = map [KEY = validation type / VALUE = * set of validation messages (dictionary keys possible)]] */ - Map>> validateMap( - Map requestMap); + Map>> validateMap(Map requestMap); /** * validateField validates the given class name, field name and value for all @@ -66,7 +65,6 @@ Map>> validateMap( * @return map [KEY = validation type / VALUE = set of validation messages (dictionary * keys possible)]] */ - Map> validateField(String className, String fieldName, - String value); + Map> validateField(String className, String fieldName, String value); } diff --git a/src/main/java/com/celements/validation/IRequestValidationRuleRole.java b/src/main/java/com/celements/validation/IRequestValidationRuleRole.java index 3ad91c6e8..535725bf4 100644 --- a/src/main/java/com/celements/validation/IRequestValidationRuleRole.java +++ b/src/main/java/com/celements/validation/IRequestValidationRuleRole.java @@ -26,7 +26,6 @@ /** * @deprecated instead use {@link IRequestValidationRule} - * */ @Deprecated @ComponentRole diff --git a/src/main/java/com/celements/validation/XClassRegexRule.java b/src/main/java/com/celements/validation/XClassRegexRule.java index f0f0d1760..d18fa5790 100644 --- a/src/main/java/com/celements/validation/XClassRegexRule.java +++ b/src/main/java/com/celements/validation/XClassRegexRule.java @@ -109,16 +109,16 @@ public Map> validateField(String className, String f } LOGGER.warn("invalid class/field key '{}'", className + "." + fieldName); } - LOGGER.trace("Returning validation map for field '{}' and value '{}': {}", className + "." - + fieldName, value, ret); + LOGGER.trace("Returning validation map for field '{}' and value '{}': {}", + className + "." + fieldName, value, ret); return ret; } private PropertyClass getBaseClassProperty(String className, String fieldName) { PropertyClass propertyClass = null; try { - BaseClass bclass = getContext().getWiki().getDocument(webUtils.resolveDocumentReference( - className), getContext()).getXClass(); + BaseClass bclass = getContext().getWiki() + .getDocument(webUtils.resolveDocumentReference(className), getContext()).getXClass(); if (bclass != null) { propertyClass = (PropertyClass) bclass.getField(fieldName); } diff --git a/src/main/java/com/celements/velocity/DefaultVelocityService.java b/src/main/java/com/celements/velocity/DefaultVelocityService.java index ac15f8169..75ce458c8 100644 --- a/src/main/java/com/celements/velocity/DefaultVelocityService.java +++ b/src/main/java/com/celements/velocity/DefaultVelocityService.java @@ -74,8 +74,7 @@ public String evaluateVelocityText(String text) throws XWikiVelocityException { public String evaluateVelocityText(String text, VelocityContextModifier contextModifier) throws XWikiVelocityException { return context.getCurrentDoc().toJavaUtil() - .map(rethrowFunction(doc -> evaluateVelocityText(doc, text, contextModifier))) - .orElse(""); + .map(rethrowFunction(doc -> evaluateVelocityText(doc, text, contextModifier))).orElse(""); } @Override diff --git a/src/main/java/com/celements/web/FileAction.java b/src/main/java/com/celements/web/FileAction.java index 199897ec5..3e4331377 100644 --- a/src/main/java/com/celements/web/FileAction.java +++ b/src/main/java/com/celements/web/FileAction.java @@ -188,8 +188,8 @@ public String render(String path, XWikiContext context) throws XWikiException, I private boolean renderSkin(String filename, XWikiDocument doc, XWikiContext context) throws XWikiException, IOException { if (_Logger.isDebugEnabled()) { - _Logger.debug("Rendering file '" + filename + "' within the '" + doc.getFullName() - + "' document"); + _Logger.debug( + "Rendering file '" + filename + "' within the '" + doc.getFullName() + "' document"); } try { if (doc.isNew()) { @@ -197,8 +197,9 @@ private boolean renderSkin(String filename, XWikiDocument doc, XWikiContext cont _Logger.debug(doc.getName() + " is not a document"); } } else { - return renderFileFromObjectField(filename, doc, context) || renderFileFromAttachment( - filename, doc, context) || (SKINS_DIRECTORY.equals(doc.getSpace()) + return renderFileFromObjectField(filename, doc, context) + || renderFileFromAttachment(filename, doc, context) + || (SKINS_DIRECTORY.equals(doc.getSpace()) && renderFileFromFilesystem(getSkinFilePath(filename, doc.getName()), context)); } } catch (IOException e) { diff --git a/src/main/java/com/celements/web/classcollections/DocumentDetailsClasses.java b/src/main/java/com/celements/web/classcollections/DocumentDetailsClasses.java index 04a0cff85..77b525832 100644 --- a/src/main/java/com/celements/web/classcollections/DocumentDetailsClasses.java +++ b/src/main/java/com/celements/web/classcollections/DocumentDetailsClasses.java @@ -66,8 +66,8 @@ BaseClass getDocumentPublicationClass() throws XWikiException { bclass.setXClassReference(classRef); needsUpdate |= bclass.addDateField(PUBLISH_DATE_FIELD, "Publish Date (dd.MM.yyyy HH:mm)", "dd.MM.yyyy HH:mm", 0); - needsUpdate |= bclass.addDateField(UNPUBLISH_DATE_FIELD, "Unpublish Date (dd.MM.yyyy " - + "HH:mm)", "dd.MM.yyyy HH:mm", 0); + needsUpdate |= bclass.addDateField(UNPUBLISH_DATE_FIELD, + "Unpublish Date (dd.MM.yyyy " + "HH:mm)", "dd.MM.yyyy HH:mm", 0); if (!"internal".equals(bclass.getCustomMapping())) { needsUpdate = true; diff --git a/src/main/java/com/celements/web/classcollections/IOldCoreClassConfig.java b/src/main/java/com/celements/web/classcollections/IOldCoreClassConfig.java index 179ce694d..92deda14b 100644 --- a/src/main/java/com/celements/web/classcollections/IOldCoreClassConfig.java +++ b/src/main/java/com/celements/web/classcollections/IOldCoreClassConfig.java @@ -13,16 +13,14 @@ public interface IOldCoreClassConfig { String PHOTO_ALBUM_CLASS_DOC = "PhotoAlbumClass"; String PHOTO_ALBUM_CLASS_SPACE = "XWiki"; - String PHOTO_ALBUM_CLASS = PHOTO_ALBUM_CLASS_SPACE + "." - + PHOTO_ALBUM_CLASS_DOC; + String PHOTO_ALBUM_CLASS = PHOTO_ALBUM_CLASS_SPACE + "." + PHOTO_ALBUM_CLASS_DOC; String PHOTO_ALBUM_TITLE = "title"; String PHOTO_ALBUM_DESCRIPTION = "description"; String PHOTO_ALBUM_GALLERY_LAYOUT = "galleryLayout"; String XWIKI_USERS_CLASS_DOC = "XWikiUsers"; String XWIKI_USERS_CLASS_SPACE = "XWiki"; - String XWIKI_USERS_CLASS = XWIKI_USERS_CLASS_SPACE + "." - + XWIKI_USERS_CLASS_DOC; + String XWIKI_USERS_CLASS = XWIKI_USERS_CLASS_SPACE + "." + XWIKI_USERS_CLASS_DOC; String XWIKI_PREFERENCES_CLASS_DOC = "XWikiPreferences"; String XWIKI_PREFERENCES_CLASS_SPACE = "XWiki"; @@ -36,13 +34,11 @@ public interface IOldCoreClassConfig { String FILEBASE_TAG_CLASS_DOC = "FilebaseTag"; String FILEBASE_TAG_CLASS_SPACE = "Classes"; - String FILEBASE_TAG_CLASS = FILEBASE_TAG_CLASS_SPACE + "." - + FILEBASE_TAG_CLASS_DOC; + String FILEBASE_TAG_CLASS = FILEBASE_TAG_CLASS_SPACE + "." + FILEBASE_TAG_CLASS_DOC; String RTE_CONFIG_TYPE_CLASS_DOC = "RTEConfigTypeClass"; String RTE_CONFIG_TYPE_CLASS_SPACE = "Classes"; - String RTE_CONFIG_TYPE_CLASS = RTE_CONFIG_TYPE_CLASS_SPACE + "." - + RTE_CONFIG_TYPE_CLASS_DOC; + String RTE_CONFIG_TYPE_CLASS = RTE_CONFIG_TYPE_CLASS_SPACE + "." + RTE_CONFIG_TYPE_CLASS_DOC; @Deprecated String KEY_VALUE_CLASS_DOC = KeyValueClass.DOC_NAME; @@ -57,13 +53,11 @@ public interface IOldCoreClassConfig { String OVERLAY_CONFIG_CLASS_DOC = "OverlayConfigClass"; String OVERLAY_CONFIG_CLASS_SPACE = "Classes"; - String OVERLAY_CONFIG_CLASS = OVERLAY_CONFIG_CLASS_SPACE + "." - + OVERLAY_CONFIG_CLASS_DOC; + String OVERLAY_CONFIG_CLASS = OVERLAY_CONFIG_CLASS_SPACE + "." + OVERLAY_CONFIG_CLASS_DOC; String PANEL_CONFIG_CLASS_DOC = "PanelConfigClass"; String PANEL_CONFIG_CLASS_SPACE = "Class"; - String PANEL_CONFIG_CLASS = PANEL_CONFIG_CLASS_SPACE + "." - + PANEL_CONFIG_CLASS_DOC; + String PANEL_CONFIG_CLASS = PANEL_CONFIG_CLASS_SPACE + "." + PANEL_CONFIG_CLASS_DOC; String FORM_MAIL_CLASS_DOC = "FormMailClass"; String FORM_MAIL_CLASS_SPACE = "Celements2"; @@ -71,8 +65,7 @@ public interface IOldCoreClassConfig { String FORM_ACTION_CLASS_DOC = "FormActionClass"; String FORM_ACTION_CLASS_SPACE = "Celements2"; - String FORM_ACTION_CLASS = FORM_ACTION_CLASS_SPACE + "." - + FORM_ACTION_CLASS_DOC; + String FORM_ACTION_CLASS = FORM_ACTION_CLASS_SPACE + "." + FORM_ACTION_CLASS_DOC; @Deprecated /** @@ -88,28 +81,23 @@ public interface IOldCoreClassConfig { /** * @deprecated since 3.8, instead use com.celements.form.classes.FormConfigClass.CLASS_DEF_HINT */ - String FORM_CONFIG_CLASS = FORM_CONFIG_CLASS_SPACE + "." - + FORM_CONFIG_CLASS_DOC; + String FORM_CONFIG_CLASS = FORM_CONFIG_CLASS_SPACE + "." + FORM_CONFIG_CLASS_DOC; String ACTION_TYPE_CLASS_DOC = "ActionTypeClass"; String ACTION_TYPE_CLASS_SPACE = "Celements2"; - String ACTION_TYPE_CLASS = ACTION_TYPE_CLASS_SPACE + "." - + ACTION_TYPE_CLASS_DOC; + String ACTION_TYPE_CLASS = ACTION_TYPE_CLASS_SPACE + "." + ACTION_TYPE_CLASS_DOC; String ACTION_TYPE_PROP_CLASS_DOC = "ActionTypeProperties"; String ACTION_TYPE_PROP_CLASS_SPACE = "Celements2"; - String ACTION_TYPE_PROP_CLASS = ACTION_TYPE_PROP_CLASS_SPACE + "." - + ACTION_TYPE_PROP_CLASS_DOC; + String ACTION_TYPE_PROP_CLASS = ACTION_TYPE_PROP_CLASS_SPACE + "." + ACTION_TYPE_PROP_CLASS_DOC; String FORM_STORAGE_CLASS_DOC = "FormStorageClass"; String FORM_STORAGE_CLASS_SPACE = "Celements2"; - String FORM_STORAGE_CLASS = FORM_STORAGE_CLASS_SPACE + "." - + FORM_STORAGE_CLASS_DOC; + String FORM_STORAGE_CLASS = FORM_STORAGE_CLASS_SPACE + "." + FORM_STORAGE_CLASS_DOC; String RECEIVER_EMAIL_CLASS_DOC = "ReceiverEMail"; String RECEIVER_EMAIL_CLASS_SPACE = "Celements2"; - String RECEIVER_EMAIL_CLASS = RECEIVER_EMAIL_CLASS_SPACE + "." - + RECEIVER_EMAIL_CLASS_DOC; + String RECEIVER_EMAIL_CLASS = RECEIVER_EMAIL_CLASS_SPACE + "." + RECEIVER_EMAIL_CLASS_DOC; String USER_CSS_CLASS_DOC = "UserCSS"; String USER_CSS_CLASS_SPACE = "Skins"; @@ -129,8 +117,8 @@ public interface IOldCoreClassConfig { * @deprecated since 5.4, instead use {@link JavaScriptExternalFilesClass#CLASS_DEF_HINT} */ @Deprecated - String JAVA_SCRIPTS_EXTERNAL_FILES_CLASS = JAVA_SCRIPTS_EXTERNAL_FILES_CLASS_SPACE - + "." + JAVA_SCRIPTS_EXTERNAL_FILES_CLASS_DOC; + String JAVA_SCRIPTS_EXTERNAL_FILES_CLASS = JAVA_SCRIPTS_EXTERNAL_FILES_CLASS_SPACE + "." + + JAVA_SCRIPTS_EXTERNAL_FILES_CLASS_DOC; DocumentReference getFromStorageClassRef(WikiReference wikiRef); diff --git a/src/main/java/com/celements/web/classcollections/OldCoreClassConfig.java b/src/main/java/com/celements/web/classcollections/OldCoreClassConfig.java index 2a5e3ac22..a5d4de3d5 100644 --- a/src/main/java/com/celements/web/classcollections/OldCoreClassConfig.java +++ b/src/main/java/com/celements/web/classcollections/OldCoreClassConfig.java @@ -30,14 +30,14 @@ public class OldCoreClassConfig implements IOldCoreClassConfig { @Override public DocumentReference getFromStorageClassRef(WikiReference wikiRef) { - return new DocumentReference(FORM_STORAGE_CLASS_DOC, new SpaceReference( - FORM_STORAGE_CLASS_SPACE, wikiRef)); + return new DocumentReference(FORM_STORAGE_CLASS_DOC, + new SpaceReference(FORM_STORAGE_CLASS_SPACE, wikiRef)); } @Override public DocumentReference getXWikiUsersClassRef(WikiReference wikiRef) { - return new DocumentReference(XWIKI_USERS_CLASS_DOC, new SpaceReference(XWIKI_USERS_CLASS_SPACE, - wikiRef)); + return new DocumentReference(XWIKI_USERS_CLASS_DOC, + new SpaceReference(XWIKI_USERS_CLASS_SPACE, wikiRef)); } @Override diff --git a/src/main/java/com/celements/web/classes/DocumentExtractClass.java b/src/main/java/com/celements/web/classes/DocumentExtractClass.java index b03499fdd..c0d312844 100644 --- a/src/main/java/com/celements/web/classes/DocumentExtractClass.java +++ b/src/main/java/com/celements/web/classes/DocumentExtractClass.java @@ -9,16 +9,16 @@ import com.celements.model.classes.fields.StringField; @Component(DocumentExtractClass.NAME) -public class DocumentExtractClass extends AbstractClassDefinition implements - CelementsClassDefinition { +public class DocumentExtractClass extends AbstractClassDefinition + implements CelementsClassDefinition { public static final String SPACE_NAME = "Classes"; public static final String DOC_NAME = "DocumentExtract"; public static final String NAME = SPACE_NAME + "." + DOC_NAME; public static final ClassReference CLASS_REF = new ClassReference(SPACE_NAME, DOC_NAME); - public static final ClassField FIELD_LANG = new StringField.Builder(NAME, - "language").build(); + public static final ClassField FIELD_LANG = new StringField.Builder(NAME, "language") + .build(); public static final ClassField FIELD_EXTRACT = new LargeStringField.Builder(NAME, "extract").build(); diff --git a/src/main/java/com/celements/web/classes/KeyValueClass.java b/src/main/java/com/celements/web/classes/KeyValueClass.java index 80838708c..4b2b1bb61 100644 --- a/src/main/java/com/celements/web/classes/KeyValueClass.java +++ b/src/main/java/com/celements/web/classes/KeyValueClass.java @@ -18,14 +18,14 @@ public class KeyValueClass extends AbstractClassDefinition implements CelementsC public static final String CLASS_DEF_HINT = SPACE_NAME + "." + DOC_NAME; public static final ClassReference CLASS_REF = new ClassReference(SPACE_NAME, DOC_NAME); - public static final ClassField FIELD_LABEL = new StringField.Builder( - CLASS_REF, "label").build(); + public static final ClassField FIELD_LABEL = new StringField.Builder(CLASS_REF, "label") + .build(); - public static final ClassField FIELD_KEY = new StringField.Builder( - CLASS_REF, "key").build(); + public static final ClassField FIELD_KEY = new StringField.Builder(CLASS_REF, "key") + .build(); - public static final ClassField FIELD_VALUE = new StringField.Builder( - CLASS_REF, "value").build(); + public static final ClassField FIELD_VALUE = new StringField.Builder(CLASS_REF, "value") + .build(); public KeyValueClass() { super(CLASS_REF); diff --git a/src/main/java/com/celements/web/classes/MetaTagClass.java b/src/main/java/com/celements/web/classes/MetaTagClass.java index 1f71f7b4f..d0bedbf7f 100644 --- a/src/main/java/com/celements/web/classes/MetaTagClass.java +++ b/src/main/java/com/celements/web/classes/MetaTagClass.java @@ -36,8 +36,8 @@ public class MetaTagClass extends AbstractClassDefinition implements CelementsCl public static final String CLASS_DEF_HINT = SPACE_NAME + "." + DOC_NAME; public static final ClassReference CLASS_REF = new ClassReference(SPACE_NAME, DOC_NAME); - public static final ClassField FIELD_KEY = new StringField.Builder(CLASS_DEF_HINT, - "key").size(30).build(); + public static final ClassField FIELD_KEY = new StringField.Builder(CLASS_DEF_HINT, "key") + .size(30).build(); public static final ClassField FIELD_VALUE = new LargeStringField.Builder(CLASS_DEF_HINT, "value").rows(15).size(80).build(); diff --git a/src/main/java/com/celements/web/classes/helper/CssMediaType.java b/src/main/java/com/celements/web/classes/helper/CssMediaType.java index 3bd96ca67..5fdc91b74 100644 --- a/src/main/java/com/celements/web/classes/helper/CssMediaType.java +++ b/src/main/java/com/celements/web/classes/helper/CssMediaType.java @@ -20,8 +20,17 @@ package com.celements.web.classes.helper; public enum CssMediaType { - ALL("all"), AURAL("aural"), BRAILLE("braille"), EMBOSSED("embossed"), HANDHELD("handheld"), PRINT( - "print"), PROJECTION("projection"), SCREEN("screen"), TTY("tty"), TV("tv"); + + ALL("all"), + AURAL("aural"), + BRAILLE("braille"), + EMBOSSED("embossed"), + HANDHELD("handheld"), + PRINT("print"), + PROJECTION("projection"), + SCREEN("screen"), + TTY("tty"), + TV("tv"); private final String mediaType; diff --git a/src/main/java/com/celements/web/comparators/AttachmentAscendingNameComparator.java b/src/main/java/com/celements/web/comparators/AttachmentAscendingNameComparator.java index 8728a37b2..8d5a1f299 100644 --- a/src/main/java/com/celements/web/comparators/AttachmentAscendingNameComparator.java +++ b/src/main/java/com/celements/web/comparators/AttachmentAscendingNameComparator.java @@ -32,7 +32,7 @@ public class AttachmentAscendingNameComparator implements Comparator */ @Override public int compare(Attachment attachmentOne, Attachment attachmentTwo) { - return attachmentOne.getFilename().toLowerCase().replace('_', '-').compareTo( - attachmentTwo.getFilename().toLowerCase().replace('_', '-')); + return attachmentOne.getFilename().toLowerCase().replace('_', '-') + .compareTo(attachmentTwo.getFilename().toLowerCase().replace('_', '-')); } } diff --git a/src/main/java/com/celements/web/comparators/AttachmentDescendingNameComparator.java b/src/main/java/com/celements/web/comparators/AttachmentDescendingNameComparator.java index fcc68d610..86cfe4f2c 100644 --- a/src/main/java/com/celements/web/comparators/AttachmentDescendingNameComparator.java +++ b/src/main/java/com/celements/web/comparators/AttachmentDescendingNameComparator.java @@ -32,7 +32,7 @@ public class AttachmentDescendingNameComparator implements Comparator create(String orderField, boolean asc) { } public static Optional> create(Collection orderFields) { - return orderFields.stream() - .map(String::trim).filter(not(String::isEmpty)) + return orderFields.stream().map(String::trim).filter(not(String::isEmpty)) .map(sort -> create(sort.replaceFirst("-", ""), !sort.startsWith("-"))) .reduce((c1, c2) -> c1.thenComparing(c2)); } @@ -66,15 +65,12 @@ public String getOrderField() { @Override public int compare(BaseObject obj1, BaseObject obj2) { - return valueComparator.compare( - getProperty(obj1, orderField).getValue(), + return valueComparator.compare(getProperty(obj1, orderField).getValue(), getProperty(obj2, orderField).getValue()); } BaseProperty getProperty(BaseObject obj, String field) { - return Optional.ofNullable(obj) - .map(o -> o.getField(field)) - .flatMap(prop -> tryCast(prop, BaseProperty.class)) - .orElseGet(BaseProperty::new); + return Optional.ofNullable(obj).map(o -> o.getField(field)) + .flatMap(prop -> tryCast(prop, BaseProperty.class)).orElseGet(BaseProperty::new); } } diff --git a/src/main/java/com/celements/web/comparators/CollectionComparator.java b/src/main/java/com/celements/web/comparators/CollectionComparator.java index 2358a9a94..c049844c6 100644 --- a/src/main/java/com/celements/web/comparators/CollectionComparator.java +++ b/src/main/java/com/celements/web/comparators/CollectionComparator.java @@ -17,10 +17,7 @@ public CollectionComparator(Comparator comparator) { @Override public int compare(Collection l1, Collection l2) { - return StreamEx.of(l1).zipWith(l2.stream()) - .mapKeyValue(comparator::compare) - .filter(c -> c != 0) - .findFirst() - .orElseGet(() -> Integer.compare(l1.size(), l2.size())); + return StreamEx.of(l1).zipWith(l2.stream()).mapKeyValue(comparator::compare).filter(c -> c != 0) + .findFirst().orElseGet(() -> Integer.compare(l1.size(), l2.size())); } } diff --git a/src/main/java/com/celements/web/comparators/ObjectComparator.java b/src/main/java/com/celements/web/comparators/ObjectComparator.java index 37e529be1..f2c48eb70 100644 --- a/src/main/java/com/celements/web/comparators/ObjectComparator.java +++ b/src/main/java/com/celements/web/comparators/ObjectComparator.java @@ -35,8 +35,7 @@ private Object unwrapOptional(Object obj) { } private boolean isAssignable(Object o1, Object o2) { - return (o1 != null) && (o2 != null) - && (o1.getClass().isAssignableFrom(o2.getClass()) - || o2.getClass().isAssignableFrom(o1.getClass())); + return (o1 != null) && (o2 != null) && (o1.getClass().isAssignableFrom(o2.getClass()) + || o2.getClass().isAssignableFrom(o1.getClass())); } } diff --git a/src/main/java/com/celements/web/comparators/XDocumentFieldComparator.java b/src/main/java/com/celements/web/comparators/XDocumentFieldComparator.java index ca6d77062..2e81a5b14 100644 --- a/src/main/java/com/celements/web/comparators/XDocumentFieldComparator.java +++ b/src/main/java/com/celements/web/comparators/XDocumentFieldComparator.java @@ -29,9 +29,7 @@ public class XDocumentFieldComparator implements Comparator { private final Comparator comparator; public XDocumentFieldComparator(@NotNull Stream sorts) { - this.comparator = sorts - .map(SortField::asDocComparator) - .reduce((c1, c2) -> c1.thenComparing(c2)) + this.comparator = sorts.map(SortField::asDocComparator).reduce((c1, c2) -> c1.thenComparing(c2)) .orElseGet(() -> Comparator.comparing(doc -> 0)); } @@ -63,8 +61,8 @@ public SortField(ClassField field, Integer number, boolean asc) { } public Comparator asDocComparator() { - Comparator cmp = Comparator.comparing(doc -> fetcher(doc) - .streamNullable().collect(toList()), COMPARATOR); + Comparator cmp = Comparator + .comparing(doc -> fetcher(doc).streamNullable().collect(toList()), COMPARATOR); return asc ? cmp : cmp.reversed(); } diff --git a/src/main/java/com/celements/web/comparators/XWikiAttachmentAscendingNameComparator.java b/src/main/java/com/celements/web/comparators/XWikiAttachmentAscendingNameComparator.java index 2f4e18fa8..11cf42e0b 100644 --- a/src/main/java/com/celements/web/comparators/XWikiAttachmentAscendingNameComparator.java +++ b/src/main/java/com/celements/web/comparators/XWikiAttachmentAscendingNameComparator.java @@ -8,8 +8,8 @@ public class XWikiAttachmentAscendingNameComparator implements Comparator getCMItems(String className, String elemId) { private FluentIterable getCMObjects(String className) { FluentIterable objs = FluentIterable.of(); RefBuilder refBuilder = new RefBuilder().doc(className).space("CelementsContextMenu"); - objs = objs.append(getObjectFetcher(refBuilder.wiki("celements2web").build( - DocumentReference.class)).iter()); - objs = objs.append(getObjectFetcher(refBuilder.with(getContext().getWikiRef()).build( - DocumentReference.class)).iter()); + objs = objs.append( + getObjectFetcher(refBuilder.wiki("celements2web").build(DocumentReference.class)).iter()); + objs = objs.append( + getObjectFetcher(refBuilder.with(getContext().getWikiRef()).build(DocumentReference.class)) + .iter()); return objs; } @@ -182,8 +182,8 @@ public String getJson() { } private XWikiObjectFetcher getObjectFetcher(DocumentReference docRef) { - return XWikiObjectFetcher.on(getModelAccess().getOrCreateDocument(docRef)).filter( - OldCoreClasses.getContextMenuItemClassRef()); + return XWikiObjectFetcher.on(getModelAccess().getOrCreateDocument(docRef)) + .filter(OldCoreClasses.getContextMenuItemClassRef()); } private IModelAccessFacade getModelAccess() { diff --git a/src/main/java/com/celements/web/contextmenu/ERequestLiteral.java b/src/main/java/com/celements/web/contextmenu/ERequestLiteral.java index ce9e4e40d..90142a163 100644 --- a/src/main/java/com/celements/web/contextmenu/ERequestLiteral.java +++ b/src/main/java/com/celements/web/contextmenu/ERequestLiteral.java @@ -26,6 +26,7 @@ import com.celements.sajson.IGenericLiteral; public enum ERequestLiteral implements IGenericLiteral { + ELEMENT_ID(ECommand.VALUE_COMMAND), ELEM_IDS_ARRAY(ECommand.ARRAY_COMMAND, ELEMENT_ID), ELEM_ID_KEY(ECommand.PROPERTY_COMMAND, ELEM_IDS_ARRAY), diff --git a/src/main/java/com/celements/web/css/CSS.java b/src/main/java/com/celements/web/css/CSS.java index 783ef5889..eddc27738 100644 --- a/src/main/java/com/celements/web/css/CSS.java +++ b/src/main/java/com/celements/web/css/CSS.java @@ -41,8 +41,8 @@ public abstract class CSS extends Api { private static XWikiContext getContext() { - return (XWikiContext) Utils.getComponent(Execution.class).getContext().getProperty( - XWikiContext.EXECUTIONCONTEXT_KEY); + return (XWikiContext) Utils.getComponent(Execution.class).getContext() + .getProperty(XWikiContext.EXECUTIONCONTEXT_KEY); } public CSS() { diff --git a/src/main/java/com/celements/web/css/CSSBaseObject.java b/src/main/java/com/celements/web/css/CSSBaseObject.java index e1f7337d5..fc8fe814b 100644 --- a/src/main/java/com/celements/web/css/CSSBaseObject.java +++ b/src/main/java/com/celements/web/css/CSSBaseObject.java @@ -89,9 +89,9 @@ public String getMedia() { @Override public boolean isContentCSS() { - if ((obj != null) && ((obj.getIntValue("is_rte_content") == 1) || obj.getStringValue( - "cssname").endsWith("-content.css") || obj.getStringValue("cssname").endsWith( - "_content.css"))) { + if ((obj != null) && ((obj.getIntValue("is_rte_content") == 1) + || obj.getStringValue("cssname").endsWith("-content.css") + || obj.getStringValue("cssname").endsWith("_content.css"))) { return true; } else { return false; @@ -102,8 +102,8 @@ public boolean isContentCSS() { public Attachment getAttachment() { if (isAttachment()) { String cssName = getCssBasePath(); - DocumentReference addDocRef = getWebUtilsService().resolveDocumentReference( - attURLcmd.getPageFullName(cssName)); + DocumentReference addDocRef = getWebUtilsService() + .resolveDocumentReference(attURLcmd.getPageFullName(cssName)); LOGGER.debug("getAttachment for [" + cssName + "]."); try { XWikiDocument attDoc = context.getWiki().getDocument(addDocRef, context); diff --git a/src/main/java/com/celements/web/css/CSSEngine.java b/src/main/java/com/celements/web/css/CSSEngine.java index 6694a3d53..3ab631d81 100644 --- a/src/main/java/com/celements/web/css/CSSEngine.java +++ b/src/main/java/com/celements/web/css/CSSEngine.java @@ -74,23 +74,18 @@ public List includeCSS(String css, String field, List baseCSSLi } else if (vcontext.containsKey(field)) { cssList = (List) vcontext.get(field); } else { - cssList = Stream.ofNullable(baseCSSList).flatMap(List::stream) - .filter(Objects::nonNull) - .map(CSSBaseObject::new) - .collect(toList()); + cssList = Stream.ofNullable(baseCSSList).flatMap(List::stream).filter(Objects::nonNull) + .map(CSSBaseObject::new).collect(toList()); } - Splitter.on(" ").trimResults().omitEmptyStrings() - .splitToStream(requireNonNullElse(css, "")) - .flatMap(this::collectCssPaths) - .forEach(cssList::add); + Splitter.on(" ").trimResults().omitEmptyStrings().splitToStream(requireNonNullElse(css, "")) + .flatMap(this::collectCssPaths).forEach(cssList::add); vcontext.put(field, cssList); return cssList; } private Stream collectCssPaths(String path) { if (resolver.isFrontendSource(path)) { - return resolver.get(path).stream() - .flatMap(resource -> resource.cssPaths().stream()) + return resolver.get(path).stream().flatMap(resource -> resource.cssPaths().stream()) .map(CSSFrontendResource::new); } else { return Stream.of(new CSSString(path)); diff --git a/src/main/java/com/celements/web/css/CSSString.java b/src/main/java/com/celements/web/css/CSSString.java index 323ee064a..6445acd72 100644 --- a/src/main/java/com/celements/web/css/CSSString.java +++ b/src/main/java/com/celements/web/css/CSSString.java @@ -108,8 +108,8 @@ public Attachment getAttachment() { if (isAttachment()) { String pageFN = getAttachmentURLcmd().getPageFullName(file); try { - XWikiDocument attDoc = context.getWiki().getDocument( - getWebUtilsService().resolveDocumentReference(pageFN), context); + XWikiDocument attDoc = context.getWiki() + .getDocument(getWebUtilsService().resolveDocumentReference(pageFN), context); XWikiAttachment att = getAttachmentService().getAttachmentNameEqual(attDoc, getAttachmentURLcmd().getAttachmentName(file)); return getAttachmentService().getApiAttachment(att); diff --git a/src/main/java/com/celements/web/medialib/JSONExporter.java b/src/main/java/com/celements/web/medialib/JSONExporter.java index 8c2d298a6..bc46c2b4b 100644 --- a/src/main/java/com/celements/web/medialib/JSONExporter.java +++ b/src/main/java/com/celements/web/medialib/JSONExporter.java @@ -23,8 +23,7 @@ public class JSONExporter { private static JSONExporter exporter; - private JSONExporter() { - } + private JSONExporter() {} public static JSONExporter getInstance() { if (exporter == null) { diff --git a/src/main/java/com/celements/web/plugin/api/CelementsWebPluginApi.java b/src/main/java/com/celements/web/plugin/api/CelementsWebPluginApi.java index 25ec4fbec..637fa0c42 100644 --- a/src/main/java/com/celements/web/plugin/api/CelementsWebPluginApi.java +++ b/src/main/java/com/celements/web/plugin/api/CelementsWebPluginApi.java @@ -310,8 +310,8 @@ public void includeCSSAfterPreferences(String css) throws XWikiException { **/ @Deprecated public boolean isEmptyRTEDocument(String fullName) { - return getEmptyCheckScriptService().isEmptyRTEDocument( - getWebUtilsService().resolveDocumentReference(fullName)); + return getEmptyCheckScriptService() + .isEmptyRTEDocument(getWebUtilsService().resolveDocumentReference(fullName)); } /** @@ -402,8 +402,8 @@ public DocumentReference getNextTitledPageDocRef(String space, String title) { */ @Deprecated public String getNextTitledPageFullName(String space, String title) { - return getWebUtilsService().getRefLocalSerializer().serialize(getNextTitledPageDocRef(space, - title)); + return getWebUtilsService().getRefLocalSerializer() + .serialize(getNextTitledPageDocRef(space, title)); } /** @@ -577,8 +577,8 @@ public boolean resetProgrammingRights() { */ @Deprecated public String navReorderSave(String fullName, String structureJSON) { - return getTreeNodeScriptService().navReorderSave(getWebUtilsService().resolveDocumentReference( - fullName), structureJSON); + return getTreeNodeScriptService() + .navReorderSave(getWebUtilsService().resolveDocumentReference(fullName), structureJSON); } /** @@ -605,8 +605,8 @@ public String renderCelementsDocument(String elementFullName) { */ @Deprecated public String renderCelementsDocument(String elementFullName, String renderMode) { - return getScriptService().renderCelementsDocument(getWebUtilsService().resolveDocumentReference( - elementFullName), renderMode); + return getScriptService().renderCelementsDocument( + getWebUtilsService().resolveDocumentReference(elementFullName), renderMode); } /** @@ -714,8 +714,8 @@ public String getCaptchaId() { */ @Deprecated public boolean isCelementsRights(String fullName) { - return getScriptService().isCelementsRights(getWebUtilsService().resolveDocumentReference( - fullName)); + return getScriptService() + .isCelementsRights(getWebUtilsService().resolveDocumentReference(fullName)); } /** @@ -819,8 +819,8 @@ public List getSuggestList(DocumentReference classRef, String fieldname, @Deprecated public boolean useImageAnimations() { String defaultValue = context.getWiki().Param("celements.celImageAnimation", "0"); - return "1".equals(context.getWiki().getSpacePreference("celImageAnimation", defaultValue, - context)); + return "1" + .equals(context.getWiki().getSpacePreference("celImageAnimation", defaultValue, context)); } /** diff --git a/src/main/java/com/celements/web/plugin/cmd/AttachmentURLCommand.java b/src/main/java/com/celements/web/plugin/cmd/AttachmentURLCommand.java index 843656d44..43603767a 100644 --- a/src/main/java/com/celements/web/plugin/cmd/AttachmentURLCommand.java +++ b/src/main/java/com/celements/web/plugin/cmd/AttachmentURLCommand.java @@ -74,8 +74,8 @@ public String getAttachmentURLPrefix() { public String getAttachmentURLPrefix(String action) { XWikiURLFactory urlf = getContext().getURLFactory(); - return urlf.createResourceURL("", true, getContext()).toString().replace("/skin/", "/" + action - + "/"); + return urlf.createResourceURL("", true, getContext()).toString().replace("/skin/", + "/" + action + "/"); } /** @@ -83,9 +83,7 @@ public String getAttachmentURLPrefix(String action) { */ @Deprecated(since = "6.2") public String getAttachmentURL(String link, String action, XWikiContext context) { - return getAttachmentURL(link, action, "") - .map(UriComponents::toUriString) - .orElse(null); + return getAttachmentURL(link, action, "").map(UriComponents::toUriString).orElse(null); } public Optional getAttachmentURL(String link, String action, String queryString) { @@ -166,8 +164,7 @@ public boolean isOnDiskLink(String link) { } public String getDiskFileUrl(String path, String action) { - return getXWiki().getSkinFile(path, true, getContext()) - .replace("/skin/", "/" + action + "/"); + return getXWiki().getSkinFile(path, true, getContext()).replace("/skin/", "/" + action + "/"); } public String getDiskFileUrl(String path) { @@ -176,8 +173,8 @@ public String getDiskFileUrl(String path) { public String getExternalAttachmentURL(String fileName, String action, XWikiContext context) { try { - return context.getURLFactory().getServerURL(context).toExternalForm() + getAttachmentURL( - fileName, action, context); + return context.getURLFactory().getServerURL(context).toExternalForm() + + getAttachmentURL(fileName, action, context); } catch (MalformedURLException exp) { LOGGER.error("Failed to getServerURL.", exp); } diff --git a/src/main/java/com/celements/web/plugin/cmd/CelementsRightsCommand.java b/src/main/java/com/celements/web/plugin/cmd/CelementsRightsCommand.java index 304a5cc1d..8bbe18b37 100644 --- a/src/main/java/com/celements/web/plugin/cmd/CelementsRightsCommand.java +++ b/src/main/java/com/celements/web/plugin/cmd/CelementsRightsCommand.java @@ -45,9 +45,9 @@ public boolean isCelementsRights(String fullName, XWikiContext context) { boolean validGroups = isValidGroups(right); boolean validUsers = isValidUsers(right); boolean validLevels = isValidLevels(right); - LOGGER.debug("isCelementsRights: for doc [" + fullName + "], objNr [" - + right.getNumber() + "] results: " + validGroups + ", " + validUsers + ", " - + validLevels); + LOGGER + .debug("isCelementsRights: for doc [" + fullName + "], objNr [" + right.getNumber() + + "] results: " + validGroups + ", " + validUsers + ", " + validLevels); if ((!validGroups || !validUsers || !validLevels)) { return false; } @@ -62,16 +62,18 @@ public boolean isCelementsRights(String fullName, XWikiContext context) { } boolean isValidGroups(BaseObject right) { - return ((getPropertyList(right, "groups").size() == 0) || ((getPropertyList(right, - "groups").size() == 1) && (getPropertyList(right, "users").size() == 0))); + return ((getPropertyList(right, "groups").size() == 0) + || ((getPropertyList(right, "groups").size() == 1) + && (getPropertyList(right, "users").size() == 0))); } boolean isValidUsers(BaseObject right) { if (getPropertyList(right, "users").size() == 0) { return true; } - if ((getPropertyList(right, "users").size() == 1) && "XWiki.XWikiGuest".equals(getPropertyList( - right, "users").get(0)) && (getPropertyList(right, "groups").size() == 0)) { + if ((getPropertyList(right, "users").size() == 1) + && "XWiki.XWikiGuest".equals(getPropertyList(right, "users").get(0)) + && (getPropertyList(right, "groups").size() == 0)) { return true; } return false; @@ -89,8 +91,8 @@ boolean isValidLevels(BaseObject right) { } private List getPropertyList(BaseObject right, String key) { - LOGGER.trace("getPropertyList: key [" + key + "] value [" + right.getLargeStringValue(key) - + "] "); + LOGGER.trace( + "getPropertyList: key [" + key + "] value [" + right.getLargeStringValue(key) + "] "); if ((right.getLargeStringValue(key) == null) || "".equals(right.getLargeStringValue(key))) { return Collections.emptyList(); } diff --git a/src/main/java/com/celements/web/plugin/cmd/CreateDocumentCommand.java b/src/main/java/com/celements/web/plugin/cmd/CreateDocumentCommand.java index 1554c8bd0..bf1734e47 100644 --- a/src/main/java/com/celements/web/plugin/cmd/CreateDocumentCommand.java +++ b/src/main/java/com/celements/web/plugin/cmd/CreateDocumentCommand.java @@ -76,8 +76,8 @@ public XWikiDocument createDocument(DocumentReference docRef, String pageType, b throws XWikiException { try { XWikiDocument doc = getModelAccess().createDocument(docRef); - PageTypeReference ptRef = getPageTypeService().getPageTypeRefByConfigName(Strings.nullToEmpty( - pageType)); + PageTypeReference ptRef = getPageTypeService() + .getPageTypeRefByConfigName(Strings.nullToEmpty(pageType)); String pageTypeStr = ""; if (ptRef != null) { getPageTypeService().setPageType(doc, ptRef); diff --git a/src/main/java/com/celements/web/plugin/cmd/CssCommand.java b/src/main/java/com/celements/web/plugin/cmd/CssCommand.java index a5f9beb04..a30994fad 100644 --- a/src/main/java/com/celements/web/plugin/cmd/CssCommand.java +++ b/src/main/java/com/celements/web/plugin/cmd/CssCommand.java @@ -68,12 +68,8 @@ public class CssCommand { private final Execution execution; @Inject - public CssCommand( - CSSEngine cssEngine, - IModelAccessFacade modelAccess, - LayoutServiceRole layoutService, - List cssExtensions, - Execution execution) { + public CssCommand(CSSEngine cssEngine, IModelAccessFacade modelAccess, + LayoutServiceRole layoutService, List cssExtensions, Execution execution) { this.cssEngine = cssEngine; this.modelAccess = modelAccess; this.layoutService = layoutService; @@ -151,14 +147,12 @@ public List includeCSSPage(String css) { public List includeCSSPage(String css, XWikiContext context) { List skins = null; - if ((context != null) && (context.getDoc() != null) && !new PageLayoutCommand().layoutExists( - context.getDoc().getDocumentReference().getLastSpaceReference())) { + if ((context != null) && (context.getDoc() != null) && !new PageLayoutCommand() + .layoutExists(context.getDoc().getDocumentReference().getLastSpaceReference())) { XWikiDocument doc = context.getDoc(); skins = doc.getXObjects(getSkinsUserCssClassRef(context.getDatabase())); LOGGER.debug("CSS Page: {} has attached {} Skins.UserCSS objects.", - doc.getDocumentReference(), ((skins != null) - ? skins.size() - : "0")); + doc.getDocumentReference(), ((skins != null) ? skins.size() : "0")); } return includeCSS(css, "cel_css_list_page", skins, context); } @@ -224,8 +218,8 @@ public List includeCSSAfterSkin(String css, XWikiContext context) { public List includeCSSAfterPageType(String css, XWikiContext context) { XWikiDocument pageTypeDoc = null; try { - pageTypeDoc = PageTypeCommand.getInstance().getPageTypeObj(context.getDoc(), - context).getTemplateDocument(context); + pageTypeDoc = PageTypeCommand.getInstance().getPageTypeObj(context.getDoc(), context) + .getTemplateDocument(context); } catch (XWikiException exp) { LOGGER.error("Failed to include css after pageType.", exp); } @@ -255,8 +249,8 @@ public List includeCSSAfterPageLayout(String css, XWikiContext context) { LOGGER.info("includeCSSAfterPageLayout pageLayoutDoc {} does not exist", pageLayoutDocRefOpt.get(), dne); } - baseList.addAll(addUserSkinCss((DocumentReference) vcontext.get( - "after_pagelayout_cssdocref"))); + baseList + .addAll(addUserSkinCss((DocumentReference) vcontext.get("after_pagelayout_cssdocref"))); cssList = includeCSS(css, "cel_css_list_pagelayout", baseList, context); } return cssList; @@ -275,12 +269,10 @@ private List addUserSkinCss(DocumentReference docRef) { private List addUserSkinCss(XWikiDocument docAPI) { if (docAPI != null) { - List objs = docAPI.getXObjects(getSkinsUserCssClassRef( - docAPI.getDocumentReference().getWikiReference().getName())); + List objs = docAPI.getXObjects( + getSkinsUserCssClassRef(docAPI.getDocumentReference().getWikiReference().getName())); LOGGER.debug("CSS Skin: {} has attached {} Skins.UserCSS objects.", - docAPI.getDocumentReference(), ((objs != null) - ? objs.size() - : "0")); + docAPI.getDocumentReference(), ((objs != null) ? objs.size() : "0")); if (objs != null) { return objs; } diff --git a/src/main/java/com/celements/web/plugin/cmd/DocHeaderTitleCommand.java b/src/main/java/com/celements/web/plugin/cmd/DocHeaderTitleCommand.java index c63d4d0e4..17d89f3ca 100644 --- a/src/main/java/com/celements/web/plugin/cmd/DocHeaderTitleCommand.java +++ b/src/main/java/com/celements/web/plugin/cmd/DocHeaderTitleCommand.java @@ -51,16 +51,16 @@ public String getDocHeaderTitle(DocumentReference docRef) { try { XWikiDocument theDoc = getContext().getWiki().getDocument(docRef, getContext()); XWikiDocument theTDoc = theDoc.getTranslatedDocument(getContext()); - BaseObject docTitelObj = theDoc.getXObject(getWebUtils().resolveDocumentReference( - "Content.Title")); + BaseObject docTitelObj = theDoc + .getXObject(getWebUtils().resolveDocumentReference("Content.Title")); if ((theTDoc.getTitle() != null) && !"".equals(theTDoc.getTitle())) { docHeaderTitle = theTDoc.getTitle(); } else if ((theDoc.getTitle() != null) && !"".equals(theDoc.getTitle())) { docHeaderTitle = theDoc.getTitle(); } else if ((docTitelObj != null) && (docTitelObj.getStringValue("title") != null) && (!"".equals(docTitelObj.getStringValue("title")))) { - docHeaderTitle = getContext().getWiki().getRenderingEngine().renderText( - docTitelObj.getStringValue("title"), theDoc, getContext()); + docHeaderTitle = getContext().getWiki().getRenderingEngine() + .renderText(docTitelObj.getStringValue("title"), theDoc, getContext()); } else { docHeaderTitle = menuNameCmd.getMultilingualMenuNameOnly( docRef.getLastSpaceReference().getName() + "." + docRef.getName(), @@ -68,8 +68,8 @@ public String getDocHeaderTitle(DocumentReference docRef) { } if (!"".equals(getContext().getWiki().getSpacePreference("title", docRef.getLastSpaceReference().getName(), "", getContext()))) { - docHeaderTitle = docHeaderTitle + getContext().getWiki() - .parseContent(getContext().getWiki().getSpacePreference("title", + docHeaderTitle = docHeaderTitle + + getContext().getWiki().parseContent(getContext().getWiki().getSpacePreference("title", docRef.getLastSpaceReference().getName(), "", getContext()), getContext()); } } catch (Exception exp) { diff --git a/src/main/java/com/celements/web/plugin/cmd/DocMetaTagsCmd.java b/src/main/java/com/celements/web/plugin/cmd/DocMetaTagsCmd.java index a74fe6abd..f4aa38285 100644 --- a/src/main/java/com/celements/web/plugin/cmd/DocMetaTagsCmd.java +++ b/src/main/java/com/celements/web/plugin/cmd/DocMetaTagsCmd.java @@ -38,8 +38,8 @@ public Map getDocMetaTags(String language, String defaultLanguag if (metaTagsLangMap.get(defaultLanguage) != null) { // get default language meta keys metaTags.putAll(metaTagsLangMap.get(defaultLanguage)); - if ((defaultLanguage != null) && !defaultLanguage.equals(language) && (metaTagsLangMap.get( - language) != null)) { + if ((defaultLanguage != null) && !defaultLanguage.equals(language) + && (metaTagsLangMap.get(language) != null)) { // overwrite translated keys metaTags.putAll(metaTagsLangMap.get(language)); } diff --git a/src/main/java/com/celements/web/plugin/cmd/EmptyCheckCommand.java b/src/main/java/com/celements/web/plugin/cmd/EmptyCheckCommand.java index 40df058e2..7bb7c6b88 100644 --- a/src/main/java/com/celements/web/plugin/cmd/EmptyCheckCommand.java +++ b/src/main/java/com/celements/web/plugin/cmd/EmptyCheckCommand.java @@ -46,8 +46,8 @@ public DocumentReference getNextNonEmptyChildren(DocumentReference documentRef) **/ @Deprecated public boolean isEmptyRTEDocument(String fullname, XWikiContext context) { - DocumentReference docRef = new DocumentReference(context.getDatabase(), fullname.split( - "\\.")[0], fullname.split("\\.")[1]); + DocumentReference docRef = new DocumentReference(context.getDatabase(), + fullname.split("\\.")[0], fullname.split("\\.")[1]); return isEmptyRTEDocument(docRef); } diff --git a/src/main/java/com/celements/web/plugin/cmd/ExternalJavaScriptFilesCommand.java b/src/main/java/com/celements/web/plugin/cmd/ExternalJavaScriptFilesCommand.java index 83885aa4e..6277afe89 100644 --- a/src/main/java/com/celements/web/plugin/cmd/ExternalJavaScriptFilesCommand.java +++ b/src/main/java/com/celements/web/plugin/cmd/ExternalJavaScriptFilesCommand.java @@ -99,15 +99,10 @@ public class ExternalJavaScriptFilesCommand { private boolean collectedAll = false; @Inject - public ExternalJavaScriptFilesCommand( - LayoutServiceRole layoutService, - IPageTypeResolverRole pageTypeResolver, - IModelAccessFacade modelAccess, - ModelContext modelContext, - XObjectPageTypeUtilsRole objectPageTypeUtils, - IWebUtilsService webUtilsService, - AttachmentURLCommand attUrlCommand, - CssCommand cssCommand, + public ExternalJavaScriptFilesCommand(LayoutServiceRole layoutService, + IPageTypeResolverRole pageTypeResolver, IModelAccessFacade modelAccess, + ModelContext modelContext, XObjectPageTypeUtilsRole objectPageTypeUtils, + IWebUtilsService webUtilsService, AttachmentURLCommand attUrlCommand, CssCommand cssCommand, FrontendResourceResolver frontendResolver, @Named(XObjectBeanConverter.NAME) BeanClassDefConverter converter, @Named(JavaScriptExternalFilesClass.CLASS_DEF_HINT) ClassDefinition jsExtClassDef) { @@ -134,10 +129,8 @@ public Stream streamExtJsFiles() { */ @Deprecated public String addLazyExtJSfile(@NotEmpty String jsFile) { - return getLazyLoadTag(new ExtJsFileParameter.Builder() - .setJsFile(jsFile) - .setLazyLoad(true) - .build()); + return getLazyLoadTag( + new ExtJsFileParameter.Builder().setJsFile(jsFile).setLazyLoad(true).build()); } /** @@ -145,11 +138,8 @@ public String addLazyExtJSfile(@NotEmpty String jsFile) { */ @Deprecated public String addLazyExtJSfile(@NotEmpty String jsFile, @Nullable String action) { - return getLazyLoadTag(new ExtJsFileParameter.Builder() - .setJsFile(jsFile) - .setAction(action) - .setLazyLoad(true) - .build()); + return getLazyLoadTag(new ExtJsFileParameter.Builder().setJsFile(jsFile).setAction(action) + .setLazyLoad(true).build()); } /** @@ -158,12 +148,8 @@ public String addLazyExtJSfile(@NotEmpty String jsFile, @Nullable String action) @Deprecated public String addLazyExtJSfile(@NotEmpty String jsFile, @Nullable String action, @Nullable String params) { - return getLazyLoadTag(new ExtJsFileParameter.Builder() - .setJsFile(jsFile) - .setAction(action) - .setQueryString(params) - .setLazyLoad(true) - .build()); + return getLazyLoadTag(new ExtJsFileParameter.Builder().setJsFile(jsFile).setAction(action) + .setQueryString(params).setLazyLoad(true).build()); } /** @@ -172,9 +158,7 @@ public String addLazyExtJSfile(@NotEmpty String jsFile, @Nullable String action, @Deprecated @NotNull public String addExtJSfileOnce(@NotEmpty String jsFile) { - return addExtJSfileOnce(new ExtJsFileParameter.Builder() - .setJsFile(jsFile) - .build()); + return addExtJSfileOnce(new ExtJsFileParameter.Builder().setJsFile(jsFile).build()); } /** @@ -183,10 +167,8 @@ public String addExtJSfileOnce(@NotEmpty String jsFile) { @Deprecated @NotNull public String addExtJSfileOnce(@NotEmpty String jsFile, @Nullable String action) { - return addExtJSfileOnce(new ExtJsFileParameter.Builder() - .setJsFile(jsFile) - .setAction(action) - .build()); + return addExtJSfileOnce( + new ExtJsFileParameter.Builder().setJsFile(jsFile).setAction(action).build()); } /** @@ -196,11 +178,8 @@ public String addExtJSfileOnce(@NotEmpty String jsFile, @Nullable String action) @NotNull public String addExtJSfileOnce(@NotEmpty String jsFile, @Nullable String action, @Nullable String params) { - return addExtJSfileOnce(new ExtJsFileParameter.Builder() - .setJsFile(jsFile) - .setAction(action) - .setQueryString(params) - .build()); + return addExtJSfileOnce(new ExtJsFileParameter.Builder().setJsFile(jsFile).setAction(action) + .setQueryString(params).build()); } /** @@ -219,16 +198,14 @@ public String includeExtJsFile(@NotNull ExtJsFileParameter extJsFileParams) { @NotEmpty public String getLazyLoadTag(@NotNull ExtJsFileParameter extJsFileParams) { - return ""; + return ""; } @NotNull private Optional generateUrl(@NotNull ExtJsFileParameter extJsFileParams) { - return attUrlCommand.getAttachmentURL( - extJsFileParams.getJsFile(), - extJsFileParams.getAction().orElse(null), - extJsFileParams.getQueryString().orElse(null)) + return attUrlCommand.getAttachmentURL(extJsFileParams.getJsFile(), + extJsFileParams.getAction().orElse(null), extJsFileParams.getQueryString().orElse(null)) .map(UriComponents::toUriString); } @@ -280,10 +257,8 @@ private String generateScriptTagOnce(@NotNull ExtJsFileParameter extJsFileParams private String resolveCssIncludes(String jsFile) { return frontendResolver.get(jsFile.trim()).stream() - .flatMap(resource -> resource.cssPaths().stream()) - .map(attUrlCommand::getDiskFileUrl) - .map(this::getCssLink) - .collect(joining()); + .flatMap(resource -> resource.cssPaths().stream()).map(attUrlCommand::getDiskFileUrl) + .map(this::getCssLink).collect(joining()); } private void includeFrontendCss(String jsFile) { @@ -312,16 +287,13 @@ void injectDisplayAll(boolean displayedAll) { String getExtStringForJsFile(JsFileEntry jsFile) { var loadMode = Optional.ofNullable(jsFile.getLoadMode()) .filter(mode -> (mode == ASYNC) || ((mode == DEFER) && !jsFile.isModule())); - return ""; + return ""; } public List getAllRteContentJsFiles() { - return getExtJsFileStream() - .filter(fs -> fs.isRteContent() != JsIsRteContent.NO) + return getExtJsFileStream().filter(fs -> fs.isRteContent() != JsIsRteContent.NO) .collect(Collectors.toList()); } @@ -347,21 +319,18 @@ private void ensureCollectAllJsExtFile() { private StringBuilder generateJsImportString() { final StringBuilder jsIncludesBuilder = new StringBuilder(); - StreamEx.of(getExtJsFileStream() - .filter(fs -> fs.isRteContent() != JsIsRteContent.ONLY) - .map(this::getExtStringForJsFile)) + StreamEx + .of(getExtJsFileStream().filter(fs -> fs.isRteContent() != JsIsRteContent.ONLY) + .map(this::getExtStringForJsFile)) .append(extJSnotFoundSet.stream().map(this::buildNotFoundWarning)) .forEach(tag -> jsIncludesBuilder.append(tag).append("\n")); return jsIncludesBuilder; } private Stream streamDocRefs2CollectJsExtFileObj() { - return StreamEx.of(getSkinDocRef()) - .append(getXWikiPreferencesDocRef()) - .append(getCurrentSpacePreferencesDocRef()) - .append(getCurrentPageTypeDocRef()) - .append(getLayoutPropDocRef()) - .append(getCurrentDocRef()); + return StreamEx.of(getSkinDocRef()).append(getXWikiPreferencesDocRef()) + .append(getCurrentSpacePreferencesDocRef()).append(getCurrentPageTypeDocRef()) + .append(getLayoutPropDocRef()).append(getCurrentDocRef()); } private Stream getCurrentDocRef() { @@ -373,19 +342,18 @@ private Stream getCurrentDocRef() { } private @NotNull DocumentReference getCurrentPageTypeDocRef() { - return objectPageTypeUtils.getDocRefForPageType( - pageTypeResolver.resolvePageTypeRefForCurrentDoc()); + return objectPageTypeUtils + .getDocRefForPageType(pageTypeResolver.resolvePageTypeRefForCurrentDoc()); } private Stream getCurrentSpacePreferencesDocRef() { - return StreamEx.of(modelContext.getCurrentSpaceRef().toJavaUtil() - .map(spaceRef -> RefBuilder.from(spaceRef).doc("WebPreferences").build( - DocumentReference.class))); + return StreamEx.of(modelContext.getCurrentSpaceRef().toJavaUtil().map(spaceRef -> RefBuilder + .from(spaceRef).doc("WebPreferences").build(DocumentReference.class))); } private @NotNull DocumentReference getXWikiPreferencesDocRef() { - return RefBuilder.from(modelContext.getWikiRef()).space("XWiki") - .doc("XWikiPreferences").build(DocumentReference.class); + return RefBuilder.from(modelContext.getWikiRef()).space("XWiki").doc("XWikiPreferences") + .build(DocumentReference.class); } private Stream getSkinDocRef() { @@ -415,14 +383,9 @@ void addAllExtJSfilesFromDocRef(@NotNull DocumentReference docRef) { checkNotNull(docRef); try { XWikiObjectFetcher.on(modelAccess.getDocument(docRef)) - .filter(JavaScriptExternalFilesClass.CLASS_REF) - .stream() - .map(jsFileEntryConverter) - .filter(JsFileEntry::isValid) - .forEachOrdered(jsFile -> addExtJSfileOnce( - new ExtJsFileParameter.Builder() - .setJsFileEntry(jsFile) - .build())); + .filter(JavaScriptExternalFilesClass.CLASS_REF).stream().map(jsFileEntryConverter) + .filter(JsFileEntry::isValid).forEachOrdered(jsFile -> addExtJSfileOnce( + new ExtJsFileParameter.Builder().setJsFileEntry(jsFile).build())); } catch (DocumentNotExistsException nExExp) { LOGGER.info("addAllExtJSfilesFromDocRef skipping [{}] because: not exist.", docRef); } diff --git a/src/main/java/com/celements/web/plugin/cmd/FileBaseTagsCmd.java b/src/main/java/com/celements/web/plugin/cmd/FileBaseTagsCmd.java index 2bf1d88b2..65f4791e1 100644 --- a/src/main/java/com/celements/web/plugin/cmd/FileBaseTagsCmd.java +++ b/src/main/java/com/celements/web/plugin/cmd/FileBaseTagsCmd.java @@ -160,8 +160,7 @@ public XWikiDocument getOrCreateTagDocument(String tagName, boolean createIfNotE if (!existsTagWithName(tagName) && createIfNotExists) { tagDoc = modelAccess.getOrCreateDocument(getTagDocRef(tagName)); BaseObject menuItemObj = XWikiObjectEditor.on(tagDoc) - .filter(INavigationClassConfig.MENU_ITEM_CLASS_REF) - .createFirstIfNotExists(); + .filter(INavigationClassConfig.MENU_ITEM_CLASS_REF).createFirstIfNotExists(); menuItemObj.setIntValue(INavigationClassConfig.MENU_POSITION_FIELD, getAllFileBaseTags().size()); menuItemObj.setStringValue("menu_parent", ""); @@ -174,8 +173,8 @@ public XWikiDocument getOrCreateTagDocument(String tagName, boolean createIfNotE try { return modelAccess.getDocument(getTagDocRef(tagName)); } catch (DocumentNotExistsException exp) { - throw new FailedToCreateTagException("Failed to get tag document [" + getTagDocRef(tagName) - + "].", exp); + throw new FailedToCreateTagException( + "Failed to get tag document [" + getTagDocRef(tagName) + "].", exp); } } diff --git a/src/main/java/com/celements/web/plugin/cmd/FormObjStorageCommand.java b/src/main/java/com/celements/web/plugin/cmd/FormObjStorageCommand.java index 10c915a14..96c1b5e18 100644 --- a/src/main/java/com/celements/web/plugin/cmd/FormObjStorageCommand.java +++ b/src/main/java/com/celements/web/plugin/cmd/FormObjStorageCommand.java @@ -37,9 +37,9 @@ public class FormObjStorageCommand { public BaseObject newObject(XWikiDocument storageDoc, String className, XWikiContext context) { Vector objects = storageDoc.getObjects(className); if ((objects != null) && (objects.size() > _MAX_OBJ_ON_DOC)) { - LOGGER.warn("PERFORMANCE WARNING! There are more than " + _MAX_OBJ_ON_DOC - + " objects of the class [" + className + "] on storageDoc [" + storageDoc.getFullName() - + "]."); + LOGGER.warn( + "PERFORMANCE WARNING! There are more than " + _MAX_OBJ_ON_DOC + " objects of the class [" + + className + "] on storageDoc [" + storageDoc.getFullName() + "]."); } try { return storageDoc.newObject(className, context); diff --git a/src/main/java/com/celements/web/plugin/cmd/ImageMapCommand.java b/src/main/java/com/celements/web/plugin/cmd/ImageMapCommand.java index da330b448..fdf4da813 100644 --- a/src/main/java/com/celements/web/plugin/cmd/ImageMapCommand.java +++ b/src/main/java/com/celements/web/plugin/cmd/ImageMapCommand.java @@ -67,8 +67,8 @@ public void addMapConfig(String mapId) { if (context.getLanguage().equals(map[1])) { mapValue = (String) map[0]; break; - } else if (context.getWiki().getSpacePreference("default_language", context).equals( - map[1])) { + } else if (context.getWiki().getSpacePreference("default_language", context) + .equals(map[1])) { mapValue = (String) map[0]; } } diff --git a/src/main/java/com/celements/web/plugin/cmd/NextFreeDocNameCommand.java b/src/main/java/com/celements/web/plugin/cmd/NextFreeDocNameCommand.java index 1faee5593..dc22affb0 100644 --- a/src/main/java/com/celements/web/plugin/cmd/NextFreeDocNameCommand.java +++ b/src/main/java/com/celements/web/plugin/cmd/NextFreeDocNameCommand.java @@ -40,8 +40,8 @@ public class NextFreeDocNameCommand { */ @Deprecated public String getNextTitledPageFullName(String space, String title, XWikiContext context) { - DocumentReference docRef = getNextFreeDocService().getNextTitledPageDocRef(new SpaceReference( - space, new WikiReference(context.getDatabase())), title); + DocumentReference docRef = getNextFreeDocService().getNextTitledPageDocRef( + new SpaceReference(space, new WikiReference(context.getDatabase())), title); return getWebUtilsService().getRefLocalSerializer().serialize(docRef); } @@ -52,8 +52,8 @@ public String getNextTitledPageFullName(String space, String title, XWikiContext @Deprecated public DocumentReference getNextTitledPageDocRef(String space, String title, XWikiContext context) { - return getNextFreeDocService().getNextTitledPageDocRef(new SpaceReference(space, - new WikiReference(context.getDatabase())), title); + return getNextFreeDocService().getNextTitledPageDocRef( + new SpaceReference(space, new WikiReference(context.getDatabase())), title); } /** @@ -62,8 +62,8 @@ public DocumentReference getNextTitledPageDocRef(String space, String title, */ @Deprecated public String getNextUntitledPageFullName(String space, XWikiContext context) { - DocumentReference docRef = getNextFreeDocService().getNextUntitledPageDocRef(new SpaceReference( - space, new WikiReference(context.getDatabase()))); + DocumentReference docRef = getNextFreeDocService().getNextUntitledPageDocRef( + new SpaceReference(space, new WikiReference(context.getDatabase()))); return getWebUtilsService().getRefLocalSerializer().serialize(docRef); } @@ -73,8 +73,8 @@ public String getNextUntitledPageFullName(String space, XWikiContext context) { */ @Deprecated public String getNextUntitledPageName(String space, XWikiContext context) { - DocumentReference docRef = getNextFreeDocService().getNextUntitledPageDocRef(new SpaceReference( - space, new WikiReference(context.getDatabase()))); + DocumentReference docRef = getNextFreeDocService().getNextUntitledPageDocRef( + new SpaceReference(space, new WikiReference(context.getDatabase()))); return docRef.getName(); } diff --git a/src/main/java/com/celements/web/plugin/cmd/PageLayoutCommand.java b/src/main/java/com/celements/web/plugin/cmd/PageLayoutCommand.java index 22aad5ff2..425ddfc2f 100644 --- a/src/main/java/com/celements/web/plugin/cmd/PageLayoutCommand.java +++ b/src/main/java/com/celements/web/plugin/cmd/PageLayoutCommand.java @@ -76,8 +76,7 @@ public class PageLayoutCommand { private Map convertMap(Map pageLayoutMap) { return EntryStream.of(pageLayoutMap) .filterKeys(spaceRef -> getModelContext().getWikiRef().equals(spaceRef.getParent())) - .mapKeys(SpaceReference::getName) - .toImmutableMap(); + .mapKeys(SpaceReference::getName).toImmutableMap(); } /** @@ -172,8 +171,8 @@ public XWikiDocument getLayoutPropDoc() { */ @Deprecated public XWikiDocument getLayoutPropDoc(SpaceReference layoutSpaceRef) { - Optional layoutPropDocRef = layoutService.getLayoutPropDocRef( - layoutSpaceRef); + Optional layoutPropDocRef = layoutService + .getLayoutPropDocRef(layoutSpaceRef); if (layoutPropDocRef.isPresent()) { try { XWikiDocument layoutPropDoc = getModelAccess().getDocument(layoutPropDocRef.get()); diff --git a/src/main/java/com/celements/web/plugin/cmd/PasswordRecoveryAndEmailValidationCommand.java b/src/main/java/com/celements/web/plugin/cmd/PasswordRecoveryAndEmailValidationCommand.java index 6151648ee..acb3681b0 100644 --- a/src/main/java/com/celements/web/plugin/cmd/PasswordRecoveryAndEmailValidationCommand.java +++ b/src/main/java/com/celements/web/plugin/cmd/PasswordRecoveryAndEmailValidationCommand.java @@ -58,8 +58,8 @@ public class PasswordRecoveryAndEmailValidationCommand { - private static final Logger LOGGER = LoggerFactory.getLogger( - PasswordRecoveryAndEmailValidationCommand.class); + private static final Logger LOGGER = LoggerFactory + .getLogger(PasswordRecoveryAndEmailValidationCommand.class); public static final String CEL_PASSWORD_RECOVERY_FAILED = "cel_password_recovery_failed"; public static final String CEL_PASSWORD_RECOVERY_SUCCESS = "cel_password_recovery_success"; @@ -145,8 +145,8 @@ private String setUserFieldsForPasswordRecovery(DocumentReference userDocRef) return validkey; } - private boolean sendRecoveryMail(String email, String lang, String defLang) throws XWikiException, - DocumentNotExistsException { + private boolean sendRecoveryMail(String email, String lang, String defLang) + throws XWikiException, DocumentNotExistsException { String sender = new CelMailConfiguration().getDefaultAdminSenderAddress(); String subject = getPasswordRecoverySubject(lang, defLang); String textContent = getPasswordRecoveryMailContent("PasswordRecoverMailTextContent", lang, @@ -164,15 +164,15 @@ private String getPasswordRecoveryMailContent(String template, String lang, Stri throws XWikiException, DocumentLoadException, DocumentNotExistsException { String mailContent = null; String newContent = ""; - XWikiDocument doc = getRTEDocWithCelementswebFallback(new DocumentReference( - getContext().getDatabase(), "Tools", template)); + XWikiDocument doc = getRTEDocWithCelementswebFallback( + new DocumentReference(getContext().getDatabase(), "Tools", template)); if (doc != null) { - newContent = getContext().getWiki().getRenderingEngine().renderText(doc.getTranslatedContent( - getContext()), getContext().getDoc(), getContext()); + newContent = getContext().getWiki().getRenderingEngine() + .renderText(doc.getTranslatedContent(getContext()), getContext().getDoc(), getContext()); } if ("".equals(newContent)) { - newContent = getWebUtilsService().renderInheritableDocument(new DocumentReference( - getContext().getDatabase(), "Mails", template), lang, defLang); + newContent = getWebUtilsService().renderInheritableDocument( + new DocumentReference(getContext().getDatabase(), "Mails", template), lang, defLang); } if (!"".equals(newContent)) { mailContent = newContent; @@ -199,8 +199,8 @@ private String getPasswordRecoverySubject(String lang, String defLang) subject = getWebUtilsService().getMessageTool(lang).get(CEL_PASSWORD_RECOVERY_SUBJECT_KEY, params); if (CEL_PASSWORD_RECOVERY_SUBJECT_KEY.equals(subject) && (defLang != null)) { - subject = getWebUtilsService().getMessageTool(defLang).get( - CEL_PASSWORD_RECOVERY_SUBJECT_KEY, params); + subject = getWebUtilsService().getMessageTool(defLang) + .get(CEL_PASSWORD_RECOVERY_SUBJECT_KEY, params); } } return subject; @@ -275,8 +275,8 @@ public boolean sendNewValidationToAccountEmail(String login, String possibleFiel getContext()); return sendNewValidationToAccountEmail(user); } catch (XWikiException exp) { - throw new SendValidationFailedException("sending new validation to accountName '" + login - + "' failed", exp); + throw new SendValidationFailedException( + "sending new validation to accountName '" + login + "' failed", exp); } } @@ -288,8 +288,8 @@ public void sendNewValidationToAccountEmail(String login, String possibleFields, getContext()); sendNewValidationToAccountEmail(user, activationMailDocRef); } catch (XWikiException exp) { - throw new SendValidationFailedException("sending new validation to accountName '" + login - + "' failed", exp); + throw new SendValidationFailedException( + "sending new validation to accountName '" + login + "' failed", exp); } } @@ -329,8 +329,8 @@ public boolean sendNewValidationToAccountEmail(@NotNull DocumentReference userDo if (activationMailDocRef == null) { activationMailDocRef = getDefaultAccountActivationMailDocRef(); } else if (!getModelAccess().exists(activationMailDocRef)) { - LOGGER.warn("Failed to get activation mail [" + activationMailDocRef - + "] now using default."); + LOGGER.warn( + "Failed to get activation mail [" + activationMailDocRef + "] now using default."); activationMailDocRef = getDefaultAccountActivationMailDocRef(); } boolean sentSuccessful = false; @@ -348,8 +348,8 @@ public boolean sendNewValidationToAccountEmail(@NotNull DocumentReference userDo } return sentSuccessful; } catch (UserInstantiationException | CreatingValidationTokenFailedException exp) { - throw new SendValidationFailedException("sending new validation to user '" + userDocRef - + "' failed", exp); + throw new SendValidationFailedException( + "sending new validation to user '" + userDocRef + "' failed", exp); } } @@ -393,8 +393,8 @@ public String createNewValidationTokenForUser(@NotNull DocumentReference userDoc getModelAccess().saveDocument(userDoc, "creating new validkey"); return validkey; } catch (UserInstantiationException | QueryException | DocumentSaveException exp) { - throw new CreatingValidationTokenFailedException("Failed to create a new validkey for user: " - + userDocRef.getName(), exp); + throw new CreatingValidationTokenFailedException( + "Failed to create a new validkey for user: " + userDocRef.getName(), exp); } } @@ -481,11 +481,11 @@ public String getValidationEmailSubject(XWikiDocument contentDoc, String lang, S } if (getDefaultEmptyDocStrategy().isEmptyRTEString(subject)) { List params = Arrays.asList(getContext().getRequest().getHeader("host")); - subject = getWebUtilsService().getMessageTool(lang).get( - CEL_ACOUNT_ACTIVATION_MAIL_SUBJECT_KEY, params); + subject = getWebUtilsService().getMessageTool(lang) + .get(CEL_ACOUNT_ACTIVATION_MAIL_SUBJECT_KEY, params); if (CEL_ACOUNT_ACTIVATION_MAIL_SUBJECT_KEY.equals(subject) && (defLang != null)) { - subject = getWebUtilsService().getMessageTool(defLang).get( - CEL_ACOUNT_ACTIVATION_MAIL_SUBJECT_KEY, params); + subject = getWebUtilsService().getMessageTool(defLang) + .get(CEL_ACOUNT_ACTIVATION_MAIL_SUBJECT_KEY, params); } } return subject; @@ -495,8 +495,8 @@ public String getValidationEmailContent(@Nullable XWikiDocument contentDoc, @Nul @Nullable String defLang) throws XWikiException { String content = ""; if (contentDoc != null) { - content = contentDoc.getTranslatedDocument(lang, getContext()).getRenderedContent( - getContext()); + content = contentDoc.getTranslatedDocument(lang, getContext()) + .getRenderedContent(getContext()); } if (getDefaultEmptyDocStrategy().isEmptyRTEString(content)) { content = getWebUtilsService().renderInheritableDocument(getDefaultMailDocRef(), lang, @@ -536,11 +536,11 @@ String getActivationLink(String to, String validkey) throws XWikiException { try { if (getContext().getWiki().getRightService().hasAccessLevel("view", "XWiki.XWikiGuest", "Content.login", getContext())) { - return getContext().getWiki().getExternalURL("Content.login", "view", "email=" - + URLEncoder.encode(to, "UTF-8") + "&ac=" + validkey, getContext()); + return getContext().getWiki().getExternalURL("Content.login", "view", + "email=" + URLEncoder.encode(to, "UTF-8") + "&ac=" + validkey, getContext()); } else { - return getContext().getWiki().getExternalURL("XWiki.XWikiLogin", "login", "email=" - + URLEncoder.encode(to, "UTF-8") + "&ac=" + validkey, getContext()); + return getContext().getWiki().getExternalURL("XWiki.XWikiLogin", "login", + "email=" + URLEncoder.encode(to, "UTF-8") + "&ac=" + validkey, getContext()); } } catch (UnsupportedEncodingException exp) { LOGGER.error("Failed to encode [" + to + "] for activation link.", exp); diff --git a/src/main/java/com/celements/web/plugin/cmd/RemoteUserValidator.java b/src/main/java/com/celements/web/plugin/cmd/RemoteUserValidator.java index d32a91240..b1f03e5ef 100644 --- a/src/main/java/com/celements/web/plugin/cmd/RemoteUserValidator.java +++ b/src/main/java/com/celements/web/plugin/cmd/RemoteUserValidator.java @@ -75,10 +75,10 @@ public String isValidUserJSON(String username, String password, String memberOfG private boolean authenticate(User user, String password, XWikiContext context) throws XWikiException { - Principal principal = context.getWiki().getAuthService().authenticate( - getModelUtils().serializeRefLocal(user.getDocRef()), password, context); - return (principal != null) && user.getDocRef().equals(getModelUtils().resolveRef( - principal.getName())); + Principal principal = context.getWiki().getAuthService() + .authenticate(getModelUtils().serializeRefLocal(user.getDocRef()), password, context); + return (principal != null) + && user.getDocRef().equals(getModelUtils().resolveRef(principal.getName())); } String getErrorJSON(String errorMsg) { @@ -133,16 +133,16 @@ boolean validationAllowed(XWikiContext context) { String requestSecret = context.getRequest().get("secret"); if ((serverSecret != null) && (serverSecret.trim().length() > 0) && serverSecret.trim().equals(requestSecret.trim())) { - LOGGER.debug("ALLOWING validation for host " + requestHost + " with secret " - + requestSecret); + LOGGER.debug( + "ALLOWING validation for host " + requestHost + " with secret " + requestSecret); return true; } else { LOGGER.warn("DENYING validation: Server secret '" + requestSecret + "' does " + "not match expectation!"); } } else { - LOGGER.warn("DENYING validation: No configuration object found for host '" + requestHost - + "'."); + LOGGER.warn( + "DENYING validation: No configuration object found for host '" + requestHost + "'."); } } else { LOGGER.warn("DENYING validation: Received no requester host!"); @@ -159,8 +159,8 @@ private boolean checkActive(User user, XWikiContext context) { boolean active; // These users are necessarly active String accountName = getModelUtils().serializeRefLocal(user.getDocRef()); - if (accountName.equals(XWikiRightService.GUEST_USER_FULLNAME) || (accountName.equals( - XWikiRightService.SUPERADMIN_USER_FULLNAME))) { + if (accountName.equals(XWikiRightService.GUEST_USER_FULLNAME) + || (accountName.equals(XWikiRightService.SUPERADMIN_USER_FULLNAME))) { active = true; } else { String checkactivefield = context.getWiki().getXWikiPreference("auth_active_check", context); diff --git a/src/main/java/com/celements/web/plugin/cmd/RenameCommand.java b/src/main/java/com/celements/web/plugin/cmd/RenameCommand.java index 6bf03efba..71cad2708 100644 --- a/src/main/java/com/celements/web/plugin/cmd/RenameCommand.java +++ b/src/main/java/com/celements/web/plugin/cmd/RenameCommand.java @@ -48,13 +48,14 @@ public List renameSpace(String spaceName, String newSpaceName, XWikiCont if (renameDoc(fullname, newDocName, true, context)) { renamedPages.add(docName); } else { - LOGGER.error("renameSpace: Failed to rename Document [" + fullname + "] to [" - + newDocName + "]."); + LOGGER.error( + "renameSpace: Failed to rename Document [" + fullname + "] to [" + newDocName + "]."); } } } catch (XWikiException exp) { - LOGGER.error("renameSpace: Failed to rename Space [" + spaceName + "] to [" + newSpaceName - + "].", exp); + LOGGER.error( + "renameSpace: Failed to rename Space [" + spaceName + "] to [" + newSpaceName + "].", + exp); } return renamedPages; } @@ -65,15 +66,16 @@ public boolean renameDoc(String fullname, String newDocName, XWikiContext contex boolean renameDoc(String fullname, String newDocName, boolean flushMenuCacheExternal, XWikiContext context) { - if (context.getWiki().exists(fullname, context) && !context.getWiki().exists(newDocName, - context)) { + if (context.getWiki().exists(fullname, context) + && !context.getWiki().exists(newDocName, context)) { try { XWikiDocument thePage = context.getWiki().getDocument(fullname, context); thePage.rename(newDocName, context); return true; } catch (XWikiException exp) { - LOGGER.error("renameDoc: Failed to rename Document [" + fullname + "] to [" + newDocName - + "].", exp); + LOGGER.error( + "renameDoc: Failed to rename Document [" + fullname + "] to [" + newDocName + "].", + exp); } } LOGGER.warn("renameDoc: Failed to rename Document [" + fullname + " ; " diff --git a/src/main/java/com/celements/web/plugin/cmd/ResetProgrammingRightsCommand.java b/src/main/java/com/celements/web/plugin/cmd/ResetProgrammingRightsCommand.java index 15eae460a..2223fe3bb 100644 --- a/src/main/java/com/celements/web/plugin/cmd/ResetProgrammingRightsCommand.java +++ b/src/main/java/com/celements/web/plugin/cmd/ResetProgrammingRightsCommand.java @@ -40,8 +40,8 @@ public boolean resetCelements2webRigths(XWikiContext context) { context.setDatabase("celements2web"); Session sess = getNewHibSession(context); Transaction transaction = sess.beginTransaction(); - Query query = sess.createQuery("update com.xpn.xwiki.doc.XWikiDocument" - + " set contentAuthor = :username"); + Query query = sess.createQuery( + "update com.xpn.xwiki.doc.XWikiDocument" + " set contentAuthor = :username"); query.setParameter("username", context.getUser()); result = query.executeUpdate(); LOGGER.info("updated [{}] documents. Set to content author [{}] in database [{}].", result, diff --git a/src/main/java/com/celements/web/service/CelementsWebScriptService.java b/src/main/java/com/celements/web/service/CelementsWebScriptService.java index c8cecbe8b..23d5c3d36 100644 --- a/src/main/java/com/celements/web/service/CelementsWebScriptService.java +++ b/src/main/java/com/celements/web/service/CelementsWebScriptService.java @@ -127,22 +127,14 @@ public class CelementsWebScriptService implements ScriptService { private final ConfigurationSource xwikiPropertiesSource; @Inject - public CelementsWebScriptService( - QueryManager queryManager, - IAppScriptService appScriptService, - IWebUtilsService webUtilsService, - ConfigurationSource configSource, - ITreeNodeCache treeNodeCacheService, - ITreeNodeService treeNodeService, + public CelementsWebScriptService(QueryManager queryManager, IAppScriptService appScriptService, + IWebUtilsService webUtilsService, ConfigurationSource configSource, + ITreeNodeCache treeNodeCacheService, ITreeNodeService treeNodeService, @Named("treeNode") ScriptService treeNodeScriptService, - IClassesCompositorComponent classesComp, - IMandatoryDocumentCompositorRole mandatoryDocComp, - @Named("deprecated") ScriptService deprecatedUsage, - ILastChangedRole lastChangedSrv, - LastStartupTimeStampRole lastStartupTimeStamp, - IRightsAccessFacadeRole rightsAccess, - ModelContext modelContext, - Execution execution, + IClassesCompositorComponent classesComp, IMandatoryDocumentCompositorRole mandatoryDocComp, + @Named("deprecated") ScriptService deprecatedUsage, ILastChangedRole lastChangedSrv, + LastStartupTimeStampRole lastStartupTimeStamp, IRightsAccessFacadeRole rightsAccess, + ModelContext modelContext, Execution execution, @Named("xwikiproperties") ConfigurationSource xwikiPropertiesSource) { this.queryManager = queryManager; this.appScriptService = appScriptService; @@ -683,8 +675,8 @@ public Integer permanentlyEmptyTrash(int waitDays) { cal.add(Calendar.SECOND, seconds); boolean isAfterMinWaitDays = cal.before(Calendar.getInstance()); if (isAfterMinWaitDays && delDoc.getDate().before(delBeforeDate)) { - XWikiDocument doc = getContext().getWiki().getDocument( - webUtilsService.resolveDocumentReference(fullName), getContext()); + XWikiDocument doc = getContext().getWiki() + .getDocument(webUtilsService.resolveDocumentReference(fullName), getContext()); getContext().getWiki().getRecycleBinStore().deleteFromRecycleBin(doc, delDoc.getId(), getContext(), true); countDeleted++; @@ -731,8 +723,8 @@ public boolean permanentlyEmptyAttachmentTrash(int waitDays) { try { Session sess = getNewHibSession(getContext()); Transaction transaction = sess.beginTransaction(); - org.hibernate.Query query = sess.createSQLQuery("delete from xwikiattrecyclebin" - + " where XDA_DATE < :deleteBeforeDate"); + org.hibernate.Query query = sess.createSQLQuery( + "delete from xwikiattrecyclebin" + " where XDA_DATE < :deleteBeforeDate"); query.setParameter("deleteBeforeDate", delBeforeDate); result = query.executeUpdate(); LOGGER.info("deleted [{}] attachments in database [{}].", result, @@ -782,8 +774,9 @@ public Map getDocMetaTags(String language, String defaultLanguag public boolean addFileToFileBaseTag(DocumentReference fileDocRef, String fileName, DocumentReference tagDocRef) { - return addFileToFileBaseTag(fileDocRef.getLastSpaceReference().getName() + "." - + fileDocRef.getName(), fileName, tagDocRef); + return addFileToFileBaseTag( + fileDocRef.getLastSpaceReference().getName() + "." + fileDocRef.getName(), fileName, + tagDocRef); } public boolean addFileToFileBaseTag(String fileDocFullName, String fileName, @@ -791,8 +784,8 @@ public boolean addFileToFileBaseTag(String fileDocFullName, String fileName, // FIXME not all tag documents have a page type: who cares? deprecated? migration? // DocumentReference pageTypeDocRef = webUtilsService.resolveDocumentReference( // "Celements2.PageType"); - DocumentReference tagClassDocRef = webUtilsService.resolveDocumentReference( - "Classes.FilebaseTag"); + DocumentReference tagClassDocRef = webUtilsService + .resolveDocumentReference("Classes.FilebaseTag"); String tagValue = fileDocFullName + "/" + fileName; try { XWikiDocument tagDoc = getContext().getWiki().getDocument(tagDocRef, getContext()); @@ -1002,8 +995,8 @@ public String getEmailAdressForCurrentUser() { public String getEmailAdressForUser(String username) { if (hasProgrammingRights()) { - return getCelementsWebService().getEmailAdressForUser( - getWebUtilsService().resolveDocumentReference(username)); + return getCelementsWebService() + .getEmailAdressForUser(getWebUtilsService().resolveDocumentReference(username)); } else { return null; } @@ -1034,8 +1027,8 @@ public List renameSpace(String spaceName, String newSpaceName) { } public boolean renameDoc(DocumentReference docRef, String newDocName) { - return new RenameCommand().renameDoc(getWebUtilsService().getRefDefaultSerializer().serialize( - docRef), newDocName, getContext()); + return new RenameCommand().renameDoc( + getWebUtilsService().getRefDefaultSerializer().serialize(docRef), newDocName, getContext()); } public List getSupportedAdminLanguages() { diff --git a/src/main/java/com/celements/web/service/CelementsWebService.java b/src/main/java/com/celements/web/service/CelementsWebService.java index a4ebe57d1..b5d8595c1 100644 --- a/src/main/java/com/celements/web/service/CelementsWebService.java +++ b/src/main/java/com/celements/web/service/CelementsWebService.java @@ -114,11 +114,9 @@ public synchronized int createUser(Map userData, String possible @Override public Map getUniqueNameValueRequestMap() { - return EntryStream.of(context.request() - .map(XWikiRequest::getParameterMap) - .orElse(ImmutableMap.of())) - .mapValues(values -> Stream.of(values).findFirst().orElse("")) - .toMap(); + return EntryStream + .of(context.request().map(XWikiRequest::getParameterMap).orElse(ImmutableMap.of())) + .mapValues(values -> Stream.of(values).findFirst().orElse("")).toMap(); } @Override @@ -133,8 +131,8 @@ public List getSupportedAdminLanguages() { public boolean writeUTF8Response(String filename, String renderDocFullName) { boolean success = false; try { - XWikiDocument renderDoc = modelAccess.getDocument(modelUtils.resolveRef(renderDocFullName, - DocumentReference.class)); + XWikiDocument renderDoc = modelAccess + .getDocument(modelUtils.resolveRef(renderDocFullName, DocumentReference.class)); adjustResponseHeader(filename, context.getResponse().get()); setResponseContent(renderDoc, context.getResponse().get()); success = true; @@ -150,8 +148,8 @@ public boolean writeUTF8Response(String filename, String renderDocFullName) { private void adjustResponseHeader(String filename, XWikiResponse response) { response.setContentType("text/plain"); String ofilename = Util.encodeURI(filename, getXWikiContext()).replaceAll("\\+", " "); - response.addHeader("Content-disposition", "attachment; filename=\"" + ofilename - + "\"; charset='UTF-8'"); + response.addHeader("Content-disposition", + "attachment; filename=\"" + ofilename + "\"; charset='UTF-8'"); } private void setResponseContent(XWikiDocument renderDoc, XWikiResponse response) diff --git a/src/main/java/com/celements/web/service/IWebUtilsService.java b/src/main/java/com/celements/web/service/IWebUtilsService.java index 9d9fcb777..3a0071bde 100644 --- a/src/main/java/com/celements/web/service/IWebUtilsService.java +++ b/src/main/java/com/celements/web/service/IWebUtilsService.java @@ -83,14 +83,12 @@ public interface IWebUtilsService { * DocumentReference docRef, boolean includeDoc) */ @Deprecated - List getDocumentParentsList(DocumentReference docRef, - boolean includeDoc); + List getDocumentParentsList(DocumentReference docRef, boolean includeDoc); String getDocSectionAsJSON(String regex, DocumentReference docRef, int section) throws XWikiException; - String getDocSection(String regex, DocumentReference docRef, int section) - throws XWikiException; + String getDocSection(String regex, DocumentReference docRef, int section) throws XWikiException; int countSections(String regex, DocumentReference docRef) throws XWikiException; @@ -208,24 +206,22 @@ String getDocSection(String regex, DocumentReference docRef, int section) * @deprecated instead use {@link ModelUtils#resolveRef(String, Class, EntityReference)} */ @Deprecated - EntityReference resolveEntityReference(String name, EntityType type, - WikiReference wikiRef); + EntityReference resolveEntityReference(String name, EntityType type, WikiReference wikiRef); /** * @deprecated instead use {@link ModelUtils#resolveRef(String, Class, EntityReference)} */ @Deprecated @NotNull - T resolveReference(@NotNull String name, - @NotNull Class token); + T resolveReference(@NotNull String name, @NotNull Class token); /** * @deprecated instead use {@link ModelUtils#resolveRef(String, Class, EntityReference)} */ @Deprecated @NotNull - T resolveReference(@NotNull String name, - @NotNull Class token, @Nullable EntityReference baseRef); + T resolveReference(@NotNull String name, @NotNull Class token, + @Nullable EntityReference baseRef); /** * @deprecated instead use {@link IRightsAccessFacadeRole#isAdmin()} @@ -290,8 +286,7 @@ List getAttachmentListSorted(XWikiDocument doc, * @deprecated instead use {@link #getAttachmentListSorted(XWikiDocument, Comparator, boolean)} */ @Deprecated - List getAttachmentListSorted(Document doc, String comparator, - boolean imagesOnly); + List getAttachmentListSorted(Document doc, String comparator, boolean imagesOnly); List getAttachmentListSorted(XWikiDocument doc, Comparator comparator, boolean imagesOnly); @@ -301,8 +296,8 @@ List getAttachmentListSorted(XWikiDocument doc, * {@link #getAttachmentListSorted(XWikiDocument, Comparator, boolean, int, int)} */ @Deprecated - List getAttachmentListSorted(Document doc, String comparator, - boolean imagesOnly, int start, int nb); + List getAttachmentListSorted(Document doc, String comparator, boolean imagesOnly, + int start, int nb); List getAttachmentListSorted(XWikiDocument doc, Comparator comparator, boolean imagesOnly, int start, int nb); @@ -314,8 +309,8 @@ List getAttachmentListSortedSpace(String spaceName, String comparato // TODO change signature requirement to XWikiDocument instead of document and mark // the old version as deprecated - List getAttachmentListForTagSorted(Document doc, String tagName, - String comparator, boolean imagesOnly, int start, int nb); + List getAttachmentListForTagSorted(Document doc, String tagName, String comparator, + boolean imagesOnly, int start, int nb); // TODO change signature requirement to XWikiDocument instead of document and mark // the old version as deprecated @@ -438,21 +433,18 @@ List getObjectsOrdered(XWikiDocument doc, DocumentReference classRef String getTemplatePathOnDisk(String renderTemplatePath, String lang); - String renderInheritableDocument(DocumentReference docRef, String lang) - throws XWikiException; + String renderInheritableDocument(DocumentReference docRef, String lang) throws XWikiException; String renderInheritableDocument(DocumentReference docRef, String lang, String defLang) throws XWikiException; List getAttachmentsForDocs(List docsFN); - String getTranslatedDiscTemplateContent(String renderTemplatePath, String lang, - String defLang); + String getTranslatedDiscTemplateContent(String renderTemplatePath, String lang, String defLang); boolean existsInheritableDocument(@NotNull DocumentReference docRef); - boolean existsInheritableDocument(@NotNull DocumentReference docRef, - @Nullable String lang); + boolean existsInheritableDocument(@NotNull DocumentReference docRef, @Nullable String lang); boolean existsInheritableDocument(@NotNull DocumentReference docRef, @Nullable String lang, @Nullable String defLang); @@ -472,8 +464,7 @@ boolean existsInheritableDocument(@NotNull DocumentReference docRef, @Nullable S * instead */ @Deprecated(since = "6.11", forRemoval = true) - void sendCheckJobMail(String jobMailName, String fromAddr, String toAddr, - List params); + void sendCheckJobMail(String jobMailName, String fromAddr, String toAddr, List params); /** * @deprecated instead use {@link CelConstant#CENTRAL_WIKI} diff --git a/src/main/java/com/celements/web/service/MobileLoggingScriptService.java b/src/main/java/com/celements/web/service/MobileLoggingScriptService.java index 3b06e0d8e..911ae1808 100644 --- a/src/main/java/com/celements/web/service/MobileLoggingScriptService.java +++ b/src/main/java/com/celements/web/service/MobileLoggingScriptService.java @@ -27,10 +27,11 @@ public String dimensionAndAgentLog() { } public String dimensionAndAgentLog(String message) { - LOGGER.info("dimensionAndAgentLog: mobileDim [" + getContext().getRequest().getParameter( - "mobileDim") + "], userAgent [" + getContext().getRequest().getParameter("userAgent") - + "], isOrientationLandscape [" + getContext().getRequest().getParameter( - "isOrientationLandscape") + "], message [" + message + "]"); + LOGGER.info("dimensionAndAgentLog: mobileDim [" + + getContext().getRequest().getParameter("mobileDim") + "], userAgent [" + + getContext().getRequest().getParameter("userAgent") + "], isOrientationLandscape [" + + getContext().getRequest().getParameter("isOrientationLandscape") + "], message [" + + message + "]"); Builder jsonBuilder = new Builder(); jsonBuilder.openDictionary(); jsonBuilder.addStringProperty("message", "OK"); diff --git a/src/main/java/com/celements/web/service/PrepareVelocityContextService.java b/src/main/java/com/celements/web/service/PrepareVelocityContextService.java index 642d3f9f8..dce443142 100644 --- a/src/main/java/com/celements/web/service/PrepareVelocityContextService.java +++ b/src/main/java/com/celements/web/service/PrepareVelocityContextService.java @@ -162,8 +162,8 @@ void initCelementsVelocity(VelocityContext vcontext) { } if ((vcontext != null) && (getContext().getWiki() != null)) { if (!vcontext.containsKey(getVelocityName())) { - vcontext.put(getVelocityName(), getContext().getWiki().getPluginApi(getVelocityName(), - getContext())); + vcontext.put(getVelocityName(), + getContext().getWiki().getPluginApi(getVelocityName(), getContext())); } if (!vcontext.containsKey("default_language")) { vcontext.put("default_language", webUtilsService.getDefaultLanguage()); @@ -187,10 +187,10 @@ void initCelementsVelocity(VelocityContext vcontext) { } if (!vcontext.containsKey("skin_doc") && (baseRef != null)) { try { - DocumentReference skinDocRef = modelUtils.resolveRef(getContext().getWiki().getSkin( - getContext()), DocumentReference.class, baseRef); - Document skinDoc = getContext().getWiki().getDocument(skinDocRef, - getContext()).newDocument(getContext()); + DocumentReference skinDocRef = modelUtils.resolveRef( + getContext().getWiki().getSkin(getContext()), DocumentReference.class, baseRef); + Document skinDoc = getContext().getWiki().getDocument(skinDocRef, getContext()) + .newDocument(getContext()); vcontext.put("skin_doc", skinDoc); } catch (XWikiException | IllegalArgumentException e) { LOGGER.info("Failed to get skin_doc", e); @@ -217,8 +217,8 @@ void initCelementsVelocity(VelocityContext vcontext) { XWikiDocument celementsSkinXWikiDoc = getCelementsSkinXWikiDoc(getContext()); String celements2_baseurl = celementsSkinXWikiDoc.getURL("view", getContext()); if (celements2_baseurl.indexOf("/", 8) > 0) { - vcontext.put("celements2_baseurl", celements2_baseurl.substring(0, - celements2_baseurl.indexOf("/", 8))); + vcontext.put("celements2_baseurl", + celements2_baseurl.substring(0, celements2_baseurl.indexOf("/", 8))); } } } catch (XWikiException exp) { @@ -237,8 +237,9 @@ void initCelementsVelocity(VelocityContext vcontext) { vcontext.put("user", getContext().getUser()); } if (!vcontext.containsKey("isContentEditor")) { - vcontext.put("isContentEditor", getContext().getWiki().getUser(getContext().getUser(), - getContext()).isUserInGroup("XWiki.ContentEditorsGroup")); + vcontext.put("isContentEditor", + getContext().getWiki().getUser(getContext().getUser(), getContext()) + .isUserInGroup("XWiki.ContentEditorsGroup")); } if (!vcontext.containsKey("q")) { vcontext.put("q", "'"); @@ -259,8 +260,8 @@ String getRTEwidth(XWikiContext context) { int tinyMCEwidth = -1; String tinyMCEwidthStr = ""; if (getCelementsSkinDoc(context) != null) { - BaseObject pageTypeObj = new PageTypeCommand().getPageTypeObj(context.getDoc(), - context).getPageTypeProperties(context); + BaseObject pageTypeObj = new PageTypeCommand().getPageTypeObj(context.getDoc(), context) + .getPageTypeProperties(context); if (pageTypeObj != null) { tinyMCEwidth = pageTypeObj.getIntValue("rte_width", -1); tinyMCEwidthStr = Integer.toString(tinyMCEwidth); @@ -316,8 +317,8 @@ private Document getCelementsSkinDoc(XWikiContext context) { } private XWikiDocument getCelementsSkinXWikiDoc(XWikiContext context) throws XWikiException { - return context.getWiki().getDocument(new DocumentReference("celements2web", "XWiki", - "Celements2Skin"), context); + return context.getWiki() + .getDocument(new DocumentReference("celements2web", "XWiki", "Celements2Skin"), context); } @Override @@ -367,17 +368,17 @@ public List getLeftPanels() { boolean showPanelByConfigName(XWikiContext context, String configName) { if (isPageShowPanelOverwrite(configName, context.getDoc())) { return (1 == getPagePanelObj(configName, context.getDoc()).getIntValue("show_panels")); - } else if ((getPageTypeDoc(context) != null) && isPageShowPanelOverwrite(configName, - getPageTypeDoc(context))) { - boolean showPanels = (1 == getPagePanelObj(configName, getPageTypeDoc(context)).getIntValue( - "show_panels")); + } else if ((getPageTypeDoc(context) != null) + && isPageShowPanelOverwrite(configName, getPageTypeDoc(context))) { + boolean showPanels = (1 == getPagePanelObj(configName, getPageTypeDoc(context)) + .getIntValue("show_panels")); LOGGER.debug("using pagetype for panels " + configName + " -> " + showPanels); return showPanels; } else if (isSpaceOverwrite(context)) { boolean showPanels = "1".equals(context.getWiki().getSpacePreference(configName, getSpaceOverwrite(context), "0", context)); - LOGGER.debug("using spaceover webPrefs for panels " + configName + "," + getSpaceOverwrite( - context) + " -> " + showPanels); + LOGGER.debug("using spaceover webPrefs for panels " + configName + "," + + getSpaceOverwrite(context) + " -> " + showPanels); return showPanels; } else if (isGlobalPref(context)) { boolean showPanels = ("1".equals(context.getWiki().getXWikiPreference(configName, context))); @@ -398,8 +399,8 @@ XWikiDocument getPageTypeDoc(XWikiContext context) { try { DocumentReference pageTypeDocRef = new DocumentReference(context.getDatabase(), "PageTypes", pTRefForCurrDoc.getConfigName()); - XWikiDocument pageTypeDoc = new PageType(pageTypeDocRef).getTemplateDocument( - getContext()); + XWikiDocument pageTypeDoc = new PageType(pageTypeDocRef) + .getTemplateDocument(getContext()); LOGGER.debug("getPageTypeDoc: pageTypeDoc=" + pageTypeDoc); return pageTypeDoc; } catch (XWikiException exp) { @@ -423,8 +424,9 @@ private BaseObject getPagePanelObj(String configName, XWikiDocument theDoc) { private boolean isPageShowPanelOverwrite(String configName, XWikiDocument theDoc) { try { - return ((getPagePanelObj(configName, theDoc) != null) && (((BaseProperty) getPagePanelObj( - configName, theDoc).get("show_panels")).getValue() != null)); + return ((getPagePanelObj(configName, theDoc) != null) + && (((BaseProperty) getPagePanelObj(configName, theDoc).get("show_panels")) + .getValue() != null)); } catch (XWikiException exp) { LOGGER.error("", exp); return false; @@ -451,8 +453,8 @@ private String getPanelString(XWikiContext context, String configName) { panelsString = context.getWiki().getXWikiPreference(configName, context); } else if (isPagePanelsOverwrite(configName, context.getDoc())) { panelsString = getPagePanelObj(configName, context.getDoc()).getStringValue("panels"); - } else if ((getPageTypeDoc(context) != null) && isPagePanelsOverwrite(configName, - getPageTypeDoc(context))) { + } else if ((getPageTypeDoc(context) != null) + && isPagePanelsOverwrite(configName, getPageTypeDoc(context))) { panelsString = getPagePanelObj(configName, getPageTypeDoc(context)).getStringValue("panels"); } else if (isSpaceOverwrite(context)) { panelsString = context.getWiki().getSpacePreference(configName, getSpaceOverwrite(context), @@ -470,8 +472,8 @@ private String getPanelString(XWikiContext context, String configName) { } private boolean isPagePanelsOverwrite(String configName, XWikiDocument theDoc) { - return ((getPagePanelObj(configName, theDoc) != null) && (!"".equals(getPagePanelObj(configName, - theDoc).getStringValue("panels")))); + return ((getPagePanelObj(configName, theDoc) != null) + && (!"".equals(getPagePanelObj(configName, theDoc).getStringValue("panels")))); } private String getSpaceOverwrite(XWikiContext context) { @@ -483,10 +485,9 @@ private String getSpaceOverwrite(XWikiContext context) { private boolean isGlobalPref(XWikiContext context) { if ((context.getDoc() != null) && (context.getRequest() != null)) { - return new DocumentReference(context.getDatabase(), "XWiki", "XWikiPreferences").equals( - context.getDoc().getDocumentReference()) - || "globaladmin".equals(context.getRequest().get( - "editor")); + return new DocumentReference(context.getDatabase(), "XWiki", "XWikiPreferences") + .equals(context.getDoc().getDocumentReference()) + || "globaladmin".equals(context.getRequest().get("editor")); } return false; } @@ -516,8 +517,9 @@ String getLanguagePreference(XWikiContext context) { // If the wiki is non multilingual then the language is the default // language. if (!context.getWiki().isMultiLingual(context)) { - LOGGER.debug("getLanguagePreference: isMultiLingual [" + context.getWiki().isMultiLingual( - context) + "] defaultLanguage [" + webUtilsService.getDefaultLanguage() + "]."); + LOGGER.debug( + "getLanguagePreference: isMultiLingual [" + context.getWiki().isMultiLingual(context) + + "] defaultLanguage [" + webUtilsService.getDefaultLanguage() + "]."); return webUtilsService.getDefaultLanguage(); } @@ -597,10 +599,10 @@ private String getLanguageFromAcceptedHeaderLanguages() { // If the client didn't specify some languages, skip this phase if ((acceptHeader != null) && (!acceptHeader.equals(""))) { List acceptedLanguages = getAcceptedLanguages(getContext().getRequest()); - LOGGER.debug("getLanguageFromAcceptedHeaderLanguages: getAcceptedLanguages " - + acceptedLanguages); - LOGGER.debug("getLanguageFromAcceptedHeaderLanguages: forceSupported " + xwiki.Param( - "xwiki.language.forceSupported", "0")); + LOGGER.debug( + "getLanguageFromAcceptedHeaderLanguages: getAcceptedLanguages " + acceptedLanguages); + LOGGER.debug("getLanguageFromAcceptedHeaderLanguages: forceSupported " + + xwiki.Param("xwiki.language.forceSupported", "0")); // We can force one of the configured languages to be accepted if (xwiki.Param("xwiki.language.forceSupported", "0").equals("1")) { List available = webUtilsService.getAllowedLanguages(); @@ -609,8 +611,8 @@ private String getLanguageFromAcceptedHeaderLanguages() { // Filter only configured languages acceptedLanguages.retainAll(available); } - LOGGER.debug("getLanguageFromAcceptedHeaderLanguages: acceptedLanguages after " - + acceptedLanguages); + LOGGER.debug( + "getLanguageFromAcceptedHeaderLanguages: acceptedLanguages after " + acceptedLanguages); if (acceptedLanguages.size() > 0) { // Use the "most-preferred" language, as requested by the client. language = acceptedLanguages.get(0); @@ -632,11 +634,11 @@ private String getLanguageFromUserPreferences() throws XWikiException { String language = null; String userFN = getContext().getUser(); XWikiDocument userdoc = null; - userdoc = getContext().getWiki().getDocument(modelUtils.resolveRef(userFN, - DocumentReference.class), getContext()); + userdoc = getContext().getWiki() + .getDocument(modelUtils.resolveRef(userFN, DocumentReference.class), getContext()); if (userdoc != null) { - language = Util.normalizeLanguage(userdoc.getStringValue("XWiki.XWikiUsers", - "default_language")); + language = Util + .normalizeLanguage(userdoc.getStringValue("XWiki.XWikiUsers", "default_language")); } return language; } @@ -644,8 +646,8 @@ private String getLanguageFromUserPreferences() throws XWikiException { private String getLanguageFromCookie() { // First we get the language from the cookie // !!! getUserPreferenceFromCookie throws NPE if request is NULL !!! - return Util.normalizeLanguage(getContext().getWiki().getUserPreferenceFromCookie("language", - getContext())); + return Util.normalizeLanguage( + getContext().getWiki().getUserPreferenceFromCookie("language", getContext())); } /** @@ -682,8 +684,8 @@ private String getLanguageInRequestParam() { } boolean isInvalidLanguageOrDefault(String language) { - return language.equals("default") || (isSuppressInvalid() - && !webUtilsService.getAllowedLanguages().contains(language)); + return language.equals("default") + || (isSuppressInvalid() && !webUtilsService.getAllowedLanguages().contains(language)); } private boolean isSuppressInvalid() { diff --git a/src/main/java/com/celements/web/service/WebUtilsService.java b/src/main/java/com/celements/web/service/WebUtilsService.java index f3c83900d..5630427ae 100644 --- a/src/main/java/com/celements/web/service/WebUtilsService.java +++ b/src/main/java/com/celements/web/service/WebUtilsService.java @@ -302,13 +302,13 @@ public List getAllowedLanguages(String spaceName) { languages.addAll(Arrays.asList(spaceLanguages.split("[ ,]"))); languages.remove(""); if (languages.size() > 0) { - LOGGER.debug("getAllowedLanguages: returning [" + spaceLanguages + "] for space [" + spaceName - + "]"); + LOGGER.debug( + "getAllowedLanguages: returning [" + spaceLanguages + "] for space [" + spaceName + "]"); return languages; } LOGGER.warn("Deprecated usage of Preferences field 'language'." + " Instead use 'languages'."); - return Arrays.asList(getContext().getWiki().getSpacePreference("language", spaceName, "", - getContext()).split("[ ,]")); + return Arrays.asList(getContext().getWiki() + .getSpacePreference("language", spaceName, "", getContext()).split("[ ,]")); } @Override @@ -326,10 +326,10 @@ public List getAllowedLanguages(SpaceReference spaceRef) { + spaceRef.getName() + "]"); return languages; } - LOGGER.warn("Deprecated usage of Preferences field 'language'." - + " Instead use 'languages'."); - return Arrays.asList(getContext().getWiki().getSpacePreference("language", spaceRef.getName(), - "", getContext()).split("[ ,]")); + LOGGER + .warn("Deprecated usage of Preferences field 'language'." + " Instead use 'languages'."); + return Arrays.asList(getContext().getWiki() + .getSpacePreference("language", spaceRef.getName(), "", getContext()).split("[ ,]")); } finally { getContext().setDatabase(curDB); } @@ -348,8 +348,8 @@ public Date parseDate(String date, String format) { @Override public XWikiMessageTool getMessageTool(String adminLanguage) { if (adminLanguage != null) { - if ((getContext().getLanguage() != null) && getContext().getLanguage().equals( - adminLanguage)) { + if ((getContext().getLanguage() != null) + && getContext().getLanguage().equals(adminLanguage)) { return getContext().getMessageTool(); } else { Locale locale = new Locale(adminLanguage); @@ -630,8 +630,8 @@ public List getAttachmentListSorted(Document doc, String comparator) List attachments = doc.getAttachmentList(); try { - Comparator comparatorClass = (Comparator) Class.forName( - "com.celements.web.comparators." + comparator).newInstance(); + Comparator comparatorClass = (Comparator) Class + .forName("com.celements.web.comparators." + comparator).newInstance(); Collections.sort(attachments, comparatorClass); } catch (InstantiationException e) { LOGGER.error("getAttachmentListSorted failed.", e); @@ -732,8 +732,8 @@ public List getAttachmentListForTagSortedSpace(String spaceName, Str LOGGER.error("Could not get all documents in " + spaceName, xwe); } try { - Comparator comparatorClass = (Comparator) Class.forName( - "com.celements.web.comparators." + comparator).newInstance(); + Comparator comparatorClass = (Comparator) Class + .forName("com.celements.web.comparators." + comparator).newInstance(); Collections.sort(attachments, comparatorClass); } catch (InstantiationException e) { LOGGER.error("getAttachmentListSortedSpace failed.", e); @@ -753,8 +753,8 @@ public List getAttachmentListForTagSortedSpace(String spaceName, Str } List filterAttachmentsByTag(List attachments, String tagName) { - if ((tagName != null) && getContext().getWiki().exists(resolveDocumentReference(tagName), - getContext())) { + if ((tagName != null) + && getContext().getWiki().exists(resolveDocumentReference(tagName), getContext())) { XWikiDocument filterDoc = null; try { filterDoc = getContext().getWiki().getDocument(resolveDocumentReference(tagName), @@ -808,8 +808,8 @@ List reduceListToSize(List list, int start, int nb) { if ((start <= 0) && ((nb <= 0) || (nb >= list.size()))) { countedAtts = list; } else if (start < list.size()) { - countedAtts = list.subList(Math.max(0, start), Math.min(Math.max(0, start) + Math.max(0, nb), - list.size())); + countedAtts = list.subList(Math.max(0, start), + Math.min(Math.max(0, start) + Math.max(0, nb), list.size())); } return countedAtts; } @@ -862,8 +862,10 @@ Map xwikiDoctoLinkedMap(XWikiDocument xwikiDoc, boolean bWithObj docData.put("comment", xwikiDoc.getComment()); docData.put("minorEdit", String.valueOf(xwikiDoc.isMinorEdit())); docData.put("syntaxId", xwikiDoc.getSyntax().toIdString()); - docData.put("menuName", menuNameCmd.getMultilingualMenuName(modelUtils.serializeRef( - xwikiDoc.getDocumentReference()), getContext().getLanguage(), getContext())); + docData.put("menuName", + menuNameCmd.getMultilingualMenuName( + modelUtils.serializeRef(xwikiDoc.getDocumentReference()), getContext().getLanguage(), + getContext())); // docData.put("hidden", String.valueOf(xwikiDoc.isHidden())); /** @@ -902,16 +904,15 @@ Map xwikiDoctoLinkedMap(XWikiDocument xwikiDoc, boolean bWithObj if (bWithRendering) { try { - docData.put("renderedcontent", replaceInternalWithExternalLinks(xwikiDoc.getRenderedContent( - getContext()), host)); + docData.put("renderedcontent", + replaceInternalWithExternalLinks(xwikiDoc.getRenderedContent(getContext()), host)); } catch (XWikiException exp) { LOGGER.error("Exception with rendering content: ", exp); } try { - docData.put("celrenderedcontent", replaceInternalWithExternalLinks( - getCelementsRenderCmd().renderCelementsDocument(xwikiDoc.getDocumentReference(), - getContext().getLanguage(), "view"), - host)); + docData.put("celrenderedcontent", + replaceInternalWithExternalLinks(getCelementsRenderCmd().renderCelementsDocument( + xwikiDoc.getDocumentReference(), getContext().getLanguage(), "view"), host)); } catch (XWikiException exp) { LOGGER.error("Exception with rendering content: ", exp); } @@ -934,10 +935,10 @@ private RenderCommand getCelementsRenderCmd() { } String replaceInternalWithExternalLinks(String content, String host) { - String result = content.replaceAll("src=\\\"(\\.\\./)*/?download/", "src=\"http://" + host - + "/download/"); - result = result.replaceAll("href=\\\"(\\.\\./)*/?download/", "href=\"http://" + host - + "/download/"); + String result = content.replaceAll("src=\\\"(\\.\\./)*/?download/", + "src=\"http://" + host + "/download/"); + result = result.replaceAll("href=\\\"(\\.\\./)*/?download/", + "href=\"http://" + host + "/download/"); result = result.replaceAll("href=\\\"(\\.\\./)*/?skin/", "href=\"http://" + host + "/skin/"); result = result.replaceAll("href=\\\"(\\.\\./)*/?view/", "href=\"http://" + host + "/view/"); result = result.replaceAll("href=\\\"(\\.\\./)*/?edit/", "href=\"http://" + host + "/edit/"); @@ -1240,12 +1241,12 @@ public List getAttachmentsForDocs(List docsFN) { for (String docFN : docsFN) { try { LOGGER.info("getAttachmentsForDocs: processing doc " + docFN); - for (XWikiAttachment xwikiAttachment : getContext().getWiki().getDocument( - resolveDocumentReference(docFN), getContext()).getAttachmentList()) { + for (XWikiAttachment xwikiAttachment : getContext().getWiki() + .getDocument(resolveDocumentReference(docFN), getContext()).getAttachmentList()) { LOGGER.info("getAttachmentsForDocs: adding attachment " + xwikiAttachment.getFilename() + " to list."); - attachments.add(new Attachment(getContext().getWiki().getDocument( - resolveDocumentReference(docFN), getContext()).newDocument(getContext()), + attachments.add(new Attachment(getContext().getWiki() + .getDocument(resolveDocumentReference(docFN), getContext()).newDocument(getContext()), xwikiAttachment, getContext())); } } catch (XWikiException exp) { @@ -1256,16 +1257,11 @@ public List getAttachmentsForDocs(List docsFN) { } @Override - public String getTranslatedDiscTemplateContent(String renderTemplatePath, - String language, String defaultLanguage) { - return StreamEx.of(language, defaultLanguage) - .mapPartial(MoreOptional::asNonBlank) - .append("") - .distinct() - .map(lang -> getTemplatePathOnDisk(renderTemplatePath, lang)) - .mapPartial(this::loadResourceContent) - .findFirst() - .orElse(""); + public String getTranslatedDiscTemplateContent(String renderTemplatePath, String language, + String defaultLanguage) { + return StreamEx.of(language, defaultLanguage).mapPartial(MoreOptional::asNonBlank).append("") + .distinct().map(lang -> getTemplatePathOnDisk(renderTemplatePath, lang)) + .mapPartial(this::loadResourceContent).findFirst().orElse(""); } private Optional loadResourceContent(String templatePath) { @@ -1306,11 +1302,11 @@ public void sendCheckJobMail(String jobMailName, String fromAddr, String toAddr, String textContent = new PlainTextCommand().convertToPlainText(htmlContent); sender.setTextContent(textContent); int successfulSend = sender.sendMail(); - LOGGER.debug("sendCheckJobMail ended for [" + toAddr + "] email send [" + successfulSend - + "]."); + LOGGER.debug( + "sendCheckJobMail ended for [" + toAddr + "] email send [" + successfulSend + "]."); } else { - LOGGER.warn("No Email content found for [" + jobMailName + "] [" + emailTemplateDocRef - + "]."); + LOGGER.warn( + "No Email content found for [" + jobMailName + "] [" + emailTemplateDocRef + "]."); } } catch (XWikiException exp) { LOGGER.error("Failed to render email template document [" + emailTemplateDocRef + "].", exp); @@ -1386,8 +1382,8 @@ public DocumentReference checkWikiRef(DocumentReference docRef, XWikiDocument to public DocumentReference checkWikiRef(DocumentReference docRef, EntityReference toRef) { WikiReference wikiRef = getWikiRef(toRef); if (!docRef.getWikiReference().equals(wikiRef)) { - docRef = new DocumentReference(docRef.getName(), new SpaceReference( - docRef.getLastSpaceReference().getName(), wikiRef)); + docRef = new DocumentReference(docRef.getName(), + new SpaceReference(docRef.getLastSpaceReference().getName(), wikiRef)); } return docRef; } diff --git a/src/main/java/com/celements/webform/ActionService.java b/src/main/java/com/celements/webform/ActionService.java index 341a95e34..6bc34a6b0 100644 --- a/src/main/java/com/celements/webform/ActionService.java +++ b/src/main/java/com/celements/webform/ActionService.java @@ -55,8 +55,8 @@ public boolean executeAction(Document actionDoc, Map request, XWikiDocument execAct = null; try { // TODO reimplement the celements2web:Macros.executeActions in Java - execAct = modelAccess.getDocument(create(DocumentReference.class, "executeActions", create( - EntityType.SPACE, "Macros", create(EntityType.WIKI, "celements2web")))); + execAct = modelAccess.getDocument(create(DocumentReference.class, "executeActions", + create(EntityType.SPACE, "Macros", create(EntityType.WIKI, "celements2web")))); final Object configJavaDebug = configSource.getProperty("celements.action.javaDebug"); vcontext.put("javaDebug", configJavaDebug); execContent = execAct.getContent(); @@ -69,8 +69,8 @@ public boolean executeAction(Document actionDoc, Map request, final Object successfulObj = vcontext.get("successful"); final boolean successful = (successfulObj != null) && "true".equals(successfulObj.toString()); if (!successful) { - LOGGER.error("executeAction: Error executing action. Output: {}", vcontext.get( - "actionScriptOutput")); + LOGGER.error("executeAction: Error executing action. Output: {}", + vcontext.get("actionScriptOutput")); LOGGER.error("executeAction: Rendered Action Script: {}", actionContent); LOGGER.error("executeAction: execAct == {}", execAct); LOGGER.error("executeAction: includingDoc: {}", includingDoc); diff --git a/src/test/java/com/celements/appScript/AppScriptServiceTest.java b/src/test/java/com/celements/appScript/AppScriptServiceTest.java index 8774ebbf0..80220b39f 100644 --- a/src/test/java/com/celements/appScript/AppScriptServiceTest.java +++ b/src/test/java/com/celements/appScript/AppScriptServiceTest.java @@ -61,12 +61,12 @@ public void test_isAppScriptRequest_appXpage() { XWikiRequest mockRequest = createMock(XWikiRequest.class); context.setRequest(mockRequest); context.setAction("view"); - expect(mockRequest.getParameter(eq("xpage"))).andReturn( - IAppScriptService.APP_SCRIPT_XPAGE).anyTimes(); + expect(mockRequest.getParameter(eq("xpage"))).andReturn(IAppScriptService.APP_SCRIPT_XPAGE) + .anyTimes(); expect(mockRequest.getParameter(eq("s"))).andReturn("myScript").anyTimes(); - expect(xwiki.getXWikiPreference(eq(IAppScriptService.APP_SCRIPT_XWPREF_OVERW_DOCS), eq( - IAppScriptService.APP_SCRIPT_CONF_OVERW_DOCS), eq("-"), same(context))).andReturn( - "Content.login").anyTimes(); + expect(xwiki.getXWikiPreference(eq(IAppScriptService.APP_SCRIPT_XWPREF_OVERW_DOCS), + eq(IAppScriptService.APP_SCRIPT_CONF_OVERW_DOCS), eq("-"), same(context))) + .andReturn("Content.login").anyTimes(); replayDefault(mockRequest); assertTrue(appScriptService.isAppScriptRequest()); verifyDefault(mockRequest); @@ -109,9 +109,9 @@ public void test_isAppScriptRequest_view_overwriteAppDoc_comma() { XWikiDocument contextDoc = new XWikiDocument(contextDocRef); context.setDoc(contextDoc); expect(mockRequest.getParameter(eq("xpage"))).andReturn("").anyTimes(); - expect(xwiki.getXWikiPreference(eq(IAppScriptService.APP_SCRIPT_XWPREF_OVERW_DOCS), eq( - IAppScriptService.APP_SCRIPT_CONF_OVERW_DOCS), eq("-"), same(context))).andReturn( - "Content.login,Content.WhatsNew").anyTimes(); + expect(xwiki.getXWikiPreference(eq(IAppScriptService.APP_SCRIPT_XWPREF_OVERW_DOCS), + eq(IAppScriptService.APP_SCRIPT_CONF_OVERW_DOCS), eq("-"), same(context))) + .andReturn("Content.login,Content.WhatsNew").anyTimes(); replayDefault(mockRequest); assertTrue(appScriptService.isAppScriptRequest()); verifyDefault(mockRequest); @@ -127,9 +127,9 @@ public void test_isAppScriptRequest_view_overwriteAppDoc_space() { XWikiDocument contextDoc = new XWikiDocument(contextDocRef); context.setDoc(contextDoc); expect(mockRequest.getParameter(eq("xpage"))).andReturn("").anyTimes(); - expect(xwiki.getXWikiPreference(eq(IAppScriptService.APP_SCRIPT_XWPREF_OVERW_DOCS), eq( - IAppScriptService.APP_SCRIPT_CONF_OVERW_DOCS), eq("-"), same(context))).andReturn( - "Content.WhatsNew Content.login").anyTimes(); + expect(xwiki.getXWikiPreference(eq(IAppScriptService.APP_SCRIPT_XWPREF_OVERW_DOCS), + eq(IAppScriptService.APP_SCRIPT_CONF_OVERW_DOCS), eq("-"), same(context))) + .andReturn("Content.WhatsNew Content.login").anyTimes(); replayDefault(mockRequest); assertTrue(appScriptService.isAppScriptRequest()); verifyDefault(mockRequest); @@ -145,9 +145,9 @@ public void test_isAppScriptRequest_view_overwriteAppDoc_noConfig() { XWikiDocument contextDoc = new XWikiDocument(contextDocRef); context.setDoc(contextDoc); expect(mockRequest.getParameter(eq("xpage"))).andReturn("").anyTimes(); - expect(xwiki.getXWikiPreference(eq("appScriptOverwriteDocs"), eq( - "com.celements.appScript.overwriteDocs"), eq("-"), same(context))).andReturn( - "-").anyTimes(); + expect(xwiki.getXWikiPreference(eq("appScriptOverwriteDocs"), + eq("com.celements.appScript.overwriteDocs"), eq("-"), same(context))).andReturn("-") + .anyTimes(); replayDefault(mockRequest); assertFalse(appScriptService.isAppScriptRequest()); verifyDefault(mockRequest); @@ -163,9 +163,9 @@ public void test_isAppScriptRequest_view_noAppSpace() { XWikiDocument contextDoc = new XWikiDocument(contextDocRef); context.setDoc(contextDoc); expect(mockRequest.getParameter(eq("xpage"))).andReturn("").anyTimes(); - expect(xwiki.getXWikiPreference(eq("appScriptOverwriteDocs"), eq( - "com.celements.appScript.overwriteDocs"), eq("-"), same(context))).andReturn( - "-").anyTimes(); + expect(xwiki.getXWikiPreference(eq("appScriptOverwriteDocs"), + eq("com.celements.appScript.overwriteDocs"), eq("-"), same(context))).andReturn("-") + .anyTimes(); replayDefault(mockRequest); assertFalse(appScriptService.isAppScriptRequest()); verifyDefault(mockRequest); @@ -180,12 +180,12 @@ public void test_getAppScriptNameFromRequestURL_appXpage() { XWikiRequest mockRequest = createMock(XWikiRequest.class); context.setRequest(mockRequest); context.setAction("view"); - expect(mockRequest.getParameter(eq("xpage"))).andReturn( - IAppScriptService.APP_SCRIPT_XPAGE).anyTimes(); + expect(mockRequest.getParameter(eq("xpage"))).andReturn(IAppScriptService.APP_SCRIPT_XPAGE) + .anyTimes(); expect(mockRequest.getParameter(eq("s"))).andReturn("myScript").anyTimes(); - expect(xwiki.getXWikiPreference(eq(IAppScriptService.APP_SCRIPT_XWPREF_OVERW_DOCS), eq( - IAppScriptService.APP_SCRIPT_CONF_OVERW_DOCS), eq("-"), same(context))).andReturn( - "Content.login").anyTimes(); + expect(xwiki.getXWikiPreference(eq(IAppScriptService.APP_SCRIPT_XWPREF_OVERW_DOCS), + eq(IAppScriptService.APP_SCRIPT_CONF_OVERW_DOCS), eq("-"), same(context))) + .andReturn("Content.login").anyTimes(); replayDefault(mockRequest); assertEquals("myScript", appScriptService.getAppScriptNameFromRequestURL()); verifyDefault(mockRequest); @@ -203,8 +203,8 @@ public void test_getAppScriptNameFromRequestURL_appAction() { context.setDoc(contextDoc); expect(mockRequest.getParameter(eq("xpage"))).andReturn("").anyTimes(); expect(mockRequest.getParameter(eq("s"))).andReturn("").anyTimes(); - expect(mockRequest.getPathInfo()).andReturn("/" + IAppScriptService.APP_SCRIPT_XPAGE - + "/pathTo/myScript").anyTimes(); + expect(mockRequest.getPathInfo()) + .andReturn("/" + IAppScriptService.APP_SCRIPT_XPAGE + "/pathTo/myScript").anyTimes(); getConfigurationSource().setProperty(IAppScriptService.APP_SCRIPT_ACTION_NAME_CONF_PROPERTY, IAppScriptService.APP_SCRIPT_XPAGE); replayDefault(mockRequest); @@ -224,8 +224,9 @@ public void test_getAppScriptNameFromRequestURL_appAction2() { context.setDoc(contextDoc); expect(mockRequest.getParameter(eq("xpage"))).andReturn("").anyTimes(); expect(mockRequest.getParameter(eq("s"))).andReturn("").anyTimes(); - expect(mockRequest.getPathInfo()).andReturn("/" + IAppScriptService.APP_SCRIPT_XPAGE - + "/pathTo/pathTo2/myScript").anyTimes(); + expect(mockRequest.getPathInfo()) + .andReturn("/" + IAppScriptService.APP_SCRIPT_XPAGE + "/pathTo/pathTo2/myScript") + .anyTimes(); getConfigurationSource().setProperty(IAppScriptService.APP_SCRIPT_ACTION_NAME_CONF_PROPERTY, IAppScriptService.APP_SCRIPT_XPAGE); replayDefault(mockRequest); @@ -244,8 +245,8 @@ public void test_getAppScriptNameFromRequestURL_view_appSpace() { context.setDoc(contextDoc); expect(mockRequest.getParameter(eq("xpage"))).andReturn("").anyTimes(); expect(mockRequest.getParameter(eq("s"))).andReturn("").anyTimes(); - expect(mockRequest.getPathInfo()).andReturn("/" + IAppScriptService.APP_SCRIPT_XPAGE - + "/myScript").anyTimes(); + expect(mockRequest.getPathInfo()) + .andReturn("/" + IAppScriptService.APP_SCRIPT_XPAGE + "/myScript").anyTimes(); getConfigurationSource().setProperty(IAppScriptService.APP_SCRIPT_ACTION_NAME_CONF_PROPERTY, IAppScriptService.APP_SCRIPT_XPAGE); replayDefault(mockRequest); @@ -266,9 +267,9 @@ public void test_getAppScriptNameFromRequestURL_view_noAppSpace() { expect(mockRequest.getParameter(eq("s"))).andReturn("").anyTimes(); getConfigurationSource().setProperty(IAppScriptService.APP_SCRIPT_ACTION_NAME_CONF_PROPERTY, IAppScriptService.APP_SCRIPT_XPAGE); - expect(xwiki.getXWikiPreference(eq(IAppScriptService.APP_SCRIPT_XWPREF_OVERW_DOCS), eq( - IAppScriptService.APP_SCRIPT_CONF_OVERW_DOCS), eq("-"), same(context))).andReturn( - "Content.login").anyTimes(); + expect(xwiki.getXWikiPreference(eq(IAppScriptService.APP_SCRIPT_XWPREF_OVERW_DOCS), + eq(IAppScriptService.APP_SCRIPT_CONF_OVERW_DOCS), eq("-"), same(context))) + .andReturn("Content.login").anyTimes(); replayDefault(mockRequest); assertEquals("", appScriptService.getAppScriptNameFromRequestURL()); verifyDefault(mockRequest); @@ -288,9 +289,9 @@ public void test_getAppScriptNameFromRequestURL_view_overwriteAppDoc() { expect(mockRequest.getPathInfo()).andReturn("/login").anyTimes(); getConfigurationSource().setProperty(IAppScriptService.APP_SCRIPT_ACTION_NAME_CONF_PROPERTY, IAppScriptService.APP_SCRIPT_XPAGE); - expect(xwiki.getXWikiPreference(eq(IAppScriptService.APP_SCRIPT_XWPREF_OVERW_DOCS), eq( - IAppScriptService.APP_SCRIPT_CONF_OVERW_DOCS), eq("-"), same(context))).andReturn( - "Content.WhatsNew Content.login").anyTimes(); + expect(xwiki.getXWikiPreference(eq(IAppScriptService.APP_SCRIPT_XWPREF_OVERW_DOCS), + eq(IAppScriptService.APP_SCRIPT_CONF_OVERW_DOCS), eq("-"), same(context))) + .andReturn("Content.WhatsNew Content.login").anyTimes(); replayDefault(mockRequest); assertEquals("login", appScriptService.getAppScriptNameFromRequestURL()); verifyDefault(mockRequest); @@ -317,8 +318,8 @@ public void test_hasDocAppScript_appAction() { IAppScriptService.APP_SCRIPT_SPACE_NAME, "sub/testScript"); expect(modelAccessMock.exists(eq(centralAppScriptDocRef))).andReturn(false); expect(emptyCheckMock.isEmptyRTEDocument(eq(appScriptDocRef))).andReturn(false).anyTimes(); - expect(emptyCheckMock.isEmptyRTEDocument(eq(centralAppScriptDocRef))).andReturn( - false).anyTimes(); + expect(emptyCheckMock.isEmptyRTEDocument(eq(centralAppScriptDocRef))).andReturn(false) + .anyTimes(); replayDefault(mockRequest); assertFalse(appScriptService.hasDocAppScript("sub/testScript")); verifyDefault(mockRequest); @@ -358,15 +359,14 @@ public void test_getAppScriptDocRef_localOverwritesCentral() throws Exception { expect(modelAccessMock.exists(eq(appScriptDocRef))).andReturn(true).anyTimes(); DocumentReference centralAppScriptDocRef = new DocumentReference("celements2web", IAppScriptService.APP_SCRIPT_SPACE_NAME, "testScript"); - expect(modelAccessMock.exists(eq(centralAppScriptDocRef))).andReturn(false) - .anyTimes(); + expect(modelAccessMock.exists(eq(centralAppScriptDocRef))).andReturn(false).anyTimes(); XWikiDocument appScriptDoc = new XWikiDocument(appScriptDocRef); appScriptDoc.setContent("this is no empty script!"); - expect(xwiki.getDocument(eq(appScriptDocRef), same(context))).andReturn( - appScriptDoc).anyTimes(); - expect(xwiki.getXWikiPreference(eq(IEmptyCheckRole.EMPTYCHECK_MODULS_PREF_NAME), eq( - "celements.emptycheckModuls"), eq("default"), same(context))).andReturn( - "default").anyTimes(); + expect(xwiki.getDocument(eq(appScriptDocRef), same(context))).andReturn(appScriptDoc) + .anyTimes(); + expect(xwiki.getXWikiPreference(eq(IEmptyCheckRole.EMPTYCHECK_MODULS_PREF_NAME), + eq("celements.emptycheckModuls"), eq("default"), same(context))).andReturn("default") + .anyTimes(); expect(emptyCheckMock.isEmptyRTEDocument(eq(appScriptDocRef))).andReturn(false).anyTimes(); replayDefault(mockRequest); DocumentReference expectedAppDocRef = new DocumentReference(context.getDatabase(), @@ -392,15 +392,14 @@ public void test_getAppScriptDocRef_noLocalButCentral() throws Exception { expect(modelAccessMock.exists(eq(appScriptDocRef))).andReturn(false).anyTimes(); DocumentReference centralAppScriptDocRef = new DocumentReference("celements2web", IAppScriptService.APP_SCRIPT_SPACE_NAME, "testScript"); - expect(modelAccessMock.exists(eq(centralAppScriptDocRef))).andReturn(true) - .anyTimes(); + expect(modelAccessMock.exists(eq(centralAppScriptDocRef))).andReturn(true).anyTimes(); XWikiDocument appScriptDoc = new XWikiDocument(appScriptDocRef); appScriptDoc.setContent("this is no empty script!"); - expect(xwiki.getDocument(eq(centralAppScriptDocRef), same(context))).andReturn( - appScriptDoc).anyTimes(); + expect(xwiki.getDocument(eq(centralAppScriptDocRef), same(context))).andReturn(appScriptDoc) + .anyTimes(); expect(emptyCheckMock.isEmptyRTEDocument(eq(appScriptDocRef))).andReturn(false).anyTimes(); - expect(emptyCheckMock.isEmptyRTEDocument(eq(centralAppScriptDocRef))).andReturn( - true).anyTimes(); + expect(emptyCheckMock.isEmptyRTEDocument(eq(centralAppScriptDocRef))).andReturn(true) + .anyTimes(); replayDefault(mockRequest); DocumentReference expectedAppDocRef = new DocumentReference("celements2web", IAppScriptService.APP_SCRIPT_SPACE_NAME, "testScript"); @@ -419,9 +418,9 @@ public void test_getScriptNameFromURL_emptyPathInfo() { context.setDoc(contextDoc); expect(mockRequest.getParameter(eq("xpage"))).andReturn("").anyTimes(); expect(mockRequest.getParameter(eq("s"))).andReturn("").anyTimes(); - expect(xwiki.getXWikiPreference(eq(IAppScriptService.APP_SCRIPT_XWPREF_OVERW_DOCS), eq( - IAppScriptService.APP_SCRIPT_CONF_OVERW_DOCS), eq("-"), same(context))).andReturn( - "Main.WebHome").anyTimes(); + expect(xwiki.getXWikiPreference(eq(IAppScriptService.APP_SCRIPT_XWPREF_OVERW_DOCS), + eq(IAppScriptService.APP_SCRIPT_CONF_OVERW_DOCS), eq("-"), same(context))) + .andReturn("Main.WebHome").anyTimes(); expect(mockRequest.getPathInfo()).andReturn("").anyTimes(); replayDefault(mockRequest); assertEquals("WebHome", appScriptService.getScriptNameFromURL()); @@ -438,9 +437,9 @@ public void test_getScriptNameFromURL_explicit_DefaultSpace() { context.setDoc(contextDoc); expect(mockRequest.getParameter(eq("xpage"))).andReturn("").anyTimes(); expect(mockRequest.getParameter(eq("s"))).andReturn("").anyTimes(); - expect(xwiki.getXWikiPreference(eq(IAppScriptService.APP_SCRIPT_XWPREF_OVERW_DOCS), eq( - IAppScriptService.APP_SCRIPT_CONF_OVERW_DOCS), eq("-"), same(context))).andReturn( - "Main.Test").anyTimes(); + expect(xwiki.getXWikiPreference(eq(IAppScriptService.APP_SCRIPT_XWPREF_OVERW_DOCS), + eq(IAppScriptService.APP_SCRIPT_CONF_OVERW_DOCS), eq("-"), same(context))) + .andReturn("Main.Test").anyTimes(); expect(mockRequest.getPathInfo()).andReturn("/Main/Test").anyTimes(); replayDefault(mockRequest); assertEquals("Test", appScriptService.getScriptNameFromURL()); @@ -458,9 +457,9 @@ public void test_getScriptNameFromURL_explicit_DefaultPage() { context.setDoc(contextDoc); expect(mockRequest.getParameter(eq("xpage"))).andReturn("").anyTimes(); expect(mockRequest.getParameter(eq("s"))).andReturn("").anyTimes(); - expect(xwiki.getXWikiPreference(eq(IAppScriptService.APP_SCRIPT_XWPREF_OVERW_DOCS), eq( - IAppScriptService.APP_SCRIPT_CONF_OVERW_DOCS), eq("-"), same(context))).andReturn( - "Test.WebHome").anyTimes(); + expect(xwiki.getXWikiPreference(eq(IAppScriptService.APP_SCRIPT_XWPREF_OVERW_DOCS), + eq(IAppScriptService.APP_SCRIPT_CONF_OVERW_DOCS), eq("-"), same(context))) + .andReturn("Test.WebHome").anyTimes(); expect(mockRequest.getPathInfo()).andReturn("/Test/WebHome").anyTimes(); replayDefault(mockRequest); assertEquals("Test/WebHome", appScriptService.getScriptNameFromURL()); @@ -478,9 +477,9 @@ public void test_getScriptNameFromURL_implicit_DefaultPage() { context.setDoc(contextDoc); expect(mockRequest.getParameter(eq("xpage"))).andReturn("").anyTimes(); expect(mockRequest.getParameter(eq("s"))).andReturn("").anyTimes(); - expect(xwiki.getXWikiPreference(eq(IAppScriptService.APP_SCRIPT_XWPREF_OVERW_DOCS), eq( - IAppScriptService.APP_SCRIPT_CONF_OVERW_DOCS), eq("-"), same(context))).andReturn( - "Test.WebHome").anyTimes(); + expect(xwiki.getXWikiPreference(eq(IAppScriptService.APP_SCRIPT_XWPREF_OVERW_DOCS), + eq(IAppScriptService.APP_SCRIPT_CONF_OVERW_DOCS), eq("-"), same(context))) + .andReturn("Test.WebHome").anyTimes(); expect(mockRequest.getPathInfo()).andReturn("/Test/").anyTimes(); replayDefault(mockRequest); assertEquals("Test/WebHome", appScriptService.getScriptNameFromURL()); @@ -498,9 +497,9 @@ public void test_getScriptNameFromURL_explicit_DefaultSpace_DefaultPage() { context.setDoc(contextDoc); expect(mockRequest.getParameter(eq("xpage"))).andReturn("").anyTimes(); expect(mockRequest.getParameter(eq("s"))).andReturn("").anyTimes(); - expect(xwiki.getXWikiPreference(eq(IAppScriptService.APP_SCRIPT_XWPREF_OVERW_DOCS), eq( - IAppScriptService.APP_SCRIPT_CONF_OVERW_DOCS), eq("-"), same(context))).andReturn( - "Main.WebHome").anyTimes(); + expect(xwiki.getXWikiPreference(eq(IAppScriptService.APP_SCRIPT_XWPREF_OVERW_DOCS), + eq(IAppScriptService.APP_SCRIPT_CONF_OVERW_DOCS), eq("-"), same(context))) + .andReturn("Main.WebHome").anyTimes(); expect(mockRequest.getPathInfo()).andReturn("/Main/WebHome").anyTimes(); replayDefault(mockRequest); assertEquals("WebHome", appScriptService.getScriptNameFromURL()); @@ -518,9 +517,9 @@ public void test_getScriptNameFromURL_export_action() { context.setDoc(contextDoc); expect(mockRequest.getParameter(eq("xpage"))).andReturn("").anyTimes(); expect(mockRequest.getParameter(eq("s"))).andReturn("").anyTimes(); - expect(xwiki.getXWikiPreference(eq(IAppScriptService.APP_SCRIPT_XWPREF_OVERW_DOCS), eq( - IAppScriptService.APP_SCRIPT_CONF_OVERW_DOCS), eq("-"), same(context))).andReturn( - "TestSpace.TestScript").anyTimes(); + expect(xwiki.getXWikiPreference(eq(IAppScriptService.APP_SCRIPT_XWPREF_OVERW_DOCS), + eq(IAppScriptService.APP_SCRIPT_CONF_OVERW_DOCS), eq("-"), same(context))) + .andReturn("TestSpace.TestScript").anyTimes(); expect(mockRequest.getPathInfo()).andReturn("/export/TestSpace/TestScript").anyTimes(); replayDefault(mockRequest); assertEquals("TestSpace/TestScript", appScriptService.getScriptNameFromURL()); @@ -625,11 +624,9 @@ public void test_getAppRecursiveScript_exists() throws Exception { String scriptNamePathBase = "/templates/celAppScripts/"; String expectedScriptName = "path/to++"; expect(xwiki.getResourceContentAsBytes(eq(scriptNamePathBase + expectedScriptName + ".vm"))) - .andReturn(new byte[0]) - .atLeastOnce(); + .andReturn(new byte[0]).atLeastOnce(); expect(xwiki.getResourceContentAsBytes(eq(scriptNamePathBase + "path/to/my++.vm"))) - .andThrow(new IOException()) - .atLeastOnce(); + .andThrow(new IOException()).atLeastOnce(); replayDefault(); assertEquals(expectedScriptName, appScriptService.getAppRecursiveScript(scriptName).get()); verifyDefault(); @@ -640,14 +637,11 @@ public void test_getAppRecursiveScript_notExists() throws Exception { String scriptName = "path/to/my/appscript"; String scriptNamePathBase = "/templates/celAppScripts/"; expect(xwiki.getResourceContentAsBytes(eq(scriptNamePathBase + "path/to/my++.vm"))) - .andThrow(new IOException()) - .atLeastOnce(); + .andThrow(new IOException()).atLeastOnce(); expect(xwiki.getResourceContentAsBytes(eq(scriptNamePathBase + "path/to++.vm"))) - .andThrow(new IOException()) - .atLeastOnce(); + .andThrow(new IOException()).atLeastOnce(); expect(xwiki.getResourceContentAsBytes(eq(scriptNamePathBase + "path++.vm"))) - .andThrow(new IOException()) - .atLeastOnce(); + .andThrow(new IOException()).atLeastOnce(); replayDefault(); assertFalse(appScriptService.getAppRecursiveScript(scriptName).isPresent()); verifyDefault(); @@ -660,16 +654,14 @@ public void test_getAppRecursiveScriptDocRef_found() { expect(modelAccessMock.exists(eq(appScriptDocRef2))).andReturn(false).atLeastOnce(); expect(emptyCheckMock.isEmptyRTEDocument(eq(appScriptDocRef2))).andReturn(true).atLeastOnce(); DocumentReference appScriptCentralDocRef2 = createScriptCentralDocRef("path/to/my"); - expect(modelAccessMock.exists(eq(appScriptCentralDocRef2))).andReturn(false) - .atLeastOnce(); + expect(modelAccessMock.exists(eq(appScriptCentralDocRef2))).andReturn(false).atLeastOnce(); expect(emptyCheckMock.isEmptyRTEDocument(eq(appScriptCentralDocRef2))).andReturn(true) .atLeastOnce(); DocumentReference appScriptDocRef3 = createScriptDocRef("path/to"); expect(modelAccessMock.exists(eq(appScriptDocRef3))).andReturn(false).atLeastOnce(); expect(emptyCheckMock.isEmptyRTEDocument(eq(appScriptDocRef3))).andReturn(true).atLeastOnce(); DocumentReference appScriptCentralDocRef3 = createScriptCentralDocRef("path/to"); - expect(modelAccessMock.exists(eq(appScriptCentralDocRef3))).andReturn(false) - .atLeastOnce(); + expect(modelAccessMock.exists(eq(appScriptCentralDocRef3))).andReturn(false).atLeastOnce(); expect(emptyCheckMock.isEmptyRTEDocument(eq(appScriptCentralDocRef3))).andReturn(true) .atLeastOnce(); DocumentReference appScriptDocRef = createScriptDocRef("path"); @@ -687,24 +679,21 @@ public void test_getAppRecursiveScriptDocRef_notFound() { expect(modelAccessMock.exists(eq(appScriptDocRef2))).andReturn(false).atLeastOnce(); expect(emptyCheckMock.isEmptyRTEDocument(eq(appScriptDocRef2))).andReturn(true).atLeastOnce(); DocumentReference appScriptCentralDocRef2 = createScriptCentralDocRef("path/to/my"); - expect(modelAccessMock.exists(eq(appScriptCentralDocRef2))).andReturn(false) - .atLeastOnce(); + expect(modelAccessMock.exists(eq(appScriptCentralDocRef2))).andReturn(false).atLeastOnce(); expect(emptyCheckMock.isEmptyRTEDocument(eq(appScriptCentralDocRef2))).andReturn(true) .atLeastOnce(); DocumentReference appScriptDocRef3 = createScriptDocRef("path/to"); expect(modelAccessMock.exists(eq(appScriptDocRef3))).andReturn(false).atLeastOnce(); expect(emptyCheckMock.isEmptyRTEDocument(eq(appScriptDocRef3))).andReturn(true).atLeastOnce(); DocumentReference appScriptCentralDocRef3 = createScriptCentralDocRef("path/to"); - expect(modelAccessMock.exists(eq(appScriptCentralDocRef3))).andReturn(false) - .atLeastOnce(); + expect(modelAccessMock.exists(eq(appScriptCentralDocRef3))).andReturn(false).atLeastOnce(); expect(emptyCheckMock.isEmptyRTEDocument(eq(appScriptCentralDocRef3))).andReturn(true) .atLeastOnce(); DocumentReference appScriptDocRef = createScriptDocRef("path"); expect(modelAccessMock.exists(eq(appScriptDocRef))).andReturn(false).atLeastOnce(); expect(emptyCheckMock.isEmptyRTEDocument(eq(appScriptDocRef))).andReturn(true).atLeastOnce(); DocumentReference appScriptCentralDocRef = createScriptCentralDocRef("path"); - expect(modelAccessMock.exists(eq(appScriptCentralDocRef))).andReturn(false) - .atLeastOnce(); + expect(modelAccessMock.exists(eq(appScriptCentralDocRef))).andReturn(false).atLeastOnce(); expect(emptyCheckMock.isEmptyRTEDocument(eq(appScriptCentralDocRef))).andReturn(true) .atLeastOnce(); replayDefault(); @@ -717,14 +706,11 @@ public void test_getAppRecursiveSetupScript_exists() throws Exception { String scriptName = "path/to/my/appscript"; String scriptNamePathBase = "/templates/celAppScripts/"; expect(xwiki.getResourceContentAsBytes(eq(scriptNamePathBase + "path/to/my++.vm"))) - .andThrow(new IOException()) - .atLeastOnce(); + .andThrow(new IOException()).atLeastOnce(); expect(xwiki.getResourceContentAsBytes(eq(scriptNamePathBase + "path/to++.vm"))) - .andReturn(new byte[0]) - .atLeastOnce(); + .andReturn(new byte[0]).atLeastOnce(); expect(xwiki.getResourceContentAsBytes(eq(scriptNamePathBase + "path/to_setup++.vm"))) - .andReturn(new byte[0]) - .once(); + .andReturn(new byte[0]).once(); replayDefault(); assertEquals("path/to_setup++", appScriptService.getAppRecursiveSetupScript(scriptName).get()); verifyDefault(); @@ -735,14 +721,11 @@ public void test_getAppRecursiveSetupScript_setupNotExists() throws Exception { String scriptName = "path/to/my/appscript"; String scriptNamePathBase = "/templates/celAppScripts/"; expect(xwiki.getResourceContentAsBytes(eq(scriptNamePathBase + "path/to/my++.vm"))) - .andThrow(new IOException()) - .atLeastOnce(); + .andThrow(new IOException()).atLeastOnce(); expect(xwiki.getResourceContentAsBytes(eq(scriptNamePathBase + "path/to++.vm"))) - .andReturn(new byte[0]) - .atLeastOnce(); + .andReturn(new byte[0]).atLeastOnce(); expect(xwiki.getResourceContentAsBytes(eq(scriptNamePathBase + "path/to_setup++.vm"))) - .andThrow(new IOException()) - .once(); + .andThrow(new IOException()).once(); replayDefault(); assertFalse(appScriptService.getAppRecursiveSetupScript(scriptName).isPresent()); verifyDefault(); @@ -777,18 +760,14 @@ public void test_getAppRecursiveScriptDocRef_null() { } private DocumentReference createScriptDocRef(String scriptName) { - return RefBuilder - .from(new WikiReference(getXContext().getDatabase())) - .space(IAppScriptService.APP_RECURSIVE_SCRIPT_SPACE_NAME) - .doc(scriptName) + return RefBuilder.from(new WikiReference(getXContext().getDatabase())) + .space(IAppScriptService.APP_RECURSIVE_SCRIPT_SPACE_NAME).doc(scriptName) .build(DocumentReference.class); } private DocumentReference createScriptCentralDocRef(String scriptName) { - return RefBuilder - .from(XWikiConstant.CENTRAL_WIKI) - .space(IAppScriptService.APP_RECURSIVE_SCRIPT_SPACE_NAME) - .doc(scriptName) + return RefBuilder.from(XWikiConstant.CENTRAL_WIKI) + .space(IAppScriptService.APP_RECURSIVE_SCRIPT_SPACE_NAME).doc(scriptName) .build(DocumentReference.class); } diff --git a/src/test/java/com/celements/cells/CellsScriptServiceTest.java b/src/test/java/com/celements/cells/CellsScriptServiceTest.java index 3ed17cbe7..31549d188 100644 --- a/src/test/java/com/celements/cells/CellsScriptServiceTest.java +++ b/src/test/java/com/celements/cells/CellsScriptServiceTest.java @@ -90,8 +90,8 @@ public void testGetPageDepDocRefCmd_inject() { public void testGetPageDependentDocRef_DocumentReference() { DocumentReference expectedDocRef = new DocumentReference(context.getDatabase(), "mySpace", "myExpectedDoc"); - expect(mockPageDepDocRefCmd.getDocumentReference(eq(currentDocRef), same( - cellDocRef))).andReturn(expectedDocRef).once(); + expect(mockPageDepDocRefCmd.getDocumentReference(eq(currentDocRef), same(cellDocRef))) + .andReturn(expectedDocRef).once(); replayDefault(); assertEquals(expectedDocRef, cellsScriptService.getPageDependentDocRef(cellDocRef)); verifyDefault(); @@ -101,60 +101,60 @@ public void testGetPageDependentDocRef_DocumentReference() { public void testGetPageDependentDocRef_DocumentReferenceDocumentReference() throws Exception { DocumentReference expectedDocRef = new DocumentReference(context.getDatabase(), "mySpace", "myExpectedDoc"); - expect(mockPageDepDocRefCmd.getDocumentReference(eq(currentDocRef), same( - cellDocRef))).andReturn(expectedDocRef).once(); + expect(mockPageDepDocRefCmd.getDocumentReference(eq(currentDocRef), same(cellDocRef))) + .andReturn(expectedDocRef).once(); replayDefault(); - assertEquals(expectedDocRef, cellsScriptService.getPageDependentDocRef(currentDocRef, - cellDocRef)); + assertEquals(expectedDocRef, + cellsScriptService.getPageDependentDocRef(currentDocRef, cellDocRef)); verifyDefault(); } @Test public void testGetPageDependentTranslatedDocument() throws XWikiException { XWikiDocument expectedXDoc = createDefaultMock(XWikiDocument.class); - expect(mockPageDepDocRefCmd.getTranslatedDocument(same(currentXDoc), same( - cellDocRef))).andReturn(expectedXDoc).once(); + expect(mockPageDepDocRefCmd.getTranslatedDocument(same(currentXDoc), same(cellDocRef))) + .andReturn(expectedXDoc).once(); expect(currentDoc.getDocumentReference()).andReturn(currentDocRef).anyTimes(); expect(xwiki.getDocument(eq(currentDocRef), same(context))).andReturn(currentXDoc).once(); expect(currentDoc.getLanguage()).andReturn("").once(); Document expectedDoc = new Document(expectedXDoc, context); expect(expectedXDoc.newDocument(same(context))).andReturn(expectedDoc).once(); replayDefault(); - assertSame(expectedDoc, cellsScriptService.getPageDependentTranslatedDocument(currentDoc, - cellDocRef)); + assertSame(expectedDoc, + cellsScriptService.getPageDependentTranslatedDocument(currentDoc, cellDocRef)); verifyDefault(); } @Test public void testGetPageDependentTranslatedDocument_translations() throws XWikiException { XWikiDocument expectedXDoc = createDefaultMock(XWikiDocument.class); - expect(mockPageDepDocRefCmd.getTranslatedDocument(same(currentXDoc), same( - cellDocRef))).andReturn(expectedXDoc).once(); + expect(mockPageDepDocRefCmd.getTranslatedDocument(same(currentXDoc), same(cellDocRef))) + .andReturn(expectedXDoc).once(); expect(currentDoc.getDocumentReference()).andReturn(currentDocRef).anyTimes(); XWikiDocument currentXDocDef = createDefaultMock(XWikiDocument.class); expect(xwiki.getDocument(eq(currentDocRef), same(context))).andReturn(currentXDocDef).once(); - expect(currentXDocDef.getTranslatedDocument(eq("fr"), same(context))).andReturn( - currentXDoc).once(); + expect(currentXDocDef.getTranslatedDocument(eq("fr"), same(context))).andReturn(currentXDoc) + .once(); expect(currentDoc.getLanguage()).andReturn("fr").atLeastOnce(); Document expectedDoc = new Document(expectedXDoc, context); expect(expectedXDoc.newDocument(same(context))).andReturn(expectedDoc).once(); replayDefault(); - assertSame(expectedDoc, cellsScriptService.getPageDependentTranslatedDocument(currentDoc, - cellDocRef)); + assertSame(expectedDoc, + cellsScriptService.getPageDependentTranslatedDocument(currentDoc, cellDocRef)); verifyDefault(); } @Test public void testGetPageDependentTranslatedDocument_Exception() throws XWikiException { try { - expect(mockPageDepDocRefCmd.getTranslatedDocument(same(currentXDoc), same( - cellDocRef))).andThrow(new XWikiException()).once(); + expect(mockPageDepDocRefCmd.getTranslatedDocument(same(currentXDoc), same(cellDocRef))) + .andThrow(new XWikiException()).once(); expect(currentDoc.getDocumentReference()).andReturn(currentDocRef).anyTimes(); expect(xwiki.getDocument(eq(currentDocRef), same(context))).andReturn(currentXDoc).once(); expect(currentDoc.getLanguage()).andReturn("").once(); replayDefault(); - assertSame(currentDoc, cellsScriptService.getPageDependentTranslatedDocument(currentDoc, - cellDocRef)); + assertSame(currentDoc, + cellsScriptService.getPageDependentTranslatedDocument(currentDoc, cellDocRef)); verifyDefault(); } catch (XWikiException exp) { fail("Expecting to catch XWikiException and return currentDoc."); diff --git a/src/test/java/com/celements/cells/RenderingEngineTest.java b/src/test/java/com/celements/cells/RenderingEngineTest.java index de3e600e0..4da6f4a2a 100644 --- a/src/test/java/com/celements/cells/RenderingEngineTest.java +++ b/src/test/java/com/celements/cells/RenderingEngineTest.java @@ -85,8 +85,8 @@ public void test_renderCell_isRendering() { @Test public void test_renderLayout_notRender() { - SpaceReference spaceReference = new SpaceReference("MySkin", new WikiReference( - context.getDatabase())); + SpaceReference spaceReference = new SpaceReference("MySkin", + new WikiReference(context.getDatabase())); renderStrategyMock.startRendering(); renderStrategyMock.endRendering(); expect(renderStrategyMock.isRenderSubCells(eq(spaceReference))).andReturn(false).once(); @@ -97,16 +97,16 @@ public void test_renderLayout_notRender() { @Test public void test_renderLayout_isRendering() { - SpaceReference masterPageLayoutRef = new SpaceReference("MasterPageLayout", new WikiReference( - context.getDatabase())); + SpaceReference masterPageLayoutRef = new SpaceReference("MasterPageLayout", + new WikiReference(context.getDatabase())); renderStrategyMock.startRendering(); renderStrategyMock.endRendering(); expect(renderStrategyMock.isRenderSubCells(eq(masterPageLayoutRef))).andReturn(true).once(); String menuPart = "mainPart"; expect(renderStrategyMock.getMenuPart((TreeNode) isNull())).andReturn(menuPart); List subCellList = new ArrayList<>(); - expect(mockTreeNodeService.getSubNodesForParent(eq(masterPageLayoutRef), eq( - menuPart))).andReturn(subCellList); + expect(mockTreeNodeService.getSubNodesForParent(eq(masterPageLayoutRef), eq(menuPart))) + .andReturn(subCellList); expect(renderStrategyMock.isRenderCell((TreeNode) isNull())).andReturn(false).once(); replayDefault(); renderingEngine.renderLayout(masterPageLayoutRef); @@ -115,8 +115,8 @@ public void test_renderLayout_isRendering() { @Test public void test_renderLayout_otherDB() { - SpaceReference layoutRef = new SpaceReference("MasterPageLayout", new WikiReference( - "celements2web")); + SpaceReference layoutRef = new SpaceReference("MasterPageLayout", + new WikiReference("celements2web")); renderStrategyMock.startRendering(); renderStrategyMock.endRendering(); expect(renderStrategyMock.isRenderSubCells(eq(layoutRef))).andReturn(true).once(); @@ -147,9 +147,8 @@ public void test_renderPageLayoutPartial() { TreeNode node = new TreeNode(docRef, parentDocRef, 0); renderStrategyMock.startRendering(); renderStrategyMock.endRendering(); - expect(renderStrategyMock - .isRenderSubCells(eq(node.getDocumentReference()))).andReturn(false) - .once(); + expect(renderStrategyMock.isRenderSubCells(eq(node.getDocumentReference()))).andReturn(false) + .once(); replayDefault(); renderingEngine.renderLayoutPartial(node); verifyDefault(); @@ -189,8 +188,8 @@ public void test_renderSubCells_isRendering_noSubcells() { String menuPart = "mainPart"; expect(renderStrategyMock.getMenuPart(eq(node))).andReturn(menuPart); List subCellList = new ArrayList<>(); - expect(mockTreeNodeService.getSubNodesForParent(eq(docRef), eq(menuPart))).andReturn( - subCellList); + expect(mockTreeNodeService.getSubNodesForParent(eq(docRef), eq(menuPart))) + .andReturn(subCellList); expect(renderStrategyMock.isRenderCell(eq(node))).andReturn(true); renderStrategyMock.renderEmptyChildren(eq(node)); replayDefault(); @@ -207,20 +206,20 @@ public void test_renderSubCells_isRendering_withSubcells() { String menuPart = "mainPart"; expect(renderStrategyMock.getMenuPart(eq(cellNode))).andReturn(menuPart).once(); List subCellList = new ArrayList<>(); - TreeNode subCell1 = new TreeNode(new DocumentReference(context.getDatabase(), menuSpace, - "subCell1"), null, 1); + TreeNode subCell1 = new TreeNode( + new DocumentReference(context.getDatabase(), menuSpace, "subCell1"), null, 1); subCellList.add(subCell1); - TreeNode subCell2 = new TreeNode(new DocumentReference(context.getDatabase(), menuSpace, - "subCell2"), null, 2); + TreeNode subCell2 = new TreeNode( + new DocumentReference(context.getDatabase(), menuSpace, "subCell2"), null, 2); subCellList.add(subCell2); - TreeNode subCell3 = new TreeNode(new DocumentReference(context.getDatabase(), menuSpace, - "subCell3"), null, 3); + TreeNode subCell3 = new TreeNode( + new DocumentReference(context.getDatabase(), menuSpace, "subCell3"), null, 3); subCellList.add(subCell3); - TreeNode subCell4 = new TreeNode(new DocumentReference(context.getDatabase(), menuSpace, - "subCell4"), null, 4); + TreeNode subCell4 = new TreeNode( + new DocumentReference(context.getDatabase(), menuSpace, "subCell4"), null, 4); subCellList.add(subCell4); - expect(mockTreeNodeService.getSubNodesForParent(eq(cellRef), eq(menuPart))).andReturn( - subCellList); + expect(mockTreeNodeService.getSubNodesForParent(eq(cellRef), eq(menuPart))) + .andReturn(subCellList); renderStrategyMock.startRenderChildren(eq(cellRef)); renderStrategyMock.endRenderChildren(eq(cellRef)); expect(renderStrategyMock.isRenderCell(same(subCell1))).andReturn(true).once(); diff --git a/src/test/java/com/celements/cells/classes/TranslationBoxCellConfigClassTest.java b/src/test/java/com/celements/cells/classes/TranslationBoxCellConfigClassTest.java index 96062da50..4dcc0ce05 100644 --- a/src/test/java/com/celements/cells/classes/TranslationBoxCellConfigClassTest.java +++ b/src/test/java/com/celements/cells/classes/TranslationBoxCellConfigClassTest.java @@ -87,7 +87,6 @@ public void test_fields() throws Exception { cellsClassesColl.getTranslationBoxCellConfigClass(); verifyDefault(); - assertEquals(doc.getXClass(), - xClassCreator.generateXClass(translationBoxCellConfigClass)); + assertEquals(doc.getXClass(), xClassCreator.generateXClass(translationBoxCellConfigClass)); } } diff --git a/src/test/java/com/celements/cells/cmd/PageDependentDocumentReferenceCommandOverlayTest.java b/src/test/java/com/celements/cells/cmd/PageDependentDocumentReferenceCommandOverlayTest.java index 18f5d2f92..b0d8dadaa 100644 --- a/src/test/java/com/celements/cells/cmd/PageDependentDocumentReferenceCommandOverlayTest.java +++ b/src/test/java/com/celements/cells/cmd/PageDependentDocumentReferenceCommandOverlayTest.java @@ -47,8 +47,8 @@ public void prepare() throws Exception { cellDocRef = new DocumentReference(context.getDatabase(), "MyLayout", "Cell2"); cellDoc = new XWikiDocument(cellDocRef); cellDoc.setNew(false); - expect(getMock(IModelAccessFacade.class).getOrCreateDocument(eq(cellDocRef))) - .andReturn(cellDoc).anyTimes(); + expect(getMock(IModelAccessFacade.class).getOrCreateDocument(eq(cellDocRef))).andReturn(cellDoc) + .anyTimes(); pageDepDocRefCmd = new PageDependentDocumentReferenceCommand(); webUtilsMock = createDefaultMock(IWebUtilsService.class); webUtilsServiceDesc = getComponentManager().getComponentDescriptor(IWebUtilsService.class, @@ -102,8 +102,8 @@ public void test_getDependentDocList() { DocumentReference myDocRef = new DocumentReference(context.getDatabase(), "mySpace", "MyDoc"); List expDepDocList = Arrays.asList("leftColumn_mySpace.MyDoc", "leftColumn_mySpace.MyParentDoc"); - List docParentList = Arrays.asList(myDocRef, new DocumentReference( - context.getDatabase(), "mySpace", "MyParentDoc")); + List docParentList = Arrays.asList(myDocRef, + new DocumentReference(context.getDatabase(), "mySpace", "MyParentDoc")); expect(webUtilsMock.getDocumentParentsList(eq(myDocRef), eq(true))).andReturn(docParentList); replayDefault(); List depDocList = pageDepDocRefCmd.getDependentDocList(myDocRef, "leftColumn_mySpace"); @@ -126,13 +126,13 @@ public void test_getDependentDocumentReference() throws Exception { expect(webUtilsMock.resolveDocumentReference(eq(myDocFN))).andReturn(myDocRef).atLeastOnce(); expect(getMock(IModelAccessFacade.class).exists(eq(myDocRef))).andReturn(false).atLeastOnce(); String leftParentFullName = "mySpace_leftColumn.MyParentDoc"; - expect(webUtilsMock.resolveDocumentReference(eq(leftParentFullName))).andReturn( - expDepDocRef).atLeastOnce(); + expect(webUtilsMock.resolveDocumentReference(eq(leftParentFullName))).andReturn(expDepDocRef) + .atLeastOnce(); expect(getMock(IModelAccessFacade.class).exists(eq(expDepDocRef))).andReturn(true) .atLeastOnce(); XWikiDocument leftParentDoc = createDefaultMock(XWikiDocument.class); - expect(getMock(IModelAccessFacade.class).getDocument(eq(expDepDocRef))) - .andReturn(leftParentDoc).atLeastOnce(); + expect(getMock(IModelAccessFacade.class).getDocument(eq(expDepDocRef))).andReturn(leftParentDoc) + .atLeastOnce(); expect(leftParentDoc.getContent()).andReturn("parent Content").atLeastOnce(); expect(leftParentDoc.getDocumentReference()).andReturn(expDepDocRef).atLeastOnce(); expect(leftParentDoc.getDefaultLanguage()).andReturn("en").anyTimes(); @@ -165,25 +165,25 @@ public void test_getDependentDocumentReference_defaultContent_noDefaults() throw String leftParentFullName = "mySpace_leftColumn.MyParentDoc"; DocumentReference leftParentDocRef = new DocumentReference(context.getDatabase(), "mySpace_leftColumn", "MyParentDoc"); - expect(webUtilsMock.resolveDocumentReference(eq(leftParentFullName))).andReturn( - leftParentDocRef).atLeastOnce(); + expect(webUtilsMock.resolveDocumentReference(eq(leftParentFullName))) + .andReturn(leftParentDocRef).atLeastOnce(); expect(getMock(IModelAccessFacade.class).exists(eq(leftParentDocRef))).andReturn(false) .atLeastOnce(); String mySpaceLeftColumnDefaultFN = context.getDatabase() + ":mySpace_leftColumn." + PageDependentDocumentReferenceCommand.PDC_DEFAULT_CONTENT_NAME; - expect(refDefaultSerializerMock.serialize(eq(expDepDocRef))).andReturn( - mySpaceLeftColumnDefaultFN); - expect(webUtilsMock.resolveDocumentReference(eq(mySpaceLeftColumnDefaultFN))).andReturn( - expDepDocRef).atLeastOnce(); + expect(refDefaultSerializerMock.serialize(eq(expDepDocRef))) + .andReturn(mySpaceLeftColumnDefaultFN); + expect(webUtilsMock.resolveDocumentReference(eq(mySpaceLeftColumnDefaultFN))) + .andReturn(expDepDocRef).atLeastOnce(); expect(getMock(IModelAccessFacade.class).exists(eq(expDepDocRef))).andReturn(false) .atLeastOnce(); String wikiLeftColumnDefaultFN = context.getDatabase() + ":" + PageDependentDocumentReferenceCommand.PDC_WIKIDEFAULT_SPACE_NAME + "_leftColumn" + "." + PageDependentDocumentReferenceCommand.PDC_DEFAULT_CONTENT_NAME; - expect(refDefaultSerializerMock.serialize(eq(pdcWikiDefaultDocRef))).andReturn( - wikiLeftColumnDefaultFN); - expect(webUtilsMock.resolveDocumentReference(eq(wikiLeftColumnDefaultFN))).andReturn( - pdcWikiDefaultDocRef).atLeastOnce(); + expect(refDefaultSerializerMock.serialize(eq(pdcWikiDefaultDocRef))) + .andReturn(wikiLeftColumnDefaultFN); + expect(webUtilsMock.resolveDocumentReference(eq(wikiLeftColumnDefaultFN))) + .andReturn(pdcWikiDefaultDocRef).atLeastOnce(); expect(getMock(IModelAccessFacade.class).exists(eq(pdcWikiDefaultDocRef))).andReturn(false) .anyTimes(); expect(layoutService.getPageLayoutForCurrentDoc()).andReturn(null).atLeastOnce(); @@ -217,16 +217,16 @@ public void test_getDependentDocumentReference_defaultContent_space() throws Exc String leftParentFullName = "mySpace_leftColumn.MyParentDoc"; DocumentReference leftParentDocRef = new DocumentReference(context.getDatabase(), "mySpace_leftColumn", "MyParentDoc"); - expect(webUtilsMock.resolveDocumentReference(eq(leftParentFullName))).andReturn( - leftParentDocRef).atLeastOnce(); + expect(webUtilsMock.resolveDocumentReference(eq(leftParentFullName))) + .andReturn(leftParentDocRef).atLeastOnce(); expect(getMock(IModelAccessFacade.class).exists(eq(leftParentDocRef))).andReturn(false) .atLeastOnce(); String mySpaceLeftColumnDefaultFN = context.getDatabase() + ":mySpace_leftColumn." + PageDependentDocumentReferenceCommand.PDC_DEFAULT_CONTENT_NAME; - expect(refDefaultSerializerMock.serialize(eq(expDepDocRef))).andReturn( - mySpaceLeftColumnDefaultFN); - expect(webUtilsMock.resolveDocumentReference(eq(mySpaceLeftColumnDefaultFN))).andReturn( - expDepDocRef).atLeastOnce(); + expect(refDefaultSerializerMock.serialize(eq(expDepDocRef))) + .andReturn(mySpaceLeftColumnDefaultFN); + expect(webUtilsMock.resolveDocumentReference(eq(mySpaceLeftColumnDefaultFN))) + .andReturn(expDepDocRef).atLeastOnce(); expect(getMock(IModelAccessFacade.class).exists(eq(expDepDocRef))).andReturn(true) .atLeastOnce(); XWikiDocument spaceDefaultDocument = new XWikiDocument(expDepDocRef); @@ -238,8 +238,8 @@ public void test_getDependentDocumentReference_defaultContent_space() throws Exc String wikiLeftColumnDefaultFN = context.getDatabase() + ":" + PageDependentDocumentReferenceCommand.PDC_WIKIDEFAULT_SPACE_NAME + "_leftColumn" + "." + PageDependentDocumentReferenceCommand.PDC_DEFAULT_CONTENT_NAME; - expect(refDefaultSerializerMock.serialize(eq(pdcWikiDefaultDocRef))).andReturn( - wikiLeftColumnDefaultFN); + expect(refDefaultSerializerMock.serialize(eq(pdcWikiDefaultDocRef))) + .andReturn(wikiLeftColumnDefaultFN); expect(layoutService.getPageLayoutForCurrentDoc()).andReturn(null).atLeastOnce(); replayDefault(); DocumentReference depDocRef = pageDepDocRefCmd.getDependentDocumentReference(myDocRef, @@ -271,25 +271,25 @@ public void test_getDependentDocumentReference_defaultContent_wiki() throws Exce String leftParentFullName = "mySpace_leftColumn.MyParentDoc"; DocumentReference leftParentDocRef = new DocumentReference(context.getDatabase(), "mySpace_leftColumn", "MyParentDoc"); - expect(webUtilsMock.resolveDocumentReference(eq(leftParentFullName))).andReturn( - leftParentDocRef).atLeastOnce(); + expect(webUtilsMock.resolveDocumentReference(eq(leftParentFullName))) + .andReturn(leftParentDocRef).atLeastOnce(); expect(getMock(IModelAccessFacade.class).exists(eq(leftParentDocRef))).andReturn(false) .atLeastOnce(); String mySpaceLeftColumnDefaultFN = context.getDatabase() + ":mySpace_leftColumn." + PageDependentDocumentReferenceCommand.PDC_DEFAULT_CONTENT_NAME; - expect(refDefaultSerializerMock.serialize(eq(spaceDepDocRef))).andReturn( - mySpaceLeftColumnDefaultFN); - expect(webUtilsMock.resolveDocumentReference(eq(mySpaceLeftColumnDefaultFN))).andReturn( - spaceDepDocRef).atLeastOnce(); + expect(refDefaultSerializerMock.serialize(eq(spaceDepDocRef))) + .andReturn(mySpaceLeftColumnDefaultFN); + expect(webUtilsMock.resolveDocumentReference(eq(mySpaceLeftColumnDefaultFN))) + .andReturn(spaceDepDocRef).atLeastOnce(); expect(getMock(IModelAccessFacade.class).exists(eq(spaceDepDocRef))).andReturn(false) .atLeastOnce(); String wikiLeftColumnDefaultFN = context.getDatabase() + ":" + PageDependentDocumentReferenceCommand.PDC_WIKIDEFAULT_SPACE_NAME + "_leftColumn" + "." + PageDependentDocumentReferenceCommand.PDC_DEFAULT_CONTENT_NAME; - expect(refDefaultSerializerMock.serialize(eq(pdcWikiDefaultDocRef))).andReturn( - wikiLeftColumnDefaultFN); - expect(webUtilsMock.resolveDocumentReference(eq(wikiLeftColumnDefaultFN))).andReturn( - pdcWikiDefaultDocRef).atLeastOnce(); + expect(refDefaultSerializerMock.serialize(eq(pdcWikiDefaultDocRef))) + .andReturn(wikiLeftColumnDefaultFN); + expect(webUtilsMock.resolveDocumentReference(eq(wikiLeftColumnDefaultFN))) + .andReturn(pdcWikiDefaultDocRef).atLeastOnce(); expect(getMock(IModelAccessFacade.class).exists(eq(pdcWikiDefaultDocRef))).andReturn(true) .atLeastOnce(); XWikiDocument wikiDefaultDocument = new XWikiDocument(pdcWikiDefaultDocRef); @@ -329,40 +329,40 @@ public void test_getDependentDocumentReference_defaultContent_layout() throws Ex String leftParentFullName = "mySpace_leftColumn.MyParentDoc"; DocumentReference leftParentDocRef = new DocumentReference(context.getDatabase(), "mySpace_leftColumn", "MyParentDoc"); - expect(webUtilsMock.resolveDocumentReference(eq(leftParentFullName))).andReturn( - leftParentDocRef).atLeastOnce(); + expect(webUtilsMock.resolveDocumentReference(eq(leftParentFullName))) + .andReturn(leftParentDocRef).atLeastOnce(); expect(getMock(IModelAccessFacade.class).exists(eq(leftParentDocRef))).andReturn(false) .atLeastOnce(); String mySpaceLeftColumnDefaultFN = context.getDatabase() + ":mySpace_leftColumn." + PageDependentDocumentReferenceCommand.PDC_DEFAULT_CONTENT_NAME; - expect(refDefaultSerializerMock.serialize(eq(spaceDepDocRef))).andReturn( - mySpaceLeftColumnDefaultFN); - expect(webUtilsMock.resolveDocumentReference(eq(mySpaceLeftColumnDefaultFN))).andReturn( - spaceDepDocRef).atLeastOnce(); + expect(refDefaultSerializerMock.serialize(eq(spaceDepDocRef))) + .andReturn(mySpaceLeftColumnDefaultFN); + expect(webUtilsMock.resolveDocumentReference(eq(mySpaceLeftColumnDefaultFN))) + .andReturn(spaceDepDocRef).atLeastOnce(); expect(getMock(IModelAccessFacade.class).exists(eq(spaceDepDocRef))).andReturn(false) .atLeastOnce(); String wikiLeftColumnDefaultFN = context.getDatabase() + ":" + PageDependentDocumentReferenceCommand.PDC_WIKIDEFAULT_SPACE_NAME + "_leftColumn" + "." + PageDependentDocumentReferenceCommand.PDC_DEFAULT_CONTENT_NAME; - expect(refDefaultSerializerMock.serialize(eq(pdcWikiDefaultDocRef))).andReturn( - wikiLeftColumnDefaultFN); - expect(webUtilsMock.resolveDocumentReference(eq(wikiLeftColumnDefaultFN))).andReturn( - pdcWikiDefaultDocRef).atLeastOnce(); + expect(refDefaultSerializerMock.serialize(eq(pdcWikiDefaultDocRef))) + .andReturn(wikiLeftColumnDefaultFN); + expect(webUtilsMock.resolveDocumentReference(eq(wikiLeftColumnDefaultFN))) + .andReturn(pdcWikiDefaultDocRef).atLeastOnce(); expect(getMock(IModelAccessFacade.class).exists(eq(pdcWikiDefaultDocRef))).andReturn(false) .atLeastOnce(); String layoutSpaceName = "myLayout"; DocumentReference expectedLayoutDefaultRef = new DocumentReference(context.getDatabase(), - layoutSpaceName, "leftColumn-" - + PageDependentDocumentReferenceCommand.PDC_DEFAULT_CONTENT_NAME); - SpaceReference layoutSpace = new SpaceReference(layoutSpaceName, new WikiReference( - context.getDatabase())); + layoutSpaceName, + "leftColumn-" + PageDependentDocumentReferenceCommand.PDC_DEFAULT_CONTENT_NAME); + SpaceReference layoutSpace = new SpaceReference(layoutSpaceName, + new WikiReference(context.getDatabase())); expect(layoutService.getPageLayoutForCurrentDoc()).andReturn(layoutSpace).atLeastOnce(); String layoutDefaultFN = context.getDatabase() + ":" + layoutSpaceName + "." + "leftColumn-" + PageDependentDocumentReferenceCommand.PDC_DEFAULT_CONTENT_NAME; - expect(refDefaultSerializerMock.serialize(eq(expectedLayoutDefaultRef))).andReturn( - layoutDefaultFN); - expect(webUtilsMock.resolveDocumentReference(eq(layoutDefaultFN))).andReturn( - expectedLayoutDefaultRef).atLeastOnce(); + expect(refDefaultSerializerMock.serialize(eq(expectedLayoutDefaultRef))) + .andReturn(layoutDefaultFN); + expect(webUtilsMock.resolveDocumentReference(eq(layoutDefaultFN))) + .andReturn(expectedLayoutDefaultRef).atLeastOnce(); expect(getMock(IModelAccessFacade.class).exists(eq(expectedLayoutDefaultRef))).andReturn(true) .atLeastOnce(); XWikiDocument layoutDefaultDocument = new XWikiDocument(expectedLayoutDefaultRef); @@ -402,40 +402,40 @@ public void test_getDependentDocumentReference_defaultContent_overwrite_layout() String leftParentFullName = "mySpace_leftColumn.MyParentDoc"; DocumentReference leftParentDocRef = new DocumentReference(context.getDatabase(), "mySpace_leftColumn", "MyParentDoc"); - expect(webUtilsMock.resolveDocumentReference(eq(leftParentFullName))).andReturn( - leftParentDocRef).atLeastOnce(); + expect(webUtilsMock.resolveDocumentReference(eq(leftParentFullName))) + .andReturn(leftParentDocRef).atLeastOnce(); expect(getMock(IModelAccessFacade.class).exists(eq(leftParentDocRef))).andReturn(false) .atLeastOnce(); String mySpaceLeftColumnDefaultFN = context.getDatabase() + ":mySpace_leftColumn." + PageDependentDocumentReferenceCommand.PDC_DEFAULT_CONTENT_NAME; - expect(refDefaultSerializerMock.serialize(eq(spaceDepDocRef))).andReturn( - mySpaceLeftColumnDefaultFN); - expect(webUtilsMock.resolveDocumentReference(eq(mySpaceLeftColumnDefaultFN))).andReturn( - spaceDepDocRef).atLeastOnce(); + expect(refDefaultSerializerMock.serialize(eq(spaceDepDocRef))) + .andReturn(mySpaceLeftColumnDefaultFN); + expect(webUtilsMock.resolveDocumentReference(eq(mySpaceLeftColumnDefaultFN))) + .andReturn(spaceDepDocRef).atLeastOnce(); expect(getMock(IModelAccessFacade.class).exists(eq(spaceDepDocRef))).andReturn(false) .atLeastOnce(); String wikiLeftColumnDefaultFN = context.getDatabase() + ":" + PageDependentDocumentReferenceCommand.PDC_WIKIDEFAULT_SPACE_NAME + "_leftColumn" + "." + PageDependentDocumentReferenceCommand.PDC_DEFAULT_CONTENT_NAME; - expect(refDefaultSerializerMock.serialize(eq(pdcWikiDefaultDocRef))).andReturn( - wikiLeftColumnDefaultFN); - expect(webUtilsMock.resolveDocumentReference(eq(wikiLeftColumnDefaultFN))).andReturn( - pdcWikiDefaultDocRef).atLeastOnce(); + expect(refDefaultSerializerMock.serialize(eq(pdcWikiDefaultDocRef))) + .andReturn(wikiLeftColumnDefaultFN); + expect(webUtilsMock.resolveDocumentReference(eq(wikiLeftColumnDefaultFN))) + .andReturn(pdcWikiDefaultDocRef).atLeastOnce(); expect(getMock(IModelAccessFacade.class).exists(eq(pdcWikiDefaultDocRef))).andReturn(false) .atLeastOnce(); String overwriteLayoutSpaceName = "myOverwriteLayout"; DocumentReference expectedLayoutDefaultRef = new DocumentReference(context.getDatabase(), - overwriteLayoutSpaceName, "leftColumn-" - + PageDependentDocumentReferenceCommand.PDC_DEFAULT_CONTENT_NAME); + overwriteLayoutSpaceName, + "leftColumn-" + PageDependentDocumentReferenceCommand.PDC_DEFAULT_CONTENT_NAME); SpaceReference overwriteLayoutRef = new SpaceReference(overwriteLayoutSpaceName, new WikiReference(context.getDatabase())); pageDepDocRefCmd.setCurrentLayoutRef(overwriteLayoutRef); String layoutDefaultFN = context.getDatabase() + ":" + overwriteLayoutSpaceName + "." + "leftColumn-" + PageDependentDocumentReferenceCommand.PDC_DEFAULT_CONTENT_NAME; - expect(refDefaultSerializerMock.serialize(eq(expectedLayoutDefaultRef))).andReturn( - layoutDefaultFN); - expect(webUtilsMock.resolveDocumentReference(eq(layoutDefaultFN))).andReturn( - expectedLayoutDefaultRef).atLeastOnce(); + expect(refDefaultSerializerMock.serialize(eq(expectedLayoutDefaultRef))) + .andReturn(layoutDefaultFN); + expect(webUtilsMock.resolveDocumentReference(eq(layoutDefaultFN))) + .andReturn(expectedLayoutDefaultRef).atLeastOnce(); expect(getMock(IModelAccessFacade.class).exists(eq(expectedLayoutDefaultRef))).andReturn(true) .atLeastOnce(); XWikiDocument layoutDefaultDocument = new XWikiDocument(expectedLayoutDefaultRef); @@ -474,41 +474,41 @@ public void test_getDependentDocumentReference_defaultContent_centrallayout() th String leftParentFullName = "mySpace_leftColumn.MyParentDoc"; DocumentReference leftParentDocRef = new DocumentReference(context.getDatabase(), "mySpace_leftColumn", "MyParentDoc"); - expect(webUtilsMock.resolveDocumentReference(eq(leftParentFullName))).andReturn( - leftParentDocRef).atLeastOnce(); + expect(webUtilsMock.resolveDocumentReference(eq(leftParentFullName))) + .andReturn(leftParentDocRef).atLeastOnce(); expect(getMock(IModelAccessFacade.class).exists(eq(leftParentDocRef))).andReturn(false) .atLeastOnce(); String mySpaceLeftColumnDefaultFN = context.getDatabase() + ":mySpace_leftColumn." + PageDependentDocumentReferenceCommand.PDC_DEFAULT_CONTENT_NAME; - expect(refDefaultSerializerMock.serialize(eq(spaceDepDocRef))).andReturn( - mySpaceLeftColumnDefaultFN); - expect(webUtilsMock.resolveDocumentReference(eq(mySpaceLeftColumnDefaultFN))).andReturn( - spaceDepDocRef).atLeastOnce(); + expect(refDefaultSerializerMock.serialize(eq(spaceDepDocRef))) + .andReturn(mySpaceLeftColumnDefaultFN); + expect(webUtilsMock.resolveDocumentReference(eq(mySpaceLeftColumnDefaultFN))) + .andReturn(spaceDepDocRef).atLeastOnce(); expect(getMock(IModelAccessFacade.class).exists(eq(spaceDepDocRef))).andReturn(false) .atLeastOnce(); String wikiLeftColumnDefaultFN = context.getDatabase() + ":" + PageDependentDocumentReferenceCommand.PDC_WIKIDEFAULT_SPACE_NAME + "_leftColumn" + "." + PageDependentDocumentReferenceCommand.PDC_DEFAULT_CONTENT_NAME; - expect(refDefaultSerializerMock.serialize(eq(pdcWikiDefaultDocRef))).andReturn( - wikiLeftColumnDefaultFN); - expect(webUtilsMock.resolveDocumentReference(eq(wikiLeftColumnDefaultFN))).andReturn( - pdcWikiDefaultDocRef).atLeastOnce(); + expect(refDefaultSerializerMock.serialize(eq(pdcWikiDefaultDocRef))) + .andReturn(wikiLeftColumnDefaultFN); + expect(webUtilsMock.resolveDocumentReference(eq(wikiLeftColumnDefaultFN))) + .andReturn(pdcWikiDefaultDocRef).atLeastOnce(); expect(getMock(IModelAccessFacade.class).exists(eq(pdcWikiDefaultDocRef))).andReturn(false) .atLeastOnce(); String layoutSpaceName = "myLayout"; String layoutDatabase = "layoutDb"; DocumentReference expectedLayoutDefaultRef = new DocumentReference(layoutDatabase, - layoutSpaceName, "leftColumn-" - + PageDependentDocumentReferenceCommand.PDC_DEFAULT_CONTENT_NAME); - SpaceReference layoutSpace = new SpaceReference(layoutSpaceName, new WikiReference( - layoutDatabase)); + layoutSpaceName, + "leftColumn-" + PageDependentDocumentReferenceCommand.PDC_DEFAULT_CONTENT_NAME); + SpaceReference layoutSpace = new SpaceReference(layoutSpaceName, + new WikiReference(layoutDatabase)); expect(layoutService.getPageLayoutForCurrentDoc()).andReturn(layoutSpace).atLeastOnce(); String layoutDefaultFN = layoutDatabase + ":" + layoutSpaceName + "." + "leftColumn-" + PageDependentDocumentReferenceCommand.PDC_DEFAULT_CONTENT_NAME; - expect(refDefaultSerializerMock.serialize(eq(expectedLayoutDefaultRef))).andReturn( - layoutDefaultFN); - expect(webUtilsMock.resolveDocumentReference(eq(layoutDefaultFN))).andReturn( - expectedLayoutDefaultRef).atLeastOnce(); + expect(refDefaultSerializerMock.serialize(eq(expectedLayoutDefaultRef))) + .andReturn(layoutDefaultFN); + expect(webUtilsMock.resolveDocumentReference(eq(layoutDefaultFN))) + .andReturn(expectedLayoutDefaultRef).atLeastOnce(); expect(getMock(IModelAccessFacade.class).exists(eq(expectedLayoutDefaultRef))).andReturn(true) .atLeastOnce(); XWikiDocument layoutDefaultDocument = new XWikiDocument(expectedLayoutDefaultRef); diff --git a/src/test/java/com/celements/cells/cmd/PageDependentDocumentReferenceCommandTest.java b/src/test/java/com/celements/cells/cmd/PageDependentDocumentReferenceCommandTest.java index 954048a24..09a218db1 100644 --- a/src/test/java/com/celements/cells/cmd/PageDependentDocumentReferenceCommandTest.java +++ b/src/test/java/com/celements/cells/cmd/PageDependentDocumentReferenceCommandTest.java @@ -50,11 +50,11 @@ public void prepare() throws Exception { document = createDefaultMock(XWikiDocument.class); cellDocRef = new DocumentReference(context.getDatabase(), "MyLayout", "Cell2"); cellDoc = new XWikiDocument(cellDocRef); - expect(getMock(IModelAccessFacade.class).getOrCreateDocument(eq(cellDocRef))) - .andReturn(cellDoc).anyTimes(); + expect(getMock(IModelAccessFacade.class).getOrCreateDocument(eq(cellDocRef))).andReturn(cellDoc) + .anyTimes(); pageDepDocRefCmd = new PageDependentDocumentReferenceCommand(); - defaultValueProviderDesc = getComponentManager().getComponentDescriptor( - EntityReferenceValueProvider.class, "default"); + defaultValueProviderDesc = getComponentManager() + .getComponentDescriptor(EntityReferenceValueProvider.class, "default"); savedDefaultValueProviderService = Utils.getComponent(EntityReferenceValueProvider.class); getComponentManager().unregisterComponent(ITreeNodeService.class, "default"); defValueProviderMock = createDefaultMock(EntityReferenceValueProvider.class); @@ -71,17 +71,18 @@ public void shutdown_EmptyCheckCommandTest() throws Exception { @Test public void test_getPageDepCellConfigClassDocRef() { replayDefault(); - assertEquals(new DocumentReference(context.getDatabase(), - PageDependentDocumentReferenceCommand.PAGE_DEP_CELL_CONFIG_CLASS_SPACE, - PageDependentDocumentReferenceCommand.PAGE_DEP_CELL_CONFIG_CLASS_DOC), + assertEquals( + new DocumentReference(context.getDatabase(), + PageDependentDocumentReferenceCommand.PAGE_DEP_CELL_CONFIG_CLASS_SPACE, + PageDependentDocumentReferenceCommand.PAGE_DEP_CELL_CONFIG_CLASS_DOC), pageDepDocRefCmd.getPageDepCellConfigClassDocRef()); verifyDefault(); } @Test public void test_getCurrentLayoutRef() { - SpaceReference expectedLayoutRef = new SpaceReference("MyLayout", new WikiReference( - context.getDatabase())); + SpaceReference expectedLayoutRef = new SpaceReference("MyLayout", + new WikiReference(context.getDatabase())); expect(layoutService.getPageLayoutForCurrentDoc()).andReturn(expectedLayoutRef).once(); replayDefault(); assertEquals(expectedLayoutRef, pageDepDocRefCmd.getCurrentLayoutRef()); @@ -90,8 +91,8 @@ public void test_getCurrentLayoutRef() { @Test public void test_getCurrentLayoutRef_injectLayout() { - SpaceReference expectedLayoutRef = new SpaceReference("MyLayout", new WikiReference( - context.getDatabase())); + SpaceReference expectedLayoutRef = new SpaceReference("MyLayout", + new WikiReference(context.getDatabase())); pageDepDocRefCmd.setCurrentLayoutRef(expectedLayoutRef); replayDefault(); assertEquals(expectedLayoutRef, pageDepDocRefCmd.getCurrentLayoutRef()); @@ -103,11 +104,11 @@ public void test_getCurrentDocumentSpaceName_ZeroSpaces() { DocumentReference currentDocRef = createDefaultMock(DocumentReference.class); List emptySpaceRefList = Collections.emptyList(); expect(currentDocRef.getSpaceReferences()).andReturn(emptySpaceRefList); - expect(defValueProviderMock.getDefaultValue(eq(EntityType.SPACE))).andReturn( - "myDefaultSpace").once(); + expect(defValueProviderMock.getDefaultValue(eq(EntityType.SPACE))).andReturn("myDefaultSpace") + .once(); replayDefault(); - assertEquals("myDefaultSpace", pageDepDocRefCmd.getCurrentDocumentSpaceRef( - currentDocRef).getName()); + assertEquals("myDefaultSpace", + pageDepDocRefCmd.getCurrentDocumentSpaceRef(currentDocRef).getName()); verifyDefault(); } @@ -171,8 +172,8 @@ public void test_getDependentDocumentSpace_cellDocWithoutObject_Content() { DocumentReference currentDocRef = new DocumentReference(context.getDatabase(), "Content", "myDocument"); replayDefault(); - assertEquals("Content", pageDepDocRefCmd.getDependentDocumentSpaceRef(currentDocRef, - cellDocRef).getName()); + assertEquals("Content", + pageDepDocRefCmd.getDependentDocumentSpaceRef(currentDocRef, cellDocRef).getName()); verifyDefault(); } @@ -181,8 +182,8 @@ public void test_getDependentDocumentSpace_cellDocWithoutObject_anySpace() { DocumentReference currentDocRef = new DocumentReference(context.getDatabase(), "mySpace", "myDocument"); replayDefault(); - assertEquals("mySpace", pageDepDocRefCmd.getDependentDocumentSpaceRef(currentDocRef, - cellDocRef).getName()); + assertEquals("mySpace", + pageDepDocRefCmd.getDependentDocumentSpaceRef(currentDocRef, cellDocRef).getName()); verifyDefault(); } @@ -192,8 +193,8 @@ public void test_getDependentDocumentSpace_cellDocWithEmptyObject_Content() { DocumentReference currentDocRef = new DocumentReference(context.getDatabase(), "Content", "myDocument"); replayDefault(); - assertEquals("Content", pageDepDocRefCmd.getDependentDocumentSpaceRef(currentDocRef, - cellDocRef).getName()); + assertEquals("Content", + pageDepDocRefCmd.getDependentDocumentSpaceRef(currentDocRef, cellDocRef).getName()); verifyDefault(); } @@ -203,8 +204,8 @@ public void test_getDependentDocumentSpace_cellDocWithEmptyObject_anySpace() { DocumentReference currentDocRef = new DocumentReference(context.getDatabase(), "MySpace", "myDocument"); replayDefault(); - assertEquals("MySpace", pageDepDocRefCmd.getDependentDocumentSpaceRef(currentDocRef, - cellDocRef).getName()); + assertEquals("MySpace", + pageDepDocRefCmd.getDependentDocumentSpaceRef(currentDocRef, cellDocRef).getName()); verifyDefault(); } @@ -214,8 +215,8 @@ public void test_getDependentDocumentSpace_cellDocWithNonEmptyObject_Content() { DocumentReference currentDocRef = new DocumentReference(context.getDatabase(), "Content", "myDocument"); replayDefault(); - assertEquals("Content_myDepSpace", pageDepDocRefCmd.getDependentDocumentSpaceRef(currentDocRef, - cellDocRef).getName()); + assertEquals("Content_myDepSpace", + pageDepDocRefCmd.getDependentDocumentSpaceRef(currentDocRef, cellDocRef).getName()); verifyDefault(); } @@ -225,8 +226,8 @@ public void test_getDependentDocumentSpace_cellDocWithNonEmptyObject_anySpace() DocumentReference currentDocRef = new DocumentReference(context.getDatabase(), "mySpace", "myDocument"); replayDefault(); - assertEquals("mySpace_myDepSpace", pageDepDocRefCmd.getDependentDocumentSpaceRef(currentDocRef, - cellDocRef).getName()); + assertEquals("mySpace_myDepSpace", + pageDepDocRefCmd.getDependentDocumentSpaceRef(currentDocRef, cellDocRef).getName()); verifyDefault(); } @@ -256,8 +257,8 @@ public void test_getDocumentReference_isCurrent_inheritable() { DocumentReference expectedDocRef = new DocumentReference(context.getDatabase(), "mySpace", "myDocument"); replayDefault(); - assertEquals(expectedDocRef, pageDepDocRefCmd.getDocumentReference(expectedDocRef, cellDocRef, - false)); + assertEquals(expectedDocRef, + pageDepDocRefCmd.getDocumentReference(expectedDocRef, cellDocRef, false)); verifyDefault(); } @@ -269,8 +270,8 @@ public void test_getDocumentReference_isNotCurrent_inheritable() { DocumentReference expectedDocRef = new DocumentReference(context.getDatabase(), "mySpace_myDepSpace", "myDocument"); replayDefault(); - assertEquals(expectedDocRef, pageDepDocRefCmd.getDocumentReference(currentDocRef, cellDocRef, - false)); + assertEquals(expectedDocRef, + pageDepDocRefCmd.getDocumentReference(currentDocRef, cellDocRef, false)); verifyDefault(); } @@ -322,8 +323,8 @@ public void test_getTranslatedDocument_isNotCurrent() throws XWikiException { XWikiDocument expectedDoc = createDefaultMock(XWikiDocument.class); expect(xwiki.getDocument(eq(expectedDocRef), same(context))).andReturn(expectedDoc).once(); XWikiDocument expectedTransDoc = new XWikiDocument(expectedDocRef); - expect(expectedDoc.getTranslatedDocument(eq(contextLang), same(context))).andReturn( - expectedTransDoc).once(); + expect(expectedDoc.getTranslatedDocument(eq(contextLang), same(context))) + .andReturn(expectedTransDoc).once(); replayDefault(); assertEquals(expectedTransDoc, pageDepDocRefCmd.getTranslatedDocument(document, cellDocRef)); verifyDefault(); diff --git a/src/test/java/com/celements/cells/div/CellRenderStrategyTest.java b/src/test/java/com/celements/cells/div/CellRenderStrategyTest.java index ff9cf1018..51300155f 100644 --- a/src/test/java/com/celements/cells/div/CellRenderStrategyTest.java +++ b/src/test/java/com/celements/cells/div/CellRenderStrategyTest.java @@ -118,8 +118,8 @@ public void test_isRenderCell() { @Test public void test_isRenderSubCells() { assertFalse(renderer.isRenderSubCells(null)); - SpaceReference layoutSpaceRef = new SpaceReference("TestLayout", new WikiReference( - context.getDatabase())); + SpaceReference layoutSpaceRef = new SpaceReference("TestLayout", + new WikiReference(context.getDatabase())); assertTrue(renderer.isRenderSubCells(layoutSpaceRef)); } @@ -242,8 +242,8 @@ public void test_startRenderCell_auto_id_forEmpty_diffdb() throws Exception { @Test public void test_startRenderCell_id_repetitiveCell() throws Exception { - getBeanFactory().getBean(Execution.class).getContext() - .setProperty(EXEC_CTX_KEY_REPETITIVE, true); + getBeanFactory().getBean(Execution.class).getContext().setProperty(EXEC_CTX_KEY_REPETITIVE, + true); DocumentReference cellRef = new DocumentReference(context.getDatabase(), "Skin", "MasterCell"); TreeNode node = new TreeNode(cellRef, null, 0); expectNewDoc(cellRef); @@ -310,8 +310,7 @@ public void test_startRenderCell_additionalAttributes() throws Exception { typeConfig.collectAttributes(isA(AttributeBuilder.class), eq(cellRef)); expect(getMock(VelocityService.class).evaluateVelocityText("custom velocity x")) .andReturn("custom_evaluated_x"); - expect(getMock(VelocityService.class).evaluateVelocityText("custom velocity y")) - .andReturn(""); + expect(getMock(VelocityService.class).evaluateVelocityText("custom velocity y")).andReturn(""); replayDefault(); renderer.startRenderCell(node, isFirstItem, isLastItem); verifyDefault(); @@ -329,8 +328,8 @@ public void test_renderEmptyChildren() throws Exception { DocumentReference cellRef = new DocumentReference(context.getDatabase(), "Skin", "MasterCell"); TreeNode cellNode = new TreeNode(cellRef, null, 0); String cellContentExpected = "Cell test content Skin.MasterCell"; - expect(mockctRendererCmd.renderCelementsCell(eq(cellRef))).andReturn( - cellContentExpected).once(); + expect(mockctRendererCmd.renderCelementsCell(eq(cellRef))).andReturn(cellContentExpected) + .once(); // ASSERT expect(outWriterMock.appendContent(eq(cellContentExpected))).andReturn(outWriterMock); replayDefault(); @@ -365,8 +364,7 @@ private BaseObject addCellObj(XWikiDocument doc) { private BaseObject addObj(XWikiDocument doc, ClassReference classRef) { BaseObject cellObj = new BaseObject(); cellObj.setDocumentReference(doc.getDocumentReference()); - cellObj.setXClassReference(classRef.getDocRef( - doc.getDocumentReference().getWikiReference())); + cellObj.setXClassReference(classRef.getDocRef(doc.getDocumentReference().getWikiReference())); doc.addXObject(cellObj); return cellObj; } @@ -394,8 +392,7 @@ private Map assertDefaultAttributes(String cssClasses, St assertEquals("wrong id attribute", idname, attrMap.get("id").getValue().orElse("")); } assertTrue("cell-ref attribute not found", attrMap.containsKey("data-cell-ref")); - assertEquals("wrong cell-ref attribute", cellFN, - attrMap.get("data-cell-ref").getValue().get()); + assertEquals("wrong cell-ref attribute", cellFN, attrMap.get("data-cell-ref").getValue().get()); assertTrue("cssClass attribute not found", attrMap.containsKey("class")); assertEquals("wrong cssClass attribute", ("cel_cell " + cssClasses).trim(), attrMap.get("class").getValue().get()); diff --git a/src/test/java/com/celements/cells/div/DivWriterTest.java b/src/test/java/com/celements/cells/div/DivWriterTest.java index 355dc0d01..307ab0ce7 100644 --- a/src/test/java/com/celements/cells/div/DivWriterTest.java +++ b/src/test/java/com/celements/cells/div/DivWriterTest.java @@ -69,9 +69,8 @@ public void test_openLevel() { String idname = "newId"; String cssClasses = "classes"; String cssStyles = "width:100px;\nheight:10px;\n"; - divWriter.openLevel(DivWriter.DEFAULT_TAGNAME, - new DefaultAttributeBuilder().addId(idname).addCssClasses( - cssClasses).addStyles(cssStyles).build()); + divWriter.openLevel(DivWriter.DEFAULT_TAGNAME, new DefaultAttributeBuilder().addId(idname) + .addCssClasses(cssClasses).addStyles(cssStyles).build()); String returnedString = divWriter.getAsString(); assertTrue("Must start with '
'", divWriter.getAsString().endsWith(">")); String cssClassExpected = " class=\"" + cssClasses + "\""; - assertTrue("Must contain '" + cssClassExpected + "'", divWriter.getAsString().contains( - cssClassExpected)); - assertFalse("Must not contain any style values.", divWriter.getAsString().contains( - " style=\"")); + assertTrue("Must contain '" + cssClassExpected + "'", + divWriter.getAsString().contains(cssClassExpected)); + assertFalse("Must not contain any style values.", + divWriter.getAsString().contains(" style=\"")); } @Test @@ -152,10 +150,10 @@ public void test_appendContent() { @Test public void test_openLevel_Attributes() { - DefaultCellAttribute.Builder attrBuilder = new DefaultCellAttribute.Builder().attrName( - "testName").addValue("testValue"); - DefaultCellAttribute.Builder attrBuilder2 = new DefaultCellAttribute.Builder().attrName( - "testName2").addValue("testValue2"); + DefaultCellAttribute.Builder attrBuilder = new DefaultCellAttribute.Builder() + .attrName("testName").addValue("testValue"); + DefaultCellAttribute.Builder attrBuilder2 = new DefaultCellAttribute.Builder() + .attrName("testName2").addValue("testValue2"); List attributes = Arrays.asList((CellAttribute) attrBuilder.build(), (CellAttribute) attrBuilder2.build()); divWriter.openLevel(DivWriter.DEFAULT_TAGNAME, attributes); @@ -171,8 +169,8 @@ public void test_openLevel_Attributes() { @Test public void test_openLevel_quotes() { - DefaultCellAttribute.Builder attrBuilder = new DefaultCellAttribute.Builder().attrName( - "testName").addValue("test. : -äöü\"Value"); + DefaultCellAttribute.Builder attrBuilder = new DefaultCellAttribute.Builder() + .attrName("testName").addValue("test. : -äöü\"Value"); List attributes = Arrays.asList((CellAttribute) attrBuilder.build()); divWriter.openLevel(DivWriter.DEFAULT_TAGNAME, attributes); String returnedString = divWriter.getAsString(); diff --git a/src/test/java/com/celements/cells/json/JsonWriterTest.java b/src/test/java/com/celements/cells/json/JsonWriterTest.java index b0d545f00..e447d3c95 100644 --- a/src/test/java/com/celements/cells/json/JsonWriterTest.java +++ b/src/test/java/com/celements/cells/json/JsonWriterTest.java @@ -33,8 +33,7 @@ public void test_openLevel_nested() { writer.openLevel("div"); writer.closeLevel(); writer.closeLevel(); - assertEquals("[" - + "{\"tagName\" : \"div\", \"attributes\" : {}," + assertEquals("[" + "{\"tagName\" : \"div\", \"attributes\" : {}," + " \"subnodes\" : [{\"tagName\" : \"div\", \"attributes\" : {}, \"subnodes\" : []}]}" + "]", writer.getAsString()); } @@ -45,10 +44,10 @@ public void test_openLevel_onTopLevel() { writer.closeLevel(); writer.openLevel("div"); writer.closeLevel(); - assertEquals("[" - + "{\"tagName\" : \"div\", \"attributes\" : {}, \"subnodes\" : []}," - + " {\"tagName\" : \"div\", \"attributes\" : {}, \"subnodes\" : []}" - + "]", writer.getAsString()); + assertEquals( + "[" + "{\"tagName\" : \"div\", \"attributes\" : {}, \"subnodes\" : []}," + + " {\"tagName\" : \"div\", \"attributes\" : {}, \"subnodes\" : []}" + "]", + writer.getAsString()); } @Test diff --git a/src/test/java/com/celements/collections/CollectionsServiceTest.java b/src/test/java/com/celements/collections/CollectionsServiceTest.java index 9bed88785..94fb7caad 100644 --- a/src/test/java/com/celements/collections/CollectionsServiceTest.java +++ b/src/test/java/com/celements/collections/CollectionsServiceTest.java @@ -34,8 +34,8 @@ public void testGetObjectsOrdered_docNull() { @Test public void testGetObjectsOrdered_noObjects() { - XWikiDocument doc = new XWikiDocument(new DocumentReference(getContext().getDatabase(), "S", - "D")); + XWikiDocument doc = new XWikiDocument( + new DocumentReference(getContext().getDatabase(), "S", "D")); List list = collectionsService.getObjectsOrdered(doc, getBOClassRef(), "s1", true, "s2", false); assertNotNull(list); @@ -44,8 +44,8 @@ public void testGetObjectsOrdered_noObjects() { @Test public void testGetObjectsOrdered_oneObject() { - XWikiDocument doc = new XWikiDocument(new DocumentReference(getContext().getDatabase(), "S", - "D")); + XWikiDocument doc = new XWikiDocument( + new DocumentReference(getContext().getDatabase(), "S", "D")); doc.addXObject(getSortTestBaseObjects().get(0)); List list = collectionsService.getObjectsOrdered(doc, getBOClassRef(), "s1", true, "s2", true); @@ -54,8 +54,8 @@ public void testGetObjectsOrdered_oneObject() { @Test public void testGetObjectsOrdered_onlyOneFieldSort() { - XWikiDocument doc = new XWikiDocument(new DocumentReference(getContext().getDatabase(), "S", - "D")); + XWikiDocument doc = new XWikiDocument( + new DocumentReference(getContext().getDatabase(), "S", "D")); for (BaseObject obj : getSortTestBaseObjects()) { doc.addXObject(obj); } @@ -72,8 +72,8 @@ public void testGetObjectsOrdered_onlyOneFieldSort() { @Test public void testGetObjectsOrdered_severalObjects_asc() { - XWikiDocument doc = new XWikiDocument(new DocumentReference(getContext().getDatabase(), "S", - "D")); + XWikiDocument doc = new XWikiDocument( + new DocumentReference(getContext().getDatabase(), "S", "D")); for (BaseObject obj : getSortTestBaseObjects()) { doc.addXObject(obj); } @@ -91,8 +91,8 @@ public void testGetObjectsOrdered_severalObjects_asc() { @Test public void testGetObjectsOrdered_severalObjects_desc() { - XWikiDocument doc = new XWikiDocument(new DocumentReference(getContext().getDatabase(), "S", - "D")); + XWikiDocument doc = new XWikiDocument( + new DocumentReference(getContext().getDatabase(), "S", "D")); for (BaseObject obj : getSortTestBaseObjects()) { doc.addXObject(obj); } @@ -111,8 +111,8 @@ public void testGetObjectsOrdered_severalObjects_desc() { @Test public void testGetObjectsOrdered_severalObjects_unset_fields() { - XWikiDocument doc = new XWikiDocument(new DocumentReference(getContext().getDatabase(), "S", - "D")); + XWikiDocument doc = new XWikiDocument( + new DocumentReference(getContext().getDatabase(), "S", "D")); for (BaseObject obj : getSortTestBaseObjects()) { doc.addXObject(obj); } diff --git a/src/test/java/com/celements/collections/service/CollectionsScriptServiceTest.java b/src/test/java/com/celements/collections/service/CollectionsScriptServiceTest.java index 286eee968..eaee6e038 100644 --- a/src/test/java/com/celements/collections/service/CollectionsScriptServiceTest.java +++ b/src/test/java/com/celements/collections/service/CollectionsScriptServiceTest.java @@ -82,8 +82,8 @@ public void testGetObjectsOrdered_orderByTwoFields() throws XWikiException { BaseObject expectedBO = new BaseObject(); expectedBO.setStringValue("myField", "abcd"); List expResultList = Arrays.asList(expectedBO); - expect(mockCollService.getObjectsOrdered(same(xdoc), eq(classRef), eq("myField"), eq(true), eq( - "myField2"), eq(false))).andReturn(expResultList); + expect(mockCollService.getObjectsOrdered(same(xdoc), eq(classRef), eq("myField"), eq(true), + eq("myField2"), eq(false))).andReturn(expResultList); replayAll(); List resultList = collScriptService.getObjectsOrdered(docRef, classRef, "myField", true, "myField2", false); diff --git a/src/test/java/com/celements/common/collections/ListUtilsTest.java b/src/test/java/com/celements/common/collections/ListUtilsTest.java index 95b255d71..cb32d519a 100644 --- a/src/test/java/com/celements/common/collections/ListUtilsTest.java +++ b/src/test/java/com/celements/common/collections/ListUtilsTest.java @@ -30,8 +30,7 @@ public class ListUtilsTest { @Before - public void prepareTest() throws Exception { - } + public void prepareTest() throws Exception {} @Test public void testImplode_null() { diff --git a/src/test/java/com/celements/common/observation/listener/AbstractDocumentCreateListenerTest.java b/src/test/java/com/celements/common/observation/listener/AbstractDocumentCreateListenerTest.java index 8a32e637b..6433ad91d 100644 --- a/src/test/java/com/celements/common/observation/listener/AbstractDocumentCreateListenerTest.java +++ b/src/test/java/com/celements/common/observation/listener/AbstractDocumentCreateListenerTest.java @@ -57,8 +57,7 @@ public void setUp_AbstractDocumentCreateListenerTest() throws Exception { listener.injectWebUtilsService(Utils.getComponent(IWebUtilsService.class)); listener.injectRemoteObservationManagerContext( remoteObsManContextMock = createDefaultMock(RemoteObservationManagerContext.class)); - listener.injectObservationManager(obsManagerMock = createDefaultMock( - ObservationManager.class)); + listener.injectObservationManager(obsManagerMock = createDefaultMock(ObservationManager.class)); listener.configSrc = Utils.getComponent(ConfigurationSource.class); creatingEventMock = createDefaultMock(Event.class); @@ -72,10 +71,10 @@ public void testGetEvents() { eventClasses.add(theEvent.getClass()); } assertEquals(2, eventClasses.size()); - assertTrue("Expecting registration for DocumentCreatingEvent", eventClasses.contains( - DocumentCreatingEvent.class)); - assertTrue("Expecting registration for DocumentCreatedEvent events", eventClasses.contains( - DocumentCreatedEvent.class)); + assertTrue("Expecting registration for DocumentCreatingEvent", + eventClasses.contains(DocumentCreatingEvent.class)); + assertTrue("Expecting registration for DocumentCreatedEvent events", + eventClasses.contains(DocumentCreatedEvent.class)); } @Test diff --git a/src/test/java/com/celements/common/observation/listener/AbstractDocumentDeleteListenerTest.java b/src/test/java/com/celements/common/observation/listener/AbstractDocumentDeleteListenerTest.java index aad366b67..d427a8853 100644 --- a/src/test/java/com/celements/common/observation/listener/AbstractDocumentDeleteListenerTest.java +++ b/src/test/java/com/celements/common/observation/listener/AbstractDocumentDeleteListenerTest.java @@ -62,8 +62,7 @@ public void prepareTest() throws Exception { listener.injectWebUtilsService(Utils.getComponent(IWebUtilsService.class)); listener.injectRemoteObservationManagerContext( remoteObsManContextMock = createDefaultMock(RemoteObservationManagerContext.class)); - listener.injectObservationManager(obsManagerMock = createDefaultMock( - ObservationManager.class)); + listener.injectObservationManager(obsManagerMock = createDefaultMock(ObservationManager.class)); listener.configSrc = Utils.getComponent(ConfigurationSource.class); deletingEventMock = createDefaultMock(Event.class); @@ -77,10 +76,10 @@ public void testGetEvents() { eventClasses.add(theEvent.getClass()); } assertEquals(2, eventClasses.size()); - assertTrue("Expecting registration for DocumentDeletingEvent", eventClasses.contains( - DocumentDeletingEvent.class)); - assertTrue("Expecting registration for DocumentDeletedEvent events", eventClasses.contains( - DocumentDeletedEvent.class)); + assertTrue("Expecting registration for DocumentDeletingEvent", + eventClasses.contains(DocumentDeletingEvent.class)); + assertTrue("Expecting registration for DocumentDeletedEvent events", + eventClasses.contains(DocumentDeletedEvent.class)); } @Test diff --git a/src/test/java/com/celements/common/observation/listener/AbstractDocumentUpdateListenerTest.java b/src/test/java/com/celements/common/observation/listener/AbstractDocumentUpdateListenerTest.java index a595b845e..aae964a5c 100644 --- a/src/test/java/com/celements/common/observation/listener/AbstractDocumentUpdateListenerTest.java +++ b/src/test/java/com/celements/common/observation/listener/AbstractDocumentUpdateListenerTest.java @@ -71,8 +71,7 @@ public void setUp_AbstractDocumentUpdateListenerTest() throws Exception { listener.injectCopyDocService(Utils.getComponent(ICopyDocumentRole.class)); listener.injectRemoteObservationManagerContext( remoteObsManContextMock = createDefaultMock(RemoteObservationManagerContext.class)); - listener.injectObservationManager(obsManagerMock = createDefaultMock( - ObservationManager.class)); + listener.injectObservationManager(obsManagerMock = createDefaultMock(ObservationManager.class)); listener.configSrc = Utils.getComponent(ConfigurationSource.class); creatingEventMock = createDefaultMock(Event.class); @@ -90,10 +89,10 @@ public void testGetEvents() { eventClasses.add(theEvent.getClass()); } assertEquals(2, eventClasses.size()); - assertTrue("Expecting registration for DocumentUpdatingEvent", eventClasses.contains( - DocumentUpdatingEvent.class)); - assertTrue("Expecting registration for DocumentUpdatedEvent events", eventClasses.contains( - DocumentUpdatedEvent.class)); + assertTrue("Expecting registration for DocumentUpdatingEvent", + eventClasses.contains(DocumentUpdatingEvent.class)); + assertTrue("Expecting registration for DocumentUpdatedEvent events", + eventClasses.contains(DocumentUpdatedEvent.class)); } @Test diff --git a/src/test/java/com/celements/copydoc/CopyDocumentServiceTest.java b/src/test/java/com/celements/copydoc/CopyDocumentServiceTest.java index 4a3d98221..352887aa9 100644 --- a/src/test/java/com/celements/copydoc/CopyDocumentServiceTest.java +++ b/src/test/java/com/celements/copydoc/CopyDocumentServiceTest.java @@ -391,8 +391,8 @@ public void test_copyObject_added() throws Exception { Date val2 = new Date(); srcObj.setDateValue(name2, val2); BaseObject trgObj = createObj(classRef); - expectPropertyClasses(classRef, ImmutableMap.builder().put(name1, - new StringClass()).put(name2, new DateClass()).build()); + expectPropertyClasses(classRef, ImmutableMap.builder() + .put(name1, new StringClass()).put(name2, new DateClass()).build()); replayDefault(); boolean ret = copyDocService.copyObject(srcObj, trgObj, set); diff --git a/src/test/java/com/celements/docform/DocFormCommandTest.java b/src/test/java/com/celements/docform/DocFormCommandTest.java index 3b63f52d9..8456551f3 100644 --- a/src/test/java/com/celements/docform/DocFormCommandTest.java +++ b/src/test/java/com/celements/docform/DocFormCommandTest.java @@ -79,8 +79,7 @@ public void prepareTest() throws Exception { getContext().setDatabase(wiki.getName()); docRef = new DocumentReference(wiki.getName(), "Space", "Doc"); parser = new DocFormRequestKeyParser(docRef); - docFormCmd = (DocFormCommand) Utils.getComponent(IDocForm.class) - .initialize(docRef, true); + docFormCmd = (DocFormCommand) Utils.getComponent(IDocForm.class).initialize(docRef, true); xdoc = create(docRef); tdoc = create(docRef, "it"); @@ -138,9 +137,8 @@ public void test_updateDoc_objField_alreadySet() throws Exception { @Test public void test_updateDoc_objField_multipleFields() throws Exception { - List params = parseParams(ImmutableMap.of( - "A.B_0_hi", "val1", - "A.B_0_content", "val2")); + List params = parseParams( + ImmutableMap.of("A.B_0_hi", "val1", "A.B_0_content", "val2")); BaseObject obj = addXObject(xdoc, params.get(0).getKey()); replayDefault(); @@ -180,9 +178,8 @@ public void test_updateDoc_objField_create_negativeNb() throws Exception { @Test public void test_updateDoc_objField_create_multiple_sameClass() throws Exception { - List params = parseParams(ImmutableMap.of( - "A.B_0_hi", "val1", - "A.B_-1_hi", "val2")); + List params = parseParams( + ImmutableMap.of("A.B_0_hi", "val1", "A.B_-1_hi", "val2")); replayDefault(); assertSame(xdoc, docFormCmd.updateDocFromParam(xdoc, tdoc, params.get(0))); @@ -196,9 +193,8 @@ public void test_updateDoc_objField_create_multiple_sameClass() throws Exception @Test public void test_updateDoc_objField_create_multiple_otherClasses() throws Exception { - List params = parseParams(ImmutableMap.of( - "A.B_-1_hi", "val1", - "X.Y_-1_hi", "val2")); + List params = parseParams( + ImmutableMap.of("A.B_-1_hi", "val1", "X.Y_-1_hi", "val2")); replayDefault(); assertSame(xdoc, docFormCmd.updateDocFromParam(xdoc, tdoc, params.get(0))); @@ -212,8 +208,8 @@ public void test_updateDoc_objField_create_multiple_otherClasses() throws Except @Test public void test_updateDoc_objField_list() throws Exception { - List params = parseParamsArr(ImmutableMap.of( - "A.B_-1_hi", new String[] { "val1", "val2" })); + List params = parseParamsArr( + ImmutableMap.of("A.B_-1_hi", new String[] { "val1", "val2" })); replayDefault(); assertSame(xdoc, docFormCmd.updateDocFromParam(xdoc, tdoc, params.get(0))); @@ -304,13 +300,12 @@ public void test_updateDocs_alreadySet() throws Exception { @Test public void test_updateDocs_multipleDocs() throws Exception { - List params = parseParams(ImmutableMap.of( - "This.Doc_A.B_0_foo", "val1", - "That.Doc_A.B_0_foo", "val1")); - XWikiDocument docThis = expectDocWithSave(create( - new DocumentReference(wiki.getName(), "This", "Doc"))); - XWikiDocument docThat = expectDocWithSave(create( - new DocumentReference(wiki.getName(), "That", "Doc"))); + List params = parseParams( + ImmutableMap.of("This.Doc_A.B_0_foo", "val1", "That.Doc_A.B_0_foo", "val1")); + XWikiDocument docThis = expectDocWithSave( + create(new DocumentReference(wiki.getName(), "This", "Doc"))); + XWikiDocument docThat = expectDocWithSave( + create(new DocumentReference(wiki.getName(), "That", "Doc"))); expectDoc(xdoc); replayDefault(); @@ -346,9 +341,8 @@ public void test_updateDocs_newFromTemplate() throws Exception { @Test public void test_updateDocs_docFields() throws Exception { - List params = parseParams(ImmutableMap.of( - "Space.Doc_title", "Title", - "content", "Content")); + List params = parseParams( + ImmutableMap.of("Space.Doc_title", "Title", "content", "Content")); expectDocWithSave(xdoc); replayDefault(); @@ -362,9 +356,8 @@ public void test_updateDocs_docFields() throws Exception { @Test public void test_updateDocs_docFields_translation() throws Exception { - List params = parseParams(ImmutableMap.of( - "Space.Doc_title", "Title", - "content", "Content")); + List params = parseParams( + ImmutableMap.of("Space.Doc_title", "Title", "content", "Content")); expectDoc(xdoc); getContext().setLanguage(tdoc.getLanguage()); docFormCmd.addTranslationCmd = createDefaultMock(AddTranslationCommand.class); @@ -385,10 +378,8 @@ public void test_updateDocs_docFields_translation() throws Exception { @Test public void test_updateDocs_objFields_deleteAndSet() throws Exception { - List params = parseParams(ImmutableMap.of( - "A.B_^0", "", - "A.B_1_foo", "val1", - "A.B_0_foo", "val2")); + List params = parseParams( + ImmutableMap.of("A.B_^0", "", "A.B_1_foo", "val1", "A.B_0_foo", "val2")); addXObject(xdoc, params.get(0).getKey()); expectDocWithSave(xdoc); @@ -402,8 +393,7 @@ public void test_updateDocs_objFields_deleteAndSet() throws Exception { @Test public void test_updateDocs_createNotAllowed() throws Exception { - docFormCmd = (DocFormCommand) Utils.getComponent(IDocForm.class) - .initialize(docRef, false); + docFormCmd = (DocFormCommand) Utils.getComponent(IDocForm.class).initialize(docRef, false); List params = parseParams(ImmutableMap.of("A.B_0_foo", "val")); xdoc.setNew(true); expectDoc(xdoc); @@ -417,8 +407,7 @@ public void test_updateDocs_createNotAllowed() throws Exception { @Test public void test_updateDocs_createNotAllowed_notNew() throws Exception { - docFormCmd = (DocFormCommand) Utils.getComponent(IDocForm.class) - .initialize(docRef, false); + docFormCmd = (DocFormCommand) Utils.getComponent(IDocForm.class).initialize(docRef, false); List params = parseParams(ImmutableMap.of("A.B_0_foo", "val")); xdoc.setNew(false); expectDocWithSave(xdoc); @@ -444,10 +433,8 @@ public void test_updateDocs_saveFail() throws Exception { assertResponse(params, null, ImmutableSet.of(xdoc), null); } - private void assertResponse(List params, - Set successful, - Set failed, - Set unchanged) { + private void assertResponse(List params, Set successful, + Set failed, Set unchanged) { Map> responseMap = docFormCmd.getResponseMap(params); assertEquals(3, responseMap.size()); assertEquals("successful", convert(successful), responseMap.get(ResponseState.successful)); @@ -468,10 +455,10 @@ private BaseObject addXObject(XWikiDocument doc, DocFormRequestKey key) { } private XWikiDocument expectDoc(XWikiDocument doc) throws DocumentNotExistsException { - expect(getMock(IModelAccessFacade.class).exists(doc.getDocumentReference())) - .andReturn(true).anyTimes(); - expect(getMock(IModelAccessFacade.class).getDocument(doc.getDocumentReference())) - .andReturn(doc).anyTimes(); + expect(getMock(IModelAccessFacade.class).exists(doc.getDocumentReference())).andReturn(true) + .anyTimes(); + expect(getMock(IModelAccessFacade.class).getDocument(doc.getDocumentReference())).andReturn(doc) + .anyTimes(); expect(getMock(IModelAccessFacade.class).getOrCreateDocument(doc.getDocumentReference())) .andReturn(doc).anyTimes(); return doc; @@ -493,14 +480,12 @@ private List parseParams(Map map) throws Ex private List parseParamsArr(Map map) throws Exception { List requestParams = parser.parseParameterMap(map); - requestParams.stream().map(DocFormRequestParam::getKey) - .filter(key -> key.getClassRef() != null) + requestParams.stream().map(DocFormRequestParam::getKey).filter(key -> key.getClassRef() != null) .collect(Collectors.groupingBy(key -> key.getClassRef())) .forEach(rethrowBiConsumer((classRef, keys) -> { final BaseClass bClass = expectNewBaseObject(classRef.getDocRef(wiki)); keys.stream().forEach(key -> expect(bClass.get(key.getFieldName())) - .andReturn(new StringClass()) - .anyTimes()); + .andReturn(new StringClass()).anyTimes()); })); return requestParams; } @@ -509,10 +494,8 @@ private BaseObject assertObj(DocFormRequestParam param, XWikiDocument xdoc) throws XWikiException { DocFormRequestKey key = param.getKey(); int actualObjNb = docFormCmd.getChangedObjects().get(key.getObjHash()); - BaseObject obj = XWikiObjectEditor.on(xdoc) - .filter(param.getKey().getClassRef()) - .filter(actualObjNb) - .fetch().unique(); + BaseObject obj = XWikiObjectEditor.on(xdoc).filter(param.getKey().getClassRef()) + .filter(actualObjNb).fetch().unique(); assertEquals(param.getValuesAsString(), obj.getStringValue(key.getFieldName())); assertEquals(obj.getNumber(), actualObjNb); return obj; diff --git a/src/test/java/com/celements/docform/DocFormRequestKeyParserTest.java b/src/test/java/com/celements/docform/DocFormRequestKeyParserTest.java index d1e8a4c9d..c3b8c52da 100644 --- a/src/test/java/com/celements/docform/DocFormRequestKeyParserTest.java +++ b/src/test/java/com/celements/docform/DocFormRequestKeyParserTest.java @@ -80,8 +80,8 @@ public void test_parse_obj() throws Exception { ClassReference classRef = new ClassReference("Classes", "Class"); Integer objNb = 3; String fieldName = "asdf"; - String keyString = serialize(docRef) + KEY_DELIM + serialize(classRef) - + KEY_DELIM + objNb + KEY_DELIM + fieldName; + String keyString = serialize(docRef) + KEY_DELIM + serialize(classRef) + KEY_DELIM + objNb + + KEY_DELIM + fieldName; DocFormRequestKey key = parser.parse(keyString).orElse(null); assertKey(key, keyString, docRef, classRef, objNb, false, fieldName); } @@ -91,8 +91,7 @@ public void test_parse_obj_noFullName() throws Exception { ClassReference classRef = new ClassReference("Classes", "Class"); Integer objNb = 3; String fieldName = "asdf"; - String keyString = serialize(classRef) + KEY_DELIM + objNb - + KEY_DELIM + fieldName; + String keyString = serialize(classRef) + KEY_DELIM + objNb + KEY_DELIM + fieldName; DocFormRequestKey key = parser.parse(keyString).orElse(null); assertKey(key, keyString, defaultDocRef, classRef, objNb, false, fieldName); } @@ -103,8 +102,8 @@ public void test_parse_obj_local() throws Exception { ClassReference classRef = new ClassReference("Classes", "Class"); Integer objNb = 3; String fieldName = "asdf"; - String keyString = serialize(docRef) + KEY_DELIM + serialize(classRef) - + KEY_DELIM + objNb + KEY_DELIM + fieldName; + String keyString = serialize(docRef) + KEY_DELIM + serialize(classRef) + KEY_DELIM + objNb + + KEY_DELIM + fieldName; DocFormRequestKey key = parser.parse(keyString).orElse(null); docRef = RefBuilder.from(docRef).wiki("xwikidb").build(DocumentReference.class); assertKey(key, keyString, docRef, classRef, objNb, false, fieldName); @@ -115,8 +114,7 @@ public void test_parse_obj_longFieldName() throws Exception { ClassReference classRef = new ClassReference("Classes", "Class"); Integer objNb = 3; String fieldName = "asdf_asdf2"; - String keyString = serialize(classRef) + KEY_DELIM + objNb - + KEY_DELIM + fieldName; + String keyString = serialize(classRef) + KEY_DELIM + objNb + KEY_DELIM + fieldName; DocFormRequestKey key = parser.parse(keyString).orElse(null); assertKey(key, keyString, defaultDocRef, classRef, objNb, false, fieldName); } @@ -126,8 +124,7 @@ public void test_parse_obj_create() throws Exception { ClassReference classRef = new ClassReference("Classes", "Class"); Integer objNb = -3; String fieldName = "asdf"; - String keyString = serialize(classRef) + KEY_DELIM + objNb - + KEY_DELIM + fieldName; + String keyString = serialize(classRef) + KEY_DELIM + objNb + KEY_DELIM + fieldName; DocFormRequestKey key = parser.parse(keyString).orElse(null); assertKey(key, keyString, defaultDocRef, classRef, objNb, false, fieldName); } @@ -164,8 +161,7 @@ public void test_parse_obj_noFieldName() throws Exception { DocumentReference docRef = new DocumentReference(db, "Space", "Doc"); ClassReference classRef = new ClassReference("Classes", "Class"); Integer objNb = 3; - String keyString = serialize(docRef) + KEY_DELIM + serialize(classRef) - + KEY_DELIM + objNb; + String keyString = serialize(docRef) + KEY_DELIM + serialize(classRef) + KEY_DELIM + objNb; DocFormRequestKey key = parser.parse(keyString).orElse(null); fail("expecting DocFormRequestParseException, obj with positive nb must have field: " + key); } @@ -183,8 +179,8 @@ public void test_parse_skip_invalidFullName() throws Exception { ClassReference classRef = new ClassReference("Classes", "Class"); Integer objNb = 3; String fieldName = "asdf"; - String keyString = "SpaceDoc" + KEY_DELIM + serialize(classRef) - + KEY_DELIM + objNb + KEY_DELIM + fieldName; + String keyString = "SpaceDoc" + KEY_DELIM + serialize(classRef) + KEY_DELIM + objNb + KEY_DELIM + + fieldName; assertFalse(parser.parse(keyString).isPresent()); } @@ -193,8 +189,8 @@ public void test_parse_skip_invalidClassName() throws Exception { DocumentReference docRef = new DocumentReference(db, "Space", "Doc"); Integer objNb = 3; String fieldName = "asdf"; - String keyString = serialize(docRef) + KEY_DELIM + "ClassesClass" - + KEY_DELIM + objNb + KEY_DELIM + fieldName; + String keyString = serialize(docRef) + KEY_DELIM + "ClassesClass" + KEY_DELIM + objNb + + KEY_DELIM + fieldName; assertFalse(parser.parse(keyString).isPresent()); } @@ -203,8 +199,8 @@ public void test_parse_skip_noObjNb() throws Exception { DocumentReference docRef = new DocumentReference(db, "Space", "Doc"); ClassReference classRef = new ClassReference("Classes", "Class"); String fieldName = "asdf"; - String keyString = serialize(docRef) + KEY_DELIM + serialize(classRef) - + KEY_DELIM + "3a" + KEY_DELIM + fieldName; + String keyString = serialize(docRef) + KEY_DELIM + serialize(classRef) + KEY_DELIM + "3a" + + KEY_DELIM + fieldName; assertFalse(parser.parse(keyString).isPresent()); } @@ -228,8 +224,7 @@ public void test_parse_skip_withDelim() throws Exception { @Test public void test_parse_skip_withDelims_two() throws Exception { - String keyString = "template" + KEY_DELIM + "other1" - + KEY_DELIM + "other2"; + String keyString = "template" + KEY_DELIM + "other1" + KEY_DELIM + "other2"; assertFalse(parser.parse(keyString).isPresent()); } @@ -259,27 +254,23 @@ public void test_parse_multiple() throws Exception { Integer objNb2 = 5; String fieldName2 = "asdf"; String keyStringClass2 = serialize(classRef2) + KEY_DELIM + objNb2 + KEY_DELIM + fieldName2; - Map requestMap = ImmutableMap.builder() - .put(keyString2, "val2") - .put(keyStringRemove, "valRemove") - .put(keyString1, "val1") - .put(keyStringContent, "valContent") - .put(keyStringClass2, "val3") - .build(); + Map requestMap = ImmutableMap.builder().put(keyString2, "val2") + .put(keyStringRemove, "valRemove").put(keyString1, "val1") + .put(keyStringContent, "valContent").put(keyStringClass2, "val3").build(); List params = parser.parseParameterMap(requestMap); assertEquals(5, params.size()); Iterator iter = params.iterator(); - assertParam(iter.next(), keyString1, defaultDocRef, - classRef, objNb1, false, "asdf1", requestMap); - assertParam(iter.next(), keyString2, defaultDocRef, - classRef, objNb1, false, "asdf2", requestMap); - assertParam(iter.next(), keyStringRemove, defaultDocRef, - classRef, objNb1, true, "", requestMap); - assertParam(iter.next(), keyStringClass2, defaultDocRef, - classRef2, objNb2, false, fieldName2, requestMap); - assertParam(iter.next(), keyStringContent, defaultDocRef, - null, 0, false, keyStringContent, requestMap); + assertParam(iter.next(), keyString1, defaultDocRef, classRef, objNb1, false, "asdf1", + requestMap); + assertParam(iter.next(), keyString2, defaultDocRef, classRef, objNb1, false, "asdf2", + requestMap); + assertParam(iter.next(), keyStringRemove, defaultDocRef, classRef, objNb1, true, "", + requestMap); + assertParam(iter.next(), keyStringClass2, defaultDocRef, classRef2, objNb2, false, fieldName2, + requestMap); + assertParam(iter.next(), keyStringContent, defaultDocRef, null, 0, false, keyStringContent, + requestMap); } @Test @@ -288,8 +279,8 @@ public void test_parse_specialFN() throws Exception { String docName = "2019-07-15"; String docSpace = "TimeSheets-ebeutler10"; String docFN = docSpace + "." + docName; - DocumentReference docRef = RefBuilder.create().wiki(getContext().getDatabase()).doc( - docName).space(docSpace).build(DocumentReference.class); + DocumentReference docRef = RefBuilder.create().wiki(getContext().getDatabase()).doc(docName) + .space(docSpace).build(DocumentReference.class); String classFN = "TimeSheetClasses.TimesheetDayClass"; ClassReference classRef = new ClassReference("TimeSheetClasses", "TimesheetDayClass"); String fieldName = "dailyComment"; diff --git a/src/test/java/com/celements/docform/DocFormRequestKeyTest.java b/src/test/java/com/celements/docform/DocFormRequestKeyTest.java index 6d92a98c3..2d2956fee 100644 --- a/src/test/java/com/celements/docform/DocFormRequestKeyTest.java +++ b/src/test/java/com/celements/docform/DocFormRequestKeyTest.java @@ -46,8 +46,7 @@ public void test_equals() { } private List getAllKeyCombinations() { - return ImmutableList.of( - createDocFieldKey("key", getDocRef("A"), "A"), + return ImmutableList.of(createDocFieldKey("key", getDocRef("A"), "A"), createDocFieldKey("key", getDocRef("A"), "B"), createDocFieldKey("key", getDocRef("B"), "A"), createDocFieldKey("key", getDocRef("B"), "B"), @@ -86,8 +85,7 @@ public void test_compareTo() { } private List getSortedKeys() { - return ImmutableList.of( - createObjFieldKey("key", getDocRef("A"), getClassRef("A"), 0, "A"), + return ImmutableList.of(createObjFieldKey("key", getDocRef("A"), getClassRef("A"), 0, "A"), createObjFieldKey("key", getDocRef("A"), getClassRef("A"), 0, "B"), createObjRemoveKey("ky", getDocRef("A"), getClassRef("A"), 0), createObjFieldKey("key", getDocRef("A"), getClassRef("A"), 1, "A"), diff --git a/src/test/java/com/celements/docform/DocFormScriptServiceTest.java b/src/test/java/com/celements/docform/DocFormScriptServiceTest.java index 5657b8b96..67e2c0885 100644 --- a/src/test/java/com/celements/docform/DocFormScriptServiceTest.java +++ b/src/test/java/com/celements/docform/DocFormScriptServiceTest.java @@ -50,8 +50,8 @@ public void test_updateAndSaveDocFromMap_empty() throws Exception { expect(getMock(IModelAccessFacade.class).getOrCreateDocument(docRef)).andReturn(doc); replayDefault(); - Map> responseMap = docFormService - .updateAndSaveDocFromMap(docRef, requestMap); + Map> responseMap = docFormService.updateAndSaveDocFromMap(docRef, + requestMap); verifyDefault(); assertEquals(responseMap.toString(), ImmutableSet.of(docRef), @@ -70,8 +70,8 @@ public void test_updateAndSaveDocFromMap() throws Exception { getMock(IModelAccessFacade.class).saveDocument(doc, "updateAndSaveDocFormRequest"); replayDefault(); - Map> responseMap = docFormService - .updateAndSaveDocFromMap(docRef, requestMap); + Map> responseMap = docFormService.updateAndSaveDocFromMap(docRef, + requestMap); verifyDefault(); assertEquals(responseMap.toString(), ImmutableSet.of(docRef), @@ -90,8 +90,8 @@ public void test_updateAndSaveDocFromMap_noChange() throws Exception { expect(getMock(IModelAccessFacade.class).getOrCreateDocument(docRef)).andReturn(doc); replayDefault(); - Map> responseMap = docFormService - .updateAndSaveDocFromMap(docRef, requestMap); + Map> responseMap = docFormService.updateAndSaveDocFromMap(docRef, + requestMap); verifyDefault(); assertEquals(responseMap.toString(), ImmutableSet.of(docRef), @@ -111,8 +111,8 @@ public void test_updateAndSaveDocFromMap_failed() throws Exception { expectLastCall().andThrow(new DocumentSaveException(docRef)); replayDefault(); - Map> responseMap = docFormService - .updateAndSaveDocFromMap(docRef, requestMap); + Map> responseMap = docFormService.updateAndSaveDocFromMap(docRef, + requestMap); verifyDefault(); assertEquals(responseMap.toString(), ImmutableSet.of(docRef), @@ -129,8 +129,8 @@ public void test_hasEditOnAllDocs_empty() throws Exception { @Test public void test_hasEditOnAllDocs_notExists_noCreate() throws Exception { getContext().setRequest(createDefaultMock(XWikiRequest.class)); - DocFormRequestParam param = new DocFormRequestParam( - createDocFieldKey("key", docRef, "field"), ""); + DocFormRequestParam param = new DocFormRequestParam(createDocFieldKey("key", docRef, "field"), + ""); expect(getMock(IModelAccessFacade.class).exists(docRef)).andReturn(false); expect(getContext().getRequest().get("createIfNotExists")).andReturn("false"); @@ -143,8 +143,8 @@ public void test_hasEditOnAllDocs_notExists_noCreate() throws Exception { @Test public void test_hasEditOnAllDocs_notExists() throws Exception { getContext().setRequest(createDefaultMock(XWikiRequest.class)); - DocFormRequestParam param = new DocFormRequestParam( - createDocFieldKey("key", docRef, "field"), ""); + DocFormRequestParam param = new DocFormRequestParam(createDocFieldKey("key", docRef, "field"), + ""); expect(getMock(IModelAccessFacade.class).exists(docRef)).andReturn(false); expect(getContext().getRequest().get("createIfNotExists")).andReturn("true"); @@ -157,8 +157,8 @@ public void test_hasEditOnAllDocs_notExists() throws Exception { @Test public void test_hasEditOnAllDocs_noAccess() throws Exception { - DocFormRequestParam param = new DocFormRequestParam( - createDocFieldKey("key", docRef, "field"), ""); + DocFormRequestParam param = new DocFormRequestParam(createDocFieldKey("key", docRef, "field"), + ""); expect(getMock(IModelAccessFacade.class).exists(docRef)).andReturn(true); expect(getMock(IRightsAccessFacadeRole.class).hasAccessLevel(docRef, EDIT)).andReturn(false); @@ -171,12 +171,12 @@ public void test_hasEditOnAllDocs_noAccess() throws Exception { @Test public void test_hasEditOnAllDocs_many_allTrue() throws Exception { List params = ImmutableList.of( - new DocFormRequestParam(createDocFieldKey("key", - new DocumentReference("db", "space", "doc1"), "field1"), ""), - new DocFormRequestParam(createDocFieldKey("key", - new DocumentReference("db", "space", "doc2"), "field2"), ""), - new DocFormRequestParam(createDocFieldKey("key", - new DocumentReference("db", "space", "doc3"), "field3"), "")); + new DocFormRequestParam( + createDocFieldKey("key", new DocumentReference("db", "space", "doc1"), "field1"), ""), + new DocFormRequestParam( + createDocFieldKey("key", new DocumentReference("db", "space", "doc2"), "field2"), ""), + new DocFormRequestParam( + createDocFieldKey("key", new DocumentReference("db", "space", "doc3"), "field3"), "")); params.stream().map(DocFormRequestParam::getDocRef).forEach(docRef -> { expect(getMock(IModelAccessFacade.class).exists(docRef)).andReturn(true); @@ -191,12 +191,12 @@ public void test_hasEditOnAllDocs_many_allTrue() throws Exception { @Test public void test_hasEditOnAllDocs_many_oneFalse() throws Exception { List params = ImmutableList.of( - new DocFormRequestParam(createDocFieldKey("key", - new DocumentReference("db", "space", "doc1"), "field1"), ""), - new DocFormRequestParam(createDocFieldKey("key", - new DocumentReference("db", "space", "doc2"), "field2"), ""), - new DocFormRequestParam(createDocFieldKey("key", - new DocumentReference("db", "space", "doc3"), "field3"), "")); + new DocFormRequestParam( + createDocFieldKey("key", new DocumentReference("db", "space", "doc1"), "field1"), ""), + new DocFormRequestParam( + createDocFieldKey("key", new DocumentReference("db", "space", "doc2"), "field2"), ""), + new DocFormRequestParam( + createDocFieldKey("key", new DocumentReference("db", "space", "doc3"), "field3"), "")); expect(getMock(IModelAccessFacade.class).exists(params.get(0).getDocRef())).andReturn(true); expect(getMock(IRightsAccessFacadeRole.class).hasAccessLevel(params.get(0).getDocRef(), EDIT)) diff --git a/src/test/java/com/celements/dom4j/Dom4JParserTest.java b/src/test/java/com/celements/dom4j/Dom4JParserTest.java index 14b263409..19e77d644 100644 --- a/src/test/java/com/celements/dom4j/Dom4JParserTest.java +++ b/src/test/java/com/celements/dom4j/Dom4JParserTest.java @@ -105,10 +105,9 @@ private void assertDomTree(Document document) { public void test_xhtml_umlaute() throws Exception { Dom4JParser parser = Dom4JParser.createXHtmlParser(); String xml = "
Aä
Bö
Cü
"; - Optional ret = parser.allowDTDs().readAndExecute("" - + xml, document -> { - return Stream.of(document.getRootElement()); - }); + Optional ret = parser.allowDTDs().readAndExecute("" + xml, document -> { + return Stream.of(document.getRootElement()); + }); assertEquals(xml, ret.orElse("")); } diff --git a/src/test/java/com/celements/emptycheck/internal/DefaultEmptyDocStrategyTest.java b/src/test/java/com/celements/emptycheck/internal/DefaultEmptyDocStrategyTest.java index cb05760af..37c33ba06 100644 --- a/src/test/java/com/celements/emptycheck/internal/DefaultEmptyDocStrategyTest.java +++ b/src/test/java/com/celements/emptycheck/internal/DefaultEmptyDocStrategyTest.java @@ -25,8 +25,8 @@ public class DefaultEmptyDocStrategyTest extends AbstractComponentTest { public void setUp_DefaultEmptyDocStrategyTest() throws Exception { context = getContext(); xwiki = getWikiMock(); - defEmptyDocStrategy = (DefaultEmptyDocStrategy) Utils.getComponent( - IDefaultEmptyDocStrategyRole.class, "default"); + defEmptyDocStrategy = (DefaultEmptyDocStrategy) Utils + .getComponent(IDefaultEmptyDocStrategyRole.class, "default"); } @Test @@ -83,8 +83,9 @@ public void testIsEmptyRTEString_nbsp() { defEmptyDocStrategy.isEmptyRTEString(" ")); assertTrue("Non breaking spaces in a paragraph should be treated as empty", defEmptyDocStrategy.isEmptyRTEString("

 

")); - assertTrue("Non breaking spaces in a paragraph with white spaces" - + " should be treated as empty", defEmptyDocStrategy.isEmptyRTEString("

 

")); + assertTrue( + "Non breaking spaces in a paragraph with white spaces" + " should be treated as empty", + defEmptyDocStrategy.isEmptyRTEString("

 

")); assertFalse("Regular Text should not be treated as empty.", defEmptyDocStrategy.isEmptyRTEString("

adsf  

")); } @@ -134,8 +135,8 @@ public void testIsEmptyRTEDocumentDefault_notEmpty() throws Exception { @Test public void testIsEmptyRTEDocumentDefault_Exception() throws Exception { DocumentReference docRef = new DocumentReference(context.getDatabase(), "mySpace", "myDoc"); - expect(xwiki.getDocument(eq(docRef), same(context))).andThrow( - new XWikiException()).atLeastOnce(); + expect(xwiki.getDocument(eq(docRef), same(context))).andThrow(new XWikiException()) + .atLeastOnce(); replayDefault(); assertTrue(defEmptyDocStrategy.isEmptyRTEDocumentDefault(docRef)); verifyDefault(); @@ -173,8 +174,8 @@ public void testIsEmptyRTEDocumentTranslated_notEmpty() throws Exception { public void testIsEmptyRTEDocumentTranslated_Exception() throws Exception { context.setLanguage("fr"); DocumentReference docRef = new DocumentReference(context.getDatabase(), "mySpace", "myDoc"); - expect(xwiki.getDocument(eq(docRef), same(context))).andThrow( - new XWikiException()).atLeastOnce(); + expect(xwiki.getDocument(eq(docRef), same(context))).andThrow(new XWikiException()) + .atLeastOnce(); replayDefault(); assertTrue(defEmptyDocStrategy.isEmptyRTEDocumentTranslated(docRef)); verifyDefault(); @@ -247,8 +248,8 @@ public void testIsEmptyDocumentDefault_notEmpty() throws Exception { @Test public void testIsEmptyDocumentDefault_Exception() throws Exception { DocumentReference docRef = new DocumentReference(context.getDatabase(), "mySpace", "myDoc"); - expect(xwiki.getDocument(eq(docRef), same(context))).andThrow( - new XWikiException()).atLeastOnce(); + expect(xwiki.getDocument(eq(docRef), same(context))).andThrow(new XWikiException()) + .atLeastOnce(); replayDefault(); assertTrue(defEmptyDocStrategy.isEmptyDocumentDefault(docRef)); verifyDefault(); @@ -286,8 +287,8 @@ public void testIsEmptyDocumentTranslated_notEmpty() throws Exception { public void testIsEmptyDocumentTranslated_Exception() throws Exception { context.setLanguage("fr"); DocumentReference docRef = new DocumentReference(context.getDatabase(), "mySpace", "myDoc"); - expect(xwiki.getDocument(eq(docRef), same(context))).andThrow( - new XWikiException()).atLeastOnce(); + expect(xwiki.getDocument(eq(docRef), same(context))).andThrow(new XWikiException()) + .atLeastOnce(); replayDefault(); assertTrue(defEmptyDocStrategy.isEmptyDocumentTranslated(docRef)); verifyDefault(); @@ -404,9 +405,9 @@ public void testIsEmptyRTEDocument_nbsp() { defEmptyDocStrategy.isEmptyRTEDocument(getTestDoc(" "))); assertTrue("Non breaking spaces in a paragraph should be treated as empty", defEmptyDocStrategy.isEmptyRTEDocument(getTestDoc("

 

"))); - assertTrue("Non breaking spaces in a paragraph with white spaces" - + " should be treated as empty", defEmptyDocStrategy.isEmptyRTEDocument(getTestDoc( - "

 

"))); + assertTrue( + "Non breaking spaces in a paragraph with white spaces" + " should be treated as empty", + defEmptyDocStrategy.isEmptyRTEDocument(getTestDoc("

 

"))); assertFalse("Regular Text should not be treated as empty.", defEmptyDocStrategy.isEmptyRTEDocument(getTestDoc("

adsf  

"))); verifyDefault(); diff --git a/src/test/java/com/celements/emptycheck/internal/NextNonEmptyChildrenCommandTest.java b/src/test/java/com/celements/emptycheck/internal/NextNonEmptyChildrenCommandTest.java index 5cba586fc..589ceed14 100644 --- a/src/test/java/com/celements/emptycheck/internal/NextNonEmptyChildrenCommandTest.java +++ b/src/test/java/com/celements/emptycheck/internal/NextNonEmptyChildrenCommandTest.java @@ -79,9 +79,9 @@ public void testGetNextNonEmptyChildren_notEmpty() throws Exception { XWikiDocument myXdoc = new XWikiDocument(documentRef); myXdoc.setContent("test content not empty"); expect(xwiki.getDocument(eq(documentRef), same(context))).andReturn(myXdoc).once(); - expect(xwiki.getXWikiPreference(eq(IEmptyCheckRole.EMPTYCHECK_MODULS_PREF_NAME), eq( - "celements.emptycheckModuls"), eq("default"), same(context))).andReturn( - "default").anyTimes(); + expect(xwiki.getXWikiPreference(eq(IEmptyCheckRole.EMPTYCHECK_MODULS_PREF_NAME), + eq("celements.emptycheckModuls"), eq("default"), same(context))).andReturn("default") + .anyTimes(); replayDefault(); assertEquals(documentRef, nextNonEmptChildCmd.getNextNonEmptyChildren(documentRef)); verifyDefault(); @@ -92,11 +92,11 @@ public void testGetNextNonEmptyChildren_empty_but_noChildren() throws Exception DocumentReference emptyDocRef = new DocumentReference(context.getDatabase(), "mySpace", "MyEmptyDoc"); createEmptyDoc(emptyDocRef); - expect(treeNodeService.getSubNodesForParent(eq(emptyDocRef), eq(""))).andReturn( - Collections.emptyList()).once(); - expect(xwiki.getXWikiPreference(eq(IEmptyCheckRole.EMPTYCHECK_MODULS_PREF_NAME), eq( - "celements.emptycheckModuls"), eq("default"), same(context))).andReturn( - "default").anyTimes(); + expect(treeNodeService.getSubNodesForParent(eq(emptyDocRef), eq(""))) + .andReturn(Collections.emptyList()).once(); + expect(xwiki.getXWikiPreference(eq(IEmptyCheckRole.EMPTYCHECK_MODULS_PREF_NAME), + eq("celements.emptycheckModuls"), eq("default"), same(context))).andReturn("default") + .anyTimes(); replayDefault(); assertNull(nextNonEmptChildCmd.getNextNonEmptyChildren(emptyDocRef)); verifyDefault(); @@ -107,19 +107,21 @@ public void testGetNextNonEmptyChildren_empty_with_nonEmptyChildren() throws Exc DocumentReference emptyDocRef = new DocumentReference(context.getDatabase(), "mySpace", "MyEmptyDoc"); createEmptyDoc(emptyDocRef); - List childrenList = Arrays.asList(new TreeNode(new DocumentReference( - context.getDatabase(), "mySpace", "myChild"), emptyDocRef, 0), new TreeNode( - new DocumentReference(context.getDatabase(), "mySpace", "myChild2"), emptyDocRef, 1)); - expect(treeNodeService.getSubNodesForParent(eq(emptyDocRef), eq(""))).andReturn( - childrenList).once(); + List childrenList = Arrays.asList( + new TreeNode(new DocumentReference(context.getDatabase(), "mySpace", "myChild"), + emptyDocRef, 0), + new TreeNode(new DocumentReference(context.getDatabase(), "mySpace", "myChild2"), + emptyDocRef, 1)); + expect(treeNodeService.getSubNodesForParent(eq(emptyDocRef), eq(""))).andReturn(childrenList) + .once(); DocumentReference expectedChildDocRef = new DocumentReference(context.getDatabase(), "mySpace", "myChild"); XWikiDocument childXdoc = new XWikiDocument(expectedChildDocRef); childXdoc.setContent("non empty child content"); expect(xwiki.getDocument(eq(expectedChildDocRef), same(context))).andReturn(childXdoc).once(); - expect(xwiki.getXWikiPreference(eq(IEmptyCheckRole.EMPTYCHECK_MODULS_PREF_NAME), eq( - "celements.emptycheckModuls"), eq("default"), same(context))).andReturn( - "default").anyTimes(); + expect(xwiki.getXWikiPreference(eq(IEmptyCheckRole.EMPTYCHECK_MODULS_PREF_NAME), + eq("celements.emptycheckModuls"), eq("default"), same(context))).andReturn("default") + .anyTimes(); replayDefault(); assertEquals(expectedChildDocRef, nextNonEmptChildCmd.getNextNonEmptyChildren(emptyDocRef)); verifyDefault(); @@ -138,24 +140,24 @@ public void testGetNextNonEmptyChildren_empty_with_nonEmptyChildren_notFirstChil "myChild"); List childrenList = Arrays.asList(new TreeNode(emptyChildDocRef, emptyDocRef, 0), new TreeNode(expectedChildDocRef, emptyDocRef, 1)); - expect(treeNodeService.getSubNodesForParent(eq(emptyDocRef), eq(""))).andReturn( - childrenList).once(); - expect(treeNodeService.getSubNodesForParent(eq(emptyChildDocRef), eq(""))).andReturn( - Collections.emptyList()).once(); + expect(treeNodeService.getSubNodesForParent(eq(emptyDocRef), eq(""))).andReturn(childrenList) + .once(); + expect(treeNodeService.getSubNodesForParent(eq(emptyChildDocRef), eq(""))) + .andReturn(Collections.emptyList()).once(); XWikiDocument childEmptyXdoc = createDefaultMock(XWikiDocument.class); expect(childEmptyXdoc.getContent()).andReturn("").once(); - expect(xwiki.getDocument(eq(emptyChildDocRef), same(context))).andReturn(childEmptyXdoc).times( - 2); + expect(xwiki.getDocument(eq(emptyChildDocRef), same(context))).andReturn(childEmptyXdoc) + .times(2); XWikiDocument childEmptyXTdoc = new XWikiDocument(emptyChildDocRef); childEmptyXTdoc.setContent(""); - expect(childEmptyXdoc.getTranslatedDocument(eq("fr"), same(context))).andReturn( - childEmptyXTdoc).once(); + expect(childEmptyXdoc.getTranslatedDocument(eq("fr"), same(context))).andReturn(childEmptyXTdoc) + .once(); XWikiDocument childXdoc = new XWikiDocument(expectedChildDocRef); childXdoc.setContent("non empty child content"); expect(xwiki.getDocument(eq(expectedChildDocRef), same(context))).andReturn(childXdoc).once(); - expect(xwiki.getXWikiPreference(eq(IEmptyCheckRole.EMPTYCHECK_MODULS_PREF_NAME), eq( - "celements.emptycheckModuls"), eq("default"), same(context))).andReturn( - "default").anyTimes(); + expect(xwiki.getXWikiPreference(eq(IEmptyCheckRole.EMPTYCHECK_MODULS_PREF_NAME), + eq("celements.emptycheckModuls"), eq("default"), same(context))).andReturn("default") + .anyTimes(); replayDefault(); assertEquals(expectedChildDocRef, nextNonEmptChildCmd.getNextNonEmptyChildren(emptyDocRef)); verifyDefault(); @@ -166,29 +168,32 @@ public void testGetNextNonEmptyChildren_empty_recurse_on_EmptyChildren() throws DocumentReference emptyDocRef = new DocumentReference(context.getDatabase(), "mySpace", "MyEmptyDoc"); createEmptyDoc(emptyDocRef); - List childrenList = Arrays.asList(new TreeNode(new DocumentReference( - context.getDatabase(), "mySpace", "myChild"), emptyDocRef, 0), new TreeNode( - new DocumentReference(context.getDatabase(), "mySpace", "myChild2"), emptyDocRef, 1)); - expect(treeNodeService.getSubNodesForParent(eq(emptyDocRef), eq(""))).andReturn( - childrenList).once(); + List childrenList = Arrays.asList( + new TreeNode(new DocumentReference(context.getDatabase(), "mySpace", "myChild"), + emptyDocRef, 0), + new TreeNode(new DocumentReference(context.getDatabase(), "mySpace", "myChild2"), + emptyDocRef, 1)); + expect(treeNodeService.getSubNodesForParent(eq(emptyDocRef), eq(""))).andReturn(childrenList) + .once(); DocumentReference childDocRef = new DocumentReference(context.getDatabase(), "mySpace", "myChild"); createEmptyDoc(childDocRef); - List childrenList2 = Arrays.asList(new TreeNode(new DocumentReference( - context.getDatabase(), "mySpace", "myChildChild"), emptyDocRef, 0), new TreeNode( - new DocumentReference(context.getDatabase(), "mySpace", "myChildChild2"), emptyDocRef, - 1)); - expect(treeNodeService.getSubNodesForParent(eq(childDocRef), eq(""))).andReturn( - childrenList2).once(); + List childrenList2 = Arrays.asList( + new TreeNode(new DocumentReference(context.getDatabase(), "mySpace", "myChildChild"), + emptyDocRef, 0), + new TreeNode(new DocumentReference(context.getDatabase(), "mySpace", "myChildChild2"), + emptyDocRef, 1)); + expect(treeNodeService.getSubNodesForParent(eq(childDocRef), eq(""))).andReturn(childrenList2) + .once(); DocumentReference expectedChildDocRef = new DocumentReference(context.getDatabase(), "mySpace", "myChildChild"); XWikiDocument childChildXdoc = new XWikiDocument(expectedChildDocRef); childChildXdoc.setContent("non empty child content"); - expect(xwiki.getDocument(eq(expectedChildDocRef), same(context))).andReturn( - childChildXdoc).once(); - expect(xwiki.getXWikiPreference(eq(IEmptyCheckRole.EMPTYCHECK_MODULS_PREF_NAME), eq( - "celements.emptycheckModuls"), eq("default"), same(context))).andReturn( - "default").anyTimes(); + expect(xwiki.getDocument(eq(expectedChildDocRef), same(context))).andReturn(childChildXdoc) + .once(); + expect(xwiki.getXWikiPreference(eq(IEmptyCheckRole.EMPTYCHECK_MODULS_PREF_NAME), + eq("celements.emptycheckModuls"), eq("default"), same(context))).andReturn("default") + .anyTimes(); replayDefault(); assertEquals(expectedChildDocRef, nextNonEmptChildCmd.getNextNonEmptyChildren(emptyDocRef)); verifyDefault(); @@ -209,8 +214,8 @@ public void testGetNextNonEmptyChildren_empty_recurse_on_EmptyChildren_reconize_ List childrenList = Arrays.asList(new TreeNode(childDocRef, emptyDocRef, 0), new TreeNode(child2DocRef, emptyDocRef, 1)); // if called more than once the recursion detection is very likely broken! - expect(treeNodeService.getSubNodesForParent(eq(emptyDocRef), eq(""))).andReturn( - childrenList).once(); + expect(treeNodeService.getSubNodesForParent(eq(emptyDocRef), eq(""))).andReturn(childrenList) + .once(); DocumentReference childChildDocRef = new DocumentReference(context.getDatabase(), "mySpace", "myChildChild"); createEmptyDoc(childChildDocRef); @@ -219,19 +224,19 @@ public void testGetNextNonEmptyChildren_empty_recurse_on_EmptyChildren_reconize_ createEmptyDoc(childChild2DocRef); List childrenList2 = Arrays.asList(new TreeNode(childChildDocRef, emptyDocRef, 0), new TreeNode(childChild2DocRef, emptyDocRef, 1)); - expect(treeNodeService.getSubNodesForParent(eq(childDocRef), eq(""))).andReturn( - childrenList2).once(); - List childrenList3 = Arrays.asList(new TreeNode(new DocumentReference( - context.getDatabase(), "mySpace", "MyEmptyDoc"), emptyDocRef, 0)); - expect(treeNodeService.getSubNodesForParent(eq(childChildDocRef), eq(""))).andReturn( - childrenList3).once(); - expect(treeNodeService.getSubNodesForParent(eq(child2DocRef), eq(""))).andReturn( - Collections.emptyList()).once(); - expect(treeNodeService.getSubNodesForParent(eq(childChild2DocRef), eq(""))).andReturn( - Collections.emptyList()).once(); - expect(xwiki.getXWikiPreference(eq(IEmptyCheckRole.EMPTYCHECK_MODULS_PREF_NAME), eq( - "celements.emptycheckModuls"), eq("default"), same(context))).andReturn( - "default").anyTimes(); + expect(treeNodeService.getSubNodesForParent(eq(childDocRef), eq(""))).andReturn(childrenList2) + .once(); + List childrenList3 = Arrays.asList(new TreeNode( + new DocumentReference(context.getDatabase(), "mySpace", "MyEmptyDoc"), emptyDocRef, 0)); + expect(treeNodeService.getSubNodesForParent(eq(childChildDocRef), eq(""))) + .andReturn(childrenList3).once(); + expect(treeNodeService.getSubNodesForParent(eq(child2DocRef), eq(""))) + .andReturn(Collections.emptyList()).once(); + expect(treeNodeService.getSubNodesForParent(eq(childChild2DocRef), eq(""))) + .andReturn(Collections.emptyList()).once(); + expect(xwiki.getXWikiPreference(eq(IEmptyCheckRole.EMPTYCHECK_MODULS_PREF_NAME), + eq("celements.emptycheckModuls"), eq("default"), same(context))).andReturn("default") + .anyTimes(); replayDefault(); assertNull(nextNonEmptChildCmd.getNextNonEmptyChildren(emptyDocRef)); verifyDefault(); diff --git a/src/test/java/com/celements/emptycheck/service/EmptyCheckServiceTest.java b/src/test/java/com/celements/emptycheck/service/EmptyCheckServiceTest.java index ee53df22e..2d02c8551 100644 --- a/src/test/java/com/celements/emptycheck/service/EmptyCheckServiceTest.java +++ b/src/test/java/com/celements/emptycheck/service/EmptyCheckServiceTest.java @@ -73,8 +73,8 @@ public void shutdown_EmptyCheckCommandTest() throws Exception { @Test public void testGetCheckImplNamesConfig_bugReturningNull() { - expect(xwiki.getXWikiPreference(eq(IEmptyCheckRole.EMPTYCHECK_MODULS_PREF_NAME), eq( - "celements.emptycheckModuls"), eq("default"), same(context))).andReturn(null).anyTimes(); + expect(xwiki.getXWikiPreference(eq(IEmptyCheckRole.EMPTYCHECK_MODULS_PREF_NAME), + eq("celements.emptycheckModuls"), eq("default"), same(context))).andReturn(null).anyTimes(); replayDefault(); assertEquals(Arrays.asList("default"), emptyCheckService.getCheckImplNamesConfig()); verifyDefault(); @@ -82,8 +82,8 @@ public void testGetCheckImplNamesConfig_bugReturningNull() { @Test public void testGetCheckImplNamesConfig_bugReturningEmtpy() { - expect(xwiki.getXWikiPreference(eq(IEmptyCheckRole.EMPTYCHECK_MODULS_PREF_NAME), eq( - "celements.emptycheckModuls"), eq("default"), same(context))).andReturn("").anyTimes(); + expect(xwiki.getXWikiPreference(eq(IEmptyCheckRole.EMPTYCHECK_MODULS_PREF_NAME), + eq("celements.emptycheckModuls"), eq("default"), same(context))).andReturn("").anyTimes(); replayDefault(); assertEquals(Arrays.asList("default"), emptyCheckService.getCheckImplNamesConfig()); verifyDefault(); @@ -91,9 +91,9 @@ public void testGetCheckImplNamesConfig_bugReturningEmtpy() { @Test public void testGetCheckImplNamesConfig_noConfig() { - expect(xwiki.getXWikiPreference(eq(IEmptyCheckRole.EMPTYCHECK_MODULS_PREF_NAME), eq( - "celements.emptycheckModuls"), eq("default"), same(context))).andReturn( - "default").anyTimes(); + expect(xwiki.getXWikiPreference(eq(IEmptyCheckRole.EMPTYCHECK_MODULS_PREF_NAME), + eq("celements.emptycheckModuls"), eq("default"), same(context))).andReturn("default") + .anyTimes(); replayDefault(); assertEquals(Arrays.asList("default"), emptyCheckService.getCheckImplNamesConfig()); verifyDefault(); @@ -101,9 +101,9 @@ public void testGetCheckImplNamesConfig_noConfig() { @Test public void testGetCheckImplNamesConfig_commaSeparated() { - expect(xwiki.getXWikiPreference(eq(IEmptyCheckRole.EMPTYCHECK_MODULS_PREF_NAME), eq( - "celements.emptycheckModuls"), eq("default"), same(context))).andReturn( - "default,sharedContent").anyTimes(); + expect(xwiki.getXWikiPreference(eq(IEmptyCheckRole.EMPTYCHECK_MODULS_PREF_NAME), + eq("celements.emptycheckModuls"), eq("default"), same(context))) + .andReturn("default,sharedContent").anyTimes(); replayDefault(); assertEquals(Arrays.asList("default", "sharedContent"), emptyCheckService.getCheckImplNamesConfig()); @@ -112,9 +112,9 @@ public void testGetCheckImplNamesConfig_commaSeparated() { @Test public void testGetCheckImplNames_semicolonSeparated() { - expect(xwiki.getXWikiPreference(eq(IEmptyCheckRole.EMPTYCHECK_MODULS_PREF_NAME), eq( - "celements.emptycheckModuls"), eq("default"), same(context))).andReturn( - "default;sharedContent").anyTimes(); + expect(xwiki.getXWikiPreference(eq(IEmptyCheckRole.EMPTYCHECK_MODULS_PREF_NAME), + eq("celements.emptycheckModuls"), eq("default"), same(context))) + .andReturn("default;sharedContent").anyTimes(); replayDefault(); assertEquals(Arrays.asList("default", "sharedContent"), emptyCheckService.getCheckImplNamesConfig()); @@ -128,15 +128,14 @@ public void testIsEmptyRTEDocument_two_impl_oneNotEmpty_skipAfterNotEmpty() { mockStrategyMap.put("testOne", testOneMock); IEmptyDocStrategyRole testTwoMock = createDefaultMock(IEmptyDocStrategyRole.class); mockStrategyMap.put("testTwo", testTwoMock); - IEmptyDocStrategyRole testNotConfiguredMock = createDefaultMock( - IEmptyDocStrategyRole.class); + IEmptyDocStrategyRole testNotConfiguredMock = createDefaultMock(IEmptyDocStrategyRole.class); mockStrategyMap.put("testNotConfigured", testNotConfiguredMock); emptyCheckService.emptyDocStrategies = mockStrategyMap; DocumentReference docRef = new DocumentReference(context.getDatabase(), "mySpace", "MyDoc"); expect(testOneMock.isEmptyRTEDocument(eq(docRef))).andReturn(false).once(); - expect(xwiki.getXWikiPreference(eq(IEmptyCheckRole.EMPTYCHECK_MODULS_PREF_NAME), eq( - "celements.emptycheckModuls"), eq("default"), same(context))).andReturn( - "testOne;testTwo;;wrongTest;").anyTimes(); + expect(xwiki.getXWikiPreference(eq(IEmptyCheckRole.EMPTYCHECK_MODULS_PREF_NAME), + eq("celements.emptycheckModuls"), eq("default"), same(context))) + .andReturn("testOne;testTwo;;wrongTest;").anyTimes(); replayDefault(); assertFalse(emptyCheckService.isEmptyRTEDocument(docRef)); verifyDefault(); @@ -149,16 +148,15 @@ public void testIsEmptyRTEDocument_two_impl_oneNotEmpty() { mockStrategyMap.put("testOne", testOneMock); IEmptyDocStrategyRole testTwoMock = createDefaultMock(IEmptyDocStrategyRole.class); mockStrategyMap.put("testTwo", testTwoMock); - IEmptyDocStrategyRole testNotConfiguredMock = createDefaultMock( - IEmptyDocStrategyRole.class); + IEmptyDocStrategyRole testNotConfiguredMock = createDefaultMock(IEmptyDocStrategyRole.class); mockStrategyMap.put("testNotConfigured", testNotConfiguredMock); emptyCheckService.emptyDocStrategies = mockStrategyMap; DocumentReference docRef = new DocumentReference(context.getDatabase(), "mySpace", "MyDoc"); expect(testOneMock.isEmptyRTEDocument(eq(docRef))).andReturn(true).once(); expect(testTwoMock.isEmptyRTEDocument(eq(docRef))).andReturn(false).once(); - expect(xwiki.getXWikiPreference(eq(IEmptyCheckRole.EMPTYCHECK_MODULS_PREF_NAME), eq( - "celements.emptycheckModuls"), eq("default"), same(context))).andReturn( - "testOne;testTwo;;wrongTest;").anyTimes(); + expect(xwiki.getXWikiPreference(eq(IEmptyCheckRole.EMPTYCHECK_MODULS_PREF_NAME), + eq("celements.emptycheckModuls"), eq("default"), same(context))) + .andReturn("testOne;testTwo;;wrongTest;").anyTimes(); replayDefault(); assertFalse(emptyCheckService.isEmptyRTEDocument(docRef)); verifyDefault(); @@ -171,16 +169,15 @@ public void testIsEmptyRTEDocument_two_impl_isEmpty() { mockStrategyMap.put("testOne", testOneMock); IEmptyDocStrategyRole testTwoMock = createDefaultMock(IEmptyDocStrategyRole.class); mockStrategyMap.put("testTwo", testTwoMock); - IEmptyDocStrategyRole testNotConfiguredMock = createDefaultMock( - IEmptyDocStrategyRole.class); + IEmptyDocStrategyRole testNotConfiguredMock = createDefaultMock(IEmptyDocStrategyRole.class); mockStrategyMap.put("testNotConfigured", testNotConfiguredMock); emptyCheckService.emptyDocStrategies = mockStrategyMap; DocumentReference docRef = new DocumentReference(context.getDatabase(), "mySpace", "MyDoc"); expect(testOneMock.isEmptyRTEDocument(eq(docRef))).andReturn(true).once(); expect(testTwoMock.isEmptyRTEDocument(eq(docRef))).andReturn(true).once(); - expect(xwiki.getXWikiPreference(eq(IEmptyCheckRole.EMPTYCHECK_MODULS_PREF_NAME), eq( - "celements.emptycheckModuls"), eq("default"), same(context))).andReturn( - "testOne;testTwo;;wrongTest;").anyTimes(); + expect(xwiki.getXWikiPreference(eq(IEmptyCheckRole.EMPTYCHECK_MODULS_PREF_NAME), + eq("celements.emptycheckModuls"), eq("default"), same(context))) + .andReturn("testOne;testTwo;;wrongTest;").anyTimes(); replayDefault(); assertTrue(emptyCheckService.isEmptyRTEDocument(docRef)); verifyDefault(); @@ -193,15 +190,14 @@ public void testIsEmptyDocument_two_impl_oneNotEmpty_skipAfterNotEmpty() { mockStrategyMap.put("testOne", testOneMock); IEmptyDocStrategyRole testTwoMock = createDefaultMock(IEmptyDocStrategyRole.class); mockStrategyMap.put("testTwo", testTwoMock); - IEmptyDocStrategyRole testNotConfiguredMock = createDefaultMock( - IEmptyDocStrategyRole.class); + IEmptyDocStrategyRole testNotConfiguredMock = createDefaultMock(IEmptyDocStrategyRole.class); mockStrategyMap.put("testNotConfigured", testNotConfiguredMock); emptyCheckService.emptyDocStrategies = mockStrategyMap; DocumentReference docRef = new DocumentReference(context.getDatabase(), "mySpace", "MyDoc"); expect(testOneMock.isEmptyDocument(eq(docRef))).andReturn(false).once(); - expect(xwiki.getXWikiPreference(eq(IEmptyCheckRole.EMPTYCHECK_MODULS_PREF_NAME), eq( - "celements.emptycheckModuls"), eq("default"), same(context))).andReturn( - "testOne;testTwo;;wrongTest;").anyTimes(); + expect(xwiki.getXWikiPreference(eq(IEmptyCheckRole.EMPTYCHECK_MODULS_PREF_NAME), + eq("celements.emptycheckModuls"), eq("default"), same(context))) + .andReturn("testOne;testTwo;;wrongTest;").anyTimes(); replayDefault(); assertFalse(emptyCheckService.isEmptyDocument(docRef)); verifyDefault(); @@ -214,16 +210,15 @@ public void testIsEmptyDocument_two_impl_oneNotEmpty() { mockStrategyMap.put("testOne", testOneMock); IEmptyDocStrategyRole testTwoMock = createDefaultMock(IEmptyDocStrategyRole.class); mockStrategyMap.put("testTwo", testTwoMock); - IEmptyDocStrategyRole testNotConfiguredMock = createDefaultMock( - IEmptyDocStrategyRole.class); + IEmptyDocStrategyRole testNotConfiguredMock = createDefaultMock(IEmptyDocStrategyRole.class); mockStrategyMap.put("testNotConfigured", testNotConfiguredMock); emptyCheckService.emptyDocStrategies = mockStrategyMap; DocumentReference docRef = new DocumentReference(context.getDatabase(), "mySpace", "MyDoc"); expect(testOneMock.isEmptyDocument(eq(docRef))).andReturn(true).once(); expect(testTwoMock.isEmptyDocument(eq(docRef))).andReturn(false).once(); - expect(xwiki.getXWikiPreference(eq(IEmptyCheckRole.EMPTYCHECK_MODULS_PREF_NAME), eq( - "celements.emptycheckModuls"), eq("default"), same(context))).andReturn( - "testOne;testTwo;;wrongTest;").anyTimes(); + expect(xwiki.getXWikiPreference(eq(IEmptyCheckRole.EMPTYCHECK_MODULS_PREF_NAME), + eq("celements.emptycheckModuls"), eq("default"), same(context))) + .andReturn("testOne;testTwo;;wrongTest;").anyTimes(); replayDefault(); assertFalse(emptyCheckService.isEmptyDocument(docRef)); verifyDefault(); @@ -236,16 +231,15 @@ public void testIsEmptyDocument_two_impl_isEmpty() { mockStrategyMap.put("testOne", testOneMock); IEmptyDocStrategyRole testTwoMock = createDefaultMock(IEmptyDocStrategyRole.class); mockStrategyMap.put("testTwo", testTwoMock); - IEmptyDocStrategyRole testNotConfiguredMock = createDefaultMock( - IEmptyDocStrategyRole.class); + IEmptyDocStrategyRole testNotConfiguredMock = createDefaultMock(IEmptyDocStrategyRole.class); mockStrategyMap.put("testNotConfigured", testNotConfiguredMock); emptyCheckService.emptyDocStrategies = mockStrategyMap; DocumentReference docRef = new DocumentReference(context.getDatabase(), "mySpace", "MyDoc"); expect(testOneMock.isEmptyDocument(eq(docRef))).andReturn(true).once(); expect(testTwoMock.isEmptyDocument(eq(docRef))).andReturn(true).once(); - expect(xwiki.getXWikiPreference(eq(IEmptyCheckRole.EMPTYCHECK_MODULS_PREF_NAME), eq( - "celements.emptycheckModuls"), eq("default"), same(context))).andReturn( - "testOne;testTwo;;wrongTest;").anyTimes(); + expect(xwiki.getXWikiPreference(eq(IEmptyCheckRole.EMPTYCHECK_MODULS_PREF_NAME), + eq("celements.emptycheckModuls"), eq("default"), same(context))) + .andReturn("testOne;testTwo;;wrongTest;").anyTimes(); replayDefault(); assertTrue(emptyCheckService.isEmptyDocument(docRef)); verifyDefault(); @@ -258,9 +252,9 @@ public void testGetNextNonEmptyChildren_notEmpty() throws Exception { XWikiDocument myXdoc = new XWikiDocument(documentRef); myXdoc.setContent("test content not empty"); expect(xwiki.getDocument(eq(documentRef), same(context))).andReturn(myXdoc).once(); - expect(xwiki.getXWikiPreference(eq(IEmptyCheckRole.EMPTYCHECK_MODULS_PREF_NAME), eq( - "celements.emptycheckModuls"), eq("default"), same(context))).andReturn( - "default").anyTimes(); + expect(xwiki.getXWikiPreference(eq(IEmptyCheckRole.EMPTYCHECK_MODULS_PREF_NAME), + eq("celements.emptycheckModuls"), eq("default"), same(context))).andReturn("default") + .anyTimes(); replayDefault(); assertEquals(documentRef, emptyCheckService.getNextNonEmptyChildren(documentRef)); verifyDefault(); @@ -272,11 +266,11 @@ public void testGetNextNonEmptyChildren_empty_but_noChildren() throws Exception "MyEmptyDoc"); createEmptyDoc(emptyDocRef); List noChildrenList = Collections.emptyList(); - expect(treeNodeService.getSubNodesForParent(eq(emptyDocRef), eq(""))).andReturn( - noChildrenList).once(); - expect(xwiki.getXWikiPreference(eq(IEmptyCheckRole.EMPTYCHECK_MODULS_PREF_NAME), eq( - "celements.emptycheckModuls"), eq("default"), same(context))).andReturn( - "default").anyTimes(); + expect(treeNodeService.getSubNodesForParent(eq(emptyDocRef), eq(""))).andReturn(noChildrenList) + .once(); + expect(xwiki.getXWikiPreference(eq(IEmptyCheckRole.EMPTYCHECK_MODULS_PREF_NAME), + eq("celements.emptycheckModuls"), eq("default"), same(context))).andReturn("default") + .anyTimes(); replayDefault(); assertEquals(emptyDocRef, emptyCheckService.getNextNonEmptyChildren(emptyDocRef)); verifyDefault(); @@ -287,19 +281,21 @@ public void testGetNextNonEmptyChildren_empty_with_nonEmptyChildren() throws Exc DocumentReference emptyDocRef = new DocumentReference(context.getDatabase(), "mySpace", "MyEmptyDoc"); createEmptyDoc(emptyDocRef); - List childrenList = Arrays.asList(new TreeNode(new DocumentReference( - context.getDatabase(), "mySpace", "myChild"), emptyDocRef, 0), new TreeNode( - new DocumentReference(context.getDatabase(), "mySpace", "myChild2"), emptyDocRef, 1)); - expect(treeNodeService.getSubNodesForParent(eq(emptyDocRef), eq(""))).andReturn( - childrenList).once(); + List childrenList = Arrays.asList( + new TreeNode(new DocumentReference(context.getDatabase(), "mySpace", "myChild"), + emptyDocRef, 0), + new TreeNode(new DocumentReference(context.getDatabase(), "mySpace", "myChild2"), + emptyDocRef, 1)); + expect(treeNodeService.getSubNodesForParent(eq(emptyDocRef), eq(""))).andReturn(childrenList) + .once(); DocumentReference expectedChildDocRef = new DocumentReference(context.getDatabase(), "mySpace", "myChild"); XWikiDocument childXdoc = new XWikiDocument(expectedChildDocRef); childXdoc.setContent("non empty child content"); expect(xwiki.getDocument(eq(expectedChildDocRef), same(context))).andReturn(childXdoc).once(); - expect(xwiki.getXWikiPreference(eq(IEmptyCheckRole.EMPTYCHECK_MODULS_PREF_NAME), eq( - "celements.emptycheckModuls"), eq("default"), same(context))).andReturn( - "default").anyTimes(); + expect(xwiki.getXWikiPreference(eq(IEmptyCheckRole.EMPTYCHECK_MODULS_PREF_NAME), + eq("celements.emptycheckModuls"), eq("default"), same(context))).andReturn("default") + .anyTimes(); replayDefault(); assertEquals(expectedChildDocRef, emptyCheckService.getNextNonEmptyChildren(emptyDocRef)); verifyDefault(); @@ -310,29 +306,32 @@ public void testGetNextNonEmptyChildren_empty_recurse_on_EmptyChildren() throws DocumentReference emptyDocRef = new DocumentReference(context.getDatabase(), "mySpace", "MyEmptyDoc"); createEmptyDoc(emptyDocRef); - List childrenList = Arrays.asList(new TreeNode(new DocumentReference( - context.getDatabase(), "mySpace", "myChild"), emptyDocRef, 0), new TreeNode( - new DocumentReference(context.getDatabase(), "mySpace", "myChild2"), emptyDocRef, 1)); - expect(treeNodeService.getSubNodesForParent(eq(emptyDocRef), eq(""))).andReturn( - childrenList).once(); + List childrenList = Arrays.asList( + new TreeNode(new DocumentReference(context.getDatabase(), "mySpace", "myChild"), + emptyDocRef, 0), + new TreeNode(new DocumentReference(context.getDatabase(), "mySpace", "myChild2"), + emptyDocRef, 1)); + expect(treeNodeService.getSubNodesForParent(eq(emptyDocRef), eq(""))).andReturn(childrenList) + .once(); DocumentReference childDocRef = new DocumentReference(context.getDatabase(), "mySpace", "myChild"); createEmptyDoc(childDocRef); - List childrenList2 = Arrays.asList(new TreeNode(new DocumentReference( - context.getDatabase(), "mySpace", "myChildChild"), emptyDocRef, 0), new TreeNode( - new DocumentReference(context.getDatabase(), "mySpace", "myChildChild2"), emptyDocRef, - 1)); - expect(treeNodeService.getSubNodesForParent(eq(childDocRef), eq(""))).andReturn( - childrenList2).once(); + List childrenList2 = Arrays.asList( + new TreeNode(new DocumentReference(context.getDatabase(), "mySpace", "myChildChild"), + emptyDocRef, 0), + new TreeNode(new DocumentReference(context.getDatabase(), "mySpace", "myChildChild2"), + emptyDocRef, 1)); + expect(treeNodeService.getSubNodesForParent(eq(childDocRef), eq(""))).andReturn(childrenList2) + .once(); DocumentReference expectedChildDocRef = new DocumentReference(context.getDatabase(), "mySpace", "myChildChild"); XWikiDocument childChildXdoc = new XWikiDocument(expectedChildDocRef); childChildXdoc.setContent("non empty child content"); - expect(xwiki.getDocument(eq(expectedChildDocRef), same(context))).andReturn( - childChildXdoc).once(); - expect(xwiki.getXWikiPreference(eq(IEmptyCheckRole.EMPTYCHECK_MODULS_PREF_NAME), eq( - "celements.emptycheckModuls"), eq("default"), same(context))).andReturn( - "default").anyTimes(); + expect(xwiki.getDocument(eq(expectedChildDocRef), same(context))).andReturn(childChildXdoc) + .once(); + expect(xwiki.getXWikiPreference(eq(IEmptyCheckRole.EMPTYCHECK_MODULS_PREF_NAME), + eq("celements.emptycheckModuls"), eq("default"), same(context))).andReturn("default") + .anyTimes(); replayDefault(); assertEquals(expectedChildDocRef, emptyCheckService.getNextNonEmptyChildren(emptyDocRef)); verifyDefault(); @@ -353,8 +352,8 @@ public void testGetNextNonEmptyChildren_empty_recurse_on_EmptyChildren_reconize_ List childrenList = Arrays.asList(new TreeNode(childDocRef, emptyDocRef, 0), new TreeNode(child2DocRef, emptyDocRef, 1)); // if called more than once the recursion detection is very likely broken! - expect(treeNodeService.getSubNodesForParent(eq(emptyDocRef), eq(""))).andReturn( - childrenList).once(); + expect(treeNodeService.getSubNodesForParent(eq(emptyDocRef), eq(""))).andReturn(childrenList) + .once(); DocumentReference childChildDocRef = new DocumentReference(context.getDatabase(), "mySpace", "myChildChild"); createEmptyDoc(childChildDocRef); @@ -363,19 +362,19 @@ public void testGetNextNonEmptyChildren_empty_recurse_on_EmptyChildren_reconize_ createEmptyDoc(childChild2DocRef); List childrenList2 = Arrays.asList(new TreeNode(childChildDocRef, emptyDocRef, 0), new TreeNode(childChild2DocRef, emptyDocRef, 1)); - expect(treeNodeService.getSubNodesForParent(eq(childDocRef), eq(""))).andReturn( - childrenList2).once(); - List childrenList3 = Arrays.asList(new TreeNode(new DocumentReference( - context.getDatabase(), "mySpace", "MyEmptyDoc"), emptyDocRef, 0)); - expect(treeNodeService.getSubNodesForParent(eq(childChildDocRef), eq(""))).andReturn( - childrenList3).once(); - expect(treeNodeService.getSubNodesForParent(eq(child2DocRef), eq(""))).andReturn( - Collections.emptyList()).once(); - expect(treeNodeService.getSubNodesForParent(eq(childChild2DocRef), eq(""))).andReturn( - Collections.emptyList()).once(); - expect(xwiki.getXWikiPreference(eq(IEmptyCheckRole.EMPTYCHECK_MODULS_PREF_NAME), eq( - "celements.emptycheckModuls"), eq("default"), same(context))).andReturn( - "default").anyTimes(); + expect(treeNodeService.getSubNodesForParent(eq(childDocRef), eq(""))).andReturn(childrenList2) + .once(); + List childrenList3 = Arrays.asList(new TreeNode( + new DocumentReference(context.getDatabase(), "mySpace", "MyEmptyDoc"), emptyDocRef, 0)); + expect(treeNodeService.getSubNodesForParent(eq(childChildDocRef), eq(""))) + .andReturn(childrenList3).once(); + expect(treeNodeService.getSubNodesForParent(eq(child2DocRef), eq(""))) + .andReturn(Collections.emptyList()).once(); + expect(treeNodeService.getSubNodesForParent(eq(childChild2DocRef), eq(""))) + .andReturn(Collections.emptyList()).once(); + expect(xwiki.getXWikiPreference(eq(IEmptyCheckRole.EMPTYCHECK_MODULS_PREF_NAME), + eq("celements.emptycheckModuls"), eq("default"), same(context))).andReturn("default") + .anyTimes(); replayDefault(); assertEquals(emptyDocRef, emptyCheckService.getNextNonEmptyChildren(emptyDocRef)); verifyDefault(); diff --git a/src/test/java/com/celements/inheritor/ContentInheritorTest.java b/src/test/java/com/celements/inheritor/ContentInheritorTest.java index 88ef70733..0b36efc09 100644 --- a/src/test/java/com/celements/inheritor/ContentInheritorTest.java +++ b/src/test/java/com/celements/inheritor/ContentInheritorTest.java @@ -94,8 +94,8 @@ public void testGetTranslatedTitle() throws Exception { translatedDoc1.setTitle(title_de); XWikiDocument testDoc1 = createDefaultMock(XWikiDocument.class); expect(testDoc1.isNew()).andReturn(false).anyTimes(); - expect(testDoc1.getTranslatedDocument(eq("de"), same(context))).andReturn( - translatedDoc1).anyTimes(); + expect(testDoc1.getTranslatedDocument(eq("de"), same(context))).andReturn(translatedDoc1) + .anyTimes(); expect(testDoc1.getDefaultLanguage()).andReturn("en").anyTimes(); expect(getMock(IModelAccessFacade.class).getDocument(eq(docRef))).andReturn(testDoc1) .anyTimes(); @@ -135,8 +135,8 @@ public void testGetTranslatedContent() throws Exception { translatedDoc1.setContent(content_de); XWikiDocument testDoc1 = createDefaultMock(XWikiDocument.class); expect(testDoc1.isNew()).andReturn(false).anyTimes(); - expect(testDoc1.getTranslatedDocument(eq("de"), same(context))).andReturn( - translatedDoc1).anyTimes(); + expect(testDoc1.getTranslatedDocument(eq("de"), same(context))).andReturn(translatedDoc1) + .anyTimes(); expect(testDoc1.getDefaultLanguage()).andReturn("en").anyTimes(); expect(getMock(IModelAccessFacade.class).getDocument(eq(docRef))).andReturn(testDoc1) .anyTimes(); @@ -144,8 +144,8 @@ public void testGetTranslatedContent() throws Exception { contentInheritor.setIteratorFactory(iteratorFactory); contentInheritor.setLanguage("de"); replayDefault(); - assertEquals("Expecting german content.", content_de, contentInheritor.getTranslatedContent( - context)); + assertEquals("Expecting german content.", content_de, + contentInheritor.getTranslatedContent(context)); verifyDefault(); } diff --git a/src/test/java/com/celements/inheritor/FieldInheritorTest.java b/src/test/java/com/celements/inheritor/FieldInheritorTest.java index f022ab4ab..07f59d14a 100644 --- a/src/test/java/com/celements/inheritor/FieldInheritorTest.java +++ b/src/test/java/com/celements/inheritor/FieldInheritorTest.java @@ -122,8 +122,8 @@ private IIteratorFactory getTestIteratorFactory(final List getIncludedCssBasePaths() { VelocityContext vcontext = (VelocityContext) context.get("vcontext"); List cssList = (List) vcontext.get("cel_css_list_page"); - return cssList.stream() - .map(CSS::getCssBasePath) - .toList(); + return cssList.stream().map(CSS::getCssBasePath).toList(); } } diff --git a/src/test/java/com/celements/javascript/FrontendResourceResolverTest.java b/src/test/java/com/celements/javascript/FrontendResourceResolverTest.java index f4373c640..ba3eefaa6 100644 --- a/src/test/java/com/celements/javascript/FrontendResourceResolverTest.java +++ b/src/test/java/com/celements/javascript/FrontendResourceResolverTest.java @@ -46,9 +46,9 @@ public void test_get() throws Exception { """) }); replayDefault(); - assertEquals(Optional.of(new FrontendResource( - "dist/vue-poc.BOsmCSyo.mjs", - Arrays.asList("dist/assets/vue-poc-ahBOTvOT.css", "dist/assets/shared.Df9z3kSS.css"))), + assertEquals( + Optional.of(new FrontendResource("dist/vue-poc.BOsmCSyo.mjs", + Arrays.asList("dist/assets/vue-poc-ahBOTvOT.css", "dist/assets/shared.Df9z3kSS.css"))), resolver.get().get(":frontend/progon/vue-poc/main.ts")); verifyDefault(); @@ -66,8 +66,9 @@ public void test_get_missingCss() throws Exception { """) }); replayDefault(); - assertEquals(Optional.of(new FrontendResource("dist/eventview.Cq6C1_9z.mjs", - Collections.emptyList())), resolver.get().get(":frontend/progon/eventview/main.ts")); + assertEquals( + Optional.of(new FrontendResource("dist/eventview.Cq6C1_9z.mjs", Collections.emptyList())), + resolver.get().get(":frontend/progon/eventview/main.ts")); verifyDefault(); } @@ -100,8 +101,9 @@ public void test_get_importedCss() throws Exception { """) }); replayDefault(); - assertEquals(Optional.of(new FrontendResource("dist/vue-poc.CPN5BtMj.mjs", - List.of("dist/assets/tailwind-5_VRq81v.css"))), + assertEquals( + Optional.of(new FrontendResource("dist/vue-poc.CPN5BtMj.mjs", + List.of("dist/assets/tailwind-5_VRq81v.css"))), resolver.get().get(":frontend/progon/vue-poc/main.ts")); verifyDefault(); diff --git a/src/test/java/com/celements/javascript/JsFileEntryTest.java b/src/test/java/com/celements/javascript/JsFileEntryTest.java index 39e415434..a4df9ef99 100644 --- a/src/test/java/com/celements/javascript/JsFileEntryTest.java +++ b/src/test/java/com/celements/javascript/JsFileEntryTest.java @@ -31,8 +31,8 @@ public class JsFileEntryTest extends AbstractComponentTest { private BeanClassDefConverter jsFileEntryConverter() { @SuppressWarnings("unchecked") - BeanClassDefConverter converter = Utils.getComponent( - BeanClassDefConverter.class, XObjectBeanConverter.NAME); + BeanClassDefConverter converter = Utils + .getComponent(BeanClassDefConverter.class, XObjectBeanConverter.NAME); converter.initialize(Utils.getComponent(CelementsClassDefinition.class, JavaScriptExternalFilesClass.CLASS_DEF_HINT)); converter.initialize(new ReflectiveInstanceSupplier<>(JsFileEntry.class)); @@ -202,15 +202,14 @@ public void test_toString() { jsFileEntry.setLoadMode(loadMode); DocumentReference docRef = new DocumentReference("wikiName", "space", "classname"); jsFileEntry.setDocumentReference(docRef); - assertTrue(jsFileEntry.toString().startsWith("JsFileEntry [jsFileUrl=" + fileUrl - + ", loadMode=" + loadMode + ", ")); + assertTrue(jsFileEntry.toString() + .startsWith("JsFileEntry [jsFileUrl=" + fileUrl + ", loadMode=" + loadMode + ", ")); } @Test public void test_JsExtFileObj_bean() { DocumentReference docRef = new DocumentReference("wikiName", "space", "document"); - jsFileEntry.addFilepath("/space/doc/attachment.mjs") - .addLoadMode(JsLoadMode.ASYNC); + jsFileEntry.addFilepath("/space/doc/attachment.mjs").addLoadMode(JsLoadMode.ASYNC); BaseObject jsExtFileObj = new BaseObject(); jsExtFileObj.setXClassReference(getJavaScriptExternalFilesClassRef()); jsExtFileObj.setDocumentReference(docRef); diff --git a/src/test/java/com/celements/lastChanged/LastChangedServiceTest.java b/src/test/java/com/celements/lastChanged/LastChangedServiceTest.java index 17d0580c7..3540e8629 100644 --- a/src/test/java/com/celements/lastChanged/LastChangedServiceTest.java +++ b/src/test/java/com/celements/lastChanged/LastChangedServiceTest.java @@ -90,8 +90,8 @@ public void testInternal_getLastChangeDate_emptyLangResponse() throws Exception @Test public void testInternal_getLastChangeDate_nullLangResponse() throws Exception { String mySpaceName = "mySpace"; - SpaceReference spaceRef = new SpaceReference(mySpaceName, new WikiReference( - context.getDatabase())); + SpaceReference spaceRef = new SpaceReference(mySpaceName, + new WikiReference(context.getDatabase())); Query mockQuery = createDefaultMock(Query.class); expect(queryManagerMock.createQuery(isA(String.class), eq("xwql"))).andReturn(mockQuery).once(); expect(mockQuery.bindValue(eq("spaceName"), eq(mySpaceName))).andReturn(mockQuery).once(); diff --git a/src/test/java/com/celements/mandatory/AbstractXWikiClassRightsTest.java b/src/test/java/com/celements/mandatory/AbstractXWikiClassRightsTest.java index 46deadf78..f8f722e95 100644 --- a/src/test/java/com/celements/mandatory/AbstractXWikiClassRightsTest.java +++ b/src/test/java/com/celements/mandatory/AbstractXWikiClassRightsTest.java @@ -49,8 +49,7 @@ public void test_checkRightsObject_changes() throws XWikiException { assertTrue(xwikiClassRights.checkRightsObject(classDoc)); verifyDefault(); - List rightsObj = XWikiObjectFetcher.on(classDoc) - .filter(XWikiRightsClass.CLASS_REF) + List rightsObj = XWikiObjectFetcher.on(classDoc).filter(XWikiRightsClass.CLASS_REF) .list(); assertEquals(1, rightsObj.size()); assertEquals("XWikiAllGroup", getValue(rightsObj.get(0), XWikiRightsClass.FIELD_GROUPS).get(0)); @@ -76,8 +75,7 @@ public void test_checkRightsObject_noChanges() throws XWikiException { assertFalse(xwikiClassRights.checkRightsObject(classDoc)); verifyDefault(); - List rightsObj = XWikiObjectFetcher.on(classDoc) - .filter(XWikiRightsClass.CLASS_REF) + List rightsObj = XWikiObjectFetcher.on(classDoc).filter(XWikiRightsClass.CLASS_REF) .list(); assertEquals(1, rightsObj.size()); } diff --git a/src/test/java/com/celements/mandatory/TestXWikiClassRights.java b/src/test/java/com/celements/mandatory/TestXWikiClassRights.java index 9a2066b95..197ef1f04 100644 --- a/src/test/java/com/celements/mandatory/TestXWikiClassRights.java +++ b/src/test/java/com/celements/mandatory/TestXWikiClassRights.java @@ -20,8 +20,8 @@ public String getName() { @Override protected DocumentReference getDocRef() { - return new RefBuilder().wiki(getWiki()).space(XWikiConstant.XWIKI_SPACE) - .doc("TestXWikiClass").build(DocumentReference.class); + return new RefBuilder().wiki(getWiki()).space(XWikiConstant.XWIKI_SPACE).doc("TestXWikiClass") + .build(DocumentReference.class); } @Override diff --git a/src/test/java/com/celements/mandatory/XWikiXWikiPreferencesTest.java b/src/test/java/com/celements/mandatory/XWikiXWikiPreferencesTest.java index e39e0a092..a37fa3447 100644 --- a/src/test/java/com/celements/mandatory/XWikiXWikiPreferencesTest.java +++ b/src/test/java/com/celements/mandatory/XWikiXWikiPreferencesTest.java @@ -32,8 +32,8 @@ public class XWikiXWikiPreferencesTest extends AbstractComponentTest { @Before public void prepareTest() throws Exception { - mandatoryXWikiPref = (XWikiXWikiPreferences) getBeanFactory().getBean( - "celements.mandatory.wikipreferences", IMandatoryDocumentRole.class); + mandatoryXWikiPref = (XWikiXWikiPreferences) getBeanFactory() + .getBean("celements.mandatory.wikipreferences", IMandatoryDocumentRole.class); } @Test diff --git a/src/test/java/com/celements/mandatory/XWikiXWikiRightsTest.java b/src/test/java/com/celements/mandatory/XWikiXWikiRightsTest.java index 10be1513e..ebeae386b 100644 --- a/src/test/java/com/celements/mandatory/XWikiXWikiRightsTest.java +++ b/src/test/java/com/celements/mandatory/XWikiXWikiRightsTest.java @@ -44,8 +44,8 @@ public class XWikiXWikiRightsTest extends AbstractComponentTest { @Before public void prepareTest() throws Exception { - mandatoryXWikiRights = (XWikiXWikiRights) getBeanFactory().getBean( - "celements.mandatory.wikirights", IMandatoryDocumentRole.class); + mandatoryXWikiRights = (XWikiXWikiRights) getBeanFactory() + .getBean("celements.mandatory.wikirights", IMandatoryDocumentRole.class); } @Test @@ -89,8 +89,7 @@ public void checkAccessRightObjs_isIdempotent() throws Exception { } private BaseObject createGlobalRights(XWikiDocument doc, String groupFN, String levels) { - BaseObject obj = XWikiObjectEditor.on(doc) - .filter(new ClassReference(getGlobalRightsRef())) + BaseObject obj = XWikiObjectEditor.on(doc).filter(new ClassReference(getGlobalRightsRef())) .createFirst(); obj.setStringValue("groups", groupFN); obj.setStringValue("levels", levels); @@ -100,25 +99,23 @@ private BaseObject createGlobalRights(XWikiDocument doc, String groupFN, String } private int countGlobalRights(XWikiDocument doc, String groupFN, String levels) { - return XWikiObjectFetcher.on(doc) - .filter(new ClassReference(getGlobalRightsRef())) + return XWikiObjectFetcher.on(doc).filter(new ClassReference(getGlobalRightsRef())) .filter(obj -> obj.getIntValue("allow", 0) == 1) .filter(obj -> groupFN.equals(obj.getStringValue("groups"))) .filter(obj -> levels.equals(obj.getStringValue("levels"))) - .filter(obj -> "".equals(obj.getStringValue("users"))) - .count(); + .filter(obj -> "".equals(obj.getStringValue("users"))).count(); } private DocumentReference getGlobalRightsRef() { - return XWikiGlobalRightsClass.CLASS_REF.getDocRef(mandatoryXWikiRights.getDocRef() - .getWikiReference()); + return XWikiGlobalRightsClass.CLASS_REF + .getDocRef(mandatoryXWikiRights.getDocRef().getWikiReference()); } private void expectGlobalRightsClass() throws Exception { ClassDefinition classDef = getBeanFactory().getBean(XWikiGlobalRightsClass.CLASS_DEF_HINT, ClassDefinition.class); - BaseClass bClass = expectNewBaseObject(classDef.getDocRef(mandatoryXWikiRights.getDocRef() - .getWikiReference())); + BaseClass bClass = expectNewBaseObject( + classDef.getDocRef(mandatoryXWikiRights.getDocRef().getWikiReference())); for (ClassField field : classDef.getFields()) { expect(bClass.get(field.getName())).andReturn(field.getXField()).anyTimes(); } diff --git a/src/test/java/com/celements/menu/MenuServiceTest.java b/src/test/java/com/celements/menu/MenuServiceTest.java index 9e22c4697..6a07048dd 100644 --- a/src/test/java/com/celements/menu/MenuServiceTest.java +++ b/src/test/java/com/celements/menu/MenuServiceTest.java @@ -63,8 +63,8 @@ public void setUp_DataProviderTest() throws Exception { @Test public void testGetHeadersHQL() { - assertTrue(menuService.getHeadersXWQL().matches( - "from doc.object\\(Celements.MenuBarHeaderItemClass\\) as mHeader.*?")); + assertTrue(menuService.getHeadersXWQL() + .matches("from doc.object\\(Celements.MenuBarHeaderItemClass\\) as mHeader.*?")); } @Test @@ -81,12 +81,12 @@ public void testAddMenuHeaders() throws Exception { List fullNames = new ArrayList<>(); fullNames.add("Celements.MenuBar"); Query mockQuery = createMock(Query.class); - expect(queryManagerMock.createQuery(isA(String.class), eq(Query.XWQL))).andReturn( - mockQuery).once(); + expect(queryManagerMock.createQuery(isA(String.class), eq(Query.XWQL))).andReturn(mockQuery) + .once(); expect(mockQuery.execute()).andReturn(fullNames).once(); expect(xwiki.exists(eq(menuBarDocRef), same(context))).andReturn(true).anyTimes(); - expect(rightsMock.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq( - "xwikidb:Celements.MenuBar"), same(context))).andReturn(true).anyTimes(); + expect(rightsMock.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), + eq("xwikidb:Celements.MenuBar"), same(context))).andReturn(true).anyTimes(); replayAll(mockQuery); TreeMap menuHeadersMap = new TreeMap<>(); @@ -117,12 +117,12 @@ public void testAddMenuHeaders_deletedObjects() throws Exception { List fullNames = new ArrayList<>(); fullNames.add("Celements.MenuBar"); Query mockQuery = createMock(Query.class); - expect(queryManagerMock.createQuery(isA(String.class), eq(Query.XWQL))).andReturn( - mockQuery).once(); + expect(queryManagerMock.createQuery(isA(String.class), eq(Query.XWQL))).andReturn(mockQuery) + .once(); expect(mockQuery.execute()).andReturn(fullNames).once(); expect(xwiki.exists(eq(menuBarDocRef), same(context))).andReturn(true).anyTimes(); - expect(rightsMock.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq( - "xwikidb:Celements.MenuBar"), same(context))).andReturn(true).anyTimes(); + expect(rightsMock.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), + eq("xwikidb:Celements.MenuBar"), same(context))).andReturn(true).anyTimes(); replayAll(mockQuery); TreeMap menuHeadersMap = new TreeMap<>(); @@ -161,15 +161,15 @@ public void testAddMenuHeaders_multipleDocs() throws Exception { fullNames.add("Celements.MenuBar"); fullNames.add("Celements.MenuBar2"); Query mockQuery = createMock(Query.class); - expect(queryManagerMock.createQuery(isA(String.class), eq(Query.XWQL))).andReturn( - mockQuery).once(); + expect(queryManagerMock.createQuery(isA(String.class), eq(Query.XWQL))).andReturn(mockQuery) + .once(); expect(mockQuery.execute()).andReturn(fullNames).once(); expect(xwiki.exists(eq(menuBarDocRef), same(context))).andReturn(true).anyTimes(); - expect(rightsMock.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq( - "xwikidb:Celements.MenuBar"), same(context))).andReturn(true).anyTimes(); + expect(rightsMock.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), + eq("xwikidb:Celements.MenuBar"), same(context))).andReturn(true).anyTimes(); expect(xwiki.exists(eq(menuBar2DocRef), same(context))).andReturn(true).anyTimes(); - expect(rightsMock.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq( - "xwikidb:Celements.MenuBar2"), same(context))).andReturn(true).anyTimes(); + expect(rightsMock.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), + eq("xwikidb:Celements.MenuBar2"), same(context))).andReturn(true).anyTimes(); replayAll(mockQuery); TreeMap menuHeadersMap = new TreeMap<>(); @@ -212,15 +212,15 @@ public void testAddMenuHeaders_multipleDocs_noAccess() throws Exception { fullNames.add("Celements.MenuBar"); fullNames.add("Celements.MenuBar2"); Query mockQuery = createMock(Query.class); - expect(queryManagerMock.createQuery(isA(String.class), eq(Query.XWQL))).andReturn( - mockQuery).once(); + expect(queryManagerMock.createQuery(isA(String.class), eq(Query.XWQL))).andReturn(mockQuery) + .once(); expect(mockQuery.execute()).andReturn(fullNames).once(); expect(xwiki.exists(eq(menuBarDocRef), same(context))).andReturn(true).anyTimes(); - expect(rightsMock.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq( - "xwikidb:Celements.MenuBar"), same(context))).andReturn(true).anyTimes(); + expect(rightsMock.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), + eq("xwikidb:Celements.MenuBar"), same(context))).andReturn(true).anyTimes(); expect(xwiki.exists(eq(menuBar2DocRef), same(context))).andReturn(true).anyTimes(); - expect(rightsMock.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq( - "xwikidb:Celements.MenuBar2"), same(context))).andReturn(false).anyTimes(); + expect(rightsMock.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), + eq("xwikidb:Celements.MenuBar2"), same(context))).andReturn(false).anyTimes(); replayAll(mockQuery); TreeMap menuHeadersMap = new TreeMap<>(); @@ -257,25 +257,25 @@ public void testGetMenuHeaders_multipleDocs_celements2web() throws Exception { List fullNames = new ArrayList<>(); fullNames.add("Celements.MenuBar"); Query mockQuery = createMock(Query.class); - expect(queryManagerMock.createQuery(isA(String.class), eq(Query.XWQL))).andReturn( - mockQuery).once(); + expect(queryManagerMock.createQuery(isA(String.class), eq(Query.XWQL))).andReturn(mockQuery) + .once(); expect(mockQuery.execute()).andReturn(fullNames).once(); List fullNamesCentral = new ArrayList<>(); fullNamesCentral.add("Celements.MenuBar2"); Query mockQuery2 = createMock(Query.class); - expect(queryManagerMock.createQuery(isA(String.class), eq(Query.XWQL))).andReturn( - mockQuery2).once(); + expect(queryManagerMock.createQuery(isA(String.class), eq(Query.XWQL))).andReturn(mockQuery2) + .once(); expect(mockQuery2.execute()).andReturn(fullNamesCentral).once(); expect(xwiki.getDocument(eq(menuBar2web2DocRef), same(context))).andReturn(doc2).once(); expect(xwiki.exists(eq(menuBarDocRef), same(context))).andReturn(true).anyTimes(); - expect(rightsMock.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq( - "xwikidb:Celements.MenuBar"), same(context))).andReturn(true).anyTimes(); + expect(rightsMock.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), + eq("xwikidb:Celements.MenuBar"), same(context))).andReturn(true).anyTimes(); expect(xwiki.exists(eq(menuBar2DocRef), same(context))).andReturn(false).anyTimes(); - expect(rightsMock.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq( - "celements2web:Celements.MenuBar2"), same(context))).andReturn(true).anyTimes(); - expect(xwiki.getXWikiPreferenceAsInt(eq("CelMenuBar-Celements.MenuBar2"), eq( - "celements.menubar.guestview.Celements.MenuBar2"), eq(0), same(context))).andReturn(1); + expect(rightsMock.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), + eq("celements2web:Celements.MenuBar2"), same(context))).andReturn(true).anyTimes(); + expect(xwiki.getXWikiPreferenceAsInt(eq("CelMenuBar-Celements.MenuBar2"), + eq("celements.menubar.guestview.Celements.MenuBar2"), eq(0), same(context))).andReturn(1); replayAll(mockQuery, mockQuery2); List menuHeaders = menuService.getMenuHeaders(); @@ -301,9 +301,9 @@ private void addMenuHeaderObject(String menuName, int headerId, int pos, XWikiDo private void addMenuHeaderObject(Integer objPos, String menuName, int headerId, int pos, XWikiDocument doc) { BaseObject obj = new BaseObject(); - obj.setXClassReference(new DocumentReference( - doc.getDocumentReference().getWikiReference().getName(), "Celements", - "MenuBarHeaderItemClass")); + obj.setXClassReference( + new DocumentReference(doc.getDocumentReference().getWikiReference().getName(), "Celements", + "MenuBarHeaderItemClass")); obj.setStringValue("name", menuName); obj.setIntValue("header_id", headerId); obj.setIntValue("pos", pos); diff --git a/src/test/java/com/celements/menu/access/DefaultMenuAccessProviderTest.java b/src/test/java/com/celements/menu/access/DefaultMenuAccessProviderTest.java index cf70e422e..a7c247056 100644 --- a/src/test/java/com/celements/menu/access/DefaultMenuAccessProviderTest.java +++ b/src/test/java/com/celements/menu/access/DefaultMenuAccessProviderTest.java @@ -27,8 +27,8 @@ public void setUp_DefaultMenuAccessProviderTest() throws Exception { xwiki = getWikiMock(); rightsMock = createDefaultMock(XWikiRightService.class); expect(xwiki.getRightService()).andReturn(rightsMock).anyTimes(); - defMenuAccessProvider = (DefaultMenuAccessProvider) Utils.getComponent( - IMenuAccessProviderRole.class, "celements.defaultMenuAccess"); + defMenuAccessProvider = (DefaultMenuAccessProvider) Utils + .getComponent(IMenuAccessProviderRole.class, "celements.defaultMenuAccess"); expect(xwiki.isVirtualMode()).andReturn(true).anyTimes(); } @@ -36,8 +36,8 @@ public void setUp_DefaultMenuAccessProviderTest() throws Exception { public void testDenyView() { replayDefault(); assertFalse(defMenuAccessProvider.denyView(null)); - assertFalse(defMenuAccessProvider.denyView(new DocumentReference(context.getDatabase(), - "Celements2", "CelMenuBar"))); + assertFalse(defMenuAccessProvider + .denyView(new DocumentReference(context.getDatabase(), "Celements2", "CelMenuBar"))); verifyDefault(); } @@ -49,10 +49,10 @@ public void testHasview_notLocal_central_hasAccess_XWikiGuest() throws Exception DocumentReference menuBar2webDocRef = new DocumentReference("celements2web", "Celements", "MenuBar"); expect(xwiki.exists(eq(menuBar2webDocRef), same(context))).andReturn(true).once(); - expect(rightsMock.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq( - "celements2web:Celements.MenuBar"), same(context))).andReturn(true).once(); - expect(xwiki.getXWikiPreferenceAsInt(eq("CelMenuBar-Celements.MenuBar"), eq( - "celements.menubar.guestview.Celements.MenuBar"), eq(0), same(context))).andReturn(0); + expect(rightsMock.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), + eq("celements2web:Celements.MenuBar"), same(context))).andReturn(true).once(); + expect(xwiki.getXWikiPreferenceAsInt(eq("CelMenuBar-Celements.MenuBar"), + eq("celements.menubar.guestview.Celements.MenuBar"), eq(0), same(context))).andReturn(0); replayDefault(); assertFalse(defMenuAccessProvider.hasview(menuBarDocRef)); verifyDefault(); @@ -67,8 +67,8 @@ public void testHasview_notLocal_central_hasAccess_user() throws Exception { DocumentReference menuBar2webDocRef = new DocumentReference("celements2web", "Celements", "MenuBar"); expect(xwiki.exists(eq(menuBar2webDocRef), same(context))).andReturn(true).once(); - expect(rightsMock.hasAccessLevel(eq("view"), eq(myUserName), eq( - "celements2web:Celements.MenuBar"), same(context))).andReturn(true).once(); + expect(rightsMock.hasAccessLevel(eq("view"), eq(myUserName), + eq("celements2web:Celements.MenuBar"), same(context))).andReturn(true).once(); replayDefault(); // important only call setUser after replayDefault. In unstable-2.0 branch setUser // calls xwiki.isVirtualMode @@ -82,14 +82,14 @@ public void testHasview_Local_central_noAccess() throws Exception { DocumentReference menuBarDocRef = new DocumentReference(context.getDatabase(), "Celements", "MenuBar"); expect(xwiki.exists(eq(menuBarDocRef), same(context))).andReturn(true).once(); - expect(rightsMock.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq( - "xwikidb:Celements.MenuBar"), same(context))).andReturn(false).once(); + expect(rightsMock.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), + eq("xwikidb:Celements.MenuBar"), same(context))).andReturn(false).once(); DocumentReference menuBar2webDocRef = new DocumentReference("celements2web", "Celements", "MenuBar"); expect(xwiki.exists(eq(menuBar2webDocRef), same(context))).andReturn(true).once(); - expect(rightsMock.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq( - "celements2web:Celements.MenuBar"), same(context))).andReturn(true).once(); + expect(rightsMock.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), + eq("celements2web:Celements.MenuBar"), same(context))).andReturn(true).once(); replayDefault(); assertFalse(defMenuAccessProvider.hasview(menuBarDocRef)); @@ -101,14 +101,14 @@ public void testHasview_local_central_hasAccess() throws Exception { DocumentReference menuBarDocRef = new DocumentReference(context.getDatabase(), "Celements", "MenuBar"); expect(xwiki.exists(eq(menuBarDocRef), same(context))).andReturn(true).once(); - expect(rightsMock.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq( - "xwikidb:Celements.MenuBar"), same(context))).andReturn(true).once(); + expect(rightsMock.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), + eq("xwikidb:Celements.MenuBar"), same(context))).andReturn(true).once(); DocumentReference menuBar2webDocRef = new DocumentReference("celements2web", "Celements", "MenuBar"); expect(xwiki.exists(eq(menuBar2webDocRef), same(context))).andReturn(true).once(); - expect(rightsMock.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq( - "celements2web:Celements.MenuBar"), same(context))).andReturn(true).once(); + expect(rightsMock.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), + eq("celements2web:Celements.MenuBar"), same(context))).andReturn(true).once(); replayDefault(); assertTrue(defMenuAccessProvider.hasview(menuBarDocRef)); @@ -124,8 +124,8 @@ public void testHasview_local_notCentral_hasAccess() throws Exception { DocumentReference menuBarDocRef = new DocumentReference(context.getDatabase(), "Celements", "MenuBar"); expect(xwiki.exists(eq(menuBarDocRef), same(context))).andReturn(true).once(); - expect(rightsMock.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq( - "xwikidb:Celements.MenuBar"), same(context))).andReturn(true).once(); + expect(rightsMock.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), + eq("xwikidb:Celements.MenuBar"), same(context))).andReturn(true).once(); replayDefault(); assertTrue(defMenuAccessProvider.hasview(menuBarDocRef)); @@ -137,14 +137,14 @@ public void testHasview_notLocal_central_noAccess() throws Exception { DocumentReference menuBar2webDocRef = new DocumentReference("celements2web", "Celements", "MenuBar"); expect(xwiki.exists(eq(menuBar2webDocRef), same(context))).andReturn(true).once(); - expect(rightsMock.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq( - "celements2web:Celements.MenuBar"), same(context))).andReturn(false).once(); + expect(rightsMock.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), + eq("celements2web:Celements.MenuBar"), same(context))).andReturn(false).once(); DocumentReference menuBarDocRef = new DocumentReference(context.getDatabase(), "Celements", "MenuBar"); expect(xwiki.exists(eq(menuBarDocRef), same(context))).andReturn(false).once(); - expect(xwiki.getXWikiPreferenceAsInt(eq("CelMenuBar-Celements.MenuBar"), eq( - "celements.menubar.guestview.Celements.MenuBar"), eq(0), same(context))).andReturn(1); + expect(xwiki.getXWikiPreferenceAsInt(eq("CelMenuBar-Celements.MenuBar"), + eq("celements.menubar.guestview.Celements.MenuBar"), eq(0), same(context))).andReturn(1); replayDefault(); assertFalse(defMenuAccessProvider.hasview(menuBarDocRef)); verifyDefault(); @@ -159,8 +159,8 @@ public void testHasview_local_notCentral_noAccess() throws Exception { DocumentReference menuBarDocRef = new DocumentReference(context.getDatabase(), "Celements", "MenuBar"); expect(xwiki.exists(eq(menuBarDocRef), same(context))).andReturn(true).once(); - expect(rightsMock.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq( - "xwikidb:Celements.MenuBar"), same(context))).andReturn(false).once(); + expect(rightsMock.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), + eq("xwikidb:Celements.MenuBar"), same(context))).andReturn(false).once(); replayDefault(); assertFalse(defMenuAccessProvider.hasview(menuBarDocRef)); diff --git a/src/test/java/com/celements/menu/access/MenuAccessServiceTest.java b/src/test/java/com/celements/menu/access/MenuAccessServiceTest.java index 26fdeb163..991418e5a 100644 --- a/src/test/java/com/celements/menu/access/MenuAccessServiceTest.java +++ b/src/test/java/com/celements/menu/access/MenuAccessServiceTest.java @@ -39,10 +39,10 @@ public void testHasview_notLocal_central_hasAccess_XWikiGuest() throws Exception DocumentReference menuBar2webDocRef = new DocumentReference("celements2web", "Celements", "MenuBar"); expect(xwiki.exists(eq(menuBar2webDocRef), same(context))).andReturn(true).once(); - expect(rightsMock.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq( - "celements2web:Celements.MenuBar"), same(context))).andReturn(true).once(); - expect(xwiki.getXWikiPreferenceAsInt(eq("CelMenuBar-Celements.MenuBar"), eq( - "celements.menubar.guestview.Celements.MenuBar"), eq(0), same(context))).andReturn(0); + expect(rightsMock.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), + eq("celements2web:Celements.MenuBar"), same(context))).andReturn(true).once(); + expect(xwiki.getXWikiPreferenceAsInt(eq("CelMenuBar-Celements.MenuBar"), + eq("celements.menubar.guestview.Celements.MenuBar"), eq(0), same(context))).andReturn(0); replayDefault(); assertFalse(menuAccessService.hasview(menuBarDocRef)); verifyDefault(); @@ -57,8 +57,8 @@ public void testHasview_notLocal_central_hasAccess_user() throws Exception { DocumentReference menuBar2webDocRef = new DocumentReference("celements2web", "Celements", "MenuBar"); expect(xwiki.exists(eq(menuBar2webDocRef), same(context))).andReturn(true).once(); - expect(rightsMock.hasAccessLevel(eq("view"), eq(myUserName), eq( - "celements2web:Celements.MenuBar"), same(context))).andReturn(true).once(); + expect(rightsMock.hasAccessLevel(eq("view"), eq(myUserName), + eq("celements2web:Celements.MenuBar"), same(context))).andReturn(true).once(); replayDefault(); // important only call setUser after replayDefault. In unstable-2.0 branch setUser // calls xwiki.isVirtualMode @@ -72,14 +72,14 @@ public void testHasview_Local_central_noAccess() throws Exception { DocumentReference menuBarDocRef = new DocumentReference(context.getDatabase(), "Celements", "MenuBar"); expect(xwiki.exists(eq(menuBarDocRef), same(context))).andReturn(true).once(); - expect(rightsMock.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq( - "xwikidb:Celements.MenuBar"), same(context))).andReturn(false).once(); + expect(rightsMock.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), + eq("xwikidb:Celements.MenuBar"), same(context))).andReturn(false).once(); DocumentReference menuBar2webDocRef = new DocumentReference("celements2web", "Celements", "MenuBar"); expect(xwiki.exists(eq(menuBar2webDocRef), same(context))).andReturn(true).once(); - expect(rightsMock.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq( - "celements2web:Celements.MenuBar"), same(context))).andReturn(true).once(); + expect(rightsMock.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), + eq("celements2web:Celements.MenuBar"), same(context))).andReturn(true).once(); replayDefault(); assertFalse(menuAccessService.hasview(menuBarDocRef)); @@ -91,14 +91,14 @@ public void testHasview_local_central_hasAccess() throws Exception { DocumentReference menuBarDocRef = new DocumentReference(context.getDatabase(), "Celements", "MenuBar"); expect(xwiki.exists(eq(menuBarDocRef), same(context))).andReturn(true).once(); - expect(rightsMock.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq( - "xwikidb:Celements.MenuBar"), same(context))).andReturn(true).once(); + expect(rightsMock.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), + eq("xwikidb:Celements.MenuBar"), same(context))).andReturn(true).once(); DocumentReference menuBar2webDocRef = new DocumentReference("celements2web", "Celements", "MenuBar"); expect(xwiki.exists(eq(menuBar2webDocRef), same(context))).andReturn(true).once(); - expect(rightsMock.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq( - "celements2web:Celements.MenuBar"), same(context))).andReturn(true).once(); + expect(rightsMock.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), + eq("celements2web:Celements.MenuBar"), same(context))).andReturn(true).once(); replayDefault(); assertTrue(menuAccessService.hasview(menuBarDocRef)); @@ -114,8 +114,8 @@ public void testHasview_local_notCentral_hasAccess() throws Exception { DocumentReference menuBarDocRef = new DocumentReference(context.getDatabase(), "Celements", "MenuBar"); expect(xwiki.exists(eq(menuBarDocRef), same(context))).andReturn(true).once(); - expect(rightsMock.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq( - "xwikidb:Celements.MenuBar"), same(context))).andReturn(true).once(); + expect(rightsMock.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), + eq("xwikidb:Celements.MenuBar"), same(context))).andReturn(true).once(); replayDefault(); assertTrue(menuAccessService.hasview(menuBarDocRef)); @@ -127,14 +127,14 @@ public void testHasview_notLocal_central_noAccess() throws Exception { DocumentReference menuBar2webDocRef = new DocumentReference("celements2web", "Celements", "MenuBar"); expect(xwiki.exists(eq(menuBar2webDocRef), same(context))).andReturn(true).once(); - expect(rightsMock.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq( - "celements2web:Celements.MenuBar"), same(context))).andReturn(false).once(); + expect(rightsMock.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), + eq("celements2web:Celements.MenuBar"), same(context))).andReturn(false).once(); DocumentReference menuBarDocRef = new DocumentReference(context.getDatabase(), "Celements", "MenuBar"); expect(xwiki.exists(eq(menuBarDocRef), same(context))).andReturn(false).once(); - expect(xwiki.getXWikiPreferenceAsInt(eq("CelMenuBar-Celements.MenuBar"), eq( - "celements.menubar.guestview.Celements.MenuBar"), eq(0), same(context))).andReturn(1); + expect(xwiki.getXWikiPreferenceAsInt(eq("CelMenuBar-Celements.MenuBar"), + eq("celements.menubar.guestview.Celements.MenuBar"), eq(0), same(context))).andReturn(1); replayDefault(); assertFalse(menuAccessService.hasview(menuBarDocRef)); verifyDefault(); @@ -149,8 +149,8 @@ public void testHasview_local_notCentral_noAccess() throws Exception { DocumentReference menuBarDocRef = new DocumentReference(context.getDatabase(), "Celements", "MenuBar"); expect(xwiki.exists(eq(menuBarDocRef), same(context))).andReturn(true).once(); - expect(rightsMock.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq( - "xwikidb:Celements.MenuBar"), same(context))).andReturn(false).once(); + expect(rightsMock.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), + eq("xwikidb:Celements.MenuBar"), same(context))).andReturn(false).once(); replayDefault(); assertFalse(menuAccessService.hasview(menuBarDocRef)); diff --git a/src/test/java/com/celements/metatag/BaseObjectMetaTagProviderTest.java b/src/test/java/com/celements/metatag/BaseObjectMetaTagProviderTest.java index 9aee7ac5d..bf1b57df6 100644 --- a/src/test/java/com/celements/metatag/BaseObjectMetaTagProviderTest.java +++ b/src/test/java/com/celements/metatag/BaseObjectMetaTagProviderTest.java @@ -53,8 +53,7 @@ public void testGetMetaTagsForDoc_none() { public void testGetMetaTagsForDoc() { DocumentReference docRef = new DocumentReference(getContext().getDatabase(), "Spc", "Doc"); XWikiDocument doc = new XWikiDocument(docRef); - doc.addXObject(createMetaTagBaseObject(docRef, "keywords", "test,schluessel,wort", "de", - null)); + doc.addXObject(createMetaTagBaseObject(docRef, "keywords", "test,schluessel,wort", "de", null)); doc.addXObject(createMetaTagBaseObject(docRef, "keywords", "test,key,word", "en", null)); replayDefault(); List tags = bomtProvider.getMetaTagsForDoc(doc); @@ -103,8 +102,8 @@ public void testAddMetaTagsFromList() { @Test public void testApplyOverride_emptyList() { replayDefault(); - assertFalse(Arrays.asList(new ArrayList()).stream().map(bomtProvider - .applyOverride()).filter(Objects::nonNull).findFirst().get().findFirst().isPresent()); + assertFalse(Arrays.asList(new ArrayList()).stream().map(bomtProvider.applyOverride()) + .filter(Objects::nonNull).findFirst().get().findFirst().isPresent()); verifyDefault(); } @@ -195,15 +194,13 @@ public void testApplyOverride_overrideMultipleMix_endTrue() { tags.add(createMetaTag(key, tag2value2, "de", true)); replayDefault(); Optional> resultTags = Arrays.asList(tags).stream() - .map(bomtProvider.applyOverride()) - .filter(Objects::nonNull) - .findFirst(); + .map(bomtProvider.applyOverride()).filter(Objects::nonNull).findFirst(); verifyDefault(); List resultList = resultTags.get().collect(Collectors.toList()); assertTrue(1 <= resultList.size()); assertEquals(key, resultList.get(0).getKeyOpt().get()); - assertEquals(tag1value1 + "," + tag1value2 + "," + tag2value1 + "," + tag2value2, resultList - .get(0).getValueOpt().get()); + assertEquals(tag1value1 + "," + tag1value2 + "," + tag2value1 + "," + tag2value2, + resultList.get(0).getValueOpt().get()); } @Test @@ -226,16 +223,15 @@ public void testAddMetaTagsFromList_emptyTarget() { verifyDefault(); assertEquals(1, finalTags.size()); List> resultLists = ImmutableList.copyOf(finalTags.values()); - assertTrue("expected tag name to be description", resultLists.get(0).get(0).display().contains( - ENameStandard.DESCRIPTION.toString().toLowerCase())); + assertTrue("expected tag name to be description", resultLists.get(0).get(0).display() + .contains(ENameStandard.DESCRIPTION.toString().toLowerCase())); } @Test public void testGetMetaTagsForDoc_filterEmptyTag() { DocumentReference docRef = new DocumentReference(getContext().getDatabase(), "Spc", "Doc"); XWikiDocument doc = new XWikiDocument(docRef); - doc.addXObject(createMetaTagBaseObject(docRef, "keywords", "test,schluessel,wort", "de", - null)); + doc.addXObject(createMetaTagBaseObject(docRef, "keywords", "test,schluessel,wort", "de", null)); doc.addXObject(createMetaTagBaseObject(docRef, "", "", "", false)); doc.addXObject(createMetaTagBaseObject(docRef, "description", "", "en", null)); replayDefault(); diff --git a/src/test/java/com/celements/metatag/MetaTagServiceTest.java b/src/test/java/com/celements/metatag/MetaTagServiceTest.java index 799fe207d..ddf947ec7 100644 --- a/src/test/java/com/celements/metatag/MetaTagServiceTest.java +++ b/src/test/java/com/celements/metatag/MetaTagServiceTest.java @@ -42,8 +42,9 @@ public void testDisplayCollectedMetaTags_callOnce() { String keywords = "test,junit,keyword"; metaTag.addMetaTagToCollector(new MetaTag(ENameStandard.KEYWORDS, keywords)); metaTag.addMetaTagToCollector(new MetaTag(ETwitterCardType.SUMMARY)); - assertEquals("" - + "\n\n", + assertEquals( + "" + + "\n\n", metaTag.displayCollectedMetaTags()); } @@ -52,8 +53,9 @@ public void testDisplayCollectedMetaTags_callRepeated() { String keywords = "test,junit,keyword"; metaTag.addMetaTagToCollector(new MetaTag(ENameStandard.KEYWORDS, keywords)); metaTag.addMetaTagToCollector(new MetaTag(ETwitterCardType.SUMMARY)); - assertEquals("" - + "\n\n", + assertEquals( + "" + + "\n\n", metaTag.displayCollectedMetaTags()); assertEquals("", metaTag.displayCollectedMetaTags()); metaTag.addMetaTagToCollector(new MetaTag(ECharset.UTF8)); @@ -63,33 +65,36 @@ public void testDisplayCollectedMetaTags_callRepeated() { @Test public void testCollectHeaderTags() throws Exception { String keywords = "test,junit,keyword"; - List tags = Arrays.asList(new MetaTag(ENameStandard.KEYWORDS, keywords), new MetaTag( - ETwitterCardType.SUMMARY)); + List tags = Arrays.asList(new MetaTag(ENameStandard.KEYWORDS, keywords), + new MetaTag(ETwitterCardType.SUMMARY)); expect(headerTag.getHeaderMetaTags()).andReturn(tags); - expect(getWikiMock().exists((DocumentReference) anyObject(), same(getContext()))).andReturn( - false).anyTimes(); - expect(modelAccess.getOrCreateDocument((DocumentReference) anyObject())).andReturn( - new XWikiDocument(new DocumentReference(getContext().getDatabase(), "Any", "Any"))) + expect(getWikiMock().exists((DocumentReference) anyObject(), same(getContext()))) + .andReturn(false).anyTimes(); + expect(modelAccess.getOrCreateDocument((DocumentReference) anyObject())) + .andReturn( + new XWikiDocument(new DocumentReference(getContext().getDatabase(), "Any", "Any"))) .anyTimes(); replayDefault(); metaTag.collectHeaderTags(); verifyDefault(); - assertEquals("" - + "\n\n", + assertEquals( + "" + + "\n\n", metaTag.displayCollectedMetaTags()); } @Test public void testCollectBodyTags() { String keywords = "test,junit,keyword"; - List tags = Arrays.asList(new MetaTag(ENameStandard.KEYWORDS, keywords), new MetaTag( - ETwitterCardType.SUMMARY)); + List tags = Arrays.asList(new MetaTag(ENameStandard.KEYWORDS, keywords), + new MetaTag(ETwitterCardType.SUMMARY)); expect(headerTag.getBodyMetaTags()).andReturn(tags); replayDefault(); metaTag.collectBodyTags(); verifyDefault(); - assertEquals("" - + "\n\n", + assertEquals( + "" + + "\n\n", metaTag.displayCollectedMetaTags()); } diff --git a/src/test/java/com/celements/metatag/MetaTagTest.java b/src/test/java/com/celements/metatag/MetaTagTest.java index 81f3cce18..d5e9dfce6 100644 --- a/src/test/java/com/celements/metatag/MetaTagTest.java +++ b/src/test/java/com/celements/metatag/MetaTagTest.java @@ -164,10 +164,10 @@ public void test_bean() { private BeanClassDefConverter createMetaTagConverter() { @SuppressWarnings("unchecked") - BeanClassDefConverter converter = Utils.getComponent( - BeanClassDefConverter.class, XObjectBeanConverter.NAME); - converter.initialize(Utils.getComponent(CelementsClassDefinition.class, - MetaTagClass.CLASS_DEF_HINT)); + BeanClassDefConverter converter = Utils + .getComponent(BeanClassDefConverter.class, XObjectBeanConverter.NAME); + converter.initialize( + Utils.getComponent(CelementsClassDefinition.class, MetaTagClass.CLASS_DEF_HINT)); converter.initialize(new ReflectiveInstanceSupplier<>(MetaTag.class)); return converter; } diff --git a/src/test/java/com/celements/metatag/enums/ECharsetTest.java b/src/test/java/com/celements/metatag/enums/ECharsetTest.java index edea79938..3aa892b71 100644 --- a/src/test/java/com/celements/metatag/enums/ECharsetTest.java +++ b/src/test/java/com/celements/metatag/enums/ECharsetTest.java @@ -19,10 +19,10 @@ public void testAttribs() { @Test public void testGetCharset() { - assertTrue(ECharset.getCharset(FIELDS_UTF8).equals(ECharset.UTF8) || ECharset.getCharset( - FIELDS_UTF8).get().equals(ECharset.DEFAULT)); - assertTrue(ECharset.getCharset(FIELDS_LATIN1).equals(ECharset.LATIN1) || ECharset.getCharset( - FIELDS_LATIN1).get().equals(ECharset.ISO8859_1)); + assertTrue(ECharset.getCharset(FIELDS_UTF8).equals(ECharset.UTF8) + || ECharset.getCharset(FIELDS_UTF8).get().equals(ECharset.DEFAULT)); + assertTrue(ECharset.getCharset(FIELDS_LATIN1).equals(ECharset.LATIN1) + || ECharset.getCharset(FIELDS_LATIN1).get().equals(ECharset.ISO8859_1)); assertEquals(ECharset.USASCII, ECharset.getCharset(FIELDS_USASCII).get()); } diff --git a/src/test/java/com/celements/metatag/enums/EHttpEquivTest.java b/src/test/java/com/celements/metatag/enums/EHttpEquivTest.java index 211fd562d..a8e563be6 100644 --- a/src/test/java/com/celements/metatag/enums/EHttpEquivTest.java +++ b/src/test/java/com/celements/metatag/enums/EHttpEquivTest.java @@ -19,8 +19,8 @@ public void testAttribs() { @Test public void testGetHttpEquiv() { - assertEquals(EHttpEquiv.CONTENT_SECURITY_POLICY, EHttpEquiv.getHttpEquiv( - FIELDS_CONTENT_SECURITY_POLICY).get()); + assertEquals(EHttpEquiv.CONTENT_SECURITY_POLICY, + EHttpEquiv.getHttpEquiv(FIELDS_CONTENT_SECURITY_POLICY).get()); assertEquals(EHttpEquiv.DEFAULT_STYLE, EHttpEquiv.getHttpEquiv(FIELDS_DEFAULT_STYLE).get()); assertEquals(EHttpEquiv.REFRESH, EHttpEquiv.getHttpEquiv(FIELDS_REFRESH).get()); } diff --git a/src/test/java/com/celements/metatag/enums/ENameStandardTest.java b/src/test/java/com/celements/metatag/enums/ENameStandardTest.java index 7d8592769..76285fa05 100644 --- a/src/test/java/com/celements/metatag/enums/ENameStandardTest.java +++ b/src/test/java/com/celements/metatag/enums/ENameStandardTest.java @@ -21,8 +21,8 @@ public void testAttribs() { @Test public void testGetName() { - assertEquals(ENameStandard.APPLICATION_NAME, ENameStandard.getName( - FIELDS_APPLICATION_NAME).get()); + assertEquals(ENameStandard.APPLICATION_NAME, + ENameStandard.getName(FIELDS_APPLICATION_NAME).get()); assertEquals(ENameStandard.AUTHOR, ENameStandard.getName(FIELDS_AUTHOR).get()); assertEquals(ENameStandard.DESCRIPTION, ENameStandard.getName(FIELDS_DESCRIPTION).get()); assertEquals(ENameStandard.GENERATOR, ENameStandard.getName(FIELDS_GENERATOR).get()); diff --git a/src/test/java/com/celements/metatag/enums/EReferrerTest.java b/src/test/java/com/celements/metatag/enums/EReferrerTest.java index dfc35c8de..bf62480e6 100644 --- a/src/test/java/com/celements/metatag/enums/EReferrerTest.java +++ b/src/test/java/com/celements/metatag/enums/EReferrerTest.java @@ -16,10 +16,10 @@ public class EReferrerTest { public void testGetReferrer() { assertEquals(EReferrer.NO_REFFERER, EReferrer.getReferrer(FIELDS_NO_REFFERER).get()); assertEquals(EReferrer.ORIGIN, EReferrer.getReferrer(FIELDS_ORIGIN).get()); - assertEquals(EReferrer.NO_REFERRER_WHEN_DOWNGRADE, EReferrer.getReferrer( - FIELDS_NO_REFERRER_WHEN_DOWNGRADE).get()); - assertEquals(EReferrer.ORIGIN_WHEN_CROSSORIGIN, EReferrer.getReferrer( - FIELDS_ORIGIN_WHEN_CROSSORIGIN).get()); + assertEquals(EReferrer.NO_REFERRER_WHEN_DOWNGRADE, + EReferrer.getReferrer(FIELDS_NO_REFERRER_WHEN_DOWNGRADE).get()); + assertEquals(EReferrer.ORIGIN_WHEN_CROSSORIGIN, + EReferrer.getReferrer(FIELDS_ORIGIN_WHEN_CROSSORIGIN).get()); assertEquals(EReferrer.UNSAVE_URL, EReferrer.getReferrer(FIELDS_UNSAVE_URL).get()); } diff --git a/src/test/java/com/celements/metatag/enums/opengraph/EOpenGraphTest.java b/src/test/java/com/celements/metatag/enums/opengraph/EOpenGraphTest.java index a29151794..19cdb7ea0 100644 --- a/src/test/java/com/celements/metatag/enums/opengraph/EOpenGraphTest.java +++ b/src/test/java/com/celements/metatag/enums/opengraph/EOpenGraphTest.java @@ -31,24 +31,24 @@ public void testGetOpenGraph() { assertEquals(EOpenGraph.OPENGRAPH_TYPE, EOpenGraph.getOpenGraph(FIELDS_OPENGRAPH_TYPE).get()); assertEquals(EOpenGraph.OPENGRAPH_IMAGE, EOpenGraph.getOpenGraph(FIELDS_OPENGRAPH_IMAGE).get()); assertEquals(EOpenGraph.OPENGRAPH_URL, EOpenGraph.getOpenGraph(FIELDS_OPENGRAPH_URL).get()); - assertEquals(EOpenGraph.OPENGRAPH_OPTIONAL_AUDIO, EOpenGraph.getOpenGraph( - FIELDS_OPENGRAPH_OPTIONAL_AUDIO).get()); - assertEquals(EOpenGraph.OPENGRAPH_OPTIONAL_DESCRIPTION, EOpenGraph.getOpenGraph( - FIELDS_OPENGRAPH_OPTIONAL_DESCRIPTION).get()); - assertEquals(EOpenGraph.OPENGRAPH_OPTIONAL_DETERMINER, EOpenGraph.getOpenGraph( - FIELDS_OPENGRAPH_OPTIONAL_DETERMINER).get()); - assertEquals(EOpenGraph.OPENGRAPH_OPTIONAL_LOCALE, EOpenGraph.getOpenGraph( - FIELDS_OPENGRAPH_OPTIONAL_LOCALE).get()); - assertEquals(EOpenGraph.OPENGRAPH_OPTIONAL_LOCALE_ALTERNATE, EOpenGraph.getOpenGraph( - FIELDS_OPENGRAPH_OPTIONAL_LOCALE_ALTERNATE).get()); - assertEquals(EOpenGraph.OPENGRAPH_OPTIONAL_SITENAME, EOpenGraph.getOpenGraph( - FIELDS_OPENGRAPH_OPTIONAL_SITENAME).get()); - assertEquals(EOpenGraph.OPENGRAPH_OPTIONAL_VIDEO, EOpenGraph.getOpenGraph( - FIELDS_OPENGRAPH_OPTIONAL_VIDEO).get()); - assertEquals(EOpenGraph.OPENGRAPH_OPTIONAL_IMAGE_WIDTH, EOpenGraph.getOpenGraph( - FIELDS_OPENGRAPH_OPTIONAL_IMAGE_WIDTH).get()); - assertEquals(EOpenGraph.OPENGRAPH_OPTIONAL_IMAGE_HEIGHT, EOpenGraph.getOpenGraph( - FIELDS_OPENGRAPH_OPTIONAL_IMAGE_HEIGHT).get()); + assertEquals(EOpenGraph.OPENGRAPH_OPTIONAL_AUDIO, + EOpenGraph.getOpenGraph(FIELDS_OPENGRAPH_OPTIONAL_AUDIO).get()); + assertEquals(EOpenGraph.OPENGRAPH_OPTIONAL_DESCRIPTION, + EOpenGraph.getOpenGraph(FIELDS_OPENGRAPH_OPTIONAL_DESCRIPTION).get()); + assertEquals(EOpenGraph.OPENGRAPH_OPTIONAL_DETERMINER, + EOpenGraph.getOpenGraph(FIELDS_OPENGRAPH_OPTIONAL_DETERMINER).get()); + assertEquals(EOpenGraph.OPENGRAPH_OPTIONAL_LOCALE, + EOpenGraph.getOpenGraph(FIELDS_OPENGRAPH_OPTIONAL_LOCALE).get()); + assertEquals(EOpenGraph.OPENGRAPH_OPTIONAL_LOCALE_ALTERNATE, + EOpenGraph.getOpenGraph(FIELDS_OPENGRAPH_OPTIONAL_LOCALE_ALTERNATE).get()); + assertEquals(EOpenGraph.OPENGRAPH_OPTIONAL_SITENAME, + EOpenGraph.getOpenGraph(FIELDS_OPENGRAPH_OPTIONAL_SITENAME).get()); + assertEquals(EOpenGraph.OPENGRAPH_OPTIONAL_VIDEO, + EOpenGraph.getOpenGraph(FIELDS_OPENGRAPH_OPTIONAL_VIDEO).get()); + assertEquals(EOpenGraph.OPENGRAPH_OPTIONAL_IMAGE_WIDTH, + EOpenGraph.getOpenGraph(FIELDS_OPENGRAPH_OPTIONAL_IMAGE_WIDTH).get()); + assertEquals(EOpenGraph.OPENGRAPH_OPTIONAL_IMAGE_HEIGHT, + EOpenGraph.getOpenGraph(FIELDS_OPENGRAPH_OPTIONAL_IMAGE_HEIGHT).get()); } @Test diff --git a/src/test/java/com/celements/metatag/enums/twitter/ETwitterCardTypeTest.java b/src/test/java/com/celements/metatag/enums/twitter/ETwitterCardTypeTest.java index 806b1180d..52e85dcf5 100644 --- a/src/test/java/com/celements/metatag/enums/twitter/ETwitterCardTypeTest.java +++ b/src/test/java/com/celements/metatag/enums/twitter/ETwitterCardTypeTest.java @@ -13,10 +13,10 @@ public class ETwitterCardTypeTest { @Test public void testGetTwitterCardType() { - assertEquals(ETwitterCardType.SUMMARY, ETwitterCardType.getTwitterCardType( - FIELDS_SUMMARY).get()); - assertEquals(ETwitterCardType.SUMMARY_LARGE_IMAGE, ETwitterCardType.getTwitterCardType( - FIELDS_SUMMARY_LARGE_IMAGE).get()); + assertEquals(ETwitterCardType.SUMMARY, + ETwitterCardType.getTwitterCardType(FIELDS_SUMMARY).get()); + assertEquals(ETwitterCardType.SUMMARY_LARGE_IMAGE, + ETwitterCardType.getTwitterCardType(FIELDS_SUMMARY_LARGE_IMAGE).get()); assertEquals(ETwitterCardType.PLAYER, ETwitterCardType.getTwitterCardType(FIELDS_PLAYER).get()); assertEquals(ETwitterCardType.APP, ETwitterCardType.getTwitterCardType(FIELDS_APP).get()); } diff --git a/src/test/java/com/celements/metatag/enums/twitter/ETwitterTest.java b/src/test/java/com/celements/metatag/enums/twitter/ETwitterTest.java index 055526139..61d47db85 100644 --- a/src/test/java/com/celements/metatag/enums/twitter/ETwitterTest.java +++ b/src/test/java/com/celements/metatag/enums/twitter/ETwitterTest.java @@ -30,8 +30,8 @@ public void testGetTwitter() { assertEquals(ETwitter.TWITTER_SITE_ID, ETwitter.getTwitter(FIELDS_TWITTER_SITE_ID).get()); assertEquals(ETwitter.TWITTER_CREATOR, ETwitter.getTwitter(FIELDS_TWITTER_CREATOR).get()); assertEquals(ETwitter.TWITTER_CREATOR_ID, ETwitter.getTwitter(FIELDS_TWITTER_CREATOR_ID).get()); - assertEquals(ETwitter.TWITTER_DESCRIPTION, ETwitter.getTwitter( - FIELDS_TWITTER_DESCRIPTION).get()); + assertEquals(ETwitter.TWITTER_DESCRIPTION, + ETwitter.getTwitter(FIELDS_TWITTER_DESCRIPTION).get()); assertEquals(ETwitter.TWITTER_TITLE, ETwitter.getTwitter(FIELDS_TWITTER_TITLE).get()); assertEquals(ETwitter.TWITTER_IMAGE, ETwitter.getTwitter(FIELDS_TWITTER_IMAGE).get()); assertEquals(ETwitter.TWITTER_IMAGE_ALT, ETwitter.getTwitter(FIELDS_TWITTER_IMAGE_ALT).get()); diff --git a/src/test/java/com/celements/migrator/MenuNameMappingCelements2_8Test.java b/src/test/java/com/celements/migrator/MenuNameMappingCelements2_8Test.java index d89d0af98..74439960c 100644 --- a/src/test/java/com/celements/migrator/MenuNameMappingCelements2_8Test.java +++ b/src/test/java/com/celements/migrator/MenuNameMappingCelements2_8Test.java @@ -51,13 +51,12 @@ public void testGetNavigationClasses() { verifyAll(); } - - private void replayAll(Object ... mocks) { + private void replayAll(Object... mocks) { replay(xwiki); replay(mocks); } - private void verifyAll(Object ... mocks) { + private void verifyAll(Object... mocks) { verify(xwiki); verify(mocks); } diff --git a/src/test/java/com/celements/migrator/TreeNodeRelativeParent_DatabaseTest.java b/src/test/java/com/celements/migrator/TreeNodeRelativeParent_DatabaseTest.java index b45c98189..f5c93f1ae 100644 --- a/src/test/java/com/celements/migrator/TreeNodeRelativeParent_DatabaseTest.java +++ b/src/test/java/com/celements/migrator/TreeNodeRelativeParent_DatabaseTest.java @@ -31,8 +31,8 @@ public class TreeNodeRelativeParent_DatabaseTest extends AbstractComponentTest { @Before public void prepareTest() throws Exception { queryManagerMock = registerComponentMock(QueryManager.class); - migrator = (TreeNodeRelativeParent_Database) getComponentManager().lookup( - ICelementsMigrator.class, "TreeNodeRelativeParent_Database"); + migrator = (TreeNodeRelativeParent_Database) getComponentManager() + .lookup(ICelementsMigrator.class, "TreeNodeRelativeParent_Database"); xwiki = getWikiMock(); context = getContext(); } @@ -42,20 +42,20 @@ public void testMigrateXWikiMigrationManagerInterfaceXWikiContext() throws Excep SubSystemHibernateMigrationManager manager = createDefaultMock( SubSystemHibernateMigrationManager.class); Query queryMock = createDefaultMock(Query.class); - expect(queryManagerMock.createQuery(anyObject(String.class), eq(Query.XWQL))).andReturn( - queryMock); + expect(queryManagerMock.createQuery(anyObject(String.class), eq(Query.XWQL))) + .andReturn(queryMock); expect(queryMock.bindValue("buggyParent", "xwikidb:%")).andReturn(queryMock); List resultList = Arrays.asList("MySpace.MyDoc"); expect(queryMock.execute()).andReturn(resultList); DocumentReference docRef = new DocumentReference(context.getDatabase(), "MySpace", "MyDoc"); XWikiDocument xwikiDoc = new XWikiDocument(docRef); EntityReference entityReference = new EntityReference("MyParent", EntityType.DOCUMENT, - new EntityReference("MySpace", EntityType.SPACE, new EntityReference(context.getDatabase(), - EntityType.WIKI))); + new EntityReference("MySpace", EntityType.SPACE, + new EntityReference(context.getDatabase(), EntityType.WIKI))); xwikiDoc.setParentReference(entityReference); expect(xwiki.getDocument(eq(docRef), same(context))).andReturn(xwikiDoc); - xwiki.saveDocument(same(xwikiDoc), eq("TreeNodeRelativeParent_Database Migration"), same( - context)); + xwiki.saveDocument(same(xwikiDoc), eq("TreeNodeRelativeParent_Database Migration"), + same(context)); expectLastCall().once(); replayDefault(); migrator.migrate(manager, context); diff --git a/src/test/java/com/celements/navigation/NavigationCacheTest.java b/src/test/java/com/celements/navigation/NavigationCacheTest.java index 8611fb974..1f32fb7d5 100644 --- a/src/test/java/com/celements/navigation/NavigationCacheTest.java +++ b/src/test/java/com/celements/navigation/NavigationCacheTest.java @@ -176,8 +176,8 @@ public void testGetCachedDocRefs_XWikiException() throws Exception { DocumentReference docRef = new DocumentReference(wikiRef.getName(), "space", "nav1"); expectXWQL(wikiRef, Arrays.asList(docRef)); - expect(getWikiMock().getDocument(eq(docRef), same(getContext()))).andThrow( - new XWikiException()).once(); + expect(getWikiMock().getDocument(eq(docRef), same(getContext()))).andThrow(new XWikiException()) + .once(); replayDefault(); try { @@ -228,8 +228,8 @@ private void expectXWQL(WikiReference wikiRef, List ret) thro private void expectMenuSpace(DocumentReference docRef, String space, int nb) throws Exception { XWikiDocument doc = new XWikiDocument(docRef); BaseObject obj = new BaseObject(); - obj.setXClassReference(Utils.getComponent( - INavigationClassConfig.class).getNavigationConfigClassRef(docRef.getWikiReference())); + obj.setXClassReference(Utils.getComponent(INavigationClassConfig.class) + .getNavigationConfigClassRef(docRef.getWikiReference())); obj.setStringValue(INavigationClassConfig.MENU_SPACE_FIELD, space); doc.setXObject(nb, obj); expect(getWikiMock().getDocument(eq(docRef), same(getContext()))).andReturn(doc).once(); diff --git a/src/test/java/com/celements/navigation/NavigationConfigTest.java b/src/test/java/com/celements/navigation/NavigationConfigTest.java index afa27b7c9..0528f32b5 100644 --- a/src/test/java/com/celements/navigation/NavigationConfigTest.java +++ b/src/test/java/com/celements/navigation/NavigationConfigTest.java @@ -231,8 +231,8 @@ public void testGetMenuPart() { @Test public void testGetNodeSpaceRef() { String spaceName = "MySpace"; - SpaceReference nodeSpaceRef = new SpaceReference(spaceName, new WikiReference( - getContext().getDatabase())); + SpaceReference nodeSpaceRef = new SpaceReference(spaceName, + new WikiReference(getContext().getDatabase())); navBuilder.nodeSpaceRef(nodeSpaceRef); NavigationConfig navConfig = navBuilder.build(); Optional firstReturnNodeSpace = navConfig.getNodeSpaceRef(); @@ -386,22 +386,17 @@ public void testOverlayValues_configName() throws Exception { Integer showInactiveToLevel2 = 55; String menuPart2 = "menuPart2"; String dataType2 = "dataType2"; - SpaceReference nodeSpaceRef2 = new SpaceReference("NavConfigSpace2", new WikiReference( - getContext().getDatabase())); + SpaceReference nodeSpaceRef2 = new SpaceReference("NavConfigSpace2", + new WikiReference(getContext().getDatabase())); String layoutType2 = "navConfig2LayoutType"; Integer itemsPerPage2 = 50; String presentationTypeHint2 = "navConfigPresTypeHint2"; String cmCssClass2 = "cm_cssTestClass2"; - NavigationConfig navConfig2 = new NavigationConfig.Builder().configName( - configName2).fromHierarchyLevel(fromHierarchyLevel2).toHierarchyLevel( - toHierarchyLevel2) - .showInactiveToLevel(showInactiveToLevel2).menuPart( - menuPart2) - .dataType(dataType2).nodeSpaceRef(nodeSpaceRef2).layoutType( - layoutType2) - .nrOfItemsPerPage(itemsPerPage2).presentationTypeHint( - presentationTypeHint2) - .cmCssClass(cmCssClass2).build(); + NavigationConfig navConfig2 = new NavigationConfig.Builder().configName(configName2) + .fromHierarchyLevel(fromHierarchyLevel2).toHierarchyLevel(toHierarchyLevel2) + .showInactiveToLevel(showInactiveToLevel2).menuPart(menuPart2).dataType(dataType2) + .nodeSpaceRef(nodeSpaceRef2).layoutType(layoutType2).nrOfItemsPerPage(itemsPerPage2) + .presentationTypeHint(presentationTypeHint2).cmCssClass(cmCssClass2).build(); IPresentationTypeRole componentInstance = registerComponentMock(IPresentationTypeRole.class, presentationTypeHint2); replayDefault(); @@ -439,22 +434,17 @@ public void testOverlayValues_fromHierarchyLevel() throws Exception { Integer showInactiveToLevel2 = 55; String menuPart2 = "menuPart2"; String dataType2 = "dataType2"; - SpaceReference nodeSpaceRef2 = new SpaceReference("NavConfigSpace2", new WikiReference( - getContext().getDatabase())); + SpaceReference nodeSpaceRef2 = new SpaceReference("NavConfigSpace2", + new WikiReference(getContext().getDatabase())); String layoutType2 = "navConfig2LayoutType"; Integer itemsPerPage2 = 50; String presentationTypeHint2 = "navConfigPresTypeHint2"; String cmCssClass2 = "cm_cssTestClass2"; - NavigationConfig navConfig2 = new NavigationConfig.Builder().configName( - configName2).fromHierarchyLevel(fromHierarchyLevel2).toHierarchyLevel( - toHierarchyLevel2) - .showInactiveToLevel(showInactiveToLevel2).menuPart( - menuPart2) - .dataType(dataType2).nodeSpaceRef(nodeSpaceRef2).layoutType( - layoutType2) - .nrOfItemsPerPage(itemsPerPage2).presentationTypeHint( - presentationTypeHint2) - .cmCssClass(cmCssClass2).build(); + NavigationConfig navConfig2 = new NavigationConfig.Builder().configName(configName2) + .fromHierarchyLevel(fromHierarchyLevel2).toHierarchyLevel(toHierarchyLevel2) + .showInactiveToLevel(showInactiveToLevel2).menuPart(menuPart2).dataType(dataType2) + .nodeSpaceRef(nodeSpaceRef2).layoutType(layoutType2).nrOfItemsPerPage(itemsPerPage2) + .presentationTypeHint(presentationTypeHint2).cmCssClass(cmCssClass2).build(); IPresentationTypeRole componentInstance = registerComponentMock(IPresentationTypeRole.class, presentationTypeHint2); replayDefault(); @@ -493,22 +483,17 @@ public void testOverlayValues_toHierarchyLevel() throws Exception { Integer showInactiveToLevel2 = 55; String menuPart2 = "menuPart2"; String dataType2 = "dataType2"; - SpaceReference nodeSpaceRef2 = new SpaceReference("NavConfigSpace2", new WikiReference( - getContext().getDatabase())); + SpaceReference nodeSpaceRef2 = new SpaceReference("NavConfigSpace2", + new WikiReference(getContext().getDatabase())); String layoutType2 = "navConfig2LayoutType"; Integer itemsPerPage2 = 50; String presentationTypeHint2 = "navConfigPresTypeHint2"; String cmCssClass2 = "cm_cssTestClass2"; - NavigationConfig navConfig2 = new NavigationConfig.Builder().configName( - configName2).fromHierarchyLevel(fromHierarchyLevel2).toHierarchyLevel( - toHierarchyLevel2) - .showInactiveToLevel(showInactiveToLevel2).menuPart( - menuPart2) - .dataType(dataType2).nodeSpaceRef(nodeSpaceRef2).layoutType( - layoutType2) - .nrOfItemsPerPage(itemsPerPage2).presentationTypeHint( - presentationTypeHint2) - .cmCssClass(cmCssClass2).build(); + NavigationConfig navConfig2 = new NavigationConfig.Builder().configName(configName2) + .fromHierarchyLevel(fromHierarchyLevel2).toHierarchyLevel(toHierarchyLevel2) + .showInactiveToLevel(showInactiveToLevel2).menuPart(menuPart2).dataType(dataType2) + .nodeSpaceRef(nodeSpaceRef2).layoutType(layoutType2).nrOfItemsPerPage(itemsPerPage2) + .presentationTypeHint(presentationTypeHint2).cmCssClass(cmCssClass2).build(); IPresentationTypeRole componentInstance = registerComponentMock(IPresentationTypeRole.class, presentationTypeHint2); replayDefault(); @@ -547,22 +532,17 @@ public void testOverlayValues_showInactiveToLevel() throws Exception { Integer showInactiveToLevel2 = 55; String menuPart2 = "menuPart2"; String dataType2 = "dataType2"; - SpaceReference nodeSpaceRef2 = new SpaceReference("NavConfigSpace2", new WikiReference( - getContext().getDatabase())); + SpaceReference nodeSpaceRef2 = new SpaceReference("NavConfigSpace2", + new WikiReference(getContext().getDatabase())); String layoutType2 = "navConfig2LayoutType"; Integer itemsPerPage2 = 50; String presentationTypeHint2 = "navConfigPresTypeHint2"; String cmCssClass2 = "cm_cssTestClass2"; - NavigationConfig navConfig2 = new NavigationConfig.Builder().configName( - configName2).fromHierarchyLevel(fromHierarchyLevel2).toHierarchyLevel( - toHierarchyLevel2) - .showInactiveToLevel(showInactiveToLevel2).menuPart( - menuPart2) - .dataType(dataType2).nodeSpaceRef(nodeSpaceRef2).layoutType( - layoutType2) - .nrOfItemsPerPage(itemsPerPage2).presentationTypeHint( - presentationTypeHint2) - .cmCssClass(cmCssClass2).build(); + NavigationConfig navConfig2 = new NavigationConfig.Builder().configName(configName2) + .fromHierarchyLevel(fromHierarchyLevel2).toHierarchyLevel(toHierarchyLevel2) + .showInactiveToLevel(showInactiveToLevel2).menuPart(menuPart2).dataType(dataType2) + .nodeSpaceRef(nodeSpaceRef2).layoutType(layoutType2).nrOfItemsPerPage(itemsPerPage2) + .presentationTypeHint(presentationTypeHint2).cmCssClass(cmCssClass2).build(); IPresentationTypeRole componentInstance = registerComponentMock(IPresentationTypeRole.class, presentationTypeHint2); replayDefault(); @@ -601,22 +581,17 @@ public void testOverlayValues_menuPart() throws Exception { Integer showInactiveToLevel2 = 55; String menuPart2 = "menuPart2"; String dataType2 = "dataType2"; - SpaceReference nodeSpaceRef2 = new SpaceReference("NavConfigSpace2", new WikiReference( - getContext().getDatabase())); + SpaceReference nodeSpaceRef2 = new SpaceReference("NavConfigSpace2", + new WikiReference(getContext().getDatabase())); String layoutType2 = "navConfig2LayoutType"; Integer itemsPerPage2 = 50; String presentationTypeHint2 = "navConfigPresTypeHint2"; String cmCssClass2 = "cm_cssTestClass2"; - NavigationConfig navConfig2 = new NavigationConfig.Builder().configName( - configName2).fromHierarchyLevel(fromHierarchyLevel2).toHierarchyLevel( - toHierarchyLevel2) - .showInactiveToLevel(showInactiveToLevel2).menuPart( - menuPart2) - .dataType(dataType2).nodeSpaceRef(nodeSpaceRef2).layoutType( - layoutType2) - .nrOfItemsPerPage(itemsPerPage2).presentationTypeHint( - presentationTypeHint2) - .cmCssClass(cmCssClass2).build(); + NavigationConfig navConfig2 = new NavigationConfig.Builder().configName(configName2) + .fromHierarchyLevel(fromHierarchyLevel2).toHierarchyLevel(toHierarchyLevel2) + .showInactiveToLevel(showInactiveToLevel2).menuPart(menuPart2).dataType(dataType2) + .nodeSpaceRef(nodeSpaceRef2).layoutType(layoutType2).nrOfItemsPerPage(itemsPerPage2) + .presentationTypeHint(presentationTypeHint2).cmCssClass(cmCssClass2).build(); IPresentationTypeRole componentInstance = registerComponentMock(IPresentationTypeRole.class, presentationTypeHint2); replayDefault(); @@ -655,22 +630,17 @@ public void testOverlayValues_dataType() throws Exception { Integer showInactiveToLevel2 = 55; String menuPart2 = "menuPart2"; String dataType2 = "dataType2"; - SpaceReference nodeSpaceRef2 = new SpaceReference("NavConfigSpace2", new WikiReference( - getContext().getDatabase())); + SpaceReference nodeSpaceRef2 = new SpaceReference("NavConfigSpace2", + new WikiReference(getContext().getDatabase())); String layoutType2 = "navConfig2LayoutType"; Integer itemsPerPage2 = 50; String presentationTypeHint2 = "navConfigPresTypeHint2"; String cmCssClass2 = "cm_cssTestClass2"; - NavigationConfig navConfig2 = new NavigationConfig.Builder().configName( - configName2).fromHierarchyLevel(fromHierarchyLevel2).toHierarchyLevel( - toHierarchyLevel2) - .showInactiveToLevel(showInactiveToLevel2).menuPart( - menuPart2) - .dataType(dataType2).nodeSpaceRef(nodeSpaceRef2).layoutType( - layoutType2) - .nrOfItemsPerPage(itemsPerPage2).presentationTypeHint( - presentationTypeHint2) - .cmCssClass(cmCssClass2).build(); + NavigationConfig navConfig2 = new NavigationConfig.Builder().configName(configName2) + .fromHierarchyLevel(fromHierarchyLevel2).toHierarchyLevel(toHierarchyLevel2) + .showInactiveToLevel(showInactiveToLevel2).menuPart(menuPart2).dataType(dataType2) + .nodeSpaceRef(nodeSpaceRef2).layoutType(layoutType2).nrOfItemsPerPage(itemsPerPage2) + .presentationTypeHint(presentationTypeHint2).cmCssClass(cmCssClass2).build(); IPresentationTypeRole componentInstance = registerComponentMock(IPresentationTypeRole.class, presentationTypeHint2); replayDefault(); @@ -700,8 +670,8 @@ public void testOverlayValues_dataType() throws Exception { @Test public void testOverlayValues_nodeSpaceRef() throws Exception { - SpaceReference nodeSpaceRef = new SpaceReference("NavConfigSpace1", new WikiReference( - getContext().getDatabase())); + SpaceReference nodeSpaceRef = new SpaceReference("NavConfigSpace1", + new WikiReference(getContext().getDatabase())); navBuilder.nodeSpaceRef(nodeSpaceRef); NavigationConfig navConfig1 = navBuilder.build(); String configName2 = "configName2"; @@ -710,22 +680,17 @@ public void testOverlayValues_nodeSpaceRef() throws Exception { Integer showInactiveToLevel2 = 55; String menuPart2 = "menuPart2"; String dataType2 = "dataType2"; - SpaceReference nodeSpaceRef2 = new SpaceReference("NavConfigSpace2", new WikiReference( - getContext().getDatabase())); + SpaceReference nodeSpaceRef2 = new SpaceReference("NavConfigSpace2", + new WikiReference(getContext().getDatabase())); String layoutType2 = "navConfig2LayoutType"; Integer itemsPerPage2 = 50; String presentationTypeHint2 = "navConfigPresTypeHint2"; String cmCssClass2 = "cm_cssTestClass2"; - NavigationConfig navConfig2 = new NavigationConfig.Builder().configName( - configName2).fromHierarchyLevel(fromHierarchyLevel2).toHierarchyLevel( - toHierarchyLevel2) - .showInactiveToLevel(showInactiveToLevel2).menuPart( - menuPart2) - .dataType(dataType2).nodeSpaceRef(nodeSpaceRef2).layoutType( - layoutType2) - .nrOfItemsPerPage(itemsPerPage2).presentationTypeHint( - presentationTypeHint2) - .cmCssClass(cmCssClass2).build(); + NavigationConfig navConfig2 = new NavigationConfig.Builder().configName(configName2) + .fromHierarchyLevel(fromHierarchyLevel2).toHierarchyLevel(toHierarchyLevel2) + .showInactiveToLevel(showInactiveToLevel2).menuPart(menuPart2).dataType(dataType2) + .nodeSpaceRef(nodeSpaceRef2).layoutType(layoutType2).nrOfItemsPerPage(itemsPerPage2) + .presentationTypeHint(presentationTypeHint2).cmCssClass(cmCssClass2).build(); IPresentationTypeRole componentInstance = registerComponentMock(IPresentationTypeRole.class, presentationTypeHint2); replayDefault(); @@ -764,22 +729,17 @@ public void testOverlayValues_layoutType() throws Exception { Integer showInactiveToLevel2 = 55; String menuPart2 = "menuPart2"; String dataType2 = "dataType2"; - SpaceReference nodeSpaceRef2 = new SpaceReference("NavConfigSpace2", new WikiReference( - getContext().getDatabase())); + SpaceReference nodeSpaceRef2 = new SpaceReference("NavConfigSpace2", + new WikiReference(getContext().getDatabase())); String layoutType2 = "navConfig2LayoutType"; Integer itemsPerPage2 = 50; String presentationTypeHint2 = "navConfigPresTypeHint2"; String cmCssClass2 = "cm_cssTestClass2"; - NavigationConfig navConfig2 = new NavigationConfig.Builder().configName( - configName2).fromHierarchyLevel(fromHierarchyLevel2).toHierarchyLevel( - toHierarchyLevel2) - .showInactiveToLevel(showInactiveToLevel2).menuPart( - menuPart2) - .dataType(dataType2).nodeSpaceRef(nodeSpaceRef2).layoutType( - layoutType2) - .nrOfItemsPerPage(itemsPerPage2).presentationTypeHint( - presentationTypeHint2) - .cmCssClass(cmCssClass2).build(); + NavigationConfig navConfig2 = new NavigationConfig.Builder().configName(configName2) + .fromHierarchyLevel(fromHierarchyLevel2).toHierarchyLevel(toHierarchyLevel2) + .showInactiveToLevel(showInactiveToLevel2).menuPart(menuPart2).dataType(dataType2) + .nodeSpaceRef(nodeSpaceRef2).layoutType(layoutType2).nrOfItemsPerPage(itemsPerPage2) + .presentationTypeHint(presentationTypeHint2).cmCssClass(cmCssClass2).build(); IPresentationTypeRole componentInstance = registerComponentMock(IPresentationTypeRole.class, presentationTypeHint2); replayDefault(); @@ -817,22 +777,17 @@ public void testOverlayValues_itemsPerPage() throws Exception { Integer showInactiveToLevel2 = 55; String menuPart2 = "menuPart2"; String dataType2 = "dataType2"; - SpaceReference nodeSpaceRef2 = new SpaceReference("NavConfigSpace2", new WikiReference( - getContext().getDatabase())); + SpaceReference nodeSpaceRef2 = new SpaceReference("NavConfigSpace2", + new WikiReference(getContext().getDatabase())); String layoutType2 = "navConfig2LayoutType"; Integer itemsPerPage2 = 50; String presentationTypeHint2 = "navConfigPresTypeHint2"; String cmCssClass2 = "cm_cssTestClass2"; - NavigationConfig navConfig2 = new NavigationConfig.Builder().configName( - configName2).fromHierarchyLevel(fromHierarchyLevel2).toHierarchyLevel( - toHierarchyLevel2) - .showInactiveToLevel(showInactiveToLevel2).menuPart( - menuPart2) - .dataType(dataType2).nodeSpaceRef(nodeSpaceRef2).layoutType( - layoutType2) - .nrOfItemsPerPage(itemsPerPage2).presentationTypeHint( - presentationTypeHint2) - .cmCssClass(cmCssClass2).build(); + NavigationConfig navConfig2 = new NavigationConfig.Builder().configName(configName2) + .fromHierarchyLevel(fromHierarchyLevel2).toHierarchyLevel(toHierarchyLevel2) + .showInactiveToLevel(showInactiveToLevel2).menuPart(menuPart2).dataType(dataType2) + .nodeSpaceRef(nodeSpaceRef2).layoutType(layoutType2).nrOfItemsPerPage(itemsPerPage2) + .presentationTypeHint(presentationTypeHint2).cmCssClass(cmCssClass2).build(); IPresentationTypeRole componentInstance = registerComponentMock(IPresentationTypeRole.class, presentationTypeHint2); replayDefault(); @@ -871,22 +826,17 @@ public void testOverlayValues_presentationTypeHint() throws Exception { Integer showInactiveToLevel2 = 55; String menuPart2 = "menuPart2"; String dataType2 = "dataType2"; - SpaceReference nodeSpaceRef2 = new SpaceReference("NavConfigSpace2", new WikiReference( - getContext().getDatabase())); + SpaceReference nodeSpaceRef2 = new SpaceReference("NavConfigSpace2", + new WikiReference(getContext().getDatabase())); String layoutType2 = "navConfig2LayoutType"; Integer itemsPerPage2 = 50; String presentationTypeHint2 = "navConfigPresTypeHint2"; String cmCssClass2 = "cm_cssTestClass2"; - NavigationConfig navConfig2 = new NavigationConfig.Builder().configName( - configName2).fromHierarchyLevel(fromHierarchyLevel2).toHierarchyLevel( - toHierarchyLevel2) - .showInactiveToLevel(showInactiveToLevel2).menuPart( - menuPart2) - .dataType(dataType2).nodeSpaceRef(nodeSpaceRef2).layoutType( - layoutType2) - .nrOfItemsPerPage(itemsPerPage2).presentationTypeHint( - presentationTypeHint2) - .cmCssClass(cmCssClass2).build(); + NavigationConfig navConfig2 = new NavigationConfig.Builder().configName(configName2) + .fromHierarchyLevel(fromHierarchyLevel2).toHierarchyLevel(toHierarchyLevel2) + .showInactiveToLevel(showInactiveToLevel2).menuPart(menuPart2).dataType(dataType2) + .nodeSpaceRef(nodeSpaceRef2).layoutType(layoutType2).nrOfItemsPerPage(itemsPerPage2) + .presentationTypeHint(presentationTypeHint2).cmCssClass(cmCssClass2).build(); IPresentationTypeRole componentInstance = registerComponentMock(IPresentationTypeRole.class, presentationTypeHint); replayDefault(); @@ -925,22 +875,17 @@ public void testOverlayValues_cmCssClass() throws Exception { Integer showInactiveToLevel2 = 55; String menuPart2 = "menuPart2"; String dataType2 = "dataType2"; - SpaceReference nodeSpaceRef2 = new SpaceReference("NavConfigSpace2", new WikiReference( - getContext().getDatabase())); + SpaceReference nodeSpaceRef2 = new SpaceReference("NavConfigSpace2", + new WikiReference(getContext().getDatabase())); String layoutType2 = "navConfig2LayoutType"; Integer itemsPerPage2 = 50; String presentationTypeHint2 = "navConfigPresTypeHint2"; String cmCssClass2 = "cm_cssTestClass2"; - NavigationConfig navConfig2 = new NavigationConfig.Builder().configName( - configName2).fromHierarchyLevel(fromHierarchyLevel2).toHierarchyLevel( - toHierarchyLevel2) - .showInactiveToLevel(showInactiveToLevel2).menuPart( - menuPart2) - .dataType(dataType2).nodeSpaceRef(nodeSpaceRef2).layoutType( - layoutType2) - .nrOfItemsPerPage(itemsPerPage2).presentationTypeHint( - presentationTypeHint2) - .cmCssClass(cmCssClass2).build(); + NavigationConfig navConfig2 = new NavigationConfig.Builder().configName(configName2) + .fromHierarchyLevel(fromHierarchyLevel2).toHierarchyLevel(toHierarchyLevel2) + .showInactiveToLevel(showInactiveToLevel2).menuPart(menuPart2).dataType(dataType2) + .nodeSpaceRef(nodeSpaceRef2).layoutType(layoutType2).nrOfItemsPerPage(itemsPerPage2) + .presentationTypeHint(presentationTypeHint2).cmCssClass(cmCssClass2).build(); IPresentationTypeRole componentInstance = registerComponentMock(IPresentationTypeRole.class, presentationTypeHint2); replayDefault(); diff --git a/src/test/java/com/celements/navigation/NavigationTest.java b/src/test/java/com/celements/navigation/NavigationTest.java index 4b8ef3011..972559ceb 100644 --- a/src/test/java/com/celements/navigation/NavigationTest.java +++ b/src/test/java/com/celements/navigation/NavigationTest.java @@ -88,8 +88,8 @@ public void prepareTest() throws Exception { tNServiceMock = createDefaultMock(ITreeNodeService.class); nav.injected_TreeNodeService = tNServiceMock; wUServiceMock = registerComponentMock(IWebUtilsService.class); - expect(wUServiceMock.getRefLocalSerializer()).andReturn(Utils.getComponent( - EntityReferenceSerializer.class, "local")).anyTimes(); + expect(wUServiceMock.getRefLocalSerializer()) + .andReturn(Utils.getComponent(EntityReferenceSerializer.class, "local")).anyTimes(); ptResolverServiceMock = createDefaultMock(PageTypeResolverService.class); nav.injected_PageTypeResolverService = ptResolverServiceMock; mockLayoutCmd = createDefaultMock(PageLayoutCommand.class); @@ -132,10 +132,10 @@ public void testSetMenuSpace() { navFilterMock.setMenuPart(eq("")); expectLastCall().atLeastOnce(); String spaceName = "MySpace"; - EntityReference mySpaceRef = new SpaceReference(spaceName, new WikiReference( - getXContext().getDatabase())); - expect(tNServiceMock.getSubNodesForParent(eq(mySpaceRef), same(navFilterMock))).andReturn( - Collections.emptyList()); + EntityReference mySpaceRef = new SpaceReference(spaceName, + new WikiReference(getXContext().getDatabase())); + expect(tNServiceMock.getSubNodesForParent(eq(mySpaceRef), same(navFilterMock))) + .andReturn(Collections.emptyList()); expect(wUServiceMock.hasParentSpace(eq(spaceName))).andReturn(false); replayDefault(); nav.setMenuSpace(""); @@ -151,10 +151,10 @@ public void testGetUniqueId_null() { navFilterMock.setMenuPart(eq(menuPart)); expectLastCall().atLeastOnce(); String spaceName = "MySpace"; - EntityReference mySpaceRef = new SpaceReference(spaceName, new WikiReference( - getXContext().getDatabase())); - expect(tNServiceMock.getSubNodesForParent(eq(mySpaceRef), same(navFilterMock))).andReturn( - Collections.emptyList()); + EntityReference mySpaceRef = new SpaceReference(spaceName, + new WikiReference(getXContext().getDatabase())); + expect(tNServiceMock.getSubNodesForParent(eq(mySpaceRef), same(navFilterMock))) + .andReturn(Collections.emptyList()); expect(wUServiceMock.hasParentSpace(eq(spaceName))).andReturn(false); replayDefault(); assertTrue(nav.getUniqueId(menuItemName).endsWith(":menuPartTest:")); @@ -169,10 +169,10 @@ public void testGetUniqueId_emptyString() { navFilterMock.setMenuPart(eq(menuPart)); expectLastCall().atLeastOnce(); String spaceName = "MySpace"; - EntityReference mySpaceRef = new SpaceReference(spaceName, new WikiReference( - getXContext().getDatabase())); - expect(tNServiceMock.getSubNodesForParent(eq(mySpaceRef), same(navFilterMock))).andReturn( - Collections.emptyList()); + EntityReference mySpaceRef = new SpaceReference(spaceName, + new WikiReference(getXContext().getDatabase())); + expect(tNServiceMock.getSubNodesForParent(eq(mySpaceRef), same(navFilterMock))) + .andReturn(Collections.emptyList()); expect(wUServiceMock.hasParentSpace(eq(spaceName))).andReturn(false); replayDefault(); assertTrue(nav.getUniqueId(menuItemName).endsWith(":menuPartTest:")); @@ -184,8 +184,8 @@ public void testGetUniqueId_null_menuSpace() { String menuItemName = null; String menuSpace = "testMenuSpace"; nav.setMenuPart("menuPartTest"); - SpaceReference menuSpaceRef = new SpaceReference(menuSpace, new WikiReference( - getXContext().getDatabase())); + SpaceReference menuSpaceRef = new SpaceReference(menuSpace, + new WikiReference(getXContext().getDatabase())); expect(wUServiceMock.resolveSpaceReference(eq(menuSpace))).andReturn(menuSpaceRef).anyTimes(); replayDefault(); nav.setMenuSpace(menuSpace); @@ -204,10 +204,10 @@ public void testGetUniqueId() { navFilterMock.setMenuPart(eq(menuPart)); expectLastCall().atLeastOnce(); String spaceName = "MySpace"; - EntityReference mySpaceRef = new SpaceReference(spaceName, new WikiReference( - getXContext().getDatabase())); - expect(tNServiceMock.getSubNodesForParent(eq(mySpaceRef), same(navFilterMock))).andReturn( - Collections.emptyList()); + EntityReference mySpaceRef = new SpaceReference(spaceName, + new WikiReference(getXContext().getDatabase())); + expect(tNServiceMock.getSubNodesForParent(eq(mySpaceRef), same(navFilterMock))) + .andReturn(Collections.emptyList()); expect(wUServiceMock.hasParentSpace(eq(spaceName))).andReturn(false); replayDefault(); assertTrue(nav.getUniqueId(menuItem.getName()).endsWith(":Space.TestName")); @@ -220,8 +220,8 @@ public void testGetUniqueId_menuSpace() { BaseObject menuItem = new BaseObject(); menuItem.setName("Space.TestName"); nav.setMenuPart("menuPartTest"); - SpaceReference menuSpaceRef = new SpaceReference(menuSpace, new WikiReference( - getXContext().getDatabase())); + SpaceReference menuSpaceRef = new SpaceReference(menuSpace, + new WikiReference(getXContext().getDatabase())); expect(wUServiceMock.resolveSpaceReference(eq(menuSpace))).andReturn(menuSpaceRef).anyTimes(); replayDefault(); nav.setMenuSpace(menuSpace); @@ -260,8 +260,8 @@ public void testSetFromHierarchyLevel_bigger() { public void testGetPageTypeConfigName_integrationTest() throws Exception { nav.injected_PageTypeResolverService = null; ComponentManager componentManager = Utils.getComponentManager(); - ComponentDescriptor ptServiceDesc = componentManager.getComponentDescriptor( - IPageTypeRole.class, "default"); + ComponentDescriptor ptServiceDesc = componentManager + .getComponentDescriptor(IPageTypeRole.class, "default"); IPageTypeRole ptServiceMock = createDefaultMock(IPageTypeRole.class); componentManager.registerComponent(ptServiceDesc, ptServiceMock); BaseObject ptObj = new BaseObject(); @@ -285,17 +285,17 @@ public void testOpenMenuItemOut_notActive() throws Exception { DocumentReference docRef = new DocumentReference(getXContext().getDatabase(), "MySpace", "MyMenuItemDoc"); PageTypeReference pageTypeRef = createDefaultMock(PageTypeReference.class); - expect(ptResolverServiceMock.getPageTypeRefForDocWithDefault(eq(docRef))).andReturn( - pageTypeRef); - expect(wUServiceMock.getDocumentParentsList(isA(DocumentReference.class), - anyBoolean())).andReturn(Arrays.asList(getDocRefForDocName("bla"), - getDocRefForDocName("bli"), getDocRefForDocName("blu"))); + expect(ptResolverServiceMock.getPageTypeRefForDocWithDefault(eq(docRef))) + .andReturn(pageTypeRef); + expect(wUServiceMock.getDocumentParentsList(isA(DocumentReference.class), anyBoolean())) + .andReturn(Arrays.asList(getDocRefForDocName("bla"), getDocRefForDocName("bli"), + getDocRefForDocName("blu"))); expect(pageTypeRef.getConfigName()).andReturn(pageType); BaseObject menuItem = new BaseObject(); menuItem.setDocumentReference(docRef); expect(mockLayoutCmd.getPageLayoutForDoc(eq(docRef))).andReturn(null).anyTimes(); - expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq( - "MySpace.MyMenuItemDoc"), same(getXContext()))).andReturn(true).atLeastOnce(); + expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), + eq("MySpace.MyMenuItemDoc"), same(getXContext()))).andReturn(true).atLeastOnce(); replayDefault(); StringBuilder outStream = new StringBuilder(); nav.openMenuItemOut(outStream, menuItem.getDocumentReference(), false, false, false, 2); @@ -309,8 +309,8 @@ public void testOpenMenuItemOut_notActive() throws Exception { public void testIsRestrictedRights() throws Exception { DocumentReference docRef = new DocumentReference(getXContext().getDatabase(), "MySpace", "MyMenuItemDoc"); - expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq( - "MySpace.MyMenuItemDoc"), same(getXContext()))).andThrow(new XWikiException()); + expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), + eq("MySpace.MyMenuItemDoc"), same(getXContext()))).andThrow(new XWikiException()); replayDefault(); assertFalse(nav.isRestrictedRights(docRef)); verifyDefault(); @@ -322,17 +322,17 @@ public void testOpenMenuItemOut_restrictedAccessRights() throws Exception { DocumentReference docRef = new DocumentReference(getXContext().getDatabase(), "MySpace", "MyMenuItemDoc"); PageTypeReference pageTypeRef = createDefaultMock(PageTypeReference.class); - expect(ptResolverServiceMock.getPageTypeRefForDocWithDefault(eq(docRef))).andReturn( - pageTypeRef); - expect(wUServiceMock.getDocumentParentsList(isA(DocumentReference.class), - anyBoolean())).andReturn(Arrays.asList(getDocRefForDocName("bla"), - getDocRefForDocName("bli"), getDocRefForDocName("blu"))); + expect(ptResolverServiceMock.getPageTypeRefForDocWithDefault(eq(docRef))) + .andReturn(pageTypeRef); + expect(wUServiceMock.getDocumentParentsList(isA(DocumentReference.class), anyBoolean())) + .andReturn(Arrays.asList(getDocRefForDocName("bla"), getDocRefForDocName("bli"), + getDocRefForDocName("blu"))); expect(pageTypeRef.getConfigName()).andReturn(pageType); BaseObject menuItem = new BaseObject(); menuItem.setDocumentReference(docRef); expect(mockLayoutCmd.getPageLayoutForDoc(eq(docRef))).andReturn(null).anyTimes(); - expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq( - "MySpace.MyMenuItemDoc"), same(getXContext()))).andReturn(false).atLeastOnce(); + expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), + eq("MySpace.MyMenuItemDoc"), same(getXContext()))).andReturn(false).atLeastOnce(); replayDefault(); StringBuilder outStream = new StringBuilder(); nav.openMenuItemOut(outStream, menuItem.getDocumentReference(), false, false, false, 2); @@ -348,17 +348,17 @@ public void testOpenMenuItemOut_active() throws Exception { DocumentReference docRef = new DocumentReference(getXContext().getDatabase(), "MySpace", "MyMenuItemDoc"); PageTypeReference pageTypeRef = createDefaultMock(PageTypeReference.class); - expect(ptResolverServiceMock.getPageTypeRefForDocWithDefault(eq(docRef))).andReturn( - pageTypeRef); - expect(wUServiceMock.getDocumentParentsList(isA(DocumentReference.class), - anyBoolean())).andReturn(Arrays.asList(getDocRefForDocName("bla"), - getDocRefForDocName("bli"), getDocRefForDocName("blu"), docRef)); + expect(ptResolverServiceMock.getPageTypeRefForDocWithDefault(eq(docRef))) + .andReturn(pageTypeRef); + expect(wUServiceMock.getDocumentParentsList(isA(DocumentReference.class), anyBoolean())) + .andReturn(Arrays.asList(getDocRefForDocName("bla"), getDocRefForDocName("bli"), + getDocRefForDocName("blu"), docRef)); expect(pageTypeRef.getConfigName()).andReturn(pageType); BaseObject menuItem = new BaseObject(); menuItem.setDocumentReference(docRef); expect(mockLayoutCmd.getPageLayoutForDoc(eq(docRef))).andReturn(null).anyTimes(); - expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq( - "MySpace.MyMenuItemDoc"), same(getXContext()))).andReturn(true).atLeastOnce(); + expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), + eq("MySpace.MyMenuItemDoc"), same(getXContext()))).andReturn(true).atLeastOnce(); replayDefault(); StringBuilder outStream = new StringBuilder(); nav.openMenuItemOut(outStream, menuItem.getDocumentReference(), false, false, false, 2); @@ -378,8 +378,8 @@ public void testGetMenuPartForLevel_firstLevel() { @Test public void testGetMenuPartForLevel_secondLevel() { nav.setMenuPart("menuPartTest"); - assertEquals("menuPart must only be concidered on first level.", "", nav.getMenuPartForLevel( - 2)); + assertEquals("menuPart must only be concidered on first level.", "", + nav.getMenuPartForLevel(2)); } @Test @@ -431,23 +431,23 @@ public void testGetCssClasses_withOut_CM() throws XWikiException { DocumentReference docRef = new DocumentReference(getXContext().getDatabase(), "MySpace", "MyMenuItemDoc"); PageTypeReference pageTypeRef = createDefaultMock(PageTypeReference.class); - expect(ptResolverServiceMock.getPageTypeRefForDocWithDefault(eq(docRef))).andReturn( - pageTypeRef); - expect(wUServiceMock.getDocumentParentsList(isA(DocumentReference.class), - anyBoolean())).andReturn(Arrays.asList(getDocRefForDocName("bla"), - getDocRefForDocName("bli"), getDocRefForDocName("blu"))); + expect(ptResolverServiceMock.getPageTypeRefForDocWithDefault(eq(docRef))) + .andReturn(pageTypeRef); + expect(wUServiceMock.getDocumentParentsList(isA(DocumentReference.class), anyBoolean())) + .andReturn(Arrays.asList(getDocRefForDocName("bla"), getDocRefForDocName("bli"), + getDocRefForDocName("blu"))); expect(pageTypeRef.getConfigName()).andReturn(pageType); BaseObject menuItem = new BaseObject(); menuItem.setDocumentReference(docRef); expect(mockLayoutCmd.getPageLayoutForDoc(eq(docRef))).andReturn(null).anyTimes(); - expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq( - "MySpace.MyMenuItemDoc"), same(getXContext()))).andReturn(true).atLeastOnce(); + expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), + eq("MySpace.MyMenuItemDoc"), same(getXContext()))).andReturn(true).atLeastOnce(); replayDefault(); String cssClasses = nav.getCssClasses(menuItem.getDocumentReference(), false, false, false, false, 2); verifyDefault(); - assertFalse("Expected to NOT find the cmCSSclass. [" + cssClasses + "]", (" " + cssClasses - + " ").contains(" cel_cm_navigation_menuitem ")); + assertFalse("Expected to NOT find the cmCSSclass. [" + cssClasses + "]", + (" " + cssClasses + " ").contains(" cel_cm_navigation_menuitem ")); } @Test @@ -456,22 +456,22 @@ public void testGetCssClasses_pageType() throws XWikiException { DocumentReference docRef = new DocumentReference(getXContext().getDatabase(), "MySpace", "MyMenuItemDoc"); PageTypeReference pageTypeRef = createDefaultMock(PageTypeReference.class); - expect(ptResolverServiceMock.getPageTypeRefForDocWithDefault(eq(docRef))).andReturn( - pageTypeRef); + expect(ptResolverServiceMock.getPageTypeRefForDocWithDefault(eq(docRef))) + .andReturn(pageTypeRef); expect(pageTypeRef.getConfigName()).andReturn(pageType); - expect(wUServiceMock.getDocumentParentsList(isA(DocumentReference.class), - anyBoolean())).andReturn(Arrays.asList(getDocRefForDocName("bla"), - getDocRefForDocName("bli"), getDocRefForDocName("blu"))); + expect(wUServiceMock.getDocumentParentsList(isA(DocumentReference.class), anyBoolean())) + .andReturn(Arrays.asList(getDocRefForDocName("bla"), getDocRefForDocName("bli"), + getDocRefForDocName("blu"))); BaseObject menuItem = new BaseObject(); menuItem.setDocumentReference(docRef); expect(mockLayoutCmd.getPageLayoutForDoc(eq(docRef))).andReturn(null).anyTimes(); - expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq( - "MySpace.MyMenuItemDoc"), same(getXContext()))).andReturn(true).atLeastOnce(); + expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), + eq("MySpace.MyMenuItemDoc"), same(getXContext()))).andReturn(true).atLeastOnce(); replayDefault(); String cssClasses = nav.getCssClasses(docRef, true, false, false, false, 3); verifyDefault(); - assertTrue("Expected to found pageType in css classes. [" + cssClasses + "]", (" " + cssClasses - + " ").contains(" " + pageType + " ")); + assertTrue("Expected to found pageType in css classes. [" + cssClasses + "]", + (" " + cssClasses + " ").contains(" " + pageType + " ")); } @Test @@ -480,24 +480,24 @@ public void testGetCssClasses_pageLayout() throws XWikiException { DocumentReference docRef = new DocumentReference(getXContext().getDatabase(), "MySpace", "MyMenuItemDoc"); PageTypeReference pageTypeRef = createDefaultMock(PageTypeReference.class); - expect(ptResolverServiceMock.getPageTypeRefForDocWithDefault(eq(docRef))).andReturn( - pageTypeRef); + expect(ptResolverServiceMock.getPageTypeRefForDocWithDefault(eq(docRef))) + .andReturn(pageTypeRef); expect(pageTypeRef.getConfigName()).andReturn(pageType); - expect(wUServiceMock.getDocumentParentsList(isA(DocumentReference.class), - anyBoolean())).andReturn(Arrays.asList(getDocRefForDocName("bla"), - getDocRefForDocName("bli"), getDocRefForDocName("blu"))); + expect(wUServiceMock.getDocumentParentsList(isA(DocumentReference.class), anyBoolean())) + .andReturn(Arrays.asList(getDocRefForDocName("bla"), getDocRefForDocName("bli"), + getDocRefForDocName("blu"))); BaseObject menuItem = new BaseObject(); menuItem.setDocumentReference(docRef); - SpaceReference layoutRef = new SpaceReference("MyLayout", new WikiReference( - getXContext().getDatabase())); + SpaceReference layoutRef = new SpaceReference("MyLayout", + new WikiReference(getXContext().getDatabase())); expect(mockLayoutCmd.getPageLayoutForDoc(eq(docRef))).andReturn(layoutRef).anyTimes(); - expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq( - "MySpace.MyMenuItemDoc"), same(getXContext()))).andReturn(true).atLeastOnce(); + expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), + eq("MySpace.MyMenuItemDoc"), same(getXContext()))).andReturn(true).atLeastOnce(); replayDefault(); String cssClasses = nav.getCssClasses(docRef, true, false, false, false, 2); verifyDefault(); - assertTrue("Expected to found pageLayout in css classes. [" + cssClasses + "]", (" " - + cssClasses + " ").contains(" layout_MyLayout ")); + assertTrue("Expected to found pageLayout in css classes. [" + cssClasses + "]", + (" " + cssClasses + " ").contains(" layout_MyLayout ")); } @Test @@ -506,24 +506,24 @@ public void testGetCssClasses_pageSpace() throws XWikiException { DocumentReference docRef = new DocumentReference(getXContext().getDatabase(), "MySpace", "MyMenuItemDoc"); PageTypeReference pageTypeRef = createDefaultMock(PageTypeReference.class); - expect(ptResolverServiceMock.getPageTypeRefForDocWithDefault(eq(docRef))).andReturn( - pageTypeRef); + expect(ptResolverServiceMock.getPageTypeRefForDocWithDefault(eq(docRef))) + .andReturn(pageTypeRef); expect(pageTypeRef.getConfigName()).andReturn(pageType); - expect(wUServiceMock.getDocumentParentsList(isA(DocumentReference.class), - anyBoolean())).andReturn(Arrays.asList(getDocRefForDocName("bla"), - getDocRefForDocName("bli"), getDocRefForDocName("blu"))); + expect(wUServiceMock.getDocumentParentsList(isA(DocumentReference.class), anyBoolean())) + .andReturn(Arrays.asList(getDocRefForDocName("bla"), getDocRefForDocName("bli"), + getDocRefForDocName("blu"))); BaseObject menuItem = new BaseObject(); menuItem.setDocumentReference(docRef); - SpaceReference layoutRef = new SpaceReference("MyLayout", new WikiReference( - getXContext().getDatabase())); + SpaceReference layoutRef = new SpaceReference("MyLayout", + new WikiReference(getXContext().getDatabase())); expect(mockLayoutCmd.getPageLayoutForDoc(eq(docRef))).andReturn(layoutRef).anyTimes(); - expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq( - "MySpace.MyMenuItemDoc"), same(getXContext()))).andReturn(true).atLeastOnce(); + expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), + eq("MySpace.MyMenuItemDoc"), same(getXContext()))).andReturn(true).atLeastOnce(); replayDefault(); String cssClasses = nav.getCssClasses(docRef, true, false, false, false, 2); verifyDefault(); - assertTrue("Expected to found page-space in css classes. [" + cssClasses + "]", (" " - + cssClasses + " ").contains(" cel_nav_nodeSpace_MySpace")); + assertTrue("Expected to found page-space in css classes. [" + cssClasses + "]", + (" " + cssClasses + " ").contains(" cel_nav_nodeSpace_MySpace")); } @Test @@ -532,24 +532,24 @@ public void testGetCssClasses_pageName() throws XWikiException { DocumentReference docRef = new DocumentReference(getXContext().getDatabase(), "MySpace", "MyMenuItemDoc"); PageTypeReference pageTypeRef = createDefaultMock(PageTypeReference.class); - expect(ptResolverServiceMock.getPageTypeRefForDocWithDefault(eq(docRef))).andReturn( - pageTypeRef); + expect(ptResolverServiceMock.getPageTypeRefForDocWithDefault(eq(docRef))) + .andReturn(pageTypeRef); expect(pageTypeRef.getConfigName()).andReturn(pageType); - expect(wUServiceMock.getDocumentParentsList(isA(DocumentReference.class), - anyBoolean())).andReturn(Arrays.asList(getDocRefForDocName("bla"), - getDocRefForDocName("bli"), getDocRefForDocName("blu"))); + expect(wUServiceMock.getDocumentParentsList(isA(DocumentReference.class), anyBoolean())) + .andReturn(Arrays.asList(getDocRefForDocName("bla"), getDocRefForDocName("bli"), + getDocRefForDocName("blu"))); BaseObject menuItem = new BaseObject(); menuItem.setDocumentReference(docRef); - SpaceReference layoutRef = new SpaceReference("MyLayout", new WikiReference( - getXContext().getDatabase())); + SpaceReference layoutRef = new SpaceReference("MyLayout", + new WikiReference(getXContext().getDatabase())); expect(mockLayoutCmd.getPageLayoutForDoc(eq(docRef))).andReturn(layoutRef).anyTimes(); - expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq( - "MySpace.MyMenuItemDoc"), same(getXContext()))).andReturn(true).atLeastOnce(); + expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), + eq("MySpace.MyMenuItemDoc"), same(getXContext()))).andReturn(true).atLeastOnce(); replayDefault(); String cssClasses = nav.getCssClasses(docRef, true, false, false, false, 2); verifyDefault(); - assertTrue("Expected to found page-space in css classes. [" + cssClasses + "]", (" " - + cssClasses + " ").contains(" cel_nav_nodeName_MyMenuItemDoc")); + assertTrue("Expected to found page-space in css classes. [" + cssClasses + "]", + (" " + cssClasses + " ").contains(" cel_nav_nodeName_MyMenuItemDoc")); } @Test @@ -599,8 +599,8 @@ public void testGetCssClasses_numItem_odd() throws XWikiException { verifyDefault(); assertFalse("Expected NOT to find 'cel_nav_even' in css classes." + " [" + cssClasses + "]", (" " + cssClasses + " ").contains(" cel_nav_even ")); - assertTrue("Expected to find 'cel_nav_odd' in css classes." + " [" + cssClasses + "]", (" " - + cssClasses + " ").contains(" cel_nav_odd ")); + assertTrue("Expected to find 'cel_nav_odd' in css classes." + " [" + cssClasses + "]", + (" " + cssClasses + " ").contains(" cel_nav_odd ")); } @Test @@ -608,10 +608,10 @@ public void testGetCssClasses_numItem_even() throws XWikiException { replayDefault(); String cssClasses = nav.getCssClasses(null, true, false, false, true, 4); verifyDefault(); - assertTrue("Expected to find 'cel_nav_even' in css classes." + " [" + cssClasses + "]", (" " - + cssClasses + " ").contains(" cel_nav_even ")); - assertFalse("Expected NOT to find 'cel_nav_odd' in css classes." + " [" + cssClasses + "]", (" " - + cssClasses + " ").contains(" cel_nav_odd ")); + assertTrue("Expected to find 'cel_nav_even' in css classes." + " [" + cssClasses + "]", + (" " + cssClasses + " ").contains(" cel_nav_even ")); + assertFalse("Expected NOT to find 'cel_nav_odd' in css classes." + " [" + cssClasses + "]", + (" " + cssClasses + " ").contains(" cel_nav_odd ")); } @Test @@ -619,8 +619,8 @@ public void testGetCssClasses_numItem() throws XWikiException { replayDefault(); String cssClasses = nav.getCssClasses(null, true, false, false, true, 4321); verifyDefault(); - assertTrue("Expected to find 'cel_nav_item4321' in css classes." + " [" + cssClasses + "]", (" " - + cssClasses + " ").contains(" cel_nav_item4321 ")); + assertTrue("Expected to find 'cel_nav_item4321' in css classes." + " [" + cssClasses + "]", + (" " + cssClasses + " ").contains(" cel_nav_item4321 ")); } @Test @@ -630,17 +630,17 @@ public void testGetMenuSpace() { String spaceName = "MySpace"; expect(wUServiceMock.hasParentSpace(eq(spaceName))).andReturn(true); expect(wUServiceMock.getParentSpace(eq(spaceName))).andReturn(parentSpaceName); - EntityReference mySpaceRef = new SpaceReference(spaceName, new WikiReference( - getXContext().getDatabase())); - expect(tNServiceMock.getSubNodesForParent(eq(mySpaceRef), same(navFilterMock))).andReturn( - emptyMenuItemList); + EntityReference mySpaceRef = new SpaceReference(spaceName, + new WikiReference(getXContext().getDatabase())); + expect(tNServiceMock.getSubNodesForParent(eq(mySpaceRef), same(navFilterMock))) + .andReturn(emptyMenuItemList); nav.setMenuPart(""); navFilterMock.setMenuPart(eq("")); expectLastCall().once(); - SpaceReference parentSpaceRef = new SpaceReference(parentSpaceName, new WikiReference( - getXContext().getDatabase())); - expect(wUServiceMock.resolveSpaceReference(eq(parentSpaceName))).andReturn( - parentSpaceRef).anyTimes(); + SpaceReference parentSpaceRef = new SpaceReference(parentSpaceName, + new WikiReference(getXContext().getDatabase())); + expect(wUServiceMock.resolveSpaceReference(eq(parentSpaceName))).andReturn(parentSpaceRef) + .anyTimes(); replayDefault(); String menuSpace = nav.getMenuSpace(getXContext()); verifyDefault(); @@ -652,9 +652,9 @@ public void testGetMenuSpace() { public void testIsActiveMenuItem_isActive() { BaseObject menuItem = new BaseObject(); menuItem.setDocumentReference(currentDocRef); - expect(wUServiceMock.getDocumentParentsList(eq(currentDocRef), anyBoolean())).andReturn( - Arrays.asList(getDocRefForDocName("bla"), getDocRefForDocName("bli"), getDocRefForDocName( - "blu"), currentDocRef)); + expect(wUServiceMock.getDocumentParentsList(eq(currentDocRef), anyBoolean())) + .andReturn(Arrays.asList(getDocRefForDocName("bla"), getDocRefForDocName("bli"), + getDocRefForDocName("blu"), currentDocRef)); replayDefault(); assertTrue(nav.isActiveMenuItem(menuItem.getDocumentReference())); verifyDefault(); @@ -664,9 +664,9 @@ public void testIsActiveMenuItem_isActive() { public void testIsActiveMenuItem_isActive_currentDoc() { BaseObject menuItem = new BaseObject(); menuItem.setDocumentReference(currentDocRef); - expect(wUServiceMock.getDocumentParentsList(eq(currentDocRef), anyBoolean())).andReturn( - Arrays.asList(getDocRefForDocName("bla"), getDocRefForDocName("bli"), getDocRefForDocName( - "blu"))); + expect(wUServiceMock.getDocumentParentsList(eq(currentDocRef), anyBoolean())) + .andReturn(Arrays.asList(getDocRefForDocName("bla"), getDocRefForDocName("bli"), + getDocRefForDocName("blu"))); replayDefault(); assertTrue(nav.isActiveMenuItem(menuItem.getDocumentReference())); verifyDefault(); @@ -675,11 +675,11 @@ public void testIsActiveMenuItem_isActive_currentDoc() { @Test public void testIsActiveMenuItem_isNOTActive() { BaseObject menuItem = new BaseObject(); - menuItem.setDocumentReference(new DocumentReference(getXContext().getDatabase(), "MySpace", - "isNotActiveDoc")); - expect(wUServiceMock.getDocumentParentsList(eq(currentDocRef), anyBoolean())).andReturn( - Arrays.asList(getDocRefForDocName("bla"), getDocRefForDocName("bli"), getDocRefForDocName( - "blu"))); + menuItem.setDocumentReference( + new DocumentReference(getXContext().getDatabase(), "MySpace", "isNotActiveDoc")); + expect(wUServiceMock.getDocumentParentsList(eq(currentDocRef), anyBoolean())) + .andReturn(Arrays.asList(getDocRefForDocName("bla"), getDocRefForDocName("bli"), + getDocRefForDocName("blu"))); replayDefault(); assertFalse(nav.isActiveMenuItem(menuItem.getDocumentReference())); verifyDefault(); @@ -687,9 +687,9 @@ public void testIsActiveMenuItem_isNOTActive() { @Test public void testIsActiveMenuItem_menuItemNULL() { - expect(wUServiceMock.getDocumentParentsList(eq(currentDocRef), anyBoolean())).andReturn( - Arrays.asList(getDocRefForDocName("bla"), getDocRefForDocName("bli"), getDocRefForDocName( - "blu"), null)); + expect(wUServiceMock.getDocumentParentsList(eq(currentDocRef), anyBoolean())) + .andReturn(Arrays.asList(getDocRefForDocName("bla"), getDocRefForDocName("bli"), + getDocRefForDocName("blu"), null)); replayDefault(); assertFalse(nav.isActiveMenuItem(null)); verifyDefault(); @@ -699,9 +699,9 @@ public void testIsActiveMenuItem_menuItemNULL() { public void testShowSubmenuForMenuItem_isActive() { BaseObject menuItem = new BaseObject(); menuItem.setDocumentReference(currentDocRef); - expect(wUServiceMock.getDocumentParentsList(eq(currentDocRef), anyBoolean())).andReturn( - Arrays.asList(getDocRefForDocName("bla"), getDocRefForDocName("bli"), getDocRefForDocName( - "blu"), currentDocRef)); + expect(wUServiceMock.getDocumentParentsList(eq(currentDocRef), anyBoolean())) + .andReturn(Arrays.asList(getDocRefForDocName("bla"), getDocRefForDocName("bli"), + getDocRefForDocName("blu"), currentDocRef)); replayDefault(); assertTrue(nav.showSubmenuForMenuItem(menuItem.getDocumentReference(), 1, getXContext())); verifyDefault(); @@ -710,11 +710,11 @@ public void testShowSubmenuForMenuItem_isActive() { @Test public void testShowSubmenuForMenuItem_isNOTActive() { BaseObject menuItem = new BaseObject(); - menuItem.setDocumentReference(new DocumentReference(getXContext().getDatabase(), "MySpace", - "isNotActiveDoc")); - expect(wUServiceMock.getDocumentParentsList(eq(currentDocRef), anyBoolean())).andReturn( - Arrays.asList(getDocRefForDocName("bla"), getDocRefForDocName("bli"), getDocRefForDocName( - "blu"))); + menuItem.setDocumentReference( + new DocumentReference(getXContext().getDatabase(), "MySpace", "isNotActiveDoc")); + expect(wUServiceMock.getDocumentParentsList(eq(currentDocRef), anyBoolean())) + .andReturn(Arrays.asList(getDocRefForDocName("bla"), getDocRefForDocName("bli"), + getDocRefForDocName("blu"))); replayDefault(); assertFalse(nav.showSubmenuForMenuItem(menuItem.getDocumentReference(), 1, getXContext())); verifyDefault(); @@ -723,8 +723,8 @@ public void testShowSubmenuForMenuItem_isNOTActive() { @Test public void testShowSubmenuForMenuItem_isNOTActive_ShowAll() { BaseObject menuItem = new BaseObject(); - menuItem.setDocumentReference(new DocumentReference(getXContext().getDatabase(), "MySpace", - "isNotActiveDoc")); + menuItem.setDocumentReference( + new DocumentReference(getXContext().getDatabase(), "MySpace", "isNotActiveDoc")); // FIXME getDocumentParentsList not needed anymore? // expect(wUServiceMock.getDocumentParentsList(eq(currentDocRef), anyBoolean()) // ).andReturn(Arrays.asList(getDocRefForDocName("bla"), @@ -738,8 +738,8 @@ public void testShowSubmenuForMenuItem_isNOTActive_ShowAll() { @Test public void testShowSubmenuForMenuItem_isNOTActive_showHierarchyLevel() { BaseObject menuItem = new BaseObject(); - menuItem.setDocumentReference(new DocumentReference(getXContext().getDatabase(), "MySpace", - "isNotActiveDoc")); + menuItem.setDocumentReference( + new DocumentReference(getXContext().getDatabase(), "MySpace", "isNotActiveDoc")); // FIXME getDocumentParentsList not needed anymore? // expect(wUServiceMock.getDocumentParentsList(eq(currentDocRef), anyBoolean()) // ).andReturn(Arrays.asList(getDocRefForDocName("bla"), @@ -754,11 +754,11 @@ public void testShowSubmenuForMenuItem_isNOTActive_showHierarchyLevel() { @Test public void testShowSubmenuForMenuItem_isNOTActive_showHierarchyLevel_Over() { BaseObject menuItem = new BaseObject(); - menuItem.setDocumentReference(new DocumentReference(getXContext().getDatabase(), "MySpace", - "isNotActiveDoc")); - expect(wUServiceMock.getDocumentParentsList(eq(currentDocRef), anyBoolean())).andReturn( - Arrays.asList(getDocRefForDocName("bla"), getDocRefForDocName("bli"), getDocRefForDocName( - "blu"))); + menuItem.setDocumentReference( + new DocumentReference(getXContext().getDatabase(), "MySpace", "isNotActiveDoc")); + expect(wUServiceMock.getDocumentParentsList(eq(currentDocRef), anyBoolean())) + .andReturn(Arrays.asList(getDocRefForDocName("bla"), getDocRefForDocName("bli"), + getDocRefForDocName("blu"))); nav.setShowAll(false); nav.setShowInactiveToLevel(3); replayDefault(); @@ -770,9 +770,9 @@ public void testShowSubmenuForMenuItem_isNOTActive_showHierarchyLevel_Over() { public void testShowSubmenuForMenuItem_isActive_showHierarchyLevel_Over() { BaseObject menuItem = new BaseObject(); menuItem.setDocumentReference(currentDocRef); - expect(wUServiceMock.getDocumentParentsList(eq(currentDocRef), anyBoolean())).andReturn( - Arrays.asList(getDocRefForDocName("bla"), getDocRefForDocName("bli"), getDocRefForDocName( - "blu"), currentDocRef)); + expect(wUServiceMock.getDocumentParentsList(eq(currentDocRef), anyBoolean())) + .andReturn(Arrays.asList(getDocRefForDocName("bla"), getDocRefForDocName("bli"), + getDocRefForDocName("blu"), currentDocRef)); nav.setShowAll(false); nav.setShowInactiveToLevel(3); replayDefault(); @@ -837,15 +837,15 @@ public void testLoadConfigFromObject_defaults() { "MySpace", "MyDoc"); BaseObject navConfigObj = new BaseObject(); navConfigObj.setDocumentReference(cellConfigDocRef); - navConfigObj.setXClassReference(getNavClasses().getNavigationConfigClassRef( - getXContext().getDatabase())); + navConfigObj.setXClassReference( + getNavClasses().getNavigationConfigClassRef(getXContext().getDatabase())); navFilterMock.setMenuPart(eq("")); expectLastCall().once(); String spaceName = "MySpace"; - SpaceReference mySpaceRef = new SpaceReference(spaceName, new WikiReference( - getXContext().getDatabase())); - expect(tNServiceMock.getSubNodesForParent(eq(mySpaceRef), same(navFilterMock))).andReturn( - Collections.emptyList()); + SpaceReference mySpaceRef = new SpaceReference(spaceName, + new WikiReference(getXContext().getDatabase())); + expect(tNServiceMock.getSubNodesForParent(eq(mySpaceRef), same(navFilterMock))) + .andReturn(Collections.emptyList()); expect(wUServiceMock.hasParentSpace(eq(spaceName))).andReturn(false); expect(wUServiceMock.resolveSpaceReference(eq(spaceName))).andReturn(mySpaceRef).anyTimes(); replayDefault(); @@ -862,14 +862,14 @@ public void testLoadConfigFromObject_menuSpace() { "MySpace", "MyDoc"); BaseObject navConfigObj = new BaseObject(); navConfigObj.setDocumentReference(cellConfigDocRef); - navConfigObj.setXClassReference(getNavClasses().getNavigationConfigClassRef( - getXContext().getDatabase())); + navConfigObj.setXClassReference( + getNavClasses().getNavigationConfigClassRef(getXContext().getDatabase())); String nodeSpaceName = "theMenuSpace"; navConfigObj.setStringValue("menu_space", nodeSpaceName); - SpaceReference parentSpaceRef = new SpaceReference(nodeSpaceName, new WikiReference( - getXContext().getDatabase())); - expect(wUServiceMock.resolveSpaceReference(eq(nodeSpaceName))).andReturn( - parentSpaceRef).anyTimes(); + SpaceReference parentSpaceRef = new SpaceReference(nodeSpaceName, + new WikiReference(getXContext().getDatabase())); + expect(wUServiceMock.resolveSpaceReference(eq(nodeSpaceName))).andReturn(parentSpaceRef) + .anyTimes(); replayDefault(); nav.loadConfigFromObject(navConfigObj); assertEquals("theMenuSpace", nav.getMenuSpace(getXContext())); @@ -882,15 +882,15 @@ public void testLoadConfigFromObject_menuSpace_empty() { "MySpace", "MyDoc"); BaseObject navConfigObj = new BaseObject(); navConfigObj.setDocumentReference(cellConfigDocRef); - navConfigObj.setXClassReference(getNavClasses().getNavigationConfigClassRef( - getXContext().getDatabase())); + navConfigObj.setXClassReference( + getNavClasses().getNavigationConfigClassRef(getXContext().getDatabase())); navFilterMock.setMenuPart(eq("")); expectLastCall().once(); String spaceName = "MySpace"; - EntityReference mySpaceRef = new SpaceReference(spaceName, new WikiReference( - getXContext().getDatabase())); - expect(tNServiceMock.getSubNodesForParent(eq(mySpaceRef), same(navFilterMock))).andReturn( - Collections.emptyList()); + EntityReference mySpaceRef = new SpaceReference(spaceName, + new WikiReference(getXContext().getDatabase())); + expect(tNServiceMock.getSubNodesForParent(eq(mySpaceRef), same(navFilterMock))) + .andReturn(Collections.emptyList()); expect(wUServiceMock.hasParentSpace(eq(spaceName))).andReturn(false); replayDefault(); nav.loadConfigFromObject(navConfigObj); @@ -904,12 +904,11 @@ public void testLoadConfigFromObject_presentationType_notEmpty() throws Exceptio "MySpace", "MyDoc"); BaseObject navConfigObj = new BaseObject(); navConfigObj.setDocumentReference(cellConfigDocRef); - navConfigObj.setXClassReference(getNavClasses().getNavigationConfigClassRef( - getXContext().getDatabase())); + navConfigObj.setXClassReference( + getNavClasses().getNavigationConfigClassRef(getXContext().getDatabase())); navConfigObj.setStringValue(INavigationClassConfig.PRESENTATION_TYPE_FIELD, "testPresentationType"); - IPresentationTypeRole componentInstance = registerComponentMock( - IPresentationTypeRole.class); + IPresentationTypeRole componentInstance = registerComponentMock(IPresentationTypeRole.class); replayDefault(); nav.loadConfigFromObject(navConfigObj); verifyDefault(); @@ -919,8 +918,8 @@ public void testLoadConfigFromObject_presentationType_notEmpty() throws Exceptio @Test public void testLoadConfig_defaults() { String spaceName = "MySpace"; - SpaceReference mySpaceRef = new SpaceReference(spaceName, new WikiReference( - getXContext().getDatabase())); + SpaceReference mySpaceRef = new SpaceReference(spaceName, + new WikiReference(getXContext().getDatabase())); NavigationConfig navConfig = new NavigationConfig.Builder().nodeSpaceRef(mySpaceRef).build(); replayDefault(); nav.loadConfig(navConfig); @@ -934,10 +933,10 @@ public void testLoadConfig_defaults() { @Test public void testLoadConfig_menuSpace() { String nodeSpaceName = "theMenuSpace"; - SpaceReference parentSpaceRef = new SpaceReference(nodeSpaceName, new WikiReference( - getXContext().getDatabase())); - NavigationConfig navConfig = new NavigationConfig.Builder().nodeSpaceRef( - parentSpaceRef).build(); + SpaceReference parentSpaceRef = new SpaceReference(nodeSpaceName, + new WikiReference(getXContext().getDatabase())); + NavigationConfig navConfig = new NavigationConfig.Builder().nodeSpaceRef(parentSpaceRef) + .build(); replayDefault(); nav.loadConfig(navConfig); assertEquals(parentSpaceRef, nav.getNodeSpaceRef()); @@ -948,8 +947,8 @@ public void testLoadConfig_menuSpace() { @Test public void testLoadConfig_menuSpace_empty() { String spaceName = "MySpace"; - SpaceReference mySpaceRef = new SpaceReference(spaceName, new WikiReference( - getXContext().getDatabase())); + SpaceReference mySpaceRef = new SpaceReference(spaceName, + new WikiReference(getXContext().getDatabase())); NavigationConfig navConfig = new NavigationConfig.Builder().nodeSpaceRef(mySpaceRef).build(); replayDefault(); nav.loadConfig(navConfig); @@ -960,11 +959,10 @@ public void testLoadConfig_menuSpace_empty() { @Test public void testLoadConfig_presentationType_notEmpty() throws Exception { - IPresentationTypeRole componentInstance = registerComponentMock( - IPresentationTypeRole.class); + IPresentationTypeRole componentInstance = registerComponentMock(IPresentationTypeRole.class); String presentationTypeHint = "testPresentationType"; - NavigationConfig navConfig = new NavigationConfig.Builder().presentationTypeHint( - presentationTypeHint).build(); + NavigationConfig navConfig = new NavigationConfig.Builder() + .presentationTypeHint(presentationTypeHint).build(); replayDefault(); nav.loadConfig(navConfig); assertEquals(componentInstance, nav.getPresentationType()); @@ -974,8 +972,7 @@ public void testLoadConfig_presentationType_notEmpty() throws Exception { @Test public void testSetPresentationType() throws Exception { - IPresentationTypeRole componentInstance = registerComponentMock( - IPresentationTypeRole.class); + IPresentationTypeRole componentInstance = registerComponentMock(IPresentationTypeRole.class); replayDefault(); nav.setPresentationType("testPresentationType"); verifyDefault(); @@ -984,8 +981,7 @@ public void testSetPresentationType() throws Exception { @Test public void testSetPresentationType_null() throws Exception { - IPresentationTypeRole componentInstance = createDefaultMock( - IPresentationTypeRole.class); + IPresentationTypeRole componentInstance = createDefaultMock(IPresentationTypeRole.class); nav.setPresentationType(componentInstance); replayDefault(); nav.setPresentationType((String) null); @@ -1019,8 +1015,7 @@ public void testWriteMenuItemContent_PresentationType() throws Exception { @Test public void testGetCMcssClass_default() { - IPresentationTypeRole componentInstance = createDefaultMock( - IPresentationTypeRole.class); + IPresentationTypeRole componentInstance = createDefaultMock(IPresentationTypeRole.class); nav.setPresentationType(componentInstance); expect(componentInstance.getDefaultCssClass()).andReturn("cel_cm_menu").atLeastOnce(); replayDefault(); @@ -1030,8 +1025,7 @@ public void testGetCMcssClass_default() { @Test public void testGetCMcssClass() { - IPresentationTypeRole componentInstance = createDefaultMock( - IPresentationTypeRole.class); + IPresentationTypeRole componentInstance = createDefaultMock(IPresentationTypeRole.class); nav.setPresentationType(componentInstance); replayDefault(); nav.setCMcssClass("cm_test_class"); @@ -1051,15 +1045,14 @@ public void testGetPageLayoutName_null() { @Test public void testGetPageLayoutName_overwritePresentationType() { - IPresentationTypeRole componentInstance = createDefaultMock( - IPresentationTypeRole.class); + IPresentationTypeRole componentInstance = createDefaultMock(IPresentationTypeRole.class); nav.setPresentationType(componentInstance); DocumentReference docRef = new DocumentReference(getXContext().getDatabase(), "MySpace", "MyMenuItemDoc"); - SpaceReference overwriteLayoutRef = new SpaceReference("MyOverwriteLayout", new WikiReference( - getXContext().getDatabase())); - SpaceReference layoutRef = new SpaceReference("MyLayout", new WikiReference( - getXContext().getDatabase())); + SpaceReference overwriteLayoutRef = new SpaceReference("MyOverwriteLayout", + new WikiReference(getXContext().getDatabase())); + SpaceReference layoutRef = new SpaceReference("MyLayout", + new WikiReference(getXContext().getDatabase())); expect(mockLayoutCmd.getPageLayoutForDoc(eq(docRef))).andReturn(layoutRef).anyTimes(); expect(componentInstance.getPageLayoutForDoc(eq(docRef))).andReturn(overwriteLayoutRef); replayDefault(); @@ -1071,8 +1064,8 @@ public void testGetPageLayoutName_overwritePresentationType() { public void testGetPageLayoutName() { DocumentReference docRef = new DocumentReference(getXContext().getDatabase(), "MySpace", "MyMenuItemDoc"); - SpaceReference layoutRef = new SpaceReference("MyLayout", new WikiReference( - getXContext().getDatabase())); + SpaceReference layoutRef = new SpaceReference("MyLayout", + new WikiReference(getXContext().getDatabase())); expect(mockLayoutCmd.getPageLayoutForDoc(eq(docRef))).andReturn(layoutRef); replayDefault(); assertEquals("layout_MyLayout", nav.getPageLayoutName(docRef)); @@ -1088,12 +1081,12 @@ public void testIncludeNavigation_noItemLevel1_hasEdit() throws Exception { navFilterMock.setMenuPart(eq("")); expectLastCall().atLeastOnce(); String spaceName = "MySpace"; - EntityReference mySpaceRef = new SpaceReference(spaceName, new WikiReference( - getXContext().getDatabase())); - expect(tNServiceMock.getSubNodesForParent(eq(mySpaceRef), same(navFilterMock))).andReturn( - Collections.emptyList()); - expect(tNServiceMock.getSubNodesForParent(eq(""), eq(spaceName), same( - navFilterMock))).andReturn(Collections.emptyList()); + EntityReference mySpaceRef = new SpaceReference(spaceName, + new WikiReference(getXContext().getDatabase())); + expect(tNServiceMock.getSubNodesForParent(eq(mySpaceRef), same(navFilterMock))) + .andReturn(Collections.emptyList()); + expect(tNServiceMock.getSubNodesForParent(eq(""), eq(spaceName), same(navFilterMock))) + .andReturn(Collections.emptyList()); expect(wUServiceMock.hasParentSpace(eq(spaceName))).andReturn(false); expect(mockRightService.hasAccessLevel(eq("edit"), eq(myUserName), eq("MySpace.MyCurrentDoc"), same(getXContext()))).andReturn(true); @@ -1134,30 +1127,31 @@ public void testIncludeNavigation_hasItemsLevel1() throws Exception { navFilterMock.setMenuPart(eq("")); expectLastCall().anyTimes(); String spaceName = "MySpace"; - EntityReference mySpaceRef = new SpaceReference(spaceName, new WikiReference( - getXContext().getDatabase())); + EntityReference mySpaceRef = new SpaceReference(spaceName, + new WikiReference(getXContext().getDatabase())); DocumentReference homeDocRef = new DocumentReference(getXContext().getDatabase(), spaceName, "Home"); List mainNodeList = Arrays.asList(new TreeNode(homeDocRef, null, 1)); - expect(tNServiceMock.getSubNodesForParent(eq(mySpaceRef), same(navFilterMock))).andReturn( - mainNodeList); - expect(tNServiceMock.getSubNodesForParent(eq(""), eq(spaceName), same( - navFilterMock))).andReturn(mainNodeList); - expect(tNServiceMock.getSubNodesForParent(eq("MySpace.Home"), eq(spaceName), same( - navFilterMock))).andReturn(Collections.emptyList()); - expect(ptResolverServiceMock.getPageTypeRefForDocWithDefault(eq(homeDocRef))).andReturn( - new PageTypeReference("RichText", "test", Collections.emptyList())).atLeastOnce(); + expect(tNServiceMock.getSubNodesForParent(eq(mySpaceRef), same(navFilterMock))) + .andReturn(mainNodeList); + expect(tNServiceMock.getSubNodesForParent(eq(""), eq(spaceName), same(navFilterMock))) + .andReturn(mainNodeList); + expect( + tNServiceMock.getSubNodesForParent(eq("MySpace.Home"), eq(spaceName), same(navFilterMock))) + .andReturn(Collections.emptyList()); + expect(ptResolverServiceMock.getPageTypeRefForDocWithDefault(eq(homeDocRef))) + .andReturn(new PageTypeReference("RichText", "test", Collections.emptyList())) + .atLeastOnce(); expect(mockLayoutCmd.getPageLayoutForDoc(eq(homeDocRef))).andReturn(null).atLeastOnce(); - expect(wUServiceMock.getDocumentParentsList(eq(currentDocRef), anyBoolean())).andReturn( - Collections.emptyList()).atLeastOnce(); - expect(wikMock.getURL(eq(homeDocRef), eq("view"), same(getXContext()))) - .andReturn("/Home"); - expect(wikMock.getSpacePreferenceAsInt(eq("use_navigation_images"), eq(0), same( - getXContext()))).andReturn(0); + expect(wUServiceMock.getDocumentParentsList(eq(currentDocRef), anyBoolean())) + .andReturn(Collections.emptyList()).atLeastOnce(); + expect(wikMock.getURL(eq(homeDocRef), eq("view"), same(getXContext()))).andReturn("/Home"); + expect(wikMock.getSpacePreferenceAsInt(eq("use_navigation_images"), eq(0), same(getXContext()))) + .andReturn(0); XWikiDocument homeDoc = new XWikiDocument(homeDocRef); homeDoc.setTitle("HomeTitle"); - expect(getMock(IModelAccessFacade.class).getOrCreateDocument(homeDocRef)) - .andReturn(homeDoc).anyTimes(); + expect(getMock(IModelAccessFacade.class).getOrCreateDocument(homeDocRef)).andReturn(homeDoc) + .anyTimes(); expect(getMock(IModelAccessFacade.class).getDocumentOpt(homeDocRef)) .andReturn(java.util.Optional.of(homeDoc)).anyTimes(); expect(getMock(IModelAccessFacade.class).getDocumentOpt(homeDocRef, "de")) @@ -1168,13 +1162,13 @@ public void testIncludeNavigation_hasItemsLevel1() throws Exception { getMessageToolStub().injectMessage(dictMenuNameKey, dictMenuNameKey); expect(wUServiceMock.getAdminMessageTool()).andReturn(getMessageToolStub()).anyTimes(); replayDefault(); - assertEquals("one tree node for level 1. Thus output expected.", "
  • HomeTitle
  • ", + assertEquals("one tree node for level 1. Thus output expected.", + "
  • HomeTitle
  • ", nav.includeNavigation()); verifyDefault(); } @@ -1189,8 +1183,8 @@ public void testIsEmpty_true() { expect(wUServiceMock.getParentForLevel(eq(3))).andReturn(parentRef).atLeastOnce(); navFilterMock.setMenuPart(eq("")); expectLastCall().anyTimes(); - expect(tNServiceMock.getSubNodesForParent(eq(parentRef), same(navFilterMock))).andReturn( - Collections.emptyList()); + expect(tNServiceMock.getSubNodesForParent(eq(parentRef), same(navFilterMock))) + .andReturn(Collections.emptyList()); replayDefault(); assertTrue(nav.isEmpty()); verifyDefault(); @@ -1209,8 +1203,8 @@ public void testIsEmpty_false() { DocumentReference subNodeRef = new DocumentReference(getXContext().getDatabase(), spaceName, "SubNodeDoc"); List nodeList = Arrays.asList(new TreeNode(subNodeRef, null, 1)); - expect(tNServiceMock.getSubNodesForParent(eq(parentRef), same(navFilterMock))).andReturn( - nodeList); + expect(tNServiceMock.getSubNodesForParent(eq(parentRef), same(navFilterMock))) + .andReturn(nodeList); replayDefault(); assertFalse(nav.isEmpty()); verifyDefault(); @@ -1227,8 +1221,8 @@ public void testIsEmpty_menuPart_sublevels() { expect(wUServiceMock.getParentForLevel(eq(3))).andReturn(parentRef).atLeastOnce(); navFilterMock.setMenuPart(eq("")); expectLastCall().anyTimes(); - expect(tNServiceMock.getSubNodesForParent(eq(parentRef), same(navFilterMock))).andReturn( - Collections.emptyList()); + expect(tNServiceMock.getSubNodesForParent(eq(parentRef), same(navFilterMock))) + .andReturn(Collections.emptyList()); replayDefault(); assertTrue(nav.isEmpty()); verifyDefault(); @@ -1245,8 +1239,8 @@ public void testIsEmpty_menuPart_mainLevel() { expect(wUServiceMock.getParentForLevel(eq(1))).andReturn(parentRef).atLeastOnce(); navFilterMock.setMenuPart(eq("myPart")); expectLastCall().anyTimes(); - expect(tNServiceMock.getSubNodesForParent(eq(parentRef), same(navFilterMock))).andReturn( - Collections.emptyList()); + expect(tNServiceMock.getSubNodesForParent(eq(parentRef), same(navFilterMock))) + .andReturn(Collections.emptyList()); replayDefault(); assertTrue(nav.isEmpty()); verifyDefault(); @@ -1353,10 +1347,10 @@ public void testGetCurrentMenuItems_noPaging_mainMenu() { TreeNode treeNode5 = new TreeNode(docRef5, mySpaceRef, 5); List expectedMenuItemsList = Arrays.asList(treeNode1, treeNode2, treeNode3, treeNode4, treeNode5); - expect(tNServiceMock.getSubNodesForParent(eq(""), eq(spaceName), same( - navFilterMock))).andReturn(expectedMenuItemsList).once(); - expect(tNServiceMock.getSubNodesForParent(eq(mySpaceRef), same(navFilterMock))).andReturn( - expectedMenuItemsList).once(); + expect(tNServiceMock.getSubNodesForParent(eq(""), eq(spaceName), same(navFilterMock))) + .andReturn(expectedMenuItemsList).once(); + expect(tNServiceMock.getSubNodesForParent(eq(mySpaceRef), same(navFilterMock))) + .andReturn(expectedMenuItemsList).once(); replayDefault(); assertEquals(expectedMenuItemsList, nav.getCurrentMenuItems(1, "")); verifyDefault(); @@ -1385,10 +1379,10 @@ public void testGetCurrentMenuItems_withPaging_mainMenu_zeroOffset() { TreeNode treeNode5 = new TreeNode(docRef5, mySpaceRef, 5); List allMenuItemsList = Arrays.asList(treeNode1, treeNode2, treeNode3, treeNode4, treeNode5); - expect(tNServiceMock.getSubNodesForParent(eq(""), eq(spaceName), same( - navFilterMock))).andReturn(allMenuItemsList).once(); - expect(tNServiceMock.getSubNodesForParent(eq(mySpaceRef), same(navFilterMock))).andReturn( - allMenuItemsList).once(); + expect(tNServiceMock.getSubNodesForParent(eq(""), eq(spaceName), same(navFilterMock))) + .andReturn(allMenuItemsList).once(); + expect(tNServiceMock.getSubNodesForParent(eq(mySpaceRef), same(navFilterMock))) + .andReturn(allMenuItemsList).once(); replayDefault(); List expectedMenuItemsList = Arrays.asList(treeNode1, treeNode2, treeNode3); assertEquals(expectedMenuItemsList, nav.getCurrentMenuItems(1, "")); @@ -1419,10 +1413,10 @@ public void testGetCurrentMenuItems_withPaging_mainMenu_NONzeroOffset() { TreeNode treeNode5 = new TreeNode(docRef5, mySpaceRef, 5); List allMenuItemsList = Arrays.asList(treeNode1, treeNode2, treeNode3, treeNode4, treeNode5); - expect(tNServiceMock.getSubNodesForParent(eq(""), eq(spaceName), same( - navFilterMock))).andReturn(allMenuItemsList).once(); - expect(tNServiceMock.getSubNodesForParent(eq(mySpaceRef), same(navFilterMock))).andReturn( - allMenuItemsList).once(); + expect(tNServiceMock.getSubNodesForParent(eq(""), eq(spaceName), same(navFilterMock))) + .andReturn(allMenuItemsList).once(); + expect(tNServiceMock.getSubNodesForParent(eq(mySpaceRef), same(navFilterMock))) + .andReturn(allMenuItemsList).once(); replayDefault(); List expectedMenuItemsList = Arrays.asList(treeNode2, treeNode3, treeNode4); assertEquals(expectedMenuItemsList, nav.getCurrentMenuItems(1, "")); @@ -1453,10 +1447,10 @@ public void testGetCurrentMenuItems_withPaging_mainMenu_OverflowEnd() { TreeNode treeNode5 = new TreeNode(docRef5, mySpaceRef, 5); List allMenuItemsList = Arrays.asList(treeNode1, treeNode2, treeNode3, treeNode4, treeNode5); - expect(tNServiceMock.getSubNodesForParent(eq(""), eq(spaceName), same( - navFilterMock))).andReturn(allMenuItemsList).once(); - expect(tNServiceMock.getSubNodesForParent(eq(mySpaceRef), same(navFilterMock))).andReturn( - allMenuItemsList).once(); + expect(tNServiceMock.getSubNodesForParent(eq(""), eq(spaceName), same(navFilterMock))) + .andReturn(allMenuItemsList).once(); + expect(tNServiceMock.getSubNodesForParent(eq(mySpaceRef), same(navFilterMock))) + .andReturn(allMenuItemsList).once(); replayDefault(); List expectedMenuItemsList = Arrays.asList(treeNode4, treeNode5); assertEquals(expectedMenuItemsList, nav.getCurrentMenuItems(1, "")); @@ -1487,10 +1481,10 @@ public void testGetCurrentMenuItems_withPaging_offsetOutOfBounds() { TreeNode treeNode5 = new TreeNode(docRef5, mySpaceRef, 5); List allMenuItemsList = Arrays.asList(treeNode1, treeNode2, treeNode3, treeNode4, treeNode5); - expect(tNServiceMock.getSubNodesForParent(eq(""), eq(spaceName), same( - navFilterMock))).andReturn(allMenuItemsList).once(); - expect(tNServiceMock.getSubNodesForParent(eq(mySpaceRef), same(navFilterMock))).andReturn( - allMenuItemsList).once(); + expect(tNServiceMock.getSubNodesForParent(eq(""), eq(spaceName), same(navFilterMock))) + .andReturn(allMenuItemsList).once(); + expect(tNServiceMock.getSubNodesForParent(eq(mySpaceRef), same(navFilterMock))) + .andReturn(allMenuItemsList).once(); replayDefault(); assertEquals(0, nav.getCurrentMenuItems(1, "").size()); verifyDefault(); @@ -1520,10 +1514,10 @@ public void testGetCurrentMenuItems_withPaging_mainMenu_negativOffset() { TreeNode treeNode5 = new TreeNode(docRef5, mySpaceRef, 5); List allMenuItemsList = Arrays.asList(treeNode1, treeNode2, treeNode3, treeNode4, treeNode5); - expect(tNServiceMock.getSubNodesForParent(eq(""), eq(spaceName), same( - navFilterMock))).andReturn(allMenuItemsList).once(); - expect(tNServiceMock.getSubNodesForParent(eq(mySpaceRef), same(navFilterMock))).andReturn( - allMenuItemsList).once(); + expect(tNServiceMock.getSubNodesForParent(eq(""), eq(spaceName), same(navFilterMock))) + .andReturn(allMenuItemsList).once(); + expect(tNServiceMock.getSubNodesForParent(eq(mySpaceRef), same(navFilterMock))) + .andReturn(allMenuItemsList).once(); replayDefault(); List expectedMenuItemsList = Arrays.asList(treeNode1, treeNode2, treeNode3); assertEquals(expectedMenuItemsList, nav.getCurrentMenuItems(1, "")); @@ -1554,10 +1548,10 @@ public void testGetCurrentMenuItems_NoPaging_mainMenu_NONzeroOffset() { TreeNode treeNode5 = new TreeNode(docRef5, mySpaceRef, 5); List allMenuItemsList = Arrays.asList(treeNode1, treeNode2, treeNode3, treeNode4, treeNode5); - expect(tNServiceMock.getSubNodesForParent(eq(""), eq(spaceName), same( - navFilterMock))).andReturn(allMenuItemsList).once(); - expect(tNServiceMock.getSubNodesForParent(eq(mySpaceRef), same(navFilterMock))).andReturn( - allMenuItemsList).once(); + expect(tNServiceMock.getSubNodesForParent(eq(""), eq(spaceName), same(navFilterMock))) + .andReturn(allMenuItemsList).once(); + expect(tNServiceMock.getSubNodesForParent(eq(mySpaceRef), same(navFilterMock))) + .andReturn(allMenuItemsList).once(); replayDefault(); List expectedMenuItemsList = Arrays.asList(treeNode4, treeNode5); assertEquals(expectedMenuItemsList, nav.getCurrentMenuItems(1, "")); diff --git a/src/test/java/com/celements/navigation/TreeNodeTest.java b/src/test/java/com/celements/navigation/TreeNodeTest.java index 19c7d2917..ffa8145db 100644 --- a/src/test/java/com/celements/navigation/TreeNodeTest.java +++ b/src/test/java/com/celements/navigation/TreeNodeTest.java @@ -47,9 +47,9 @@ public void setUp_TreeNodeTest() throws Exception { @Test public void test_ConstructorParentSpaceRef_partName_null() { - TreeNode treeNodeTest = new TreeNode(new DocumentReference(context.getDatabase(), "MySpace", - "myPage"), new SpaceReference("MySpace", new WikiReference(context.getDatabase())), 1, - (String) null); + TreeNode treeNodeTest = new TreeNode( + new DocumentReference(context.getDatabase(), "MySpace", "myPage"), + new SpaceReference("MySpace", new WikiReference(context.getDatabase())), 1, (String) null); replayDefault(); assertTrue(treeNode.equals(treeNodeTest)); assertEquals("", treeNodeTest.getPartName()); @@ -58,8 +58,9 @@ public void test_ConstructorParentSpaceRef_partName_null() { @Test public void test_ConstructorParentSpaceRef_partName_empty() { - TreeNode treeNodeTest = new TreeNode(new DocumentReference(context.getDatabase(), "MySpace", - "myPage"), new SpaceReference("MySpace", new WikiReference(context.getDatabase())), 1, ""); + TreeNode treeNodeTest = new TreeNode( + new DocumentReference(context.getDatabase(), "MySpace", "myPage"), + new SpaceReference("MySpace", new WikiReference(context.getDatabase())), 1, ""); replayDefault(); assertTrue(treeNode.equals(treeNodeTest)); assertEquals("", treeNodeTest.getPartName()); @@ -70,8 +71,9 @@ public void test_ConstructorParentSpaceRef_partName_empty() { public void test_ConstructorParentSpaceRef_strategy() { PartNameGetter partNameGetterMock = createDefaultMock(PartNameGetter.class); DocumentReference docRef2 = new DocumentReference(context.getDatabase(), "MySpace", "myPage"); - TreeNode treeNodeTest = new TreeNode(docRef2, new SpaceReference("MySpace", new WikiReference( - context.getDatabase())), 1, partNameGetterMock); + TreeNode treeNodeTest = new TreeNode(docRef2, + new SpaceReference("MySpace", new WikiReference(context.getDatabase())), 1, + partNameGetterMock); expect(partNameGetterMock.getPartName(eq(docRef2))).andReturn("mainPart").once(); replayDefault(); assertTrue(treeNode.equals(treeNodeTest)); @@ -84,8 +86,9 @@ public void test_ConstructorParentSpaceRef_strategy() { public void test_ConstructorParentSpaceRef_strategy_null() { PartNameGetter partNameGetterMock = createDefaultMock(PartNameGetter.class); DocumentReference docRef2 = new DocumentReference(context.getDatabase(), "MySpace", "myPage"); - TreeNode treeNodeTest = new TreeNode(docRef2, new SpaceReference("MySpace", new WikiReference( - context.getDatabase())), 1, partNameGetterMock); + TreeNode treeNodeTest = new TreeNode(docRef2, + new SpaceReference("MySpace", new WikiReference(context.getDatabase())), 1, + partNameGetterMock); expect(partNameGetterMock.getPartName(eq(docRef2))).andReturn((String) null).once(); replayDefault(); assertTrue(treeNode.equals(treeNodeTest)); @@ -98,11 +101,13 @@ public void test_ConstructorParentSpaceRef_strategy_null() { public void test_ConstructorParentSpaceRef_strategy_lazy() { PartNameGetter partNameGetterMock = createDefaultMock(PartNameGetter.class); DocumentReference docRef2 = new DocumentReference(context.getDatabase(), "MySpace", "myPage"); - TreeNode treeNodeTest = new TreeNode(docRef2, new SpaceReference("MySpace", new WikiReference( - context.getDatabase())), 1, partNameGetterMock); - expect(partNameGetterMock.getPartName(eq(docRef2))).andThrow(new RuntimeException( - "partNameGetter must be called lazily for" - + " NotMappedMenuItems for performance reasons.")).anyTimes(); + TreeNode treeNodeTest = new TreeNode(docRef2, + new SpaceReference("MySpace", new WikiReference(context.getDatabase())), 1, + partNameGetterMock); + expect(partNameGetterMock.getPartName(eq(docRef2))) + .andThrow(new RuntimeException("partNameGetter must be called lazily for" + + " NotMappedMenuItems for performance reasons.")) + .anyTimes(); replayDefault(); assertTrue(treeNode.equals(treeNodeTest)); verifyDefault(); @@ -110,9 +115,9 @@ public void test_ConstructorParentSpaceRef_strategy_lazy() { @Test public void test_ConstructorParentSpaceRef_partName() { - TreeNode treeNodeTest = new TreeNode(new DocumentReference(context.getDatabase(), "MySpace", - "myPage"), new SpaceReference("MySpace", new WikiReference(context.getDatabase())), 1, - "mainNav"); + TreeNode treeNodeTest = new TreeNode( + new DocumentReference(context.getDatabase(), "MySpace", "myPage"), + new SpaceReference("MySpace", new WikiReference(context.getDatabase())), 1, "mainNav"); replayDefault(); assertTrue(treeNode.equals(treeNodeTest)); assertEquals("mainNav", treeNodeTest.getPartName()); @@ -121,8 +126,8 @@ public void test_ConstructorParentSpaceRef_partName() { @Test public void testEquals() { - TreeNode treeNodeTest = new TreeNode(new DocumentReference(context.getDatabase(), "MySpace", - "myPage"), null, 1); + TreeNode treeNodeTest = new TreeNode( + new DocumentReference(context.getDatabase(), "MySpace", "myPage"), null, 1); replayDefault(); assertTrue(treeNode.equals(treeNodeTest)); verifyDefault(); @@ -130,10 +135,10 @@ public void testEquals() { @Test public void testEquals_position_notSameInteger() { - TreeNode treeNodeTest = new TreeNode(new DocumentReference(context.getDatabase(), "MySpace", - "myPage"), null, new Integer(1)); - TreeNode treeNodeTest2 = new TreeNode(new DocumentReference(context.getDatabase(), "MySpace", - "myPage"), null, new Integer(1)); + TreeNode treeNodeTest = new TreeNode( + new DocumentReference(context.getDatabase(), "MySpace", "myPage"), null, new Integer(1)); + TreeNode treeNodeTest2 = new TreeNode( + new DocumentReference(context.getDatabase(), "MySpace", "myPage"), null, new Integer(1)); replayDefault(); assertTrue(treeNodeTest2.equals(treeNodeTest)); verifyDefault(); @@ -148,8 +153,8 @@ public void testEquals_null() { @Test public void testHash() { - TreeNode treeNodeTest = new TreeNode(new DocumentReference(context.getDatabase(), "MySpace", - "myPage"), null, 1); + TreeNode treeNodeTest = new TreeNode( + new DocumentReference(context.getDatabase(), "MySpace", "myPage"), null, 1); replayDefault(); assertEquals(treeNodeTest.hashCode(), treeNode.hashCode()); verifyDefault(); @@ -157,10 +162,10 @@ public void testHash() { @Test public void testHash_null_position() { - TreeNode treeNodeTest = new TreeNode(new DocumentReference(context.getDatabase(), "MySpace", - "myPage"), null, null); - TreeNode treeNodeTest2 = new TreeNode(new DocumentReference(context.getDatabase(), "MySpace", - "myPage"), null, null); + TreeNode treeNodeTest = new TreeNode( + new DocumentReference(context.getDatabase(), "MySpace", "myPage"), null, null); + TreeNode treeNodeTest2 = new TreeNode( + new DocumentReference(context.getDatabase(), "MySpace", "myPage"), null, null); replayDefault(); assertEquals(treeNodeTest.hashCode(), treeNodeTest2.hashCode()); verifyDefault(); @@ -168,8 +173,9 @@ public void testHash_null_position() { @Test public void testEquals_parentSpaceRefConstructor() { - TreeNode treeNodeTest = new TreeNode(new DocumentReference(context.getDatabase(), "MySpace", - "myPage"), new SpaceReference("MySpace", new WikiReference(context.getDatabase())), 1, ""); + TreeNode treeNodeTest = new TreeNode( + new DocumentReference(context.getDatabase(), "MySpace", "myPage"), + new SpaceReference("MySpace", new WikiReference(context.getDatabase())), 1, ""); replayDefault(); assertTrue(treeNode.equals(treeNodeTest)); verifyDefault(); @@ -177,8 +183,9 @@ public void testEquals_parentSpaceRefConstructor() { @Test public void testHash_parentSpaceRefConstructor() { - TreeNode treeNodeTest = new TreeNode(new DocumentReference(context.getDatabase(), "MySpace", - "myPage"), new SpaceReference("MySpace", new WikiReference(context.getDatabase())), 1, ""); + TreeNode treeNodeTest = new TreeNode( + new DocumentReference(context.getDatabase(), "MySpace", "myPage"), + new SpaceReference("MySpace", new WikiReference(context.getDatabase())), 1, ""); replayDefault(); assertEquals(treeNodeTest.hashCode(), treeNode.hashCode()); verifyDefault(); @@ -186,10 +193,10 @@ public void testHash_parentSpaceRefConstructor() { @Test public void testGetParentRef_spaceRef() { - SpaceReference parentSpaceRef = new SpaceReference("MySpace", new WikiReference( - context.getDatabase())); - TreeNode treeNodeTest = new TreeNode(new DocumentReference(context.getDatabase(), "MySpace", - "myPage"), parentSpaceRef, 1, ""); + SpaceReference parentSpaceRef = new SpaceReference("MySpace", + new WikiReference(context.getDatabase())); + TreeNode treeNodeTest = new TreeNode( + new DocumentReference(context.getDatabase(), "MySpace", "myPage"), parentSpaceRef, 1, ""); replayDefault(); assertEquals(parentSpaceRef, treeNodeTest.getParentRef()); verifyDefault(); @@ -199,8 +206,8 @@ public void testGetParentRef_spaceRef() { public void testGetParentRef_docRef() { DocumentReference parentDocRef = new DocumentReference(context.getDatabase(), "myParentPage", "MySpace"); - TreeNode treeNodeTest = new TreeNode(new DocumentReference(context.getDatabase(), "MySpace", - "myPage"), parentDocRef, 1); + TreeNode treeNodeTest = new TreeNode( + new DocumentReference(context.getDatabase(), "MySpace", "myPage"), parentDocRef, 1); replayDefault(); assertEquals(parentDocRef, treeNodeTest.getParentRef()); verifyDefault(); @@ -208,9 +215,9 @@ public void testGetParentRef_docRef() { @Test public void testEquals_parentSpaceRefConstructorWithPartName() { - TreeNode treeNodeTest = new TreeNode(new DocumentReference(context.getDatabase(), "MySpace", - "myPage"), new SpaceReference("MySpace", new WikiReference(context.getDatabase())), 1, - "mainNav"); + TreeNode treeNodeTest = new TreeNode( + new DocumentReference(context.getDatabase(), "MySpace", "myPage"), + new SpaceReference("MySpace", new WikiReference(context.getDatabase())), 1, "mainNav"); replayDefault(); assertTrue(treeNode.equals(treeNodeTest)); verifyDefault(); @@ -218,9 +225,9 @@ public void testEquals_parentSpaceRefConstructorWithPartName() { @Test public void testHash_parentSpaceRefConstructorWithPartName() { - TreeNode treeNodeTest = new TreeNode(new DocumentReference(context.getDatabase(), "MySpace", - "myPage"), new SpaceReference("MySpace", new WikiReference(context.getDatabase())), 1, - "mainNav"); + TreeNode treeNodeTest = new TreeNode( + new DocumentReference(context.getDatabase(), "MySpace", "myPage"), + new SpaceReference("MySpace", new WikiReference(context.getDatabase())), 1, "mainNav"); replayDefault(); assertEquals(treeNodeTest.hashCode(), treeNode.hashCode()); verifyDefault(); diff --git a/src/test/java/com/celements/navigation/cmd/GetMappedMenuItemsForParentCommandTest.java b/src/test/java/com/celements/navigation/cmd/GetMappedMenuItemsForParentCommandTest.java index 97bd8d7d5..3e5e145ca 100644 --- a/src/test/java/com/celements/navigation/cmd/GetMappedMenuItemsForParentCommandTest.java +++ b/src/test/java/com/celements/navigation/cmd/GetMappedMenuItemsForParentCommandTest.java @@ -50,8 +50,8 @@ public void setUp_GetMappedMenuItemsForParentCommandTest() throws Exception { @Test public void testGetTreeNodesForParentKey_emptyResult_emptyKey_active() throws XWikiException { getMenuItemsCmd.setIsActive(true); - expect(mockStore.search(isA(String.class), eq(0), eq(0), (List) anyObject(), same( - context))).andReturn(new ArrayList<>()).anyTimes(); + expect(mockStore.search(isA(String.class), eq(0), eq(0), (List) anyObject(), same(context))) + .andReturn(new ArrayList<>()).anyTimes(); replayDefault(); assertNotNull(getMenuItemsCmd.getTreeNodesForParentKey("")); assertEquals(0, getMenuItemsCmd.getTreeNodesForParentKey("").size()); @@ -61,8 +61,8 @@ public void testGetTreeNodesForParentKey_emptyResult_emptyKey_active() throws XW @Test public void testGetTreeNodesForParentKey_emptyResult_emptyKey_inactive() throws XWikiException { getMenuItemsCmd.setIsActive(false); - expect(mockStore.search(isA(String.class), eq(0), eq(0), (List) anyObject(), same( - context))).andReturn(new ArrayList<>()).anyTimes(); + expect(mockStore.search(isA(String.class), eq(0), eq(0), (List) anyObject(), same(context))) + .andReturn(new ArrayList<>()).anyTimes(); replayDefault(); assertNotNull(getMenuItemsCmd.getTreeNodesForParentKey("")); assertEquals(0, getMenuItemsCmd.getTreeNodesForParentKey("").size()); diff --git a/src/test/java/com/celements/navigation/cmd/GetNotMappedMenuItemsForParentCommandTest.java b/src/test/java/com/celements/navigation/cmd/GetNotMappedMenuItemsForParentCommandTest.java index 4ffa5fbb8..269c23cbd 100644 --- a/src/test/java/com/celements/navigation/cmd/GetNotMappedMenuItemsForParentCommandTest.java +++ b/src/test/java/com/celements/navigation/cmd/GetNotMappedMenuItemsForParentCommandTest.java @@ -82,18 +82,18 @@ public void testGetCacheKey_space_different_db() { @Test public void testGetHQL() { String hql = notMappedItemsCmd.getHQL(); - assertTrue("missing doc name restriction [" + hql + "].", hql.matches( - ".*[where |and ]obj.name=doc.fullName .*")); - assertTrue("missing classname restriction [" + hql + "].", hql.matches( - ".*[where |and ]obj.className='Celements2.MenuItem' .*")); - assertTrue("missing object-property join restriction [" + hql + "].", hql.matches( - ".*[where |and ]obj.id = pos.id.id .*")); - assertTrue("missing property name restriction [" + hql + "].", hql.matches( - ".*[where |and ]and pos.id.name = 'menu_position' .*")); - assertTrue("missing translation restriction [" + hql + "].", hql.matches( - ".*[where |and ]doc.translation = 0 .*")); - assertTrue("expecting no trash restriction [" + hql + "].", hql.matches( - ".*[where |and ]and doc.space <> 'Trash' .*")); + assertTrue("missing doc name restriction [" + hql + "].", + hql.matches(".*[where |and ]obj.name=doc.fullName .*")); + assertTrue("missing classname restriction [" + hql + "].", + hql.matches(".*[where |and ]obj.className='Celements2.MenuItem' .*")); + assertTrue("missing object-property join restriction [" + hql + "].", + hql.matches(".*[where |and ]obj.id = pos.id.id .*")); + assertTrue("missing property name restriction [" + hql + "].", + hql.matches(".*[where |and ]and pos.id.name = 'menu_position' .*")); + assertTrue("missing translation restriction [" + hql + "].", + hql.matches(".*[where |and ]doc.translation = 0 .*")); + assertTrue("expecting no trash restriction [" + hql + "].", + hql.matches(".*[where |and ]and doc.space <> 'Trash' .*")); assertTrue("missing order by [" + hql + "].", hql.matches(".* order by doc.parent, pos.value")); } @@ -107,8 +107,8 @@ public void testGetTreeNodesForParentKey_miss() throws XWikiException { .andReturn(resultList).atLeastOnce(); DocumentReference myDoc1Ref = new DocumentReference(context.getDatabase(), "MySpace", "MyDoc1"); DocumentReference myDoc2Ref = new DocumentReference(context.getDatabase(), "MySpace", "MyDoc2"); - List expectedList = Arrays.asList(new TreeNode(myDoc1Ref, null, 1), new TreeNode( - myDoc2Ref, null, 2)); + List expectedList = Arrays.asList(new TreeNode(myDoc1Ref, null, 1), + new TreeNode(myDoc2Ref, null, 2)); XWikiDocument doc1 = new XWikiDocument(myDoc2Ref); doc1.setNew(false); expect(getMock(IModelAccessFacade.class).getOrCreateDocument(eq(myDoc1Ref))).andReturn(doc1) @@ -121,8 +121,8 @@ public void testGetTreeNodesForParentKey_miss() throws XWikiException { List resultTNlist = notMappedItemsCmd.getTreeNodesForParentKey("mydatabase:MySpace."); assertEquals(expectedList.size(), resultTNlist.size()); for (int i = 0; i < expectedList.size(); i++) { - assertEquals(expectedList.get(i).getDocumentReference(), resultTNlist.get( - i).getDocumentReference()); + assertEquals(expectedList.get(i).getDocumentReference(), + resultTNlist.get(i).getDocumentReference()); assertEquals(expectedList.get(i).getParentRef(), resultTNlist.get(i).getParentRef()); assertEquals(expectedList.get(i).getPosition(), resultTNlist.get(i).getPosition()); assertEquals(expectedList.get(i).getPartName(), resultTNlist.get(i).getPartName()); @@ -146,12 +146,12 @@ public void testGetTreeNodesForParentKey_differentParents_miss() throws XWikiExc expect(getMock(IModelAccessFacade.class).getOrCreateDocument(eq(myDoc2Ref))).andReturn(doc2) .atLeastOnce(); replayDefault(); - List resultTNlist = notMappedItemsCmd.getTreeNodesForParentKey( - "mydatabase:MySpace.MyDoc1"); + List resultTNlist = notMappedItemsCmd + .getTreeNodesForParentKey("mydatabase:MySpace.MyDoc1"); assertEquals(expectedList.size(), resultTNlist.size()); for (int i = 0; i < expectedList.size(); i++) { - assertEquals(expectedList.get(i).getDocumentReference(), resultTNlist.get( - i).getDocumentReference()); + assertEquals(expectedList.get(i).getDocumentReference(), + resultTNlist.get(i).getDocumentReference()); assertEquals(expectedList.get(i).getParentRef(), resultTNlist.get(i).getParentRef()); assertEquals(expectedList.get(i).getPosition(), resultTNlist.get(i).getPosition()); assertEquals(expectedList.get(i).getPartName(), resultTNlist.get(i).getPartName()); @@ -165,10 +165,9 @@ public void testGetTreeNodesForParentKey_hit() throws Exception { String searchParentKey = "mydatabase:MySpace."; String cacheKey = notMappedItemsCmd.getWikiCacheKey(searchParentKey); HashMap> mySpaceMap = new HashMap<>(); - List expectedList = Arrays.asList(new TreeNode(new DocumentReference( - context.getDatabase(), "MySpace", "MyDoc1"), null, 1), new TreeNode( - new DocumentReference(context.getDatabase(), "MySpace", "MyDoc2"), - null, 2)); + List expectedList = Arrays.asList( + new TreeNode(new DocumentReference(context.getDatabase(), "MySpace", "MyDoc1"), null, 1), + new TreeNode(new DocumentReference(context.getDatabase(), "MySpace", "MyDoc2"), null, 2)); mySpaceMap.put(searchParentKey, expectedList); notMappedItemsCmd.injectMapForTests(cacheKey, mySpaceMap); replayDefault(); @@ -183,11 +182,11 @@ public void testGetTreeNodesForParentKey_miss_empty() throws XWikiException { List resultList = Arrays.asList( Arrays.asList("MySpace.MyDoc1", "MySpace", "", 1).toArray(), Arrays.asList("MySpace.MyDoc2", "MySpace", "", 2).toArray()); - expect(mockStore.search(isA(String.class), eq(0), eq(0), same(context))).andReturn( - resultList).atLeastOnce(); + expect(mockStore.search(isA(String.class), eq(0), eq(0), same(context))) + .andReturn(resultList).atLeastOnce(); replayDefault(); - List resultTNlist = notMappedItemsCmd.getTreeNodesForParentKey( - "mydatabase:MySpace2."); + List resultTNlist = notMappedItemsCmd + .getTreeNodesForParentKey("mydatabase:MySpace2."); assertEquals(Collections.emptyList(), resultTNlist); verifyDefault(); } @@ -198,11 +197,9 @@ public void testGetTreeNodesForParentKey_hit_empty() throws Exception { String searchParentKey = "mydatabase:MySpace.MyDoc1"; String cacheKey = notMappedItemsCmd.getWikiCacheKey(searchParentKey); HashMap> mySpaceMap = new HashMap<>(); - mySpaceMap.put("mydatabase:MySpace.", Arrays.asList(new TreeNode(new DocumentReference( - context.getDatabase(), "MySpace", "MyDoc1"), null, 1), new TreeNode( - new DocumentReference( - context.getDatabase(), "MySpace", "MyDoc2"), - null, 2))); + mySpaceMap.put("mydatabase:MySpace.", Arrays.asList( + new TreeNode(new DocumentReference(context.getDatabase(), "MySpace", "MyDoc1"), null, 1), + new TreeNode(new DocumentReference(context.getDatabase(), "MySpace", "MyDoc2"), null, 2))); notMappedItemsCmd.injectMapForTests(cacheKey, mySpaceMap); replayDefault(); List resultTNlist = notMappedItemsCmd.getTreeNodesForParentKey(searchParentKey); @@ -216,10 +213,11 @@ public void testGetTreeNodesForParentKey_differentDbs() throws Exception { context.setDatabase("mytestwiki"); String searchParentKey = "mydatabase:MySpace."; String expectedPartName = "mainPart"; - List expectedList = Arrays.asList(new TreeNode(new DocumentReference("mydatabase", - "MySpace", "MyDoc1"), null, 1, expectedPartName), new TreeNode( - new DocumentReference("mydatabase", "MySpace", "MyDoc2"), - null, 2, expectedPartName)); + List expectedList = Arrays.asList( + new TreeNode(new DocumentReference("mydatabase", "MySpace", "MyDoc1"), null, 1, + expectedPartName), + new TreeNode(new DocumentReference("mydatabase", "MySpace", "MyDoc2"), null, 2, + expectedPartName)); List resultList = Arrays.asList( Arrays.asList("MySpace.MyDoc1", "MySpace", "", 1).toArray(), Arrays.asList("MySpace.MyDoc2", "MySpace", "", 2).toArray()); @@ -301,8 +299,8 @@ public void testGetTreeNodesForParentKey_differentDbs_deprecated() throws Except public void testGetParentKey_FullName() { context.setDatabase("mydatabase"); replayDefault(); - assertEquals("mydatabase:Full.Name", notMappedItemsCmd.getParentKey(context.getDatabase(), - "Full.Name", "Space")); + assertEquals("mydatabase:Full.Name", + notMappedItemsCmd.getParentKey(context.getDatabase(), "Full.Name", "Space")); verifyDefault(); } @@ -310,8 +308,8 @@ public void testGetParentKey_FullName() { public void testGetParentKey_Name() { context.setDatabase("mydatabase"); replayDefault(); - assertEquals("mydatabase:Space.Name", notMappedItemsCmd.getParentKey(context.getDatabase(), - "Name", "Space")); + assertEquals("mydatabase:Space.Name", + notMappedItemsCmd.getParentKey(context.getDatabase(), "Name", "Space")); verifyDefault(); } @@ -319,8 +317,8 @@ public void testGetParentKey_Name() { public void testGetParentKey_Name_differentdb() { context.setDatabase("mytestwiki"); replayDefault(); - assertEquals("mydatabase:Space.Name", notMappedItemsCmd.getParentKey("mydatabase", "Name", - "Space")); + assertEquals("mydatabase:Space.Name", + notMappedItemsCmd.getParentKey("mydatabase", "Name", "Space")); verifyDefault(); } @@ -340,20 +338,19 @@ public void testFlushMenuItemCache() { public void testGetTreeNodesForParentKey_miss_IllegalArgumentExp_emptySpace_deprecated() throws XWikiException { context.setDatabase("mydatabase"); - List resultList = Arrays.asList( - Arrays.asList(".MyDoc1", "", "", 1).toArray(), + List resultList = Arrays.asList(Arrays.asList(".MyDoc1", "", "", 1).toArray(), Arrays.asList("MySpace.MyDoc2", "MySpace", "", 2).toArray()); - expect(mockStore.search(isA(String.class), eq(0), eq(0), same(context))).andReturn( - resultList).atLeastOnce(); - List expectedList = Arrays.asList(new TreeNode(new DocumentReference( - context.getDatabase(), "MySpace", "MyDoc2"), null, 2)); + expect(mockStore.search(isA(String.class), eq(0), eq(0), same(context))) + .andReturn(resultList).atLeastOnce(); + List expectedList = Arrays.asList( + new TreeNode(new DocumentReference(context.getDatabase(), "MySpace", "MyDoc2"), null, 2)); replayDefault(); List resultTNlist = notMappedItemsCmd.getTreeNodesForParentKey("mydatabase:MySpace.", context); assertEquals(expectedList.size(), resultTNlist.size()); for (int i = 0; i < expectedList.size(); i++) { - assertEquals(expectedList.get(i).getDocumentReference(), resultTNlist.get( - i).getDocumentReference()); + assertEquals(expectedList.get(i).getDocumentReference(), + resultTNlist.get(i).getDocumentReference()); } verifyDefault(); } @@ -362,19 +359,18 @@ public void testGetTreeNodesForParentKey_miss_IllegalArgumentExp_emptySpace_depr public void testGetTreeNodesForParentKey_miss_IllegalArgumentExp_emptySpace() throws XWikiException { context.setDatabase("mydatabase"); - List resultList = Arrays.asList( - Arrays.asList(".MyDoc1", "", "", 1).toArray(), + List resultList = Arrays.asList(Arrays.asList(".MyDoc1", "", "", 1).toArray(), Arrays.asList("MySpace.MyDoc2", "MySpace", "", 2).toArray()); - expect(mockStore.search(isA(String.class), eq(0), eq(0), same(context))).andReturn( - resultList).atLeastOnce(); - List expectedList = Arrays.asList(new TreeNode(new DocumentReference( - context.getDatabase(), "MySpace", "MyDoc2"), null, 2)); + expect(mockStore.search(isA(String.class), eq(0), eq(0), same(context))) + .andReturn(resultList).atLeastOnce(); + List expectedList = Arrays.asList( + new TreeNode(new DocumentReference(context.getDatabase(), "MySpace", "MyDoc2"), null, 2)); replayDefault(); List resultTNlist = notMappedItemsCmd.getTreeNodesForParentKey("mydatabase:MySpace."); assertEquals(expectedList.size(), resultTNlist.size()); for (int i = 0; i < expectedList.size(); i++) { - assertEquals(expectedList.get(i).getDocumentReference(), resultTNlist.get( - i).getDocumentReference()); + assertEquals(expectedList.get(i).getDocumentReference(), + resultTNlist.get(i).getDocumentReference()); } verifyDefault(); } @@ -382,11 +378,10 @@ public void testGetTreeNodesForParentKey_miss_IllegalArgumentExp_emptySpace() @Test public void testExecuteSearch_fixDbForSearch() throws Exception { context.setDatabase("mytestwiki"); - List resultList = Arrays.asList( - Arrays.asList(".MyDoc1", "", "", 1).toArray(), + List resultList = Arrays.asList(Arrays.asList(".MyDoc1", "", "", 1).toArray(), Arrays.asList("MySpace.MyDoc2", "MySpace", "", 2).toArray()); - expect(mockStore.search(isA(String.class), eq(0), eq(0), same(context))).andReturn( - resultList).atLeastOnce(); + expect(mockStore.search(isA(String.class), eq(0), eq(0), same(context))) + .andReturn(resultList).atLeastOnce(); replayDefault(); List result = notMappedItemsCmd.executeSearch("mydatabase"); assertEquals("expect database being adjusted.", "mydatabase", context.getDatabase()); @@ -400,8 +395,8 @@ public void testGetFromDBForParentKey_preserve_db() throws Exception { List resultList = Arrays.asList( Arrays.asList("MySpace.MyDoc1", "MySpace", "", 1).toArray(), Arrays.asList("MySpace.MyDoc2", "MySpace", "", 2).toArray()); - expect(mockStore.search(isA(String.class), eq(0), eq(0), same(context))).andReturn( - resultList).atLeastOnce(); + expect(mockStore.search(isA(String.class), eq(0), eq(0), same(context))) + .andReturn(resultList).atLeastOnce(); replayDefault(); List result = notMappedItemsCmd.getFromDBForParentKey("mydatabase:MySpace."); assertEquals("expect database being preserved.", "mytestwiki", context.getDatabase()); @@ -416,8 +411,9 @@ private INavigationClassConfig getNavClassConfig() { private void assertTreeNoteEquals(TreeNode expectedNode, TreeNode testNode) { assertEquals("wrong parentRef for [" + expectedNode.getDocumentReference().getName() + "]", expectedNode.getParentRef(), testNode.getParentRef()); - assertEquals("wrong documentReference for [" + expectedNode.getDocumentReference().getName() - + "]", expectedNode.getDocumentReference(), testNode.getDocumentReference()); + assertEquals( + "wrong documentReference for [" + expectedNode.getDocumentReference().getName() + "]", + expectedNode.getDocumentReference(), testNode.getDocumentReference()); assertEquals("wrong position for [" + expectedNode.getDocumentReference().getName() + "]", expectedNode.getPosition(), testNode.getPosition()); assertEquals("wrong partName for [" + expectedNode.getDocumentReference().getName() + "]", diff --git a/src/test/java/com/celements/navigation/cmd/MultilingualMenuNameCommandTest.java b/src/test/java/com/celements/navigation/cmd/MultilingualMenuNameCommandTest.java index a21e84dd4..df2724f5b 100644 --- a/src/test/java/com/celements/navigation/cmd/MultilingualMenuNameCommandTest.java +++ b/src/test/java/com/celements/navigation/cmd/MultilingualMenuNameCommandTest.java @@ -121,8 +121,8 @@ public void testAddToolTip() throws Exception { currentDoc.setObject(MultilingualMenuNameCommand.CELEMENTS_MENU_NAME, 0, menuNameObj); expect(xwiki.isMultiLingual(same(context))).andReturn(true).anyTimes(); replayDefault(); - assertEquals("title=\"Tool tip for test\"", menuNameCmd.addToolTip(currentDoc.getFullName(), - "de", context)); + assertEquals("title=\"Tool tip for test\"", + menuNameCmd.addToolTip(currentDoc.getFullName(), "de", context)); verifyDefault(); } diff --git a/src/test/java/com/celements/navigation/cmd/RestructureSaveHandlerTest.java b/src/test/java/com/celements/navigation/cmd/RestructureSaveHandlerTest.java index 3ad4f7bc9..3690ed8da 100644 --- a/src/test/java/com/celements/navigation/cmd/RestructureSaveHandlerTest.java +++ b/src/test/java/com/celements/navigation/cmd/RestructureSaveHandlerTest.java @@ -77,9 +77,10 @@ public void testExtractDocFN_NavigationCreateID() { helpNav.setNodeSpace(new SpaceReference("MySpace", new WikiReference(context.getDatabase()))); String menuItemName = "MySpace.MyDoc"; String navUniqLiId = helpNav.getUniqueId(menuItemName); - assertEquals("getUniqueId in Navigation returns [" + navUniqLiId + "] which cannot be" - + " parsed correctly in extractDocFN.", menuItemName, - restrSaveCmd.extractDocFN(navUniqLiId)); + assertEquals( + "getUniqueId in Navigation returns [" + navUniqLiId + "] which cannot be" + + " parsed correctly in extractDocFN.", + menuItemName, restrSaveCmd.extractDocFN(navUniqLiId)); } @Test @@ -250,10 +251,10 @@ public void testStringEvent_onlyParents() throws Exception { restrSaveCmd.stringEvent("LIN1:MySpace:MySpace.MyDoc1"); assertEquals("expecting increment afterwards.", new Integer(1), restrSaveCmd.getCurrentPos()); assertEquals("expecting parent reset.", parentRef, xdoc.getParentReference()); - assertTrue("expecting old parent in dirtyParents.", restrSaveCmd.getDirtyParents().contains( - oldParentRef)); - assertTrue("expecting new parent in dirtyParents.", restrSaveCmd.getDirtyParents().contains( - parentRef)); + assertTrue("expecting old parent in dirtyParents.", + restrSaveCmd.getDirtyParents().contains(oldParentRef)); + assertTrue("expecting new parent in dirtyParents.", + restrSaveCmd.getDirtyParents().contains(parentRef)); assertEquals(2, restrSaveCmd.getDirtyParents().size()); verifyDefault(); } @@ -282,10 +283,10 @@ public void testStringEvent_parentsAndPosition() throws Exception { assertEquals("expecting increment afterwards.", new Integer(1), restrSaveCmd.getCurrentPos()); assertEquals("expecting parent reset.", parentRef, xdoc.getParentReference()); assertEquals("expecting position reset.", 0, menuItemObj.getIntValue("menu_position")); - assertTrue("expecting old parent in dirtyParents.", restrSaveCmd.getDirtyParents().contains( - oldParentRef)); - assertTrue("expecting new parent in dirtyParents.", restrSaveCmd.getDirtyParents().contains( - parentRef)); + assertTrue("expecting old parent in dirtyParents.", + restrSaveCmd.getDirtyParents().contains(oldParentRef)); + assertTrue("expecting new parent in dirtyParents.", + restrSaveCmd.getDirtyParents().contains(parentRef)); assertEquals(2, restrSaveCmd.getDirtyParents().size()); verifyDefault(); } diff --git a/src/test/java/com/celements/navigation/factories/DefaultNavigationFactoryTest.java b/src/test/java/com/celements/navigation/factories/DefaultNavigationFactoryTest.java index b5358b7ff..9828e322d 100644 --- a/src/test/java/com/celements/navigation/factories/DefaultNavigationFactoryTest.java +++ b/src/test/java/com/celements/navigation/factories/DefaultNavigationFactoryTest.java @@ -56,10 +56,10 @@ public void setUp_DefaultNavigationFactoryTest() throws Exception { pageTypeRef = new PageTypeReference(pageTypeDocRef.getName(), XObjectPageTypeProvider.X_OBJECT_PAGE_TYPE_PROVIDER, Collections.emptyList()); testDocRef = new DocumentReference(getContext().getDatabase(), "MySpace", "MyTestDoc"); - expect(pageTypeResolverMock.getPageTypeRefForDocWithDefault(eq(testDocRef))).andReturn( - pageTypeRef).anyTimes(); - expect(pageTypeResolverMock.getPageTypeRefForCurrentDoc()).andReturn( - defaultPageTypeRef).anyTimes(); + expect(pageTypeResolverMock.getPageTypeRefForDocWithDefault(eq(testDocRef))) + .andReturn(pageTypeRef).anyTimes(); + expect(pageTypeResolverMock.getPageTypeRefForCurrentDoc()).andReturn(defaultPageTypeRef) + .anyTimes(); defNavFactory = (DefaultNavigationFactory) Utils.getComponent(NavigationFactory.class); currDocRef = new DocumentReference(getContext().getDatabase(), "mySpace", "myCurDoc"); curDoc = new XWikiDocument(currDocRef); @@ -86,14 +86,14 @@ public void testGetNavigationConfig_curDoc_defaults() { @Test public void testGetNavigationConfig_curDoc_true() { expect(javaNavFactoryMock.hasNavigationConfig(eq(defaultPageTypeRef))).andReturn(true); - expect(javaNavFactoryMock.getNavigationConfig(eq(defaultPageTypeRef))).andReturn( - NavigationConfig.DEFAULTS); + expect(javaNavFactoryMock.getNavigationConfig(eq(defaultPageTypeRef))) + .andReturn(NavigationConfig.DEFAULTS); expect(pageTypeNavFactoryMock.hasNavigationConfig(eq(currDocRef))).andReturn(true); - expect(pageTypeNavFactoryMock.getNavigationConfig(eq(currDocRef))).andReturn( - NavigationConfig.DEFAULTS); + expect(pageTypeNavFactoryMock.getNavigationConfig(eq(currDocRef))) + .andReturn(NavigationConfig.DEFAULTS); expect(xobjNavFactoryMock.hasNavigationConfig(eq(currDocRef))).andReturn(true); - expect(xobjNavFactoryMock.getNavigationConfig(eq(currDocRef))).andReturn( - NavigationConfig.DEFAULTS); + expect(xobjNavFactoryMock.getNavigationConfig(eq(currDocRef))) + .andReturn(NavigationConfig.DEFAULTS); replayDefault(); assertNotNull(defNavFactory.getNavigationConfig(currDocRef)); verifyDefault(); @@ -102,14 +102,14 @@ public void testGetNavigationConfig_curDoc_true() { @Test public void testGetNavigationConfig_testDoc() { expect(javaNavFactoryMock.hasNavigationConfig(eq(pageTypeRef))).andReturn(true); - expect(javaNavFactoryMock.getNavigationConfig(eq(pageTypeRef))).andReturn( - NavigationConfig.DEFAULTS); + expect(javaNavFactoryMock.getNavigationConfig(eq(pageTypeRef))) + .andReturn(NavigationConfig.DEFAULTS); expect(pageTypeNavFactoryMock.hasNavigationConfig(eq(testDocRef))).andReturn(true); - expect(pageTypeNavFactoryMock.getNavigationConfig(eq(testDocRef))).andReturn( - NavigationConfig.DEFAULTS); + expect(pageTypeNavFactoryMock.getNavigationConfig(eq(testDocRef))) + .andReturn(NavigationConfig.DEFAULTS); expect(xobjNavFactoryMock.hasNavigationConfig(eq(testDocRef))).andReturn(true); - expect(xobjNavFactoryMock.getNavigationConfig(eq(testDocRef))).andReturn( - NavigationConfig.DEFAULTS); + expect(xobjNavFactoryMock.getNavigationConfig(eq(testDocRef))) + .andReturn(NavigationConfig.DEFAULTS); replayDefault(); assertNotNull(defNavFactory.getNavigationConfig(testDocRef)); verifyDefault(); @@ -137,8 +137,8 @@ public void testHasNavigationConfig_curDoc_java() { @Test public void testHasNavigationConfig_curDoc_pageType() { - expect(javaNavFactoryMock.hasNavigationConfig(eq(defaultPageTypeRef))).andReturn( - false).anyTimes(); + expect(javaNavFactoryMock.hasNavigationConfig(eq(defaultPageTypeRef))).andReturn(false) + .anyTimes(); expect(pageTypeNavFactoryMock.hasNavigationConfig(eq(currDocRef))).andReturn(true); expect(xobjNavFactoryMock.hasNavigationConfig(eq(currDocRef))).andReturn(false).anyTimes(); replayDefault(); @@ -148,8 +148,8 @@ public void testHasNavigationConfig_curDoc_pageType() { @Test public void testHasNavigationConfig_curDoc_xobj() { - expect(javaNavFactoryMock.hasNavigationConfig(eq(defaultPageTypeRef))).andReturn( - false).anyTimes(); + expect(javaNavFactoryMock.hasNavigationConfig(eq(defaultPageTypeRef))).andReturn(false) + .anyTimes(); expect(pageTypeNavFactoryMock.hasNavigationConfig(eq(currDocRef))).andReturn(false).anyTimes(); expect(xobjNavFactoryMock.hasNavigationConfig(eq(currDocRef))).andReturn(true); replayDefault(); diff --git a/src/test/java/com/celements/navigation/factories/JavaNavigationFactoryTest.java b/src/test/java/com/celements/navigation/factories/JavaNavigationFactoryTest.java index c99ce7fb3..378c9bce0 100644 --- a/src/test/java/com/celements/navigation/factories/JavaNavigationFactoryTest.java +++ b/src/test/java/com/celements/navigation/factories/JavaNavigationFactoryTest.java @@ -43,14 +43,14 @@ public void setUp_JavaNavigationFactoryTest() throws Exception { pageTypeRef = new PageTypeReference(pageTypeDocRef.getName(), XObjectPageTypeProvider.X_OBJECT_PAGE_TYPE_PROVIDER, Collections.emptyList()); testDocRef = new DocumentReference(getContext().getDatabase(), "MySpace", "MyTestDoc"); - expect(pageTypeResolverMock.getPageTypeRefForDocWithDefault(eq(testDocRef))).andReturn( - pageTypeRef).anyTimes(); + expect(pageTypeResolverMock.getPageTypeRefForDocWithDefault(eq(testDocRef))) + .andReturn(pageTypeRef).anyTimes(); defaultPageTypeDocRef = new DocumentReference(getContext().getDatabase(), "PageTypes", "RichText"); defaultPageTypeRef = new PageTypeReference(defaultPageTypeDocRef.getName(), XObjectPageTypeProvider.X_OBJECT_PAGE_TYPE_PROVIDER, Collections.emptyList()); - expect(pageTypeResolverMock.getPageTypeRefForCurrentDoc()).andReturn( - defaultPageTypeRef).anyTimes(); + expect(pageTypeResolverMock.getPageTypeRefForCurrentDoc()).andReturn(defaultPageTypeRef) + .anyTimes(); } @Test @@ -78,16 +78,16 @@ public void testGetNavigationConfigString() throws Exception { Integer showInactiveToLevel = 55; String menuPart = "menuPart"; String dataType = "dataType"; - SpaceReference nodeSpaceRef = new SpaceReference("NavConfigSpace", new WikiReference( - getContext().getDatabase())); + SpaceReference nodeSpaceRef = new SpaceReference("NavConfigSpace", + new WikiReference(getContext().getDatabase())); String layoutType = "navConfig2LayoutType"; Integer itemsPerPage = 20; String cmCssClass = "cm_cssTestClass2"; - final NavigationConfig expectedNavConfig = new NavigationConfig.Builder().configName( - configName).fromHierarchyLevel(fromHierarchyLevel).toHierarchyLevel( - toHierarchyLevel).showInactiveToLevel(showInactiveToLevel).menuPart(menuPart).dataType( - dataType).nodeSpaceRef(nodeSpaceRef).layoutType(layoutType).nrOfItemsPerPage( - itemsPerPage).cmCssClass(cmCssClass).build(); + final NavigationConfig expectedNavConfig = new NavigationConfig.Builder().configName(configName) + .fromHierarchyLevel(fromHierarchyLevel).toHierarchyLevel(toHierarchyLevel) + .showInactiveToLevel(showInactiveToLevel).menuPart(menuPart).dataType(dataType) + .nodeSpaceRef(nodeSpaceRef).layoutType(layoutType).nrOfItemsPerPage(itemsPerPage) + .cmCssClass(cmCssClass).build(); expect(testConfigurator.handles(eq(pageTypeRef))).andReturn(true); expect(testConfigurator.getNavigationConfig(eq(pageTypeRef))).andReturn(expectedNavConfig); replayDefault(); diff --git a/src/test/java/com/celements/navigation/factories/PageTypeNavigationFactoryTest.java b/src/test/java/com/celements/navigation/factories/PageTypeNavigationFactoryTest.java index 8fb965c75..92c06cf65 100644 --- a/src/test/java/com/celements/navigation/factories/PageTypeNavigationFactoryTest.java +++ b/src/test/java/com/celements/navigation/factories/PageTypeNavigationFactoryTest.java @@ -52,16 +52,16 @@ public void setUp_PageTypeNavigationFactoryTest() throws Exception { defaultPageTypeDoc.setNew(false); PageTypeReference defaultPageTypeRef = new PageTypeReference(defaultPageTypeDocRef.getName(), XObjectPageTypeProvider.X_OBJECT_PAGE_TYPE_PROVIDER, Collections.emptyList()); - expect(mockPageTypeResolver.getPageTypeRefForCurrentDoc()).andReturn( - defaultPageTypeRef).anyTimes(); + expect(mockPageTypeResolver.getPageTypeRefForCurrentDoc()).andReturn(defaultPageTypeRef) + .anyTimes(); pageTypeDocRef = new DocumentReference(getXContext().getDatabase(), "PageTypes", "MyPageType"); pageTypeDoc = new XWikiDocument(pageTypeDocRef); pageTypeDoc.setNew(false); PageTypeReference pageTypeRef = new PageTypeReference(pageTypeDocRef.getName(), XObjectPageTypeProvider.X_OBJECT_PAGE_TYPE_PROVIDER, Collections.emptyList()); testDocRef = new DocumentReference(getXContext().getDatabase(), "MySpace", "MyTestDoc"); - expect(mockPageTypeResolver.getPageTypeRefForDocWithDefault(eq(testDocRef))).andReturn( - pageTypeRef).anyTimes(); + expect(mockPageTypeResolver.getPageTypeRefForDocWithDefault(eq(testDocRef))) + .andReturn(pageTypeRef).anyTimes(); currDocRef = new DocumentReference(getXContext().getDatabase(), "MySpace", "MyDoc"); currDoc = new XWikiDocument(currDocRef); currDoc.setNew(false); @@ -72,15 +72,15 @@ public void setUp_PageTypeNavigationFactoryTest() throws Exception { public void testCreateNavigation() throws Exception { BaseObject navConfigObj = new BaseObject(); navConfigObj.setDocumentReference(defaultPageTypeDocRef); - navConfigObj.setXClassReference(getNavClasses().getNavigationConfigClassRef( - getXContext().getDatabase())); + navConfigObj.setXClassReference( + getNavClasses().getNavigationConfigClassRef(getXContext().getDatabase())); defaultPageTypeDoc.addXObject(navConfigObj); expect(getMock(IModelAccessFacade.class).getOrCreateDocument(defaultPageTypeDocRef)) .andReturn(defaultPageTypeDoc); String spaceName = "MySpace"; navConfigObj.setStringValue("menu_space", spaceName); - EntityReference mySpaceRef = new SpaceReference(spaceName, new WikiReference( - getXContext().getDatabase())); + EntityReference mySpaceRef = new SpaceReference(spaceName, + new WikiReference(getXContext().getDatabase())); replayDefault(); INavigation nav = xobjNavFactory.createNavigation(); assertEquals(mySpaceRef, nav.getNodeSpaceRef()); @@ -91,15 +91,15 @@ public void testCreateNavigation() throws Exception { public void testCreateNavigation_docRef() throws Exception { BaseObject navConfigObj = new BaseObject(); navConfigObj.setDocumentReference(pageTypeDocRef); - navConfigObj.setXClassReference(getNavClasses().getNavigationConfigClassRef( - getXContext().getDatabase())); + navConfigObj.setXClassReference( + getNavClasses().getNavigationConfigClassRef(getXContext().getDatabase())); pageTypeDoc.addXObject(navConfigObj); expect(getMock(IModelAccessFacade.class).getOrCreateDocument(pageTypeDocRef)) .andReturn(pageTypeDoc); String spaceName = "MySpace"; navConfigObj.setStringValue("menu_space", spaceName); - EntityReference mySpaceRef = new SpaceReference(spaceName, new WikiReference( - getXContext().getDatabase())); + EntityReference mySpaceRef = new SpaceReference(spaceName, + new WikiReference(getXContext().getDatabase())); replayDefault(); INavigation nav = xobjNavFactory.createNavigation(testDocRef); assertEquals(mySpaceRef, nav.getNodeSpaceRef()); @@ -110,8 +110,8 @@ public void testCreateNavigation_docRef() throws Exception { public void testHasNavigationConfig() throws Exception { BaseObject navConfigObj = new BaseObject(); navConfigObj.setDocumentReference(defaultPageTypeDocRef); - navConfigObj.setXClassReference(getNavClasses().getNavigationConfigClassRef( - getXContext().getDatabase())); + navConfigObj.setXClassReference( + getNavClasses().getNavigationConfigClassRef(getXContext().getDatabase())); defaultPageTypeDoc.addXObject(navConfigObj); expect(getMock(IModelAccessFacade.class).getOrCreateDocument(defaultPageTypeDocRef)) .andReturn(defaultPageTypeDoc); @@ -126,8 +126,8 @@ public void testHasNavigationConfig() throws Exception { public void testHasNavigationConfig_docRef() throws Exception { BaseObject navConfigObj = new BaseObject(); navConfigObj.setDocumentReference(pageTypeDocRef); - navConfigObj.setXClassReference(getNavClasses().getNavigationConfigClassRef( - getXContext().getDatabase())); + navConfigObj.setXClassReference( + getNavClasses().getNavigationConfigClassRef(getXContext().getDatabase())); pageTypeDoc.addXObject(navConfigObj); expect(getMock(IModelAccessFacade.class).getOrCreateDocument(pageTypeDocRef)) .andReturn(pageTypeDoc); @@ -161,15 +161,15 @@ public void testHasNavigationConfig_docRef_NotExists_false() throws Exception { public void testGetNavigationConfig_docRef() throws Exception { BaseObject navConfigObj = new BaseObject(); navConfigObj.setDocumentReference(pageTypeDocRef); - navConfigObj.setXClassReference(getNavClasses().getNavigationConfigClassRef( - getXContext().getDatabase())); + navConfigObj.setXClassReference( + getNavClasses().getNavigationConfigClassRef(getXContext().getDatabase())); pageTypeDoc.addXObject(navConfigObj); expect(getMock(IModelAccessFacade.class).getOrCreateDocument(pageTypeDocRef)) .andReturn(pageTypeDoc); String spaceName = "MySpace"; navConfigObj.setStringValue("menu_space", spaceName); - EntityReference mySpaceRef = new SpaceReference(spaceName, new WikiReference( - getXContext().getDatabase())); + EntityReference mySpaceRef = new SpaceReference(spaceName, + new WikiReference(getXContext().getDatabase())); replayDefault(); NavigationConfig navConfig = xobjNavFactory.getNavigationConfig(testDocRef); assertEquals(mySpaceRef, navConfig.getNodeSpaceRef().get()); diff --git a/src/test/java/com/celements/navigation/factories/XObjectNavigationFactoryTest.java b/src/test/java/com/celements/navigation/factories/XObjectNavigationFactoryTest.java index 0b2289378..dc2c8158b 100644 --- a/src/test/java/com/celements/navigation/factories/XObjectNavigationFactoryTest.java +++ b/src/test/java/com/celements/navigation/factories/XObjectNavigationFactoryTest.java @@ -39,12 +39,12 @@ public void testLoadConfigFromObject_defaults() { "MySpace", "MyDoc"); BaseObject navConfigObj = new BaseObject(); navConfigObj.setDocumentReference(cellConfigDocRef); - navConfigObj.setXClassReference(getNavClasses().getNavigationConfigClassRef( - new WikiReference(getContext().getDatabase()))); + navConfigObj.setXClassReference( + getNavClasses().getNavigationConfigClassRef(new WikiReference(getContext().getDatabase()))); String spaceName = "MySpace"; navConfigObj.setStringValue("menu_space", spaceName); - SpaceReference mySpaceRef = new SpaceReference(spaceName, new WikiReference( - getContext().getDatabase())); + SpaceReference mySpaceRef = new SpaceReference(spaceName, + new WikiReference(getContext().getDatabase())); replayDefault(); NavigationConfig navConfig = xobjNavFactory.loadConfigFromObject(navConfigObj); assertEquals(mySpaceRef, navConfig.getNodeSpaceRef().get()); @@ -59,12 +59,12 @@ public void testLoadConfigFromObject_menuSpace() { "MySpace", "MyDoc"); BaseObject navConfigObj = new BaseObject(); navConfigObj.setDocumentReference(cellConfigDocRef); - navConfigObj.setXClassReference(getNavClasses().getNavigationConfigClassRef( - new WikiReference(getContext().getDatabase()))); + navConfigObj.setXClassReference( + getNavClasses().getNavigationConfigClassRef(new WikiReference(getContext().getDatabase()))); String nodeSpaceName = "theMenuSpace"; navConfigObj.setStringValue("menu_space", nodeSpaceName); - SpaceReference parentSpaceRef = new SpaceReference(nodeSpaceName, new WikiReference( - getContext().getDatabase())); + SpaceReference parentSpaceRef = new SpaceReference(nodeSpaceName, + new WikiReference(getContext().getDatabase())); replayDefault(); NavigationConfig navConfig = xobjNavFactory.loadConfigFromObject(navConfigObj); assertEquals(parentSpaceRef, navConfig.getNodeSpaceRef().get()); @@ -77,12 +77,12 @@ public void testLoadConfigFromObject_menuSpace_empty() { "MySpace", "MyDoc"); BaseObject navConfigObj = new BaseObject(); navConfigObj.setDocumentReference(cellConfigDocRef); - navConfigObj.setXClassReference(getNavClasses().getNavigationConfigClassRef( - new WikiReference(getContext().getDatabase()))); + navConfigObj.setXClassReference( + getNavClasses().getNavigationConfigClassRef(new WikiReference(getContext().getDatabase()))); String spaceName = "MySpace"; navConfigObj.setStringValue("menu_space", spaceName); - EntityReference mySpaceRef = new SpaceReference(spaceName, new WikiReference( - getContext().getDatabase())); + EntityReference mySpaceRef = new SpaceReference(spaceName, + new WikiReference(getContext().getDatabase())); replayDefault(); NavigationConfig navConfig = xobjNavFactory.loadConfigFromObject(navConfigObj); assertEquals(mySpaceRef, navConfig.getNodeSpaceRef().get()); @@ -95,8 +95,8 @@ public void testLoadConfigFromObject_presentationType_notEmpty() throws Exceptio "MySpace", "MyDoc"); BaseObject navConfigObj = new BaseObject(); navConfigObj.setDocumentReference(cellConfigDocRef); - navConfigObj.setXClassReference(getNavClasses().getNavigationConfigClassRef( - new WikiReference(getContext().getDatabase()))); + navConfigObj.setXClassReference( + getNavClasses().getNavigationConfigClassRef(new WikiReference(getContext().getDatabase()))); navConfigObj.setStringValue(INavigationClassConfig.PRESENTATION_TYPE_FIELD, "testPresentationType"); IPresentationTypeRole componentInstance = registerComponentMock(IPresentationTypeRole.class, @@ -116,15 +116,15 @@ public void testCreateNavigation() throws Exception { getContext().setDoc(collConfigDoc); BaseObject navConfigObj = new BaseObject(); navConfigObj.setDocumentReference(cellConfigDocRef); - navConfigObj.setXClassReference(getNavClasses().getNavigationConfigClassRef( - new WikiReference(getContext().getDatabase()))); + navConfigObj.setXClassReference( + getNavClasses().getNavigationConfigClassRef(new WikiReference(getContext().getDatabase()))); collConfigDoc.addXObject(navConfigObj); expect(getMock(IModelAccessFacade.class).getOrCreateDocument(cellConfigDocRef)) .andReturn(collConfigDoc); String spaceName = "MySpace"; navConfigObj.setStringValue("menu_space", spaceName); - EntityReference mySpaceRef = new SpaceReference(spaceName, new WikiReference( - getContext().getDatabase())); + EntityReference mySpaceRef = new SpaceReference(spaceName, + new WikiReference(getContext().getDatabase())); replayDefault(); INavigation nav = xobjNavFactory.createNavigation(); assertEquals(mySpaceRef, nav.getNodeSpaceRef()); @@ -139,15 +139,15 @@ public void testCreateNavigation_docRef() throws Exception { collConfigDoc.setNew(false); BaseObject navConfigObj = new BaseObject(); navConfigObj.setDocumentReference(cellConfigDocRef); - navConfigObj.setXClassReference(getNavClasses().getNavigationConfigClassRef( - new WikiReference(getContext().getDatabase()))); + navConfigObj.setXClassReference( + getNavClasses().getNavigationConfigClassRef(new WikiReference(getContext().getDatabase()))); collConfigDoc.addXObject(navConfigObj); expect(getMock(IModelAccessFacade.class).getOrCreateDocument(cellConfigDocRef)) .andReturn(collConfigDoc); String spaceName = "MySpace"; navConfigObj.setStringValue("menu_space", spaceName); - EntityReference mySpaceRef = new SpaceReference(spaceName, new WikiReference( - getContext().getDatabase())); + EntityReference mySpaceRef = new SpaceReference(spaceName, + new WikiReference(getContext().getDatabase())); replayDefault(); INavigation nav = xobjNavFactory.createNavigation(cellConfigDocRef); assertEquals(mySpaceRef, nav.getNodeSpaceRef()); @@ -163,8 +163,8 @@ public void testHasNavigationConfig() throws Exception { getContext().setDoc(collConfigDoc); BaseObject navConfigObj = new BaseObject(); navConfigObj.setDocumentReference(cellConfigDocRef); - navConfigObj.setXClassReference(getNavClasses().getNavigationConfigClassRef( - new WikiReference(getContext().getDatabase()))); + navConfigObj.setXClassReference( + getNavClasses().getNavigationConfigClassRef(new WikiReference(getContext().getDatabase()))); collConfigDoc.addXObject(navConfigObj); expect(getMock(IModelAccessFacade.class).getOrCreateDocument(cellConfigDocRef)) .andReturn(collConfigDoc); @@ -183,8 +183,8 @@ public void testHasNavigationConfig_docRef() throws Exception { collConfigDoc.setNew(false); BaseObject navConfigObj = new BaseObject(); navConfigObj.setDocumentReference(cellConfigDocRef); - navConfigObj.setXClassReference(getNavClasses().getNavigationConfigClassRef( - new WikiReference(getContext().getDatabase()))); + navConfigObj.setXClassReference( + getNavClasses().getNavigationConfigClassRef(new WikiReference(getContext().getDatabase()))); collConfigDoc.addXObject(navConfigObj); expect(getMock(IModelAccessFacade.class).getOrCreateDocument(cellConfigDocRef)) .andReturn(collConfigDoc); @@ -229,15 +229,15 @@ public void testGetNavigationConfig_docRef() throws Exception { collConfigDoc.setNew(false); BaseObject navConfigObj = new BaseObject(); navConfigObj.setDocumentReference(cellConfigDocRef); - navConfigObj.setXClassReference(getNavClasses().getNavigationConfigClassRef( - new WikiReference(getContext().getDatabase()))); + navConfigObj.setXClassReference( + getNavClasses().getNavigationConfigClassRef(new WikiReference(getContext().getDatabase()))); collConfigDoc.addXObject(navConfigObj); expect(getMock(IModelAccessFacade.class).getOrCreateDocument(cellConfigDocRef)) .andReturn(collConfigDoc); String spaceName = "MySpace"; navConfigObj.setStringValue("menu_space", spaceName); - EntityReference mySpaceRef = new SpaceReference(spaceName, new WikiReference( - getContext().getDatabase())); + EntityReference mySpaceRef = new SpaceReference(spaceName, + new WikiReference(getContext().getDatabase())); replayDefault(); NavigationConfig navConfig = xobjNavFactory.getNavigationConfig(cellConfigDocRef); assertEquals(mySpaceRef, navConfig.getNodeSpaceRef().get()); diff --git a/src/test/java/com/celements/navigation/filter/InternalRightsFilterTest.java b/src/test/java/com/celements/navigation/filter/InternalRightsFilterTest.java index 235e6bfdd..ef5a6d708 100644 --- a/src/test/java/com/celements/navigation/filter/InternalRightsFilterTest.java +++ b/src/test/java/com/celements/navigation/filter/InternalRightsFilterTest.java @@ -86,8 +86,8 @@ public void testIncludeMenuItem_noViewRights() throws Exception { DocumentReference docRef = new DocumentReference(context.getDatabase(), "MySpace", "MyDoc"); BaseObject baseObj = new BaseObject(); baseObj.setDocumentReference(docRef); - expect(rightsService.hasAccessLevel(eq("view"), eq(context.getUser()), eq(context.getDatabase() - + ":" + docFullName), same(context))).andReturn(false); + expect(rightsService.hasAccessLevel(eq("view"), eq(context.getUser()), + eq(context.getDatabase() + ":" + docFullName), same(context))).andReturn(false); replayDefault(); assertFalse(filter.includeMenuItem(baseObj, context)); verifyDefault(); @@ -101,8 +101,8 @@ public void testIncludeMenuItem_hasViewRights_noMenuPart() throws Exception { BaseObject baseObj = new BaseObject(); baseObj.setDocumentReference(docRef); filter.setMenuPart(""); - expect(rightsService.hasAccessLevel(eq("view"), eq(context.getUser()), eq(context.getDatabase() - + ":" + docFullName), same(context))).andReturn(true); + expect(rightsService.hasAccessLevel(eq("view"), eq(context.getUser()), + eq(context.getDatabase() + ":" + docFullName), same(context))).andReturn(true); replayDefault(); assertTrue(filter.includeMenuItem(baseObj, context)); verifyDefault(); @@ -117,8 +117,8 @@ public void testIncludeMenuItem_hasViewRights_wrongMenuPart() throws Exception { baseObj.setDocumentReference(docRef); baseObj.setStringValue("part_name", "anotherPart"); filter.setMenuPart("mainPart"); - expect(rightsService.hasAccessLevel(eq("view"), eq(context.getUser()), eq(context.getDatabase() - + ":" + docFullName), same(context))).andReturn(true); + expect(rightsService.hasAccessLevel(eq("view"), eq(context.getUser()), + eq(context.getDatabase() + ":" + docFullName), same(context))).andReturn(true); replayDefault(); assertFalse(filter.includeMenuItem(baseObj, context)); verifyDefault(); @@ -133,8 +133,8 @@ public void testIncludeMenuItem_hasViewRights_matchingMenuPart() throws Exceptio baseObj.setDocumentReference(docRef); baseObj.setStringValue("part_name", "mainPart"); filter.setMenuPart("mainPart"); - expect(rightsService.hasAccessLevel(eq("view"), eq(context.getUser()), eq(context.getDatabase() - + ":" + docFullName), same(context))).andReturn(true); + expect(rightsService.hasAccessLevel(eq("view"), eq(context.getUser()), + eq(context.getDatabase() + ":" + docFullName), same(context))).andReturn(true); replayDefault(); assertTrue(filter.includeMenuItem(baseObj, context)); verifyDefault(); @@ -149,8 +149,9 @@ public void testIncludeMenuItem_Exception() throws Exception { baseObj.setDocumentReference(docRef); baseObj.setStringValue("part_name", "mainPart"); filter.setMenuPart("mainPart"); - expect(rightsService.hasAccessLevel(eq("view"), eq(context.getUser()), eq(context.getDatabase() - + ":" + docFullName), same(context))).andThrow(new XWikiException()); + expect(rightsService.hasAccessLevel(eq("view"), eq(context.getUser()), + eq(context.getDatabase() + ":" + docFullName), same(context))) + .andThrow(new XWikiException()); replayDefault(); assertFalse(filter.includeMenuItem(baseObj, context)); verifyDefault(); @@ -161,8 +162,8 @@ public void testIncludeTreeNode_noViewRights() throws Exception { String docFullName = "MySpace.MyDoc"; TreeNode node = new TreeNode(new DocumentReference(context.getDatabase(), "MySpace", "MyDoc"), null, 0); - expect(rightsService.hasAccessLevel(eq("view"), eq(context.getUser()), eq(context.getDatabase() - + ":" + docFullName), same(context))).andReturn(false); + expect(rightsService.hasAccessLevel(eq("view"), eq(context.getUser()), + eq(context.getDatabase() + ":" + docFullName), same(context))).andReturn(false); replayDefault(); assertFalse(filter.includeTreeNode(node, context)); verifyDefault(); @@ -174,8 +175,8 @@ public void testIncludeTreeNode_hasViewRights_noMenuPart() throws Exception { TreeNode node = new TreeNode(new DocumentReference(context.getDatabase(), "MySpace", "MyDoc"), null, 0); filter.setMenuPart(""); - expect(rightsService.hasAccessLevel(eq("view"), eq(context.getUser()), eq(context.getDatabase() - + ":" + docFullName), same(context))).andReturn(true); + expect(rightsService.hasAccessLevel(eq("view"), eq(context.getUser()), + eq(context.getDatabase() + ":" + docFullName), same(context))).andReturn(true); replayDefault(); assertTrue(filter.includeTreeNode(node, context)); verifyDefault(); @@ -187,8 +188,8 @@ public void testIncludeTreeNode_hasViewRights_wrongMenuPart() throws Exception { TreeNode node = new TreeNode(new DocumentReference(context.getDatabase(), "MySpace", "MyDoc"), null, 0, "anotherPart"); filter.setMenuPart("mainPart"); - expect(rightsService.hasAccessLevel(eq("view"), eq(context.getUser()), eq(context.getDatabase() - + ":" + docFullName), same(context))).andReturn(true); + expect(rightsService.hasAccessLevel(eq("view"), eq(context.getUser()), + eq(context.getDatabase() + ":" + docFullName), same(context))).andReturn(true); replayDefault(); assertFalse(filter.includeTreeNode(node, context)); verifyDefault(); @@ -200,8 +201,8 @@ public void testIncludeTreeNode_hasViewRights_matchingMenuPart() throws Exceptio TreeNode node = new TreeNode(new DocumentReference(context.getDatabase(), "MySpace", "MyDoc"), null, 0, "mainPart"); filter.setMenuPart("mainPart"); - expect(rightsService.hasAccessLevel(eq("view"), eq(context.getUser()), eq(context.getDatabase() - + ":" + docFullName), same(context))).andReturn(true); + expect(rightsService.hasAccessLevel(eq("view"), eq(context.getUser()), + eq(context.getDatabase() + ":" + docFullName), same(context))).andReturn(true); replayDefault(); assertTrue(filter.includeTreeNode(node, context)); verifyDefault(); @@ -213,8 +214,9 @@ public void testIncludeTreeNode_Exception() throws Exception { TreeNode node = new TreeNode(new DocumentReference(context.getDatabase(), "MySpace", "MyDoc"), null, 0, "mainPart"); filter.setMenuPart("mainPart"); - expect(rightsService.hasAccessLevel(eq("view"), eq(context.getUser()), eq(context.getDatabase() - + ":" + docFullName), same(context))).andThrow(new XWikiException()); + expect(rightsService.hasAccessLevel(eq("view"), eq(context.getUser()), + eq(context.getDatabase() + ":" + docFullName), same(context))) + .andThrow(new XWikiException()); replayDefault(); assertFalse(filter.includeTreeNode(node, context)); verifyDefault(); diff --git a/src/test/java/com/celements/navigation/listener/NavigationCreateListenerTest.java b/src/test/java/com/celements/navigation/listener/NavigationCreateListenerTest.java index 68876a5de..e9221bd60 100644 --- a/src/test/java/com/celements/navigation/listener/NavigationCreateListenerTest.java +++ b/src/test/java/com/celements/navigation/listener/NavigationCreateListenerTest.java @@ -31,8 +31,9 @@ public void testGetName() { @Test public void testGetRequiredObjClassRef() { WikiReference wikiRef = new WikiReference("myWiki"); - assertEquals(Utils.getComponent(INavigationClassConfig.class).getNavigationConfigClassRef( - wikiRef), listener.getRequiredObjClassRef(wikiRef)); + assertEquals( + Utils.getComponent(INavigationClassConfig.class).getNavigationConfigClassRef(wikiRef), + listener.getRequiredObjClassRef(wikiRef)); } @Test diff --git a/src/test/java/com/celements/navigation/listener/NavigationDeleteListenerTest.java b/src/test/java/com/celements/navigation/listener/NavigationDeleteListenerTest.java index 2c85ee621..c6ed550bb 100644 --- a/src/test/java/com/celements/navigation/listener/NavigationDeleteListenerTest.java +++ b/src/test/java/com/celements/navigation/listener/NavigationDeleteListenerTest.java @@ -31,8 +31,9 @@ public void testGetName() { @Test public void testGetRequiredObjClassRef() { WikiReference wikiRef = new WikiReference("myWiki"); - assertEquals(Utils.getComponent(INavigationClassConfig.class).getNavigationConfigClassRef( - wikiRef), listener.getRequiredObjClassRef(wikiRef)); + assertEquals( + Utils.getComponent(INavigationClassConfig.class).getNavigationConfigClassRef(wikiRef), + listener.getRequiredObjClassRef(wikiRef)); } @Test diff --git a/src/test/java/com/celements/navigation/listener/NavigationUpdateListenerTest.java b/src/test/java/com/celements/navigation/listener/NavigationUpdateListenerTest.java index 2f2ff6d26..9bbbe8333 100644 --- a/src/test/java/com/celements/navigation/listener/NavigationUpdateListenerTest.java +++ b/src/test/java/com/celements/navigation/listener/NavigationUpdateListenerTest.java @@ -31,8 +31,9 @@ public void testGetName() { @Test public void testGetRequiredObjClassRef() { WikiReference wikiRef = new WikiReference("myWiki"); - assertEquals(Utils.getComponent(INavigationClassConfig.class).getNavigationConfigClassRef( - wikiRef), listener.getRequiredObjClassRef(wikiRef)); + assertEquals( + Utils.getComponent(INavigationClassConfig.class).getNavigationConfigClassRef(wikiRef), + listener.getRequiredObjClassRef(wikiRef)); } @Test diff --git a/src/test/java/com/celements/navigation/listener/TreeNodeDocumentCreatedListenerTest.java b/src/test/java/com/celements/navigation/listener/TreeNodeDocumentCreatedListenerTest.java index 24b419d35..d2226e892 100644 --- a/src/test/java/com/celements/navigation/listener/TreeNodeDocumentCreatedListenerTest.java +++ b/src/test/java/com/celements/navigation/listener/TreeNodeDocumentCreatedListenerTest.java @@ -55,8 +55,8 @@ public void testGetName() { @Test public void testGetEvents() { - List expectedEventClassList = Arrays.asList( - new DocumentCreatedEvent().getClass().getName()); + List expectedEventClassList = Arrays + .asList(new DocumentCreatedEvent().getClass().getName()); replayDefault(); List actualEventList = eventListener.getEvents(); assertEquals(expectedEventClassList.size(), actualEventList.size()); diff --git a/src/test/java/com/celements/navigation/listener/TreeNodeDocumentDeletedListenerTest.java b/src/test/java/com/celements/navigation/listener/TreeNodeDocumentDeletedListenerTest.java index 1027a204d..20956e30d 100644 --- a/src/test/java/com/celements/navigation/listener/TreeNodeDocumentDeletedListenerTest.java +++ b/src/test/java/com/celements/navigation/listener/TreeNodeDocumentDeletedListenerTest.java @@ -69,8 +69,8 @@ public void testGetName() { @Test public void testGetEvents() { - List expectedEventClassList = Arrays.asList( - new DocumentDeletedEvent().getClass().getName()); + List expectedEventClassList = Arrays + .asList(new DocumentDeletedEvent().getClass().getName()); replayDefault(); List actualEventList = eventListener.getEvents(); assertEquals(expectedEventClassList.size(), actualEventList.size()); @@ -168,8 +168,8 @@ public void testOnEvent_localEvent_menuItemObj() { XWikiDocument origDoc = new XWikiDocument(treeNodeDocRef); sourceDoc.setOriginalDocument(origDoc); BaseObject menuItemObj = new BaseObject(); - menuItemObj.setXClassReference(new NavigationClasses().getMenuItemClassRef( - context.getDatabase())); + menuItemObj + .setXClassReference(new NavigationClasses().getMenuItemClassRef(context.getDatabase())); origDoc.addXObject(menuItemObj); RemoteObservationManagerContext remoteObsManagerCtx = createDefaultMock( RemoteObservationManagerContext.class); diff --git a/src/test/java/com/celements/navigation/listener/TreeNodeDocumentUpdatedListenerTest.java b/src/test/java/com/celements/navigation/listener/TreeNodeDocumentUpdatedListenerTest.java index e1090ebad..c56b4608c 100644 --- a/src/test/java/com/celements/navigation/listener/TreeNodeDocumentUpdatedListenerTest.java +++ b/src/test/java/com/celements/navigation/listener/TreeNodeDocumentUpdatedListenerTest.java @@ -65,8 +65,8 @@ public void testGetName() { @Test public void testGetEvents() { - List expectedEventClassList = Arrays.asList( - new DocumentUpdatedEvent().getClass().getName()); + List expectedEventClassList = Arrays + .asList(new DocumentUpdatedEvent().getClass().getName()); replayDefault(); List actualEventList = eventListener.getEvents(); assertEquals(expectedEventClassList.size(), actualEventList.size()); @@ -84,8 +84,8 @@ public void testIsMenuItemAdded_added() { XWikiDocument document = new XWikiDocument(testDocRef); XWikiDocument origDoc = new XWikiDocument(testDocRef); BaseObject menuItemObj = new BaseObject(); - menuItemObj.setXClassReference(getNavigationClasses().getMenuItemClassRef( - context.getDatabase())); + menuItemObj + .setXClassReference(getNavigationClasses().getMenuItemClassRef(context.getDatabase())); document.addXObject(menuItemObj); replayDefault(); assertTrue(eventListener.isMenuItemAdded(document, origDoc)); @@ -99,8 +99,8 @@ public void testIsMenuItemAdded_deleted() { XWikiDocument document = new XWikiDocument(testDocRef); XWikiDocument origDoc = new XWikiDocument(testDocRef); BaseObject menuItemOrigObj = new BaseObject(); - menuItemOrigObj.setXClassReference(getNavigationClasses().getMenuItemClassRef( - context.getDatabase())); + menuItemOrigObj + .setXClassReference(getNavigationClasses().getMenuItemClassRef(context.getDatabase())); origDoc.addXObject(menuItemOrigObj); replayDefault(); assertFalse(eventListener.isMenuItemAdded(document, origDoc)); @@ -114,12 +114,12 @@ public void testIsMenuItemAdded_changed() { XWikiDocument document = new XWikiDocument(testDocRef); XWikiDocument origDoc = new XWikiDocument(testDocRef); BaseObject menuItemObj = new BaseObject(); - menuItemObj.setXClassReference(getNavigationClasses().getMenuItemClassRef( - context.getDatabase())); + menuItemObj + .setXClassReference(getNavigationClasses().getMenuItemClassRef(context.getDatabase())); document.addXObject(menuItemObj); BaseObject menuItemOrigObj = new BaseObject(); - menuItemOrigObj.setXClassReference(getNavigationClasses().getMenuItemClassRef( - context.getDatabase())); + menuItemOrigObj + .setXClassReference(getNavigationClasses().getMenuItemClassRef(context.getDatabase())); origDoc.addXObject(menuItemOrigObj); replayDefault(); assertFalse(eventListener.isMenuItemAdded(document, origDoc)); @@ -144,8 +144,8 @@ public void testIsMenuItemDeleted_added() { XWikiDocument document = new XWikiDocument(testDocRef); XWikiDocument origDoc = new XWikiDocument(testDocRef); BaseObject menuItemObj = new BaseObject(); - menuItemObj.setXClassReference(getNavigationClasses().getMenuItemClassRef( - context.getDatabase())); + menuItemObj + .setXClassReference(getNavigationClasses().getMenuItemClassRef(context.getDatabase())); document.addXObject(menuItemObj); replayDefault(); assertFalse(eventListener.isMenuItemDeleted(document, origDoc)); @@ -159,8 +159,8 @@ public void testIsMenuItemDeleted_deleted() { XWikiDocument document = new XWikiDocument(testDocRef); XWikiDocument origDoc = new XWikiDocument(testDocRef); BaseObject menuItemOrigObj = new BaseObject(); - menuItemOrigObj.setXClassReference(getNavigationClasses().getMenuItemClassRef( - context.getDatabase())); + menuItemOrigObj + .setXClassReference(getNavigationClasses().getMenuItemClassRef(context.getDatabase())); origDoc.addXObject(menuItemOrigObj); replayDefault(); assertTrue(eventListener.isMenuItemDeleted(document, origDoc)); @@ -174,12 +174,12 @@ public void testIsMenuItemDeleted_changed() { XWikiDocument document = new XWikiDocument(testDocRef); XWikiDocument origDoc = new XWikiDocument(testDocRef); BaseObject menuItemObj = new BaseObject(); - menuItemObj.setXClassReference(getNavigationClasses().getMenuItemClassRef( - context.getDatabase())); + menuItemObj + .setXClassReference(getNavigationClasses().getMenuItemClassRef(context.getDatabase())); document.addXObject(menuItemObj); BaseObject menuItemOrigObj = new BaseObject(); - menuItemOrigObj.setXClassReference(getNavigationClasses().getMenuItemClassRef( - context.getDatabase())); + menuItemOrigObj + .setXClassReference(getNavigationClasses().getMenuItemClassRef(context.getDatabase())); origDoc.addXObject(menuItemOrigObj); replayDefault(); assertFalse(eventListener.isMenuItemDeleted(document, origDoc)); @@ -215,8 +215,8 @@ public void testIsMenuItemUpdated_remove_menuItem() { XWikiDocument document = new XWikiDocument(testDocRef); XWikiDocument origDoc = new XWikiDocument(testDocRef); BaseObject menuItemOrigObj = new BaseObject(); - menuItemOrigObj.setXClassReference(getNavigationClasses().getMenuItemClassRef( - context.getDatabase())); + menuItemOrigObj + .setXClassReference(getNavigationClasses().getMenuItemClassRef(context.getDatabase())); origDoc.addXObject(menuItemOrigObj); replayDefault(); assertFalse(eventListener.isMenuItemUpdated(document, origDoc)); @@ -230,8 +230,8 @@ public void testIsMenuItemUpdated_add_menuItem() { XWikiDocument document = new XWikiDocument(testDocRef); XWikiDocument origDoc = new XWikiDocument(testDocRef); BaseObject menuItemObj = new BaseObject(); - menuItemObj.setXClassReference(getNavigationClasses().getMenuItemClassRef( - context.getDatabase())); + menuItemObj + .setXClassReference(getNavigationClasses().getMenuItemClassRef(context.getDatabase())); document.addXObject(menuItemObj); replayDefault(); assertFalse(eventListener.isMenuItemUpdated(document, origDoc)); @@ -245,13 +245,13 @@ public void testIsMenuItemUpdated_changePos_menuItem() { XWikiDocument document = new XWikiDocument(testDocRef); XWikiDocument origDoc = new XWikiDocument(testDocRef); BaseObject menuItemOrigObj = new BaseObject(); - menuItemOrigObj.setXClassReference(getNavigationClasses().getMenuItemClassRef( - context.getDatabase())); + menuItemOrigObj + .setXClassReference(getNavigationClasses().getMenuItemClassRef(context.getDatabase())); menuItemOrigObj.setIntValue(NavigationClasses.MENU_POSITION_FIELD, 2); origDoc.addXObject(menuItemOrigObj); BaseObject menuItemObj = new BaseObject(); - menuItemObj.setXClassReference(getNavigationClasses().getMenuItemClassRef( - context.getDatabase())); + menuItemObj + .setXClassReference(getNavigationClasses().getMenuItemClassRef(context.getDatabase())); menuItemObj.setIntValue(NavigationClasses.MENU_POSITION_FIELD, 1); document.addXObject(menuItemObj); replayDefault(); @@ -266,13 +266,13 @@ public void testIsMenuItemUpdated_changeNavPart_menuItem() { XWikiDocument document = new XWikiDocument(testDocRef); XWikiDocument origDoc = new XWikiDocument(testDocRef); BaseObject menuItemOrigObj = new BaseObject(); - menuItemOrigObj.setXClassReference(getNavigationClasses().getMenuItemClassRef( - context.getDatabase())); + menuItemOrigObj + .setXClassReference(getNavigationClasses().getMenuItemClassRef(context.getDatabase())); menuItemOrigObj.setStringValue(NavigationClasses.MENU_PART_FIELD, ""); origDoc.addXObject(menuItemOrigObj); BaseObject menuItemObj = new BaseObject(); - menuItemObj.setXClassReference(getNavigationClasses().getMenuItemClassRef( - context.getDatabase())); + menuItemObj + .setXClassReference(getNavigationClasses().getMenuItemClassRef(context.getDatabase())); menuItemObj.setStringValue(NavigationClasses.MENU_PART_FIELD, "mainNav"); document.addXObject(menuItemObj); replayDefault(); @@ -293,13 +293,13 @@ public void testIsMenuItemUpdated_parentChange() { "TestSpace", "TestOrigParentPage"); origDoc.setParentReference((EntityReference) origParentReference); BaseObject menuItemOrigObj = new BaseObject(); - menuItemOrigObj.setXClassReference(getNavigationClasses().getMenuItemClassRef( - context.getDatabase())); + menuItemOrigObj + .setXClassReference(getNavigationClasses().getMenuItemClassRef(context.getDatabase())); menuItemOrigObj.setIntValue(NavigationClasses.MENU_POSITION_FIELD, 2); origDoc.addXObject(menuItemOrigObj); BaseObject menuItemObj = new BaseObject(); - menuItemObj.setXClassReference(getNavigationClasses().getMenuItemClassRef( - context.getDatabase())); + menuItemObj + .setXClassReference(getNavigationClasses().getMenuItemClassRef(context.getDatabase())); menuItemObj.setIntValue(NavigationClasses.MENU_POSITION_FIELD, 2); document.addXObject(menuItemObj); replayDefault(); @@ -337,13 +337,13 @@ public void testIsMenuItemUpdated_noChanges() { "TestSpace", "TestParentPage"); origDoc.setParentReference((EntityReference) origParentReference); BaseObject menuItemOrigObj = new BaseObject(); - menuItemOrigObj.setXClassReference(getNavigationClasses().getMenuItemClassRef( - context.getDatabase())); + menuItemOrigObj + .setXClassReference(getNavigationClasses().getMenuItemClassRef(context.getDatabase())); menuItemOrigObj.setIntValue(NavigationClasses.MENU_POSITION_FIELD, 2); origDoc.addXObject(menuItemOrigObj); BaseObject menuItemObj = new BaseObject(); - menuItemObj.setXClassReference(getNavigationClasses().getMenuItemClassRef( - context.getDatabase())); + menuItemObj + .setXClassReference(getNavigationClasses().getMenuItemClassRef(context.getDatabase())); menuItemObj.setIntValue(NavigationClasses.MENU_POSITION_FIELD, 2); document.addXObject(menuItemObj); replayDefault(); diff --git a/src/test/java/com/celements/navigation/presentation/DefaultPresentationTypeTest.java b/src/test/java/com/celements/navigation/presentation/DefaultPresentationTypeTest.java index 04e5618e1..ac7858e69 100644 --- a/src/test/java/com/celements/navigation/presentation/DefaultPresentationTypeTest.java +++ b/src/test/java/com/celements/navigation/presentation/DefaultPresentationTypeTest.java @@ -86,8 +86,8 @@ public void setUp_DefaultPresentationTypeTest() throws Exception { tNServiceMock = createDefaultMock(ITreeNodeService.class); nav.injected_TreeNodeService = tNServiceMock; wUServiceMock = registerComponentMock(IWebUtilsService.class); - expect(wUServiceMock.getRefLocalSerializer()).andReturn(Utils.getComponent( - EntityReferenceSerializer.class, "local")).anyTimes(); + expect(wUServiceMock.getRefLocalSerializer()) + .andReturn(Utils.getComponent(EntityReferenceSerializer.class, "local")).anyTimes(); ptResolverServiceMock = createDefaultMock(PageTypeResolverService.class); nav.injected_PageTypeResolverService = ptResolverServiceMock; defPresType = (DefaultPresentationType) Utils.getComponent(IPresentationTypeRole.class); @@ -108,44 +108,46 @@ public void testAppendMenuItemLink() throws Exception { boolean isFirstItem = true; boolean isLastItem = true; PageTypeReference pageTypeRef = createDefaultMock(PageTypeReference.class); - expect(ptResolverServiceMock.getPageTypeRefForDocWithDefault(eq(currentDocRef))).andReturn( - pageTypeRef); + expect(ptResolverServiceMock.getPageTypeRefForDocWithDefault(eq(currentDocRef))) + .andReturn(pageTypeRef); expect(pageTypeRef.getConfigName()).andReturn(pageType); - expect(wUServiceMock.getDocumentParentsList(eq(currentDocRef), anyBoolean())).andReturn( - Arrays.asList(getDocRefForDocName("bla"), getDocRefForDocName("bli"), getDocRefForDocName( - "blu"))); - expect(xwiki.getURL(eq(currentDocRef), eq("view"), same(context))).andReturn( - "/MySpace/MyCurrentDoc"); - expect(xwiki.getSpacePreferenceAsInt(eq("use_navigation_images"), eq(0), same( - context))).andReturn(0); + expect(wUServiceMock.getDocumentParentsList(eq(currentDocRef), anyBoolean())) + .andReturn(Arrays.asList(getDocRefForDocName("bla"), getDocRefForDocName("bli"), + getDocRefForDocName("blu"))); + expect(xwiki.getURL(eq(currentDocRef), eq("view"), same(context))) + .andReturn("/MySpace/MyCurrentDoc"); + expect(xwiki.getSpacePreferenceAsInt(eq("use_navigation_images"), eq(0), same(context))) + .andReturn(0); MultilingualMenuNameCommand menuNameCmdMock = createDefaultMock( MultilingualMenuNameCommand.class); nav.inject_menuNameCmd(menuNameCmdMock); defPresType.menuNameCmd = menuNameCmdMock; String menuName = "My Current Doc"; - expect(menuNameCmdMock.getMultilingualMenuName(eq(currentDoc.getFullName()), eq("de"), same( - context))).andReturn(menuName).atLeastOnce(); - expect(menuNameCmdMock.addToolTip(eq(currentDoc.getFullName()), eq("de"), same( - context))).andReturn("").atLeastOnce(); + expect(menuNameCmdMock.getMultilingualMenuName(eq(currentDoc.getFullName()), eq("de"), + same(context))).andReturn(menuName).atLeastOnce(); + expect(menuNameCmdMock.addToolTip(eq(currentDoc.getFullName()), eq("de"), same(context))) + .andReturn("").atLeastOnce(); navFilterMock.setMenuPart(eq("")); expectLastCall().atLeastOnce(); String spaceName = "MySpace"; - EntityReference mySpaceRef = new SpaceReference(spaceName, new WikiReference( - context.getDatabase())); - expect(tNServiceMock.getSubNodesForParent(eq(mySpaceRef), same(navFilterMock))).andReturn( - Collections.emptyList()); + EntityReference mySpaceRef = new SpaceReference(spaceName, + new WikiReference(context.getDatabase())); + expect(tNServiceMock.getSubNodesForParent(eq(mySpaceRef), same(navFilterMock))) + .andReturn(Collections.emptyList()); expect(wUServiceMock.hasParentSpace(eq(spaceName))).andReturn(false); expect(mockLayoutCmd.getPageLayoutForDoc(eq(currentDocRef))).andReturn(null); - expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq( - "MySpace.MyCurrentDoc"), same(context))).andReturn(true).atLeastOnce(); + expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), + eq("MySpace.MyCurrentDoc"), same(context))).andReturn(true).atLeastOnce(); replayDefault(); defPresType.appendMenuItemLink(outStream, isFirstItem, isLastItem, menuItem.getDocumentReference(), false, 1, nav); - assertEquals("My Current Doc", outStream.toString()); + assertEquals( + "My Current Doc", + outStream.toString()); verifyDefault(); } @@ -161,45 +163,47 @@ public void testAppendMenuItemLink_withTarget() throws Exception { boolean isFirstItem = true; boolean isLastItem = true; PageTypeReference pageTypeRef = createDefaultMock(PageTypeReference.class); - expect(ptResolverServiceMock.getPageTypeRefForDocWithDefault(eq(currentDocRef))).andReturn( - pageTypeRef); + expect(ptResolverServiceMock.getPageTypeRefForDocWithDefault(eq(currentDocRef))) + .andReturn(pageTypeRef); expect(pageTypeRef.getConfigName()).andReturn(pageType); - expect(wUServiceMock.getDocumentParentsList(eq(currentDocRef), anyBoolean())).andReturn( - Arrays.asList(getDocRefForDocName("bla"), getDocRefForDocName("bli"), getDocRefForDocName( - "blu"))); - expect(xwiki.getURL(eq(currentDocRef), eq("view"), same(context))).andReturn( - "/MySpace/MyCurrentDoc"); - expect(xwiki.getSpacePreferenceAsInt(eq("use_navigation_images"), eq(0), same( - context))).andReturn(0); + expect(wUServiceMock.getDocumentParentsList(eq(currentDocRef), anyBoolean())) + .andReturn(Arrays.asList(getDocRefForDocName("bla"), getDocRefForDocName("bli"), + getDocRefForDocName("blu"))); + expect(xwiki.getURL(eq(currentDocRef), eq("view"), same(context))) + .andReturn("/MySpace/MyCurrentDoc"); + expect(xwiki.getSpacePreferenceAsInt(eq("use_navigation_images"), eq(0), same(context))) + .andReturn(0); MultilingualMenuNameCommand menuNameCmdMock = createDefaultMock( MultilingualMenuNameCommand.class); nav.inject_menuNameCmd(menuNameCmdMock); defPresType.menuNameCmd = menuNameCmdMock; String menuName = "My Current Doc"; - expect(menuNameCmdMock.getMultilingualMenuName(eq(currentDoc.getFullName()), eq("de"), same( - context))).andReturn(menuName).atLeastOnce(); - expect(menuNameCmdMock.addToolTip(eq(currentDoc.getFullName()), eq("de"), same( - context))).andReturn("").atLeastOnce(); + expect(menuNameCmdMock.getMultilingualMenuName(eq(currentDoc.getFullName()), eq("de"), + same(context))).andReturn(menuName).atLeastOnce(); + expect(menuNameCmdMock.addToolTip(eq(currentDoc.getFullName()), eq("de"), same(context))) + .andReturn("").atLeastOnce(); navFilterMock.setMenuPart(eq("")); expectLastCall().atLeastOnce(); String spaceName = "MySpace"; - EntityReference mySpaceRef = new SpaceReference(spaceName, new WikiReference( - context.getDatabase())); - expect(tNServiceMock.getSubNodesForParent(eq(mySpaceRef), same(navFilterMock))).andReturn( - Collections.emptyList()); + EntityReference mySpaceRef = new SpaceReference(spaceName, + new WikiReference(context.getDatabase())); + expect(tNServiceMock.getSubNodesForParent(eq(mySpaceRef), same(navFilterMock))) + .andReturn(Collections.emptyList()); expect(wUServiceMock.hasParentSpace(eq(spaceName))).andReturn(false); expect(mockLayoutCmd.getPageLayoutForDoc(eq(currentDocRef))).andReturn(null); - expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq( - "MySpace.MyCurrentDoc"), same(context))).andReturn(true).atLeastOnce(); + expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), + eq("MySpace.MyCurrentDoc"), same(context))).andReturn(true).atLeastOnce(); getConfigurationSource().setProperty("navigation.linkTarget.enabled", "true"); replayDefault(); defPresType.appendMenuItemLink(outStream, isFirstItem, isLastItem, menuItem.getDocumentReference(), false, 1, nav); - assertEquals("My Current Doc", outStream.toString()); + assertEquals( + "My Current Doc", + outStream.toString()); verifyDefault(); } @@ -212,47 +216,49 @@ public void testAppendMenuItemLink_use_navImages() throws Exception { boolean isFirstItem = true; boolean isLastItem = true; PageTypeReference pageTypeRef = createDefaultMock(PageTypeReference.class); - expect(ptResolverServiceMock.getPageTypeRefForDocWithDefault(eq(currentDocRef))).andReturn( - pageTypeRef); + expect(ptResolverServiceMock.getPageTypeRefForDocWithDefault(eq(currentDocRef))) + .andReturn(pageTypeRef); expect(pageTypeRef.getConfigName()).andReturn(pageType); - expect(wUServiceMock.getDocumentParentsList(eq(currentDocRef), anyBoolean())).andReturn( - Arrays.asList(getDocRefForDocName("bla"), getDocRefForDocName("bli"), getDocRefForDocName( - "blu"))); - expect(xwiki.getURL(eq(currentDocRef), eq("view"), same(context))).andReturn( - "/MySpace/MyCurrentDoc"); + expect(wUServiceMock.getDocumentParentsList(eq(currentDocRef), anyBoolean())) + .andReturn(Arrays.asList(getDocRefForDocName("bla"), getDocRefForDocName("bli"), + getDocRefForDocName("blu"))); + expect(xwiki.getURL(eq(currentDocRef), eq("view"), same(context))) + .andReturn("/MySpace/MyCurrentDoc"); expect(xwiki.isMultiLingual(same(context))).andReturn(true).anyTimes(); - expect(xwiki.getSpacePreferenceAsInt(eq("use_navigation_images"), eq(0), same( - context))).andReturn(1); + expect(xwiki.getSpacePreferenceAsInt(eq("use_navigation_images"), eq(0), same(context))) + .andReturn(1); MultilingualMenuNameCommand menuNameCmdMock = createDefaultMock( MultilingualMenuNameCommand.class); nav.inject_menuNameCmd(menuNameCmdMock); defPresType.menuNameCmd = menuNameCmdMock; String menuName = "My Current Doc"; - expect(menuNameCmdMock.getMultilingualMenuName(eq(currentDoc.getFullName()), eq("de"), same( - context))).andReturn(menuName).atLeastOnce(); - expect(menuNameCmdMock.addNavImageStyle(eq(currentDoc.getFullName()), eq("de"), same( - context))).andReturn("style=\"background-image:url(abc);\"").atLeastOnce(); - expect(menuNameCmdMock.addToolTip(eq(currentDoc.getFullName()), eq("de"), same( - context))).andReturn("").atLeastOnce(); + expect(menuNameCmdMock.getMultilingualMenuName(eq(currentDoc.getFullName()), eq("de"), + same(context))).andReturn(menuName).atLeastOnce(); + expect(menuNameCmdMock.addNavImageStyle(eq(currentDoc.getFullName()), eq("de"), same(context))) + .andReturn("style=\"background-image:url(abc);\"").atLeastOnce(); + expect(menuNameCmdMock.addToolTip(eq(currentDoc.getFullName()), eq("de"), same(context))) + .andReturn("").atLeastOnce(); navFilterMock.setMenuPart(eq("")); expectLastCall().atLeastOnce(); String spaceName = "MySpace"; - EntityReference mySpaceRef = new SpaceReference(spaceName, new WikiReference( - context.getDatabase())); - expect(tNServiceMock.getSubNodesForParent(eq(mySpaceRef), same(navFilterMock))).andReturn( - Collections.emptyList()); + EntityReference mySpaceRef = new SpaceReference(spaceName, + new WikiReference(context.getDatabase())); + expect(tNServiceMock.getSubNodesForParent(eq(mySpaceRef), same(navFilterMock))) + .andReturn(Collections.emptyList()); expect(wUServiceMock.hasParentSpace(eq(spaceName))).andReturn(false); expect(mockLayoutCmd.getPageLayoutForDoc(eq(currentDocRef))).andReturn(null); - expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq( - "MySpace.MyCurrentDoc"), same(context))).andReturn(true).atLeastOnce(); + expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), + eq("MySpace.MyCurrentDoc"), same(context))).andReturn(true).atLeastOnce(); replayDefault(); defPresType.appendMenuItemLink(outStream, isFirstItem, isLastItem, menuItem.getDocumentReference(), false, 1, nav); - assertEquals("My Current Doc", outStream.toString()); + assertEquals( + "My Current Doc", + outStream.toString()); verifyDefault(); } @@ -265,35 +271,35 @@ public void testAppendMenuItemLink_noLink() throws Exception { boolean isFirstItem = true; boolean isLastItem = true; PageTypeReference pageTypeRef = createDefaultMock(PageTypeReference.class); - expect(ptResolverServiceMock.getPageTypeRefForDocWithDefault(eq(currentDocRef))).andReturn( - pageTypeRef); + expect(ptResolverServiceMock.getPageTypeRefForDocWithDefault(eq(currentDocRef))) + .andReturn(pageTypeRef); expect(pageTypeRef.getConfigName()).andReturn(pageType); - expect(wUServiceMock.getDocumentParentsList(eq(currentDocRef), anyBoolean())).andReturn( - Arrays.asList(getDocRefForDocName("bla"), getDocRefForDocName("bli"), getDocRefForDocName( - "blu"))); + expect(wUServiceMock.getDocumentParentsList(eq(currentDocRef), anyBoolean())) + .andReturn(Arrays.asList(getDocRefForDocName("bla"), getDocRefForDocName("bli"), + getDocRefForDocName("blu"))); expect(xwiki.isMultiLingual(same(context))).andReturn(true).anyTimes(); nav.setHasLink(false); - expect(xwiki.getSpacePreferenceAsInt(eq("use_navigation_images"), eq(0), same( - context))).andReturn(0); + expect(xwiki.getSpacePreferenceAsInt(eq("use_navigation_images"), eq(0), same(context))) + .andReturn(0); MultilingualMenuNameCommand menuNameCmdMock = createDefaultMock( MultilingualMenuNameCommand.class); nav.inject_menuNameCmd(menuNameCmdMock); defPresType.menuNameCmd = menuNameCmdMock; - expect(menuNameCmdMock.getMultilingualMenuName(eq(currentDoc.getFullName()), eq("de"), same( - context))).andReturn("My Current Doc").atLeastOnce(); - expect(menuNameCmdMock.addToolTip(eq(currentDoc.getFullName()), eq("de"), same( - context))).andReturn("").atLeastOnce(); + expect(menuNameCmdMock.getMultilingualMenuName(eq(currentDoc.getFullName()), eq("de"), + same(context))).andReturn("My Current Doc").atLeastOnce(); + expect(menuNameCmdMock.addToolTip(eq(currentDoc.getFullName()), eq("de"), same(context))) + .andReturn("").atLeastOnce(); navFilterMock.setMenuPart(eq("")); expectLastCall().atLeastOnce(); String spaceName = "MySpace"; - EntityReference mySpaceRef = new SpaceReference(spaceName, new WikiReference( - context.getDatabase())); - expect(tNServiceMock.getSubNodesForParent(eq(mySpaceRef), same(navFilterMock))).andReturn( - Collections.emptyList()); + EntityReference mySpaceRef = new SpaceReference(spaceName, + new WikiReference(context.getDatabase())); + expect(tNServiceMock.getSubNodesForParent(eq(mySpaceRef), same(navFilterMock))) + .andReturn(Collections.emptyList()); expect(wUServiceMock.hasParentSpace(eq(spaceName))).andReturn(false); expect(mockLayoutCmd.getPageLayoutForDoc(eq(currentDocRef))).andReturn(null); - expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq( - "MySpace.MyCurrentDoc"), same(context))).andReturn(true).atLeastOnce(); + expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), + eq("MySpace.MyCurrentDoc"), same(context))).andReturn(true).atLeastOnce(); replayDefault(); defPresType.appendMenuItemLink(outStream, isFirstItem, isLastItem, menuItem.getDocumentReference(), true, 1, nav); diff --git a/src/test/java/com/celements/navigation/presentation/LayoutEditorPresentationTypeTest.java b/src/test/java/com/celements/navigation/presentation/LayoutEditorPresentationTypeTest.java index 2fd29f250..32053312d 100644 --- a/src/test/java/com/celements/navigation/presentation/LayoutEditorPresentationTypeTest.java +++ b/src/test/java/com/celements/navigation/presentation/LayoutEditorPresentationTypeTest.java @@ -84,17 +84,17 @@ public void setUp_DefaultPresentationTypeTest() throws Exception { tNServiceMock = createDefaultMock(ITreeNodeService.class); nav.injected_TreeNodeService = tNServiceMock; wUServiceMock = registerComponentMock(IWebUtilsService.class); - expect(wUServiceMock.getRefLocalSerializer()).andReturn(Utils.getComponent( - EntityReferenceSerializer.class, "local")).anyTimes(); + expect(wUServiceMock.getRefLocalSerializer()) + .andReturn(Utils.getComponent(EntityReferenceSerializer.class, "local")).anyTimes(); ptResolverServiceMock = createDefaultMock(PageTypeResolverService.class); nav.injected_PageTypeResolverService = ptResolverServiceMock; - layoutEditorPresType = (LayoutEditorPresentationType) Utils.getComponent( - IPresentationTypeRole.class, "layoutEditor"); + layoutEditorPresType = (LayoutEditorPresentationType) Utils + .getComponent(IPresentationTypeRole.class, "layoutEditor"); mockRightService = createDefaultMock(XWikiRightService.class); expect(xwiki.getRightService()).andReturn(mockRightService).anyTimes(); expect(xwiki.getDocument(eq(currentDocRef), same(context))).andReturn(currentDoc).anyTimes(); - expect(xwiki.getDocument(eq("MySpace.MyCurrentDoc"), same(context))).andReturn( - currentDoc).anyTimes(); + expect(xwiki.getDocument(eq("MySpace.MyCurrentDoc"), same(context))).andReturn(currentDoc) + .anyTimes(); } @Test @@ -106,36 +106,36 @@ public void testAppendMenuItemLink() throws Exception { boolean isFirstItem = true; boolean isLastItem = true; PageTypeReference pageTypeRef = createDefaultMock(PageTypeReference.class); - expect(ptResolverServiceMock.getPageTypeRefForDocWithDefault(eq(currentDocRef))).andReturn( - pageTypeRef); + expect(ptResolverServiceMock.getPageTypeRefForDocWithDefault(eq(currentDocRef))) + .andReturn(pageTypeRef); expect(pageTypeRef.getConfigName()).andReturn(pageType); - expect(wUServiceMock.getDocumentParentsList(eq(currentDocRef), anyBoolean())).andReturn( - Arrays.asList(getDocRefForDocName("bla"), getDocRefForDocName("bli"), getDocRefForDocName( - "blu"))); - expect(xwiki.getURL(eq(currentDocRef), eq("view"), same(context))).andReturn( - "/MySpace/MyCurrentDoc"); - expect(xwiki.getSpacePreferenceAsInt(eq("use_navigation_images"), eq(0), same( - context))).andReturn(0); + expect(wUServiceMock.getDocumentParentsList(eq(currentDocRef), anyBoolean())) + .andReturn(Arrays.asList(getDocRefForDocName("bla"), getDocRefForDocName("bli"), + getDocRefForDocName("blu"))); + expect(xwiki.getURL(eq(currentDocRef), eq("view"), same(context))) + .andReturn("/MySpace/MyCurrentDoc"); + expect(xwiki.getSpacePreferenceAsInt(eq("use_navigation_images"), eq(0), same(context))) + .andReturn(0); MultilingualMenuNameCommand menuNameCmdMock = createDefaultMock( MultilingualMenuNameCommand.class); nav.inject_menuNameCmd(menuNameCmdMock); layoutEditorPresType.menuNameCmd = menuNameCmdMock; String menuName = "My Current Doc"; - expect(menuNameCmdMock.getMultilingualMenuName(eq(currentDoc.getFullName()), eq("de"), same( - context))).andReturn(menuName).atLeastOnce(); - expect(menuNameCmdMock.addToolTip(eq(currentDoc.getFullName()), eq("de"), same( - context))).andReturn("").atLeastOnce(); + expect(menuNameCmdMock.getMultilingualMenuName(eq(currentDoc.getFullName()), eq("de"), + same(context))).andReturn(menuName).atLeastOnce(); + expect(menuNameCmdMock.addToolTip(eq(currentDoc.getFullName()), eq("de"), same(context))) + .andReturn("").atLeastOnce(); navFilterMock.setMenuPart(eq("")); expectLastCall().atLeastOnce(); String spaceName = "MySpace"; - EntityReference mySpaceRef = new SpaceReference(spaceName, new WikiReference( - context.getDatabase())); - expect(tNServiceMock.getSubNodesForParent(eq(mySpaceRef), same(navFilterMock))).andReturn( - Collections.emptyList()); + EntityReference mySpaceRef = new SpaceReference(spaceName, + new WikiReference(context.getDatabase())); + expect(tNServiceMock.getSubNodesForParent(eq(mySpaceRef), same(navFilterMock))) + .andReturn(Collections.emptyList()); expect(wUServiceMock.hasParentSpace(eq(spaceName))).andReturn(false); expect(mockLayoutCmd.getPageLayoutForDoc(eq(currentDocRef))).andReturn(null); - expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq( - "MySpace.MyCurrentDoc"), same(context))).andReturn(true).atLeastOnce(); + expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), + eq("MySpace.MyCurrentDoc"), same(context))).andReturn(true).atLeastOnce(); replayDefault(); layoutEditorPresType.appendMenuItemLink(outStream, isFirstItem, isLastItem, menuItem.getDocumentReference(), false, 1, nav); @@ -156,36 +156,36 @@ public void testAppendMenuItemLink_withCellId() throws Exception { boolean isFirstItem = true; boolean isLastItem = true; PageTypeReference pageTypeRef = createDefaultMock(PageTypeReference.class); - expect(ptResolverServiceMock.getPageTypeRefForDocWithDefault(eq(currentDocRef))).andReturn( - pageTypeRef); + expect(ptResolverServiceMock.getPageTypeRefForDocWithDefault(eq(currentDocRef))) + .andReturn(pageTypeRef); expect(pageTypeRef.getConfigName()).andReturn(pageType); - expect(wUServiceMock.getDocumentParentsList(eq(currentDocRef), anyBoolean())).andReturn( - Arrays.asList(getDocRefForDocName("bla"), getDocRefForDocName("bli"), getDocRefForDocName( - "blu"))); - expect(xwiki.getURL(eq(currentDocRef), eq("view"), same(context))).andReturn( - "/MySpace/MyCurrentDoc"); - expect(xwiki.getSpacePreferenceAsInt(eq("use_navigation_images"), eq(0), same( - context))).andReturn(0); + expect(wUServiceMock.getDocumentParentsList(eq(currentDocRef), anyBoolean())) + .andReturn(Arrays.asList(getDocRefForDocName("bla"), getDocRefForDocName("bli"), + getDocRefForDocName("blu"))); + expect(xwiki.getURL(eq(currentDocRef), eq("view"), same(context))) + .andReturn("/MySpace/MyCurrentDoc"); + expect(xwiki.getSpacePreferenceAsInt(eq("use_navigation_images"), eq(0), same(context))) + .andReturn(0); MultilingualMenuNameCommand menuNameCmdMock = createDefaultMock( MultilingualMenuNameCommand.class); nav.inject_menuNameCmd(menuNameCmdMock); layoutEditorPresType.menuNameCmd = menuNameCmdMock; String menuName = "My Current Doc"; - expect(menuNameCmdMock.getMultilingualMenuName(eq(currentDoc.getFullName()), eq("de"), same( - context))).andReturn(menuName).atLeastOnce(); - expect(menuNameCmdMock.addToolTip(eq(currentDoc.getFullName()), eq("de"), same( - context))).andReturn("").atLeastOnce(); + expect(menuNameCmdMock.getMultilingualMenuName(eq(currentDoc.getFullName()), eq("de"), + same(context))).andReturn(menuName).atLeastOnce(); + expect(menuNameCmdMock.addToolTip(eq(currentDoc.getFullName()), eq("de"), same(context))) + .andReturn("").atLeastOnce(); navFilterMock.setMenuPart(eq("")); expectLastCall().atLeastOnce(); String spaceName = "MySpace"; - EntityReference mySpaceRef = new SpaceReference(spaceName, new WikiReference( - context.getDatabase())); - expect(tNServiceMock.getSubNodesForParent(eq(mySpaceRef), same(navFilterMock))).andReturn( - Collections.emptyList()); + EntityReference mySpaceRef = new SpaceReference(spaceName, + new WikiReference(context.getDatabase())); + expect(tNServiceMock.getSubNodesForParent(eq(mySpaceRef), same(navFilterMock))) + .andReturn(Collections.emptyList()); expect(wUServiceMock.hasParentSpace(eq(spaceName))).andReturn(false); expect(mockLayoutCmd.getPageLayoutForDoc(eq(currentDocRef))).andReturn(null); - expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq( - "MySpace.MyCurrentDoc"), same(context))).andReturn(true).atLeastOnce(); + expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), + eq("MySpace.MyCurrentDoc"), same(context))).andReturn(true).atLeastOnce(); BaseObject cellPropertiesObj = new BaseObject(); cellPropertiesObj.setXClassReference(new CellsClasses().getCellClassRef(context.getDatabase())); cellPropertiesObj.setStringValue(CellsClasses.CELLCLASS_IDNAME_FIELD, "cellTestId"); @@ -193,11 +193,12 @@ public void testAppendMenuItemLink_withCellId() throws Exception { replayDefault(); layoutEditorPresType.appendMenuItemLink(outStream, isFirstItem, isLastItem, menuItem.getDocumentReference(), false, 1, nav); - assertEquals("My Current Doc (#cellTestId)", + assertEquals( + "My Current Doc (#cellTestId)", outStream.toString()); verifyDefault(); } @@ -211,39 +212,39 @@ public void testAppendMenuItemLink_use_navImages() throws Exception { boolean isFirstItem = true; boolean isLastItem = true; PageTypeReference pageTypeRef = createDefaultMock(PageTypeReference.class); - expect(ptResolverServiceMock.getPageTypeRefForDocWithDefault(eq(currentDocRef))).andReturn( - pageTypeRef); + expect(ptResolverServiceMock.getPageTypeRefForDocWithDefault(eq(currentDocRef))) + .andReturn(pageTypeRef); expect(pageTypeRef.getConfigName()).andReturn(pageType); - expect(wUServiceMock.getDocumentParentsList(eq(currentDocRef), anyBoolean())).andReturn( - Arrays.asList(getDocRefForDocName("bla"), getDocRefForDocName("bli"), getDocRefForDocName( - "blu"))); - expect(xwiki.getURL(eq(currentDocRef), eq("view"), same(context))).andReturn( - "/MySpace/MyCurrentDoc"); + expect(wUServiceMock.getDocumentParentsList(eq(currentDocRef), anyBoolean())) + .andReturn(Arrays.asList(getDocRefForDocName("bla"), getDocRefForDocName("bli"), + getDocRefForDocName("blu"))); + expect(xwiki.getURL(eq(currentDocRef), eq("view"), same(context))) + .andReturn("/MySpace/MyCurrentDoc"); expect(xwiki.isMultiLingual(same(context))).andReturn(true).anyTimes(); - expect(xwiki.getSpacePreferenceAsInt(eq("use_navigation_images"), eq(0), same( - context))).andReturn(1); + expect(xwiki.getSpacePreferenceAsInt(eq("use_navigation_images"), eq(0), same(context))) + .andReturn(1); MultilingualMenuNameCommand menuNameCmdMock = createDefaultMock( MultilingualMenuNameCommand.class); nav.inject_menuNameCmd(menuNameCmdMock); layoutEditorPresType.menuNameCmd = menuNameCmdMock; String menuName = "My Current Doc"; - expect(menuNameCmdMock.getMultilingualMenuName(eq(currentDoc.getFullName()), eq("de"), same( - context))).andReturn(menuName).atLeastOnce(); - expect(menuNameCmdMock.addNavImageStyle(eq(currentDoc.getFullName()), eq("de"), same( - context))).andReturn("style=\"background-image:url(abc);\"").atLeastOnce(); - expect(menuNameCmdMock.addToolTip(eq(currentDoc.getFullName()), eq("de"), same( - context))).andReturn("").atLeastOnce(); + expect(menuNameCmdMock.getMultilingualMenuName(eq(currentDoc.getFullName()), eq("de"), + same(context))).andReturn(menuName).atLeastOnce(); + expect(menuNameCmdMock.addNavImageStyle(eq(currentDoc.getFullName()), eq("de"), same(context))) + .andReturn("style=\"background-image:url(abc);\"").atLeastOnce(); + expect(menuNameCmdMock.addToolTip(eq(currentDoc.getFullName()), eq("de"), same(context))) + .andReturn("").atLeastOnce(); navFilterMock.setMenuPart(eq("")); expectLastCall().atLeastOnce(); String spaceName = "MySpace"; - EntityReference mySpaceRef = new SpaceReference(spaceName, new WikiReference( - context.getDatabase())); - expect(tNServiceMock.getSubNodesForParent(eq(mySpaceRef), same(navFilterMock))).andReturn( - Collections.emptyList()); + EntityReference mySpaceRef = new SpaceReference(spaceName, + new WikiReference(context.getDatabase())); + expect(tNServiceMock.getSubNodesForParent(eq(mySpaceRef), same(navFilterMock))) + .andReturn(Collections.emptyList()); expect(wUServiceMock.hasParentSpace(eq(spaceName))).andReturn(false); expect(mockLayoutCmd.getPageLayoutForDoc(eq(currentDocRef))).andReturn(null); - expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq( - "MySpace.MyCurrentDoc"), same(context))).andReturn(true).atLeastOnce(); + expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), + eq("MySpace.MyCurrentDoc"), same(context))).andReturn(true).atLeastOnce(); replayDefault(); layoutEditorPresType.appendMenuItemLink(outStream, isFirstItem, isLastItem, menuItem.getDocumentReference(), false, 1, nav); @@ -264,42 +265,44 @@ public void testAppendMenuItemLink_noLink() throws Exception { boolean isFirstItem = true; boolean isLastItem = true; PageTypeReference pageTypeRef = createDefaultMock(PageTypeReference.class); - expect(ptResolverServiceMock.getPageTypeRefForDocWithDefault(eq(currentDocRef))).andReturn( - pageTypeRef); + expect(ptResolverServiceMock.getPageTypeRefForDocWithDefault(eq(currentDocRef))) + .andReturn(pageTypeRef); expect(pageTypeRef.getConfigName()).andReturn(pageType); - expect(wUServiceMock.getDocumentParentsList(eq(currentDocRef), anyBoolean())).andReturn( - Arrays.asList(getDocRefForDocName("bla"), getDocRefForDocName("bli"), getDocRefForDocName( - "blu"))); + expect(wUServiceMock.getDocumentParentsList(eq(currentDocRef), anyBoolean())) + .andReturn(Arrays.asList(getDocRefForDocName("bla"), getDocRefForDocName("bli"), + getDocRefForDocName("blu"))); expect(xwiki.isMultiLingual(same(context))).andReturn(true).anyTimes(); nav.setHasLink(false); - expect(xwiki.getSpacePreferenceAsInt(eq("use_navigation_images"), eq(0), same( - context))).andReturn(0); + expect(xwiki.getSpacePreferenceAsInt(eq("use_navigation_images"), eq(0), same(context))) + .andReturn(0); MultilingualMenuNameCommand menuNameCmdMock = createDefaultMock( MultilingualMenuNameCommand.class); nav.inject_menuNameCmd(menuNameCmdMock); layoutEditorPresType.menuNameCmd = menuNameCmdMock; - expect(menuNameCmdMock.getMultilingualMenuName(eq(currentDoc.getFullName()), eq("de"), same( - context))).andReturn("My Current Doc").atLeastOnce(); - expect(menuNameCmdMock.addToolTip(eq(currentDoc.getFullName()), eq("de"), same( - context))).andReturn("").atLeastOnce(); + expect(menuNameCmdMock.getMultilingualMenuName(eq(currentDoc.getFullName()), eq("de"), + same(context))).andReturn("My Current Doc").atLeastOnce(); + expect(menuNameCmdMock.addToolTip(eq(currentDoc.getFullName()), eq("de"), same(context))) + .andReturn("").atLeastOnce(); navFilterMock.setMenuPart(eq("")); expectLastCall().atLeastOnce(); String spaceName = "MySpace"; - EntityReference mySpaceRef = new SpaceReference(spaceName, new WikiReference( - context.getDatabase())); - expect(tNServiceMock.getSubNodesForParent(eq(mySpaceRef), same(navFilterMock))).andReturn( - Collections.emptyList()); + EntityReference mySpaceRef = new SpaceReference(spaceName, + new WikiReference(context.getDatabase())); + expect(tNServiceMock.getSubNodesForParent(eq(mySpaceRef), same(navFilterMock))) + .andReturn(Collections.emptyList()); expect(wUServiceMock.hasParentSpace(eq(spaceName))).andReturn(false); expect(mockLayoutCmd.getPageLayoutForDoc(eq(currentDocRef))).andReturn(null); - expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq( - "MySpace.MyCurrentDoc"), same(context))).andReturn(true).atLeastOnce(); + expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), + eq("MySpace.MyCurrentDoc"), same(context))).andReturn(true).atLeastOnce(); replayDefault(); layoutEditorPresType.appendMenuItemLink(outStream, isFirstItem, isLastItem, menuItem.getDocumentReference(), true, 1, nav); - assertEquals("My Current Doc", outStream.toString()); + assertEquals( + "My Current Doc", + outStream.toString()); verifyDefault(); } diff --git a/src/test/java/com/celements/navigation/presentation/PresentationPageTypeTest.java b/src/test/java/com/celements/navigation/presentation/PresentationPageTypeTest.java index dfb1d72fa..38543bc3d 100644 --- a/src/test/java/com/celements/navigation/presentation/PresentationPageTypeTest.java +++ b/src/test/java/com/celements/navigation/presentation/PresentationPageTypeTest.java @@ -70,16 +70,16 @@ public void test_isVisible() { @Test public void test_getViewTemplateName() { replayDefault(); - assertEquals(PresentationPageType.VIEW_TEMPLATE_NAME, presentationPageType - .getViewTemplateName()); + assertEquals(PresentationPageType.VIEW_TEMPLATE_NAME, + presentationPageType.getViewTemplateName()); verifyDefault(); } @Test public void test_getEditTemplateName() { replayDefault(); - assertEquals(PresentationPageType.EDIT_TEMPLATE_NAME, presentationPageType - .getEditTemplateName()); + assertEquals(PresentationPageType.EDIT_TEMPLATE_NAME, + presentationPageType.getEditTemplateName()); verifyDefault(); } diff --git a/src/test/java/com/celements/navigation/presentation/RenderedContentDynLoadPresentationTypeTest.java b/src/test/java/com/celements/navigation/presentation/RenderedContentDynLoadPresentationTypeTest.java index db5f966b4..90f7a0c74 100644 --- a/src/test/java/com/celements/navigation/presentation/RenderedContentDynLoadPresentationTypeTest.java +++ b/src/test/java/com/celements/navigation/presentation/RenderedContentDynLoadPresentationTypeTest.java @@ -110,11 +110,12 @@ public void test_writeNodeContent_emptyQuery() throws Exception { String expectedUrl = "/MySpace/MyCurrentDoc?" + queryString; String expectedNodeContent = "\n"; - expect(nav.addUniqueElementId(eq(currentDocRef))).andReturn( - "id=\"N3:Content:Content.MyPage\"").once(); - expect(nav.addCssClasses(eq(currentDocRef), eq(true), eq(isFirstItem), eq(isLastItem), eq( - isLeaf), eq(1))).andReturn("class=\"cel_cm_navigation_menuitem" - + " first cel_nav_isLeaf RichText\"").once(); + expect(nav.addUniqueElementId(eq(currentDocRef))).andReturn("id=\"N3:Content:Content.MyPage\"") + .once(); + expect(nav.addCssClasses(eq(currentDocRef), eq(true), eq(isFirstItem), eq(isLastItem), + eq(isLeaf), eq(1))) + .andReturn("class=\"cel_cm_navigation_menuitem" + " first cel_nav_isLeaf RichText\"") + .once(); expect(urlServiceMock.getURL(eq(currentDocRef), eq("view"), eq(queryString))) .andReturn(expectedUrl); XWikiRequest requestMock = createDefaultMock(XWikiRequest.class); @@ -122,8 +123,9 @@ public void test_writeNodeContent_emptyQuery() throws Exception { expect(requestMock.getParameterMap()).andReturn(paramMap); replayDefault(); vtPresType.writeNodeContent(outStream, isFirstItem, isLastItem, currentDocRef, isLeaf, 1, nav); - assertEquals("
    \n" + expectedNodeContent + "
    \n", + assertEquals( + "
    \n" + expectedNodeContent + "
    \n", outStream.toString()); verifyDefault(); } @@ -140,18 +142,19 @@ public void test_writeNodeContent_withQuery() throws Exception { boolean isLeaf = true; String additionalParams = "startDate=12.10.2023"; Map paramMap = Map.of("ajax", new String[] { "0" }, "xpage", - new String[] { "sfda" }, "startDate", new String[] { "12.10.2023" }, - "ajax_mode", new String[] { "safd", "safd2" }); + new String[] { "sfda" }, "startDate", new String[] { "12.10.2023" }, "ajax_mode", + new String[] { "safd", "safd2" }); String queryString = "xpage=ajax&ajax_mode=rendering/renderDocumentWithPageType&ajax=1&" + additionalParams; String expectedUrl = "/MySpace/MyCurrentDoc?" + queryString; String expectedNodeContent = "\n"; - expect(nav.addUniqueElementId(eq(currentDocRef))).andReturn( - "id=\"N3:Content:Content.MyPage\"").once(); - expect(nav.addCssClasses(eq(currentDocRef), eq(true), eq(isFirstItem), eq(isLastItem), eq( - isLeaf), eq(1))).andReturn("class=\"cel_cm_navigation_menuitem" - + " first cel_nav_isLeaf RichText\"").once(); + expect(nav.addUniqueElementId(eq(currentDocRef))).andReturn("id=\"N3:Content:Content.MyPage\"") + .once(); + expect(nav.addCssClasses(eq(currentDocRef), eq(true), eq(isFirstItem), eq(isLastItem), + eq(isLeaf), eq(1))) + .andReturn("class=\"cel_cm_navigation_menuitem" + " first cel_nav_isLeaf RichText\"") + .once(); expect(urlServiceMock.getURL(eq(currentDocRef), eq("view"), eq(queryString))) .andReturn(expectedUrl); XWikiRequest requestMock = createDefaultMock(XWikiRequest.class); @@ -159,8 +162,9 @@ public void test_writeNodeContent_withQuery() throws Exception { expect(requestMock.getParameterMap()).andReturn(paramMap); replayDefault(); vtPresType.writeNodeContent(outStream, isFirstItem, isLastItem, currentDocRef, isLeaf, 1, nav); - assertEquals("
    \n" + expectedNodeContent + "
    \n", + assertEquals( + "
    \n" + expectedNodeContent + "
    \n", outStream.toString()); verifyDefault(); } diff --git a/src/test/java/com/celements/navigation/presentation/RenderedContentPresentationTypeTest.java b/src/test/java/com/celements/navigation/presentation/RenderedContentPresentationTypeTest.java index 071402236..cf3107cb8 100644 --- a/src/test/java/com/celements/navigation/presentation/RenderedContentPresentationTypeTest.java +++ b/src/test/java/com/celements/navigation/presentation/RenderedContentPresentationTypeTest.java @@ -98,17 +98,19 @@ public void testWriteNodeContent() throws Exception { boolean isLastItem = false; boolean isLeaf = true; String expectedNodeContent = "expected rendered content for node"; - expect(renderCmdMock.renderCelementsDocument(eq(currentDocRef), eq("view"))).andReturn( - expectedNodeContent); - expect(nav.addUniqueElementId(eq(currentDocRef))).andReturn( - "id=\"N3:Content:Content.MyPage\"").once(); - expect(nav.addCssClasses(eq(currentDocRef), eq(true), eq(isFirstItem), eq(isLastItem), eq( - isLeaf), eq(1))).andReturn("class=\"cel_cm_navigation_menuitem" - + " first cel_nav_isLeaf RichText\"").once(); + expect(renderCmdMock.renderCelementsDocument(eq(currentDocRef), eq("view"))) + .andReturn(expectedNodeContent); + expect(nav.addUniqueElementId(eq(currentDocRef))).andReturn("id=\"N3:Content:Content.MyPage\"") + .once(); + expect(nav.addCssClasses(eq(currentDocRef), eq(true), eq(isFirstItem), eq(isLastItem), + eq(isLeaf), eq(1))) + .andReturn("class=\"cel_cm_navigation_menuitem" + " first cel_nav_isLeaf RichText\"") + .once(); replayDefault(); vtPresType.writeNodeContent(outStream, isFirstItem, isLastItem, currentDocRef, isLeaf, 1, nav); - assertEquals("
    \n" + expectedNodeContent + "
    \n", + assertEquals( + "
    \n" + expectedNodeContent + "
    \n", outStream.toString()); verifyDefault(); } diff --git a/src/test/java/com/celements/navigation/presentation/RenderedExtractPresentationTypeTest.java b/src/test/java/com/celements/navigation/presentation/RenderedExtractPresentationTypeTest.java index 7bd8e55ab..b53c606d0 100644 --- a/src/test/java/com/celements/navigation/presentation/RenderedExtractPresentationTypeTest.java +++ b/src/test/java/com/celements/navigation/presentation/RenderedExtractPresentationTypeTest.java @@ -113,23 +113,24 @@ public void testWriteNodeContent() throws Exception { boolean isLeaf = true; String expectedNodeExtract = "expected rendered extract for node"; BaseObject extractObj = new BaseObject(); - extractObj.setXClassReference(getDocDetailsClasses().getDocumentExtractClassRef( - context.getDatabase())); + extractObj.setXClassReference( + getDocDetailsClasses().getDocumentExtractClassRef(context.getDatabase())); extractObj.setStringValue(DocumentDetailsClasses.FIELD_DOC_EXTRACT_LANGUAGE, "de"); extractObj.setStringValue(DocumentDetailsClasses.FIELD_DOC_EXTRACT_CONTENT, expectedNodeExtract); currentDoc.addXObject(extractObj); - expect(nav.addUniqueElementId(eq(currentDocRef))).andReturn( - "id=\"N3:Content:Content.MyPage\"").once(); - expect(nav.addCssClasses(eq(currentDocRef), eq(true), eq(isFirstItem), eq(isLastItem), eq( - isLeaf), eq(1))).andReturn("class=\"cel_cm_navigation_menuitem" - + " first cel_nav_isLeaf RichText\"").once(); + expect(nav.addUniqueElementId(eq(currentDocRef))).andReturn("id=\"N3:Content:Content.MyPage\"") + .once(); + expect(nav.addCssClasses(eq(currentDocRef), eq(true), eq(isFirstItem), eq(isLastItem), + eq(isLeaf), eq(1))) + .andReturn("class=\"cel_cm_navigation_menuitem" + " first cel_nav_isLeaf RichText\"") + .once(); expect(xwiki.getDocument(eq(currentDocRef), same(context))).andReturn(currentDoc).atLeastOnce(); DocumentReference templateDocRef = new DocumentReference(context.getDatabase(), "Templates", "RenderedExtract"); String templateDiskPath = ":celTemplates/RenderedExtract.vm"; - expect(webUtilsServiceMock.getInheritedTemplatedPath(eq(templateDocRef))).andReturn( - templateDiskPath); + expect(webUtilsServiceMock.getInheritedTemplatedPath(eq(templateDocRef))) + .andReturn(templateDiskPath); expect(renderCmdMock.renderTemplatePath(eq(templateDiskPath), eq("de"), eq(""))) .andReturn(expectedNodeExtract); replayDefault(); diff --git a/src/test/java/com/celements/navigation/presentation/SitemapPresentationTypeTest.java b/src/test/java/com/celements/navigation/presentation/SitemapPresentationTypeTest.java index be107acdd..9523e6bb3 100644 --- a/src/test/java/com/celements/navigation/presentation/SitemapPresentationTypeTest.java +++ b/src/test/java/com/celements/navigation/presentation/SitemapPresentationTypeTest.java @@ -85,8 +85,8 @@ public void testAddLanguageLinks() throws Exception { List docTransList = new ArrayList<>(); // docTransList.add("de"); <-- defaultLanguage DOES NOT show up in translist!!! docTransList.add("en"); - expect(mockXWikiStore.getTranslationList(same(currentDoc), same(context))).andReturn( - docTransList).atLeastOnce(); + expect(mockXWikiStore.getTranslationList(same(currentDoc), same(context))) + .andReturn(docTransList).atLeastOnce(); expect(wUServiceMock.getDefaultLanguage(eq("MySpace"))).andReturn("de").anyTimes(); expect(wUServiceMock.getAllowedLanguages(eq("MySpace"))).andReturn(allowedLangs).anyTimes(); expect(admMessTool.get(eq("cel_de"))).andReturn("German").once(); @@ -95,26 +95,26 @@ public void testAddLanguageLinks() throws Exception { String currDocDeEditUrlStr = "http://test.ch/edit/MySpace/MyCurrentDoc?language=de" + "&windowClose=true"; URL currentDocDeEditUrl = new URL(currDocDeEditUrlStr); - expect(urlFactoryMock.createURL(eq("MySpace"), eq("MyCurrentDoc"), eq("edit"), eq( - "language=de&windowClose=true"), (String) isNull(), eq("xwikidb"), same(context))) - .andReturn(currentDocDeEditUrl); - expect(urlFactoryMock.getURL(same(currentDocDeEditUrl), same(context))).andReturn( - currDocDeEditUrlStr); + expect(urlFactoryMock.createURL(eq("MySpace"), eq("MyCurrentDoc"), eq("edit"), + eq("language=de&windowClose=true"), (String) isNull(), eq("xwikidb"), same(context))) + .andReturn(currentDocDeEditUrl); + expect(urlFactoryMock.getURL(same(currentDocDeEditUrl), same(context))) + .andReturn(currDocDeEditUrlStr); String currDocFrEditUrlStr = "http://test.ch/edit/MySpace/MyCurrentDoc?language=fr" + "&windowClose=true"; URL currentDocFrEditUrl = new URL(currDocFrEditUrlStr); - expect(urlFactoryMock.createURL(eq("MySpace"), eq("MyCurrentDoc"), eq("edit"), eq( - "language=fr&windowClose=true"), (String) isNull(), eq("xwikidb"), same(context))) - .andReturn(currentDocFrEditUrl); - expect(urlFactoryMock.getURL(same(currentDocFrEditUrl), same(context))).andReturn( - currDocFrEditUrlStr); + expect(urlFactoryMock.createURL(eq("MySpace"), eq("MyCurrentDoc"), eq("edit"), + eq("language=fr&windowClose=true"), (String) isNull(), eq("xwikidb"), same(context))) + .andReturn(currentDocFrEditUrl); + expect(urlFactoryMock.getURL(same(currentDocFrEditUrl), same(context))) + .andReturn(currDocFrEditUrlStr); String currDocEnEditUrlStr = "http://test.ch/edit/MySpace/MyCurrentDoc?language=en&windowClose=true"; URL currentDocEnEditUrl = new URL(currDocEnEditUrlStr); - expect(urlFactoryMock.createURL(eq("MySpace"), eq("MyCurrentDoc"), eq("edit"), eq( - "language=en&windowClose=true"), (String) isNull(), eq("xwikidb"), same(context))) - .andReturn(currentDocEnEditUrl); - expect(urlFactoryMock.getURL(same(currentDocEnEditUrl), same(context))).andReturn( - currDocEnEditUrlStr); + expect(urlFactoryMock.createURL(eq("MySpace"), eq("MyCurrentDoc"), eq("edit"), + eq("language=en&windowClose=true"), (String) isNull(), eq("xwikidb"), same(context))) + .andReturn(currentDocEnEditUrl); + expect(urlFactoryMock.getURL(same(currentDocEnEditUrl), same(context))) + .andReturn(currDocEnEditUrlStr); replayAll(); sitemapPres.addLanguageLinks(outStream, currentDocRef); assertEquals("", - outStream.toString()); + + " rel=\"opener\" class=\"transExists\">" + "en", outStream.toString()); verifyAll(); } diff --git a/src/test/java/com/celements/navigation/service/TreeNodeCacheTest.java b/src/test/java/com/celements/navigation/service/TreeNodeCacheTest.java index 00775bd17..f139ddacd 100644 --- a/src/test/java/com/celements/navigation/service/TreeNodeCacheTest.java +++ b/src/test/java/com/celements/navigation/service/TreeNodeCacheTest.java @@ -60,7 +60,8 @@ public void testGetNotMappedMenuItemsForParentCmd_injected() { @Test public void testGetNotMappedMenuItemsForParentCmd_singleton() { - GetNotMappedMenuItemsForParentCommand testGetMenuItemCommand = treeNodeCache.getNotMappedMenuItemsForParentCmd(); + GetNotMappedMenuItemsForParentCommand testGetMenuItemCommand = treeNodeCache + .getNotMappedMenuItemsForParentCmd(); assertNotNull(testGetMenuItemCommand); assertSame("Expecting injected cmd object", testGetMenuItemCommand, treeNodeCache.getNotMappedMenuItemsForParentCmd()); diff --git a/src/test/java/com/celements/navigation/service/TreeNodeServiceTest.java b/src/test/java/com/celements/navigation/service/TreeNodeServiceTest.java index 90c640826..93f1bcd7e 100644 --- a/src/test/java/com/celements/navigation/service/TreeNodeServiceTest.java +++ b/src/test/java/com/celements/navigation/service/TreeNodeServiceTest.java @@ -67,13 +67,12 @@ public void setUp_TreeNodeServiceTest() throws Exception { mockTreeNodeCache = createDefaultMock(ITreeNodeCache.class); treeNodeService.treeNodeCache = mockTreeNodeCache; treeNodeService.execution = Utils.getComponent(Execution.class); - mockGetNotMenuItemCommand = createDefaultMock( - GetNotMappedMenuItemsForParentCommand.class); - expect(mockTreeNodeCache.getNotMappedMenuItemsForParentCmd()).andReturn( - mockGetNotMenuItemCommand).anyTimes(); + mockGetNotMenuItemCommand = createDefaultMock(GetNotMappedMenuItemsForParentCommand.class); + expect(mockTreeNodeCache.getNotMappedMenuItemsForParentCmd()) + .andReturn(mockGetNotMenuItemCommand).anyTimes(); mockGetMenuItemCommand = createDefaultMock(GetMappedMenuItemsForParentCommand.class); - expect(mockTreeNodeCache.getMappedMenuItemsForParentCmd()).andReturn( - mockGetMenuItemCommand).anyTimes(); + expect(mockTreeNodeCache.getMappedMenuItemsForParentCmd()).andReturn(mockGetMenuItemCommand) + .anyTimes(); backupNodeProviders = treeNodeService.nodeProviders; treeNodeService.nodeProviders = new HashMap<>(backupNodeProviders); } @@ -90,16 +89,16 @@ public void testGetSubNodesForParent() throws Exception { String docName = "myDoc"; String parentKey = wikiName + ":" + spaceName + "."; context.setDatabase(wikiName); - EntityReference spaceRef = new SpaceReference(spaceName, new WikiReference( - context.getDatabase())); + EntityReference spaceRef = new SpaceReference(spaceName, + new WikiReference(context.getDatabase())); TreeNode treeNode = createTreeNode(spaceName, docName, spaceName, "", 1); List mockTreeNodeList = Arrays.asList(treeNode, null); - expect(mockGetNotMenuItemCommand.getTreeNodesForParentKey(eq(parentKey))).andReturn( - mockTreeNodeList); - expect(mockGetMenuItemCommand.getTreeNodesForParentKey(eq(parentKey))).andReturn( - Collections.emptyList()); - expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq(wikiName + ":" - + spaceName + "." + docName), same(context))).andReturn(true); + expect(mockGetNotMenuItemCommand.getTreeNodesForParentKey(eq(parentKey))) + .andReturn(mockTreeNodeList); + expect(mockGetMenuItemCommand.getTreeNodesForParentKey(eq(parentKey))) + .andReturn(Collections.emptyList()); + expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), + eq(wikiName + ":" + spaceName + "." + docName), same(context))).andReturn(true); replayDefault(); List resultList = treeNodeService.getSubNodesForParent(spaceRef, ""); assertEquals(1, resultList.size()); @@ -116,12 +115,12 @@ public void testGetSubNodesForParent_deprecated() throws Exception { context.setDatabase(wikiName); TreeNode treeNode = createTreeNode(spaceName, docName, spaceName, "", 1); List mockTreeNodeList = Arrays.asList(treeNode, null); - expect(mockGetNotMenuItemCommand.getTreeNodesForParentKey(eq(parentKey))).andReturn( - mockTreeNodeList); + expect(mockGetNotMenuItemCommand.getTreeNodesForParentKey(eq(parentKey))) + .andReturn(mockTreeNodeList); List emptyList = Collections.emptyList(); expect(mockGetMenuItemCommand.getTreeNodesForParentKey(eq(parentKey))).andReturn(emptyList); - expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq(wikiName + ":" - + spaceName + "." + docName), same(context))).andReturn(true); + expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), + eq(wikiName + ":" + spaceName + "." + docName), same(context))).andReturn(true); replayDefault(); List resultList = treeNodeService.getSubNodesForParent("", spaceName, ""); assertEquals(1, resultList.size()); @@ -142,15 +141,14 @@ public void testFetchNodesForParentKey_mergeCombinedResult() { TreeNode menuItem2 = createTreeNode(spaceName, "myDoc2", spaceName, docName, 2); TreeNode menuItem3 = createTreeNode(spaceName, "myDoc1", spaceName, docName, 3); TreeNode menuItem5 = createTreeNode(spaceName, "myDoc5", spaceName, docName, 5); - List mappedList = Arrays.asList(menuItem1, menuItem5), notMappedList = Arrays.asList( - menuItem2, menuItem3), - expectedList = Arrays.asList(menuItem1, menuItem2, menuItem3, - menuItem5); + List mappedList = Arrays.asList(menuItem1, menuItem5), + notMappedList = Arrays.asList(menuItem2, menuItem3), + expectedList = Arrays.asList(menuItem1, menuItem2, menuItem3, menuItem5); - expect(mockGetMenuItemCommand.getTreeNodesForParentKey(eq(parentKey))).andReturn( - mappedList).once(); - expect(mockGetNotMenuItemCommand.getTreeNodesForParentKey(eq(parentKey))).andReturn( - notMappedList).once(); + expect(mockGetMenuItemCommand.getTreeNodesForParentKey(eq(parentKey))).andReturn(mappedList) + .once(); + expect(mockGetNotMenuItemCommand.getTreeNodesForParentKey(eq(parentKey))) + .andReturn(notMappedList).once(); replayDefault(); List menuItemsMerged = treeNodeService.fetchNodesForParent(docRef); @@ -187,12 +185,12 @@ public void testFetchNodesForParentKey_merge_TreeNodeProviders() { List notMappedList = Arrays.asList(menuItem2, menuItem3); List expectedList = Arrays.asList(menuItem1, menuItem2, menuItem3, menuItem5); - expect(mockGetMenuItemCommand.getTreeNodesForParentKey(eq(parentKey))).andReturn( - mappedList).once(); - expect(mockGetNotMenuItemCommand.getTreeNodesForParentKey(eq(parentKey))).andReturn( - notMappedList).once(); - expect(nodeProviderMock.getTreeNodesForParent(eq(parentKey))).andReturn( - nodeProviderList).once(); + expect(mockGetMenuItemCommand.getTreeNodesForParentKey(eq(parentKey))).andReturn(mappedList) + .once(); + expect(mockGetNotMenuItemCommand.getTreeNodesForParentKey(eq(parentKey))) + .andReturn(notMappedList).once(); + expect(nodeProviderMock.getTreeNodesForParent(eq(parentKey))).andReturn(nodeProviderList) + .once(); replayDefault(); List menuItemsMerged = treeNodeService.fetchNodesForParent(docRef); @@ -267,10 +265,10 @@ public void testFetchNodesForParentKey_onlyOldArray() throws Exception { TreeNode menuItem3 = createTreeNode(spaceName, "myDoc1", spaceName, docName, 3); List oldNotMappedList = Arrays.asList(menuItem2, menuItem3); List mappedList = Collections.emptyList(); - expect(mockGetMenuItemCommand.getTreeNodesForParentKey(eq(parentKey))).andReturn( - mappedList).once(); - expect(mockGetNotMenuItemCommand.getTreeNodesForParentKey(eq(parentKey))).andReturn( - oldNotMappedList).once(); + expect(mockGetMenuItemCommand.getTreeNodesForParentKey(eq(parentKey))).andReturn(mappedList) + .once(); + expect(mockGetNotMenuItemCommand.getTreeNodesForParentKey(eq(parentKey))) + .andReturn(oldNotMappedList).once(); replayDefault(); List menuItemsMerged = treeNodeService.fetchNodesForParent(docRef); assertSame("expecting old notMapped list.", oldNotMappedList, menuItemsMerged); @@ -290,10 +288,10 @@ public void testFetchNodesForParentKey_onlyNewMappedList() { TreeNode menuItem1 = createTreeNode(spaceName, "myDoc1", spaceName, docName, 1); TreeNode menuItem5 = createTreeNode(spaceName, "myDoc5", spaceName, docName, 5); List mappedList = Arrays.asList(menuItem1, menuItem5); - expect(mockGetMenuItemCommand.getTreeNodesForParentKey(eq(parentKey))).andReturn( - mappedList).once(); - expect(mockGetNotMenuItemCommand.getTreeNodesForParentKey(eq(parentKey))).andReturn( - oldMenuItems).once(); + expect(mockGetMenuItemCommand.getTreeNodesForParentKey(eq(parentKey))).andReturn(mappedList) + .once(); + expect(mockGetNotMenuItemCommand.getTreeNodesForParentKey(eq(parentKey))) + .andReturn(oldMenuItems).once(); replayDefault(); List menuItemsMerged = treeNodeService.fetchNodesForParent(docRef); assertSame("expecting old notMapped list.", mappedList, menuItemsMerged); @@ -309,10 +307,10 @@ public void testFetchNodesForParentKey_noMenuItems_NPE() { context.setDatabase(wikiName); DocumentReference docRef = new DocumentReference(context.getDatabase(), spaceName, docName); List mappedList = Collections.emptyList(); - expect(mockGetMenuItemCommand.getTreeNodesForParentKey(eq(parentKey))).andReturn( - mappedList).once(); - expect(mockGetNotMenuItemCommand.getTreeNodesForParentKey(eq(parentKey))).andReturn( - null).once(); + expect(mockGetMenuItemCommand.getTreeNodesForParentKey(eq(parentKey))).andReturn(mappedList) + .once(); + expect(mockGetNotMenuItemCommand.getTreeNodesForParentKey(eq(parentKey))).andReturn(null) + .once(); replayDefault(); List menuItemsMerged = treeNodeService.fetchNodesForParent(docRef); assertNotNull("expecting not null.", menuItemsMerged); @@ -341,10 +339,10 @@ public void testResolveEntityReference() { spaceEntRef = new EntityReference(spaceName, EntityType.SPACE, wikiEntRef), docEntRef = new EntityReference(docName, EntityType.DOCUMENT, spaceEntRef); - assertEquals(docEntRef, treeNodeService.resolveEntityReference(wikiName + ":" + spaceName + "." - + docName)); - assertEquals(spaceEntRef, treeNodeService.resolveEntityReference(wikiName + ":" + spaceName - + ".")); + assertEquals(docEntRef, + treeNodeService.resolveEntityReference(wikiName + ":" + spaceName + "." + docName)); + assertEquals(spaceEntRef, + treeNodeService.resolveEntityReference(wikiName + ":" + spaceName + ".")); assertEquals(spaceEntRef, treeNodeService.resolveEntityReference(wikiName + ":" + spaceName)); assertEquals(wikiEntRef, treeNodeService.resolveEntityReference(wikiName + ":")); assertEquals(spaceEntRef, treeNodeService.resolveEntityReference(spaceName)); @@ -354,8 +352,8 @@ public void testResolveEntityReference() { public void testGetNavObjectsFromLayout() throws Exception { PageLayoutCommand mockPageLayoutCmd = createDefaultMock(PageLayoutCommand.class); treeNodeService.pageLayoutCmd = mockPageLayoutCmd; - SpaceReference layoutRef = new SpaceReference("MyLayout", new WikiReference( - context.getDatabase())); + SpaceReference layoutRef = new SpaceReference("MyLayout", + new WikiReference(context.getDatabase())); expect(mockPageLayoutCmd.getPageLayoutForCurrentDoc()).andReturn(layoutRef); DocumentReference mainCellRef = new DocumentReference(context.getDatabase(), "MyLayout", "MainCell"); @@ -365,23 +363,26 @@ public void testGetNavObjectsFromLayout() throws Exception { DocumentReference navConfigDocRef2 = new DocumentReference(context.getDatabase(), "MyLayout", "NavigationCell2"); SpaceReference layoutSpaceRef = new SpaceReference("MyLayout", new WikiReference("xwikidb")); - List myLayoutSubMenuItems = Arrays.asList(new TreeNode(navConfigDocRef1, - layoutSpaceRef, 1), new TreeNode(navConfigDocRef2, layoutSpaceRef, 2)); - expect(mockGetNotMenuItemCommand.getTreeNodesForParentKey(eq("xwikidb:MyLayout."))).andReturn( - myLayoutMenuItems); - expect(mockGetNotMenuItemCommand.getTreeNodesForParentKey(eq( - "xwikidb:MyLayout.MainCell"))).andReturn(myLayoutSubMenuItems); - expect(mockGetNotMenuItemCommand.getTreeNodesForParentKey(eq( - "xwikidb:MyLayout.NavigationCell1"))).andReturn(Collections.emptyList()); - expect(mockGetNotMenuItemCommand.getTreeNodesForParentKey(eq( - "xwikidb:MyLayout.NavigationCell2"))).andReturn(Collections.emptyList()); - expect(mockGetMenuItemCommand.getTreeNodesForParentKey(isA(String.class))).andReturn( - Collections.emptyList()).anyTimes(); - expect(mockRightService.hasAccessLevel(eq("view"), isA(String.class), isA(String.class), same( - context))).andReturn(true).anyTimes(); + List myLayoutSubMenuItems = Arrays.asList( + new TreeNode(navConfigDocRef1, layoutSpaceRef, 1), + new TreeNode(navConfigDocRef2, layoutSpaceRef, 2)); + expect(mockGetNotMenuItemCommand.getTreeNodesForParentKey(eq("xwikidb:MyLayout."))) + .andReturn(myLayoutMenuItems); + expect(mockGetNotMenuItemCommand.getTreeNodesForParentKey(eq("xwikidb:MyLayout.MainCell"))) + .andReturn(myLayoutSubMenuItems); + expect( + mockGetNotMenuItemCommand.getTreeNodesForParentKey(eq("xwikidb:MyLayout.NavigationCell1"))) + .andReturn(Collections.emptyList()); + expect( + mockGetNotMenuItemCommand.getTreeNodesForParentKey(eq("xwikidb:MyLayout.NavigationCell2"))) + .andReturn(Collections.emptyList()); + expect(mockGetMenuItemCommand.getTreeNodesForParentKey(isA(String.class))) + .andReturn(Collections.emptyList()).anyTimes(); + expect(mockRightService.hasAccessLevel(eq("view"), isA(String.class), isA(String.class), + same(context))).andReturn(true).anyTimes(); BaseObject navConfigObj1 = new BaseObject(); - DocumentReference navigationConfigClassRef = getNavClassConfig().getNavigationConfigClassRef( - context.getDatabase()); + DocumentReference navigationConfigClassRef = getNavClassConfig() + .getNavigationConfigClassRef(context.getDatabase()); XWikiDocument navConfigDoc1 = new XWikiDocument(navConfigDocRef1); navConfigObj1.setXClassReference(navigationConfigClassRef); navConfigDoc1.addXObject(navConfigObj1); @@ -410,8 +411,8 @@ public void testGetMaxConfiguredNavigationLevel_twoParents() throws Exception { "MyDocument"); XWikiDocument doc = new XWikiDocument(docRef); context.setDoc(doc); - expect(mockPageLayoutCmd.getPageLayoutForDoc(eq(doc.getFullName()), same(context))).andReturn( - null).atLeastOnce(); + expect(mockPageLayoutCmd.getPageLayoutForDoc(eq(doc.getFullName()), same(context))) + .andReturn(null).atLeastOnce(); expect(mockPageLayoutCmd.getPageLayoutForCurrentDoc()).andReturn(null).atLeastOnce(); DocumentReference webPrefDocRef = new DocumentReference(context.getDatabase(), "MySpace", "WebPreferences"); @@ -424,8 +425,8 @@ public void testGetMaxConfiguredNavigationLevel_twoParents() throws Exception { navObjects.add(createNavObj(3, webPrefDoc)); webPrefDoc.setXObjects(getNavClassConfig().getNavigationConfigClassRef(context.getDatabase()), navObjects); - expect(wiki.getSpacePreference(eq("skin"), same(context))).andReturn( - "Skins.MySkin").atLeastOnce(); + expect(wiki.getSpacePreference(eq("skin"), same(context))).andReturn("Skins.MySkin") + .atLeastOnce(); replayDefault(); int maxLevel = treeNodeService.getMaxConfiguredNavigationLevel(); verifyDefault(); @@ -443,8 +444,8 @@ public void testGetMaxConfiguredNavigationLevel_deletedObject_NPE() throws Excep "MyDocument"); XWikiDocument doc = new XWikiDocument(docRef); context.setDoc(doc); - expect(mockPageLayoutCmd.getPageLayoutForDoc(eq(doc.getFullName()), same(context))).andReturn( - null).atLeastOnce(); + expect(mockPageLayoutCmd.getPageLayoutForDoc(eq(doc.getFullName()), same(context))) + .andReturn(null).atLeastOnce(); expect(mockPageLayoutCmd.getPageLayoutForCurrentDoc()).andReturn(null).atLeastOnce(); DocumentReference webPrefDocRef = new DocumentReference(context.getDatabase(), "MySpace", "WebPreferences"); @@ -455,8 +456,8 @@ public void testGetMaxConfiguredNavigationLevel_deletedObject_NPE() throws Excep // a null pointer in the object list webPrefDoc.setXObject(2, createNavObj(8, webPrefDoc)); webPrefDoc.setXObject(3, createNavObj(3, webPrefDoc)); - expect(wiki.getSpacePreference(eq("skin"), same(context))).andReturn( - "Skins.MySkin").atLeastOnce(); + expect(wiki.getSpacePreference(eq("skin"), same(context))).andReturn("Skins.MySkin") + .atLeastOnce(); replayDefault(); int maxLevel = treeNodeService.getMaxConfiguredNavigationLevel(); verifyDefault(); @@ -474,8 +475,8 @@ public void testGetMaxConfiguredNavigationLevel_noObjectFound_NPE() throws Excep "MyDocument"); XWikiDocument doc = new XWikiDocument(docRef); context.setDoc(doc); - expect(mockPageLayoutCmd.getPageLayoutForDoc(eq(doc.getFullName()), same(context))).andReturn( - null).atLeastOnce(); + expect(mockPageLayoutCmd.getPageLayoutForDoc(eq(doc.getFullName()), same(context))) + .andReturn(null).atLeastOnce(); expect(mockPageLayoutCmd.getPageLayoutForCurrentDoc()).andReturn(null).atLeastOnce(); DocumentReference webPrefDocRef = new DocumentReference(context.getDatabase(), "MySpace", "WebPreferences"); @@ -484,13 +485,13 @@ public void testGetMaxConfiguredNavigationLevel_noObjectFound_NPE() throws Excep DocumentReference xwikiPrefDocRef = new DocumentReference(context.getDatabase(), "XWiki", "XWikiPreferences"); XWikiDocument xwikiPrefDoc = new XWikiDocument(xwikiPrefDocRef); - expect(wiki.getDocument(eq(xwikiPrefDocRef), eq(context))).andReturn( - xwikiPrefDoc).atLeastOnce(); + expect(wiki.getDocument(eq(xwikiPrefDocRef), eq(context))).andReturn(xwikiPrefDoc) + .atLeastOnce(); DocumentReference skinDocRef = new DocumentReference(context.getDatabase(), "Skins", "MySkin"); XWikiDocument skinDoc = new XWikiDocument(skinDocRef); expect(wiki.getDocument(eq(skinDocRef), eq(context))).andReturn(skinDoc).atLeastOnce(); - expect(wiki.getSpacePreference(eq("skin"), same(context))).andReturn( - "Skins.MySkin").atLeastOnce(); + expect(wiki.getSpacePreference(eq("skin"), same(context))).andReturn("Skins.MySkin") + .atLeastOnce(); replayDefault(); int maxLevel = treeNodeService.getMaxConfiguredNavigationLevel(); verifyDefault(); @@ -508,15 +509,15 @@ public void testGetMaxConfiguredNavigationLevel_threeParents() throws Exception "MyDocument"); XWikiDocument doc = new XWikiDocument(docRef); context.setDoc(doc); - expect(mockPageLayoutCmd.getPageLayoutForDoc(eq(doc.getFullName()), same(context))).andReturn( - null).atLeastOnce(); + expect(mockPageLayoutCmd.getPageLayoutForDoc(eq(doc.getFullName()), same(context))) + .andReturn(null).atLeastOnce(); expect(mockPageLayoutCmd.getPageLayoutForCurrentDoc()).andReturn(null).atLeastOnce(); DocumentReference webPrefDocRef = new DocumentReference(context.getDatabase(), "MySpace", "WebPreferences"); XWikiDocument webPrefDoc = new XWikiDocument(webPrefDocRef); expect(wiki.getDocument(eq(webPrefDocRef), eq(context))).andReturn(webPrefDoc).atLeastOnce(); - expect(wiki.getSpacePreference(eq("skin"), same(context))).andReturn( - "Skins.MySkin").atLeastOnce(); + expect(wiki.getSpacePreference(eq("skin"), same(context))).andReturn("Skins.MySkin") + .atLeastOnce(); Vector navObjects = new Vector<>(); navObjects.add(createNavObj(5, webPrefDoc)); navObjects.add(createNavObj(4, webPrefDoc)); @@ -540,20 +541,20 @@ public void testGetMaxConfiguredNavigationLevel_LayoutConfig() throws Exception "MyDocument"); XWikiDocument doc = new XWikiDocument(docRef); String layoutSpaceName = "MyLayout"; - expect(mockPageLayoutCmd.getPageLayoutForDoc(eq(doc.getFullName()), same(context))).andReturn( - layoutSpaceName).atLeastOnce(); - SpaceReference layoutRef = new SpaceReference(layoutSpaceName, new WikiReference( - context.getDatabase())); + expect(mockPageLayoutCmd.getPageLayoutForDoc(eq(doc.getFullName()), same(context))) + .andReturn(layoutSpaceName).atLeastOnce(); + SpaceReference layoutRef = new SpaceReference(layoutSpaceName, + new WikiReference(context.getDatabase())); expect(mockPageLayoutCmd.getPageLayoutForCurrentDoc()).andReturn(layoutRef); DocumentReference layoutWebHomeRef = new DocumentReference(context.getDatabase(), layoutSpaceName, "WebHome"); XWikiDocument layoutWebHomeDoc = new XWikiDocument(layoutWebHomeRef); BaseObject layoutConfigObj = new BaseObject(); - layoutConfigObj.setXClassReference(getCellsClasses().getPageLayoutPropertiesClassRef( - context.getDatabase())); + layoutConfigObj.setXClassReference( + getCellsClasses().getPageLayoutPropertiesClassRef(context.getDatabase())); layoutWebHomeDoc.addXObject(layoutConfigObj); - expect(wiki.getDocument(eq(layoutWebHomeRef), same(context))).andReturn( - layoutWebHomeDoc).atLeastOnce(); + expect(wiki.getDocument(eq(layoutWebHomeRef), same(context))).andReturn(layoutWebHomeDoc) + .atLeastOnce(); context.setDoc(doc); DocumentReference webPrefDocRef = new DocumentReference(context.getDatabase(), "MySpace", @@ -563,30 +564,31 @@ public void testGetMaxConfiguredNavigationLevel_LayoutConfig() throws Exception DocumentReference xwikiPrefDocRef = new DocumentReference(context.getDatabase(), "XWiki", "XWikiPreferences"); XWikiDocument xwikiPrefDoc = new XWikiDocument(xwikiPrefDocRef); - expect(wiki.getDocument(eq(xwikiPrefDocRef), eq(context))).andReturn( - xwikiPrefDoc).atLeastOnce(); + expect(wiki.getDocument(eq(xwikiPrefDocRef), eq(context))).andReturn(xwikiPrefDoc) + .atLeastOnce(); DocumentReference skinDocRef = new DocumentReference(context.getDatabase(), "Skins", "MySkin"); XWikiDocument skinDoc = new XWikiDocument(skinDocRef); expect(wiki.getDocument(eq(skinDocRef), eq(context))).andReturn(skinDoc).atLeastOnce(); - expect(wiki.getSpacePreference(eq("skin"), same(context))).andReturn( - "Skins.MySkin").atLeastOnce(); + expect(wiki.getSpacePreference(eq("skin"), same(context))).andReturn("Skins.MySkin") + .atLeastOnce(); DocumentReference navConfigDocRef = new DocumentReference(context.getDatabase(), "MyLayout", "NavigationCell"); SpaceReference layoutSpaceRef = new SpaceReference("MyLayout", new WikiReference("xwikidb")); - List myLayoutMenuItems = Arrays.asList(new TreeNode(navConfigDocRef, layoutSpaceRef, - 1)); - expect(mockGetNotMenuItemCommand.getTreeNodesForParentKey(eq("xwikidb:MyLayout."))).andReturn( - myLayoutMenuItems); - expect(mockGetNotMenuItemCommand.getTreeNodesForParentKey(eq( - "xwikidb:MyLayout.NavigationCell"))).andReturn(Collections.emptyList()); - expect(mockGetMenuItemCommand.getTreeNodesForParentKey(isA(String.class))).andReturn( - Collections.emptyList()).anyTimes(); - expect(mockRightService.hasAccessLevel(eq("view"), isA(String.class), isA(String.class), same( - context))).andReturn(true).anyTimes(); + List myLayoutMenuItems = Arrays + .asList(new TreeNode(navConfigDocRef, layoutSpaceRef, 1)); + expect(mockGetNotMenuItemCommand.getTreeNodesForParentKey(eq("xwikidb:MyLayout."))) + .andReturn(myLayoutMenuItems); + expect( + mockGetNotMenuItemCommand.getTreeNodesForParentKey(eq("xwikidb:MyLayout.NavigationCell"))) + .andReturn(Collections.emptyList()); + expect(mockGetMenuItemCommand.getTreeNodesForParentKey(isA(String.class))) + .andReturn(Collections.emptyList()).anyTimes(); + expect(mockRightService.hasAccessLevel(eq("view"), isA(String.class), isA(String.class), + same(context))).andReturn(true).anyTimes(); BaseObject navConfigObj = new BaseObject(); - DocumentReference navigationConfigClassRef = getNavClassConfig().getNavigationConfigClassRef( - context.getDatabase()); + DocumentReference navigationConfigClassRef = getNavClassConfig() + .getNavigationConfigClassRef(context.getDatabase()); navConfigObj.setXClassReference(navigationConfigClassRef); navConfigObj.setIntValue(INavigationClassConfig.TO_HIERARCHY_LEVEL_FIELD, 3); XWikiDocument navConfigDoc = new XWikiDocument(navConfigDocRef); @@ -612,13 +614,13 @@ public void testGetMenuItemPos() throws Exception { List nodes = new ArrayList<>(); nodes.add(tnItem); - expect(mockGetNotMenuItemCommand.getTreeNodesForParentKey(eq(parentKey))).andReturn( - nodes).once(); - expect(mockGetMenuItemCommand.getTreeNodesForParentKey(eq(parentKey))).andReturn( - new ArrayList()).once(); + expect(mockGetNotMenuItemCommand.getTreeNodesForParentKey(eq(parentKey))).andReturn(nodes) + .once(); + expect(mockGetMenuItemCommand.getTreeNodesForParentKey(eq(parentKey))) + .andReturn(new ArrayList()).once(); - expect(mockRightService.hasAccessLevel(eq("view"), isA(String.class), isA(String.class), same( - context))).andReturn(true).anyTimes(); + expect(mockRightService.hasAccessLevel(eq("view"), isA(String.class), isA(String.class), + same(context))).andReturn(true).anyTimes(); replayDefault(); assertEquals(0, treeNodeService.getMenuItemPos(docRef, menuPart)); verifyDefault(); @@ -637,10 +639,8 @@ public void getSiblingMenuItem_previous() throws XWikiException { new EntityReference(space, EntityType.SPACE, new EntityReference(db, EntityType.WIKI))); DocumentReference mItemDocRef = new DocumentReference(context.getDatabase(), "mySpace", "myMenuItemDoc"), - docRefPrev = new DocumentReference(context.getDatabase(), "mySpace", - "DocPrev"), - docRefNext = new DocumentReference(context.getDatabase(), "mySpace", - "DocNext"); + docRefPrev = new DocumentReference(context.getDatabase(), "mySpace", "DocPrev"), + docRefNext = new DocumentReference(context.getDatabase(), "mySpace", "DocNext"); XWikiDocument doc = new XWikiDocument(mItemDocRef), docPrev = new XWikiDocument(docRefPrev), docNext = new XWikiDocument(docRefNext); BaseObject menuItemItemDoc = new BaseObject(), menuItemPrev = new BaseObject(), @@ -653,8 +653,8 @@ public void getSiblingMenuItem_previous() throws XWikiException { menuItemItemDoc.setDocumentReference(mItemDocRef); menuItemPrev.setDocumentReference(docRefPrev); menuItemNext.setDocumentReference(docRefNext); - DocumentReference menuItemClassRef = getNavClassConfig().getMenuItemClassRef( - context.getDatabase()); + DocumentReference menuItemClassRef = getNavClassConfig() + .getMenuItemClassRef(context.getDatabase()); menuItemItemDoc.setXClassReference(menuItemClassRef); menuItemPrev.setXClassReference(menuItemClassRef); menuItemNext.setXClassReference(menuItemClassRef); @@ -677,13 +677,13 @@ public void getSiblingMenuItem_previous() throws XWikiException { nodes.add(tnItem); nodes.add(tnNext); - expect(mockGetNotMenuItemCommand.getTreeNodesForParentKey(eq(fullName))).andReturn( - nodes).once(); - expect(mockGetMenuItemCommand.getTreeNodesForParentKey(eq(fullName))).andReturn( - new ArrayList()).once(); + expect(mockGetNotMenuItemCommand.getTreeNodesForParentKey(eq(fullName))).andReturn(nodes) + .once(); + expect(mockGetMenuItemCommand.getTreeNodesForParentKey(eq(fullName))) + .andReturn(new ArrayList()).once(); - expect(mockRightService.hasAccessLevel(eq("view"), isA(String.class), isA(String.class), same( - context))).andReturn(true).anyTimes(); + expect(mockRightService.hasAccessLevel(eq("view"), isA(String.class), isA(String.class), + same(context))).andReturn(true).anyTimes(); replayDefault(); TreeNode prevMenuItem = treeNodeService.getSiblingMenuItem(mItemDocRef, true); assertEquals("MySpace.DocPrev TreeNode expected.", tnPrev, prevMenuItem); @@ -721,8 +721,8 @@ public void getSiblingMenuItem_next() throws XWikiException { menuItemItemDoc.setDocumentReference(mItemDocRef); menuItemPrev.setDocumentReference(docRefPrev); menuItemNext.setDocumentReference(docRefNext); - DocumentReference menuItemClassRef = getNavClassConfig().getMenuItemClassRef( - context.getDatabase()); + DocumentReference menuItemClassRef = getNavClassConfig() + .getMenuItemClassRef(context.getDatabase()); menuItemItemDoc.setXClassReference(menuItemClassRef); menuItemPrev.setXClassReference(menuItemClassRef); menuItemNext.setXClassReference(menuItemClassRef); @@ -745,13 +745,13 @@ public void getSiblingMenuItem_next() throws XWikiException { nodes.add(tnItem); nodes.add(tnNext); - expect(mockGetNotMenuItemCommand.getTreeNodesForParentKey(eq(fullName))).andReturn( - nodes).once(); - expect(mockGetMenuItemCommand.getTreeNodesForParentKey(eq(fullName))).andReturn( - new ArrayList()).once(); + expect(mockGetNotMenuItemCommand.getTreeNodesForParentKey(eq(fullName))).andReturn(nodes) + .once(); + expect(mockGetMenuItemCommand.getTreeNodesForParentKey(eq(fullName))) + .andReturn(new ArrayList()).once(); - expect(mockRightService.hasAccessLevel(eq("view"), isA(String.class), isA(String.class), same( - context))).andReturn(true).anyTimes(); + expect(mockRightService.hasAccessLevel(eq("view"), isA(String.class), isA(String.class), + same(context))).andReturn(true).anyTimes(); replayDefault(); TreeNode prevMenuItem = treeNodeService.getSiblingMenuItem(mItemDocRef, false); assertEquals("MySpace.DocNext TreeNode expected.", tnNext, prevMenuItem); @@ -768,10 +768,8 @@ public void getSiblingMenuItem_previous_mainMenu() throws XWikiException { DocumentReference mItemDocRef = new DocumentReference(context.getDatabase(), "mySpace", "myMenuItemDoc"), - docRefPrev = new DocumentReference(context.getDatabase(), "mySpace", - "DocPrev"), - docRefNext = new DocumentReference(context.getDatabase(), "mySpace", - "DocNext"); + docRefPrev = new DocumentReference(context.getDatabase(), "mySpace", "DocPrev"), + docRefNext = new DocumentReference(context.getDatabase(), "mySpace", "DocNext"); XWikiDocument doc = new XWikiDocument(mItemDocRef), docPrev = new XWikiDocument(docRefPrev), docNext = new XWikiDocument(docRefNext); BaseObject menuItemItemDoc = new BaseObject(), menuItemPrev = new BaseObject(), @@ -780,8 +778,8 @@ public void getSiblingMenuItem_previous_mainMenu() throws XWikiException { menuItemItemDoc.setDocumentReference(mItemDocRef); menuItemPrev.setDocumentReference(docRefPrev); menuItemNext.setDocumentReference(docRefNext); - DocumentReference menuItemClassRef = getNavClassConfig().getMenuItemClassRef( - context.getDatabase()); + DocumentReference menuItemClassRef = getNavClassConfig() + .getMenuItemClassRef(context.getDatabase()); menuItemItemDoc.setXClassReference(menuItemClassRef); menuItemPrev.setXClassReference(menuItemClassRef); menuItemNext.setXClassReference(menuItemClassRef); @@ -803,13 +801,13 @@ public void getSiblingMenuItem_previous_mainMenu() throws XWikiException { nodes.add(tnItem); nodes.add(tnNext); - expect(mockGetNotMenuItemCommand.getTreeNodesForParentKey(eq(fullName))).andReturn( - nodes).once(); - expect(mockGetMenuItemCommand.getTreeNodesForParentKey(eq(fullName))).andReturn( - new ArrayList()).once(); + expect(mockGetNotMenuItemCommand.getTreeNodesForParentKey(eq(fullName))).andReturn(nodes) + .once(); + expect(mockGetMenuItemCommand.getTreeNodesForParentKey(eq(fullName))) + .andReturn(new ArrayList()).once(); - expect(mockRightService.hasAccessLevel(eq("view"), isA(String.class), isA(String.class), same( - context))).andReturn(true).anyTimes(); + expect(mockRightService.hasAccessLevel(eq("view"), isA(String.class), isA(String.class), + same(context))).andReturn(true).anyTimes(); replayDefault(); TreeNode prevMenuItem = treeNodeService.getSiblingMenuItem(mItemDocRef, true); assertEquals("MySpace.DocPrev TreeNode expected.", tnPrev, prevMenuItem); @@ -826,10 +824,8 @@ public void getSiblingMenuItem_next_mainMenu() throws XWikiException { DocumentReference mItemDocRef = new DocumentReference(context.getDatabase(), "mySpace", "myMenuItemDoc"), - docRefPrev = new DocumentReference(context.getDatabase(), "mySpace", - "DocPrev"), - docRefNext = new DocumentReference(context.getDatabase(), "mySpace", - "DocNext"); + docRefPrev = new DocumentReference(context.getDatabase(), "mySpace", "DocPrev"), + docRefNext = new DocumentReference(context.getDatabase(), "mySpace", "DocNext"); XWikiDocument doc = new XWikiDocument(mItemDocRef), docPrev = new XWikiDocument(docRefPrev), docNext = new XWikiDocument(docRefNext); BaseObject menuItemItemDoc = new BaseObject(), menuItemPrev = new BaseObject(), @@ -838,8 +834,8 @@ public void getSiblingMenuItem_next_mainMenu() throws XWikiException { menuItemItemDoc.setDocumentReference(mItemDocRef); menuItemPrev.setDocumentReference(docRefPrev); menuItemNext.setDocumentReference(docRefNext); - DocumentReference menuItemClassRef = getNavClassConfig().getMenuItemClassRef( - context.getDatabase()); + DocumentReference menuItemClassRef = getNavClassConfig() + .getMenuItemClassRef(context.getDatabase()); menuItemItemDoc.setXClassReference(menuItemClassRef); menuItemPrev.setXClassReference(menuItemClassRef); menuItemNext.setXClassReference(menuItemClassRef); @@ -861,13 +857,13 @@ public void getSiblingMenuItem_next_mainMenu() throws XWikiException { nodes.add(tnItem); nodes.add(tnNext); - expect(mockGetNotMenuItemCommand.getTreeNodesForParentKey(eq(fullName))).andReturn( - nodes).once(); - expect(mockGetMenuItemCommand.getTreeNodesForParentKey(eq(fullName))).andReturn( - new ArrayList()).once(); + expect(mockGetNotMenuItemCommand.getTreeNodesForParentKey(eq(fullName))).andReturn(nodes) + .once(); + expect(mockGetMenuItemCommand.getTreeNodesForParentKey(eq(fullName))) + .andReturn(new ArrayList()).once(); - expect(mockRightService.hasAccessLevel(eq("view"), isA(String.class), isA(String.class), same( - context))).andReturn(true).anyTimes(); + expect(mockRightService.hasAccessLevel(eq("view"), isA(String.class), isA(String.class), + same(context))).andReturn(true).anyTimes(); replayDefault(); TreeNode prevMenuItem = treeNodeService.getSiblingMenuItem(mItemDocRef, false); assertEquals("MySpace.DocNext TreeNode expected.", tnNext, prevMenuItem); @@ -888,10 +884,8 @@ public void getSiblingMenuItem_next_docNotInContextSpace() throws XWikiException new EntityReference(space, EntityType.SPACE, new EntityReference(db, EntityType.WIKI))); DocumentReference mItemDocRef = new DocumentReference(context.getDatabase(), "mySpace", "myMenuItemDoc"), - docRefPrev = new DocumentReference(context.getDatabase(), "mySpace", - "DocPrev"), - docRefNext = new DocumentReference(context.getDatabase(), "mySpace", - "DocNext"); + docRefPrev = new DocumentReference(context.getDatabase(), "mySpace", "DocPrev"), + docRefNext = new DocumentReference(context.getDatabase(), "mySpace", "DocNext"); XWikiDocument doc = new XWikiDocument(mItemDocRef), docPrev = new XWikiDocument(docRefPrev), docNext = new XWikiDocument(docRefNext); BaseObject menuItemItemDoc = new BaseObject(), menuItemPrev = new BaseObject(), @@ -904,8 +898,8 @@ public void getSiblingMenuItem_next_docNotInContextSpace() throws XWikiException menuItemItemDoc.setDocumentReference(mItemDocRef); menuItemPrev.setDocumentReference(docRefPrev); menuItemNext.setDocumentReference(docRefNext); - DocumentReference menuItemClassRef = getNavClassConfig().getMenuItemClassRef( - context.getDatabase()); + DocumentReference menuItemClassRef = getNavClassConfig() + .getMenuItemClassRef(context.getDatabase()); menuItemItemDoc.setXClassReference(menuItemClassRef); menuItemPrev.setXClassReference(menuItemClassRef); menuItemNext.setXClassReference(menuItemClassRef); @@ -919,19 +913,19 @@ public void getSiblingMenuItem_next_docNotInContextSpace() throws XWikiException expect(wiki.getDocument(eq(docRefPrev), same(context))).andReturn(docPrev).anyTimes(); expect(wiki.getDocument(eq(docRefNext), same(context))).andReturn(docNext).anyTimes(); - TreeNode tnPrev = new TreeNode(docRefPrev, parentRef, 0), tnItem = new TreeNode(mItemDocRef, - parentRef, 1); + TreeNode tnPrev = new TreeNode(docRefPrev, parentRef, 0), + tnItem = new TreeNode(mItemDocRef, parentRef, 1); List nodes = new ArrayList<>(); nodes.add(tnPrev); nodes.add(tnItem); - expect(mockGetNotMenuItemCommand.getTreeNodesForParentKey(eq(fullName))).andReturn( - nodes).once(); - expect(mockGetMenuItemCommand.getTreeNodesForParentKey(eq(fullName))).andReturn( - new ArrayList()).once(); + expect(mockGetNotMenuItemCommand.getTreeNodesForParentKey(eq(fullName))).andReturn(nodes) + .once(); + expect(mockGetMenuItemCommand.getTreeNodesForParentKey(eq(fullName))) + .andReturn(new ArrayList()).once(); - expect(mockRightService.hasAccessLevel(eq("view"), isA(String.class), isA(String.class), same( - context))).andReturn(true).anyTimes(); + expect(mockRightService.hasAccessLevel(eq("view"), isA(String.class), isA(String.class), + same(context))).andReturn(true).anyTimes(); replayDefault(); TreeNode prevMenuItem = treeNodeService.getSiblingMenuItem(mItemDocRef, false); assertEquals("null expected.", null, prevMenuItem); @@ -949,8 +943,8 @@ public void testGetParentKey() throws XWikiException { DocumentReference docRef = new DocumentReference(docName, spaceRef); assertEquals(wikiName + ":", treeNodeService.getParentKey(wikiRef, true)); assertEquals(wikiName + ":" + spaceName + ".", treeNodeService.getParentKey(spaceRef, true)); - assertEquals(wikiName + ":" + spaceName + "." + docName, treeNodeService.getParentKey(docRef, - true)); + assertEquals(wikiName + ":" + spaceName + "." + docName, + treeNodeService.getParentKey(docRef, true)); assertEquals("", treeNodeService.getParentKey(wikiRef, false)); assertEquals(spaceName + ".", treeNodeService.getParentKey(spaceRef, false)); assertEquals(spaceName + "." + docName, treeNodeService.getParentKey(docRef, false)); @@ -959,12 +953,12 @@ public void testGetParentKey() throws XWikiException { @Test public void testEnableMappedMenuItems() { treeNodeService.enableMappedMenuItems(); - assertTrue(context.get( - GetMappedMenuItemsForParentCommand.CELEMENTS_MAPPED_MENU_ITEMS_KEY) != null); - assertTrue(context.get( - GetMappedMenuItemsForParentCommand.CELEMENTS_MAPPED_MENU_ITEMS_KEY) != null); - assertTrue(((GetMappedMenuItemsForParentCommand) context.get( - GetMappedMenuItemsForParentCommand.CELEMENTS_MAPPED_MENU_ITEMS_KEY)).isActive()); + assertTrue( + context.get(GetMappedMenuItemsForParentCommand.CELEMENTS_MAPPED_MENU_ITEMS_KEY) != null); + assertTrue( + context.get(GetMappedMenuItemsForParentCommand.CELEMENTS_MAPPED_MENU_ITEMS_KEY) != null); + assertTrue(((GetMappedMenuItemsForParentCommand) context + .get(GetMappedMenuItemsForParentCommand.CELEMENTS_MAPPED_MENU_ITEMS_KEY)).isActive()); } @Test @@ -1073,10 +1067,10 @@ public void testGetSiblingTreeNodes() throws Exception { TreeNode treeNode3 = new TreeNode(docRef3, parentRef, oldPos3); List expectedTreeNodes = Arrays.asList(treeNode1, moveTreeNode, treeNode2, treeNode3); String parentKey = wikiName + ":" + spaceName + ".myParent"; - expect(mockGetNotMenuItemCommand.getTreeNodesForParentKey(eq(parentKey))).andReturn( - expectedTreeNodes); - expect(mockGetMenuItemCommand.getTreeNodesForParentKey(eq(parentKey))).andReturn( - Collections.emptyList()); + expect(mockGetNotMenuItemCommand.getTreeNodesForParentKey(eq(parentKey))) + .andReturn(expectedTreeNodes); + expect(mockGetMenuItemCommand.getTreeNodesForParentKey(eq(parentKey))) + .andReturn(Collections.emptyList()); expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), isA(String.class), same(context))).andReturn(true).atLeastOnce(); replayDefault(); @@ -1108,8 +1102,8 @@ public void testMoveTreeNodeAfter() throws Exception { List expectedTreeNodes = Arrays.asList(treeNode1, moveTreeNode, treeNode2, treeNode3); String parentKey = wikiName + ":" + spaceName + ".myParent"; expect(mockGetNotMenuItemCommand.getTreeNodesForParentKey(eq(parentKey))).andReturn(treeNodes); - expect(mockGetMenuItemCommand.getTreeNodesForParentKey(eq(parentKey))).andReturn( - Collections.emptyList()); + expect(mockGetMenuItemCommand.getTreeNodesForParentKey(eq(parentKey))) + .andReturn(Collections.emptyList()); replayDefault(); assertEquals(expectedTreeNodes, treeNodeService.moveTreeNodeAfter(moveTreeNode, treeNode1)); verifyDefault(); @@ -1139,8 +1133,8 @@ public void testMoveTreeNodeAfter_nullAfter() throws Exception { List expectedTreeNodes = Arrays.asList(moveTreeNode, treeNode1, treeNode2, treeNode3); String parentKey = wikiName + ":" + spaceName + ".myParent"; expect(mockGetNotMenuItemCommand.getTreeNodesForParentKey(eq(parentKey))).andReturn(treeNodes); - expect(mockGetMenuItemCommand.getTreeNodesForParentKey(eq(parentKey))).andReturn( - Collections.emptyList()); + expect(mockGetMenuItemCommand.getTreeNodesForParentKey(eq(parentKey))) + .andReturn(Collections.emptyList()); replayDefault(); assertEquals(expectedTreeNodes, treeNodeService.moveTreeNodeAfter(moveTreeNode, null)); verifyDefault(); @@ -1170,8 +1164,8 @@ public void testMoveTreeNodeAfter_afterItemNotInList() throws Exception { List expectedTreeNodes = Arrays.asList(moveTreeNode, treeNode2, treeNode3); String parentKey = wikiName + ":" + spaceName + ".myParent"; expect(mockGetNotMenuItemCommand.getTreeNodesForParentKey(eq(parentKey))).andReturn(treeNodes); - expect(mockGetMenuItemCommand.getTreeNodesForParentKey(eq(parentKey))).andReturn( - Collections.emptyList()); + expect(mockGetMenuItemCommand.getTreeNodesForParentKey(eq(parentKey))) + .andReturn(Collections.emptyList()); replayDefault(); assertEquals(expectedTreeNodes, treeNodeService.moveTreeNodeAfter(moveTreeNode, treeNode1)); verifyDefault(); @@ -1210,16 +1204,16 @@ public void testStoreOrder() throws Exception { replayDefault(); treeNodeService.storeOrder(newTreeNodes); XWikiDocument savedDoc1 = capDoc1.getValue(); - BaseObject menuItemObj1 = savedDoc1.getXObject(getNavClassConfig().getMenuItemClassRef( - context.getDatabase())); + BaseObject menuItemObj1 = savedDoc1 + .getXObject(getNavClassConfig().getMenuItemClassRef(context.getDatabase())); assertEquals(0, menuItemObj1.getIntValue(INavigationClassConfig.MENU_POSITION_FIELD, -1)); XWikiDocument savedDoc2 = capDoc2.getValue(); - BaseObject menuItemObj2 = savedDoc2.getXObject(getNavClassConfig().getMenuItemClassRef( - context.getDatabase())); + BaseObject menuItemObj2 = savedDoc2 + .getXObject(getNavClassConfig().getMenuItemClassRef(context.getDatabase())); assertEquals(1, menuItemObj2.getIntValue(INavigationClassConfig.MENU_POSITION_FIELD, -1)); XWikiDocument savedDoc3 = capDoc3.getValue(); - BaseObject menuItemObj3 = savedDoc3.getXObject(getNavClassConfig().getMenuItemClassRef( - context.getDatabase())); + BaseObject menuItemObj3 = savedDoc3 + .getXObject(getNavClassConfig().getMenuItemClassRef(context.getDatabase())); assertEquals(2, menuItemObj3.getIntValue(INavigationClassConfig.MENU_POSITION_FIELD, -1)); verifyDefault(); } @@ -1257,16 +1251,16 @@ public void testStoreOrder_minorEdits() throws Exception { replayDefault(); treeNodeService.storeOrder(newTreeNodes, true); XWikiDocument savedDoc1 = capDoc1.getValue(); - BaseObject menuItemObj1 = savedDoc1.getXObject(getNavClassConfig().getMenuItemClassRef( - context.getDatabase())); + BaseObject menuItemObj1 = savedDoc1 + .getXObject(getNavClassConfig().getMenuItemClassRef(context.getDatabase())); assertEquals(0, menuItemObj1.getIntValue(INavigationClassConfig.MENU_POSITION_FIELD, -1)); XWikiDocument savedDoc2 = capDoc2.getValue(); - BaseObject menuItemObj2 = savedDoc2.getXObject(getNavClassConfig().getMenuItemClassRef( - context.getDatabase())); + BaseObject menuItemObj2 = savedDoc2 + .getXObject(getNavClassConfig().getMenuItemClassRef(context.getDatabase())); assertEquals(1, menuItemObj2.getIntValue(INavigationClassConfig.MENU_POSITION_FIELD, -1)); XWikiDocument savedDoc3 = capDoc3.getValue(); - BaseObject menuItemObj3 = savedDoc3.getXObject(getNavClassConfig().getMenuItemClassRef( - context.getDatabase())); + BaseObject menuItemObj3 = savedDoc3 + .getXObject(getNavClassConfig().getMenuItemClassRef(context.getDatabase())); assertEquals(2, menuItemObj3.getIntValue(INavigationClassConfig.MENU_POSITION_FIELD, -1)); verifyDefault(); } @@ -1301,12 +1295,12 @@ public void testStoreOrder_nullObjects() throws Exception { replayDefault(); treeNodeService.storeOrder(newTreeNodes, true); XWikiDocument savedDoc1 = capDoc1.getValue(); - BaseObject menuItemObj1 = savedDoc1.getXObject(getNavClassConfig().getMenuItemClassRef( - context.getDatabase())); + BaseObject menuItemObj1 = savedDoc1 + .getXObject(getNavClassConfig().getMenuItemClassRef(context.getDatabase())); assertEquals(0, menuItemObj1.getIntValue(INavigationClassConfig.MENU_POSITION_FIELD, -1)); XWikiDocument savedDoc2 = capDoc2.getValue(); - BaseObject menuItemObj2 = savedDoc2.getXObject(getNavClassConfig().getMenuItemClassRef( - context.getDatabase())); + BaseObject menuItemObj2 = savedDoc2 + .getXObject(getNavClassConfig().getMenuItemClassRef(context.getDatabase())); assertEquals(1, menuItemObj2.getIntValue(INavigationClassConfig.MENU_POSITION_FIELD, -1)); verifyDefault(); } @@ -1335,16 +1329,16 @@ public void testStoreOrder_rightOrder() throws Exception { replayDefault(); treeNodeService.storeOrder(newTreeNodes); XWikiDocument savedDoc1 = navDoc1; - BaseObject menuItemObj1 = savedDoc1.getXObject(getNavClassConfig().getMenuItemClassRef( - context.getDatabase())); + BaseObject menuItemObj1 = savedDoc1 + .getXObject(getNavClassConfig().getMenuItemClassRef(context.getDatabase())); assertEquals(0, menuItemObj1.getIntValue(INavigationClassConfig.MENU_POSITION_FIELD, -1)); XWikiDocument savedDoc2 = navDoc2; - BaseObject menuItemObj2 = savedDoc2.getXObject(getNavClassConfig().getMenuItemClassRef( - context.getDatabase())); + BaseObject menuItemObj2 = savedDoc2 + .getXObject(getNavClassConfig().getMenuItemClassRef(context.getDatabase())); assertEquals(1, menuItemObj2.getIntValue(INavigationClassConfig.MENU_POSITION_FIELD, -1)); XWikiDocument savedDoc3 = navDoc3; - BaseObject menuItemObj3 = savedDoc3.getXObject(getNavClassConfig().getMenuItemClassRef( - context.getDatabase())); + BaseObject menuItemObj3 = savedDoc3 + .getXObject(getNavClassConfig().getMenuItemClassRef(context.getDatabase())); assertEquals(2, menuItemObj3.getIntValue(INavigationClassConfig.MENU_POSITION_FIELD, -1)); verifyDefault(); } @@ -1378,12 +1372,12 @@ public void testStoreOrder_exception_onGetDoc() throws Exception { replayDefault(); treeNodeService.storeOrder(newTreeNodes); XWikiDocument savedDoc1 = capDoc1.getValue(); - BaseObject menuItemObj1 = savedDoc1.getXObject(getNavClassConfig().getMenuItemClassRef( - context.getDatabase())); + BaseObject menuItemObj1 = savedDoc1 + .getXObject(getNavClassConfig().getMenuItemClassRef(context.getDatabase())); assertEquals(0, menuItemObj1.getIntValue(INavigationClassConfig.MENU_POSITION_FIELD, -1)); XWikiDocument savedDoc3 = capDoc3.getValue(); - BaseObject menuItemObj3 = savedDoc3.getXObject(getNavClassConfig().getMenuItemClassRef( - context.getDatabase())); + BaseObject menuItemObj3 = savedDoc3 + .getXObject(getNavClassConfig().getMenuItemClassRef(context.getDatabase())); assertEquals(1, menuItemObj3.getIntValue(INavigationClassConfig.MENU_POSITION_FIELD, -1)); verifyDefault(); } @@ -1421,16 +1415,16 @@ public void testStoreOrder_exception_onSaveDoc() throws Exception { replayDefault(); treeNodeService.storeOrder(newTreeNodes); XWikiDocument savedDoc1 = capDoc1.getValue(); - BaseObject menuItemObj1 = savedDoc1.getXObject(getNavClassConfig().getMenuItemClassRef( - context.getDatabase())); + BaseObject menuItemObj1 = savedDoc1 + .getXObject(getNavClassConfig().getMenuItemClassRef(context.getDatabase())); assertEquals(0, menuItemObj1.getIntValue(INavigationClassConfig.MENU_POSITION_FIELD, -1)); XWikiDocument savedDoc2 = capDoc2.getValue(); - BaseObject menuItemObj2 = savedDoc2.getXObject(getNavClassConfig().getMenuItemClassRef( - context.getDatabase())); + BaseObject menuItemObj2 = savedDoc2 + .getXObject(getNavClassConfig().getMenuItemClassRef(context.getDatabase())); assertEquals(1, menuItemObj2.getIntValue(INavigationClassConfig.MENU_POSITION_FIELD, -1)); XWikiDocument savedDoc3 = capDoc3.getValue(); - BaseObject menuItemObj3 = savedDoc3.getXObject(getNavClassConfig().getMenuItemClassRef( - context.getDatabase())); + BaseObject menuItemObj3 = savedDoc3 + .getXObject(getNavClassConfig().getMenuItemClassRef(context.getDatabase())); assertEquals(2, menuItemObj3.getIntValue(INavigationClassConfig.MENU_POSITION_FIELD, -1)); verifyDefault(); } @@ -1460,8 +1454,8 @@ public void testMoveTreeDocAfter() throws Exception { List expectedTreeNodes = Arrays.asList(treeNode1, moveTreeNode, treeNode2); String parentKey = wikiName + ":" + spaceName + ".myParent"; expect(mockGetNotMenuItemCommand.getTreeNodesForParentKey(eq(parentKey))).andReturn(treeNodes); - expect(mockGetMenuItemCommand.getTreeNodesForParentKey(eq(parentKey))).andReturn( - Collections.emptyList()); + expect(mockGetMenuItemCommand.getTreeNodesForParentKey(eq(parentKey))) + .andReturn(Collections.emptyList()); // expecting correct savings Capture capDoc2 = newCapture(); wiki.saveDocument(capture(capDoc2), isA(String.class), eq(false), same(context)); @@ -1473,14 +1467,14 @@ public void testMoveTreeDocAfter() throws Exception { treeNodeService.moveTreeDocAfter(moveDocRef, docRef1); // first node should not be saved because it does not change. XWikiDocument savedDoc2 = capDoc2.getValue(); - BaseObject menuItemObj2 = savedDoc2.getXObject(getNavClassConfig().getMenuItemClassRef( - context.getDatabase())); + BaseObject menuItemObj2 = savedDoc2 + .getXObject(getNavClassConfig().getMenuItemClassRef(context.getDatabase())); assertEquals(1, menuItemObj2.getIntValue(INavigationClassConfig.MENU_POSITION_FIELD, -1)); TreeNode expTreeNode2 = expectedTreeNodes.get(1); assertEquals(expTreeNode2.getDocumentReference(), savedDoc2.getDocumentReference()); XWikiDocument savedDoc3 = capDoc3.getValue(); - BaseObject menuItemObj3 = savedDoc3.getXObject(getNavClassConfig().getMenuItemClassRef( - context.getDatabase())); + BaseObject menuItemObj3 = savedDoc3 + .getXObject(getNavClassConfig().getMenuItemClassRef(context.getDatabase())); assertEquals(2, menuItemObj3.getIntValue(INavigationClassConfig.MENU_POSITION_FIELD, -1)); TreeNode expTreeNode3 = expectedTreeNodes.get(2); assertEquals(expTreeNode3.getDocumentReference(), savedDoc3.getDocumentReference()); @@ -1512,8 +1506,8 @@ public void testMoveTreeDocAfter_insertAfterNull() throws Exception { List expectedTreeNodes = Arrays.asList(moveTreeNode, treeNode1, treeNode2); String parentKey = wikiName + ":" + spaceName + ".myParent"; expect(mockGetNotMenuItemCommand.getTreeNodesForParentKey(eq(parentKey))).andReturn(treeNodes); - expect(mockGetMenuItemCommand.getTreeNodesForParentKey(eq(parentKey))).andReturn( - Collections.emptyList()); + expect(mockGetMenuItemCommand.getTreeNodesForParentKey(eq(parentKey))) + .andReturn(Collections.emptyList()); // expecting correct savings Capture capDoc1 = newCapture(); wiki.saveDocument(capture(capDoc1), isA(String.class), eq(false), same(context)); @@ -1524,12 +1518,12 @@ public void testMoveTreeDocAfter_insertAfterNull() throws Exception { replayDefault(); treeNodeService.moveTreeDocAfter(moveDocRef, null); XWikiDocument savedDoc1 = capDoc1.getValue(); - BaseObject menuItemObj1 = savedDoc1.getXObject(getNavClassConfig().getMenuItemClassRef( - context.getDatabase())); + BaseObject menuItemObj1 = savedDoc1 + .getXObject(getNavClassConfig().getMenuItemClassRef(context.getDatabase())); assertEquals(0, menuItemObj1.getIntValue(INavigationClassConfig.MENU_POSITION_FIELD, -1)); XWikiDocument savedDoc2 = capDoc2.getValue(); - BaseObject menuItemObj2 = savedDoc2.getXObject(getNavClassConfig().getMenuItemClassRef( - context.getDatabase())); + BaseObject menuItemObj2 = savedDoc2 + .getXObject(getNavClassConfig().getMenuItemClassRef(context.getDatabase())); assertEquals(1, menuItemObj2.getIntValue(INavigationClassConfig.MENU_POSITION_FIELD, -1)); TreeNode expTreeNode2 = expectedTreeNodes.get(1); assertEquals(expTreeNode2.getDocumentReference(), savedDoc2.getDocumentReference()); @@ -1568,8 +1562,8 @@ private XWikiDocument createNavDoc(TreeNode treeNode1) { private BaseObject createNavObj(int toLevel, XWikiDocument doc) { BaseObject navObj = new BaseObject(); - navObj.setXClassReference(getNavClassConfig().getNavigationConfigClassRef( - context.getDatabase())); + navObj + .setXClassReference(getNavClassConfig().getNavigationConfigClassRef(context.getDatabase())); navObj.setStringValue("menu_element_name", "mainMenu"); navObj.setIntValue("to_hierarchy_level", toLevel); navObj.setDocumentReference(doc.getDocumentReference()); diff --git a/src/test/java/com/celements/nextfreedoc/NextFreeDocServiceTest.java b/src/test/java/com/celements/nextfreedoc/NextFreeDocServiceTest.java index b772ce80d..11af8bba1 100644 --- a/src/test/java/com/celements/nextfreedoc/NextFreeDocServiceTest.java +++ b/src/test/java/com/celements/nextfreedoc/NextFreeDocServiceTest.java @@ -50,8 +50,8 @@ public void prepareTest() throws Exception { @Test public void test_getNextTitledPageDocRef() throws Exception { - SpaceReference spaceRef = new SpaceReference("mySpace", new WikiReference( - context.getDatabase())); + SpaceReference spaceRef = new SpaceReference("mySpace", + new WikiReference(context.getDatabase())); String title = "asdf"; nextFreeDocService.injectNum(spaceRef, title, 5); @@ -89,8 +89,8 @@ public void test_getNextTitledPageDocRef_nullSpace() throws Exception { @Test public void test_getNextTitledPageDocRef_nullTitle() throws Exception { - SpaceReference spaceRef = new SpaceReference("mySpace", new WikiReference( - context.getDatabase())); + SpaceReference spaceRef = new SpaceReference("mySpace", + new WikiReference(context.getDatabase())); String title = ""; replayDefault(); @@ -105,8 +105,8 @@ public void test_getNextTitledPageDocRef_nullTitle() throws Exception { @Test public void test_getNextUntitledPageDocRef() throws Exception { - SpaceReference spaceRef = new SpaceReference("mySpace", new WikiReference( - context.getDatabase())); + SpaceReference spaceRef = new SpaceReference("mySpace", + new WikiReference(context.getDatabase())); nextFreeDocService.injectNum(spaceRef, INextFreeDocRole.UNTITLED_NAME, 5); DocumentReference docRef1 = new DocumentReference(INextFreeDocRole.UNTITLED_NAME + 5, spaceRef); @@ -163,8 +163,8 @@ public void test_getHighestNum() throws Exception { Query query = new DefaultQuery("statement", null, queryExecutorMock); expect(getMock(QueryManager.class).createQuery(eq(nextFreeDocService.getHighestNumHQL()), eq("hql"))).andReturn(query).once(); - expect(queryExecutorMock.execute(same(query))).andReturn(Arrays.asList(name + "NoDigit", - name + 5, name + 4)).once(); + expect(queryExecutorMock.execute(same(query))) + .andReturn(Arrays.asList(name + "NoDigit", name + 5, name + 4)).once(); replayDefault(); long ret = nextFreeDocService.getHighestNum(baseDocRef); @@ -225,8 +225,8 @@ public void test_getHighestNum_QueryException_execute() throws Exception { Query query = new DefaultQuery("statement", null, queryExecutorMock); expect(getMock(QueryManager.class).createQuery(eq(nextFreeDocService.getHighestNumHQL()), eq("hql"))).andReturn(query).once(); - expect(queryExecutorMock.execute(same(query))).andThrow(new QueryException("", query, - null)).once(); + expect(queryExecutorMock.execute(same(query))).andThrow(new QueryException("", query, null)) + .once(); replayDefault(); long ret = nextFreeDocService.getHighestNum(baseDocRef); @@ -260,8 +260,8 @@ public void test_getHighestNum_multiQuery() throws Exception { Query query3 = new DefaultQuery("statement", null, queryExecutorMock); expect(getMock(QueryManager.class).createQuery(eq(nextFreeDocService.getHighestNumHQL()), eq("hql"))).andReturn(query3).once(); - expect(queryExecutorMock.execute(same(query3))).andReturn(Arrays.asList(name - + "5")).once(); + expect(queryExecutorMock.execute(same(query3))).andReturn(Arrays.asList(name + "5")) + .once(); replayDefault(); long ret = nextFreeDocService.getHighestNum(baseDocRef); @@ -315,8 +315,9 @@ public void test_getNumFromName_emptyList() { @Test public void test_getHighestNumHQL() { - assertEquals("SELECT doc.name FROM XWikiDocument doc WHERE doc.space=:space " - + "AND doc.name LIKE :name ORDER BY LENGTH(doc.name) DESC, doc.name DESC", + assertEquals( + "SELECT doc.name FROM XWikiDocument doc WHERE doc.space=:space " + + "AND doc.name LIKE :name ORDER BY LENGTH(doc.name) DESC, doc.name DESC", nextFreeDocService.getHighestNumHQL()); } @@ -404,11 +405,10 @@ public void test_getNextRandomPageDocRef_DocumentReferenceExistsAlready() { String prefix = ""; int lengthOfRandomAlphanumeric = 10; Capture docRefCapture = newCapture(); - expect(getMock(IModelAccessFacade.class).exists(capture(docRefCapture))) - .andReturn(true).once(); + expect(getMock(IModelAccessFacade.class).exists(capture(docRefCapture))).andReturn(true).once(); Capture docRef2Capture = newCapture(); - expect(getMock(IModelAccessFacade.class).exists(capture(docRef2Capture))) - .andReturn(false).once(); + expect(getMock(IModelAccessFacade.class).exists(capture(docRef2Capture))).andReturn(false) + .once(); replayDefault(); DocumentReference docRef = nextFreeDocService.getNextRandomPageDocRef(spaceRef, @@ -425,8 +425,8 @@ public void test_getNextRandomPageDocRef() { String prefix = ""; int lengthOfRandomAlphanumeric = 10; Capture docRefCapture = newCapture(); - expect(getMock(IModelAccessFacade.class).exists(capture(docRefCapture))) - .andReturn(false).once(); + expect(getMock(IModelAccessFacade.class).exists(capture(docRefCapture))).andReturn(false) + .once(); replayDefault(); DocumentReference docRef = nextFreeDocService.getNextRandomPageDocRef(spaceRef, diff --git a/src/test/java/com/celements/pagetype/PageTypeReferenceTest.java b/src/test/java/com/celements/pagetype/PageTypeReferenceTest.java index 8c06680c6..590c5e2c9 100644 --- a/src/test/java/com/celements/pagetype/PageTypeReferenceTest.java +++ b/src/test/java/com/celements/pagetype/PageTypeReferenceTest.java @@ -70,8 +70,8 @@ public void testGetCategories_unmodifiable_output() { List ret = pageTypeRef2.getCategories(); assertThrows("category list must not be modifiable throught getCategories output", UnsupportedOperationException.class, () -> ret.add("cat2")); - assertEquals("category list must not be modifiable throught getCategories output", - ret, pageTypeRef2.getCategories()); + assertEquals("category list must not be modifiable throught getCategories output", ret, + pageTypeRef2.getCategories()); } @Test diff --git a/src/test/java/com/celements/pagetype/PageTypeTest.java b/src/test/java/com/celements/pagetype/PageTypeTest.java index 39de8143f..ad1fb1255 100644 --- a/src/test/java/com/celements/pagetype/PageTypeTest.java +++ b/src/test/java/com/celements/pagetype/PageTypeTest.java @@ -95,8 +95,8 @@ public void testShowFrame_missing_properties() throws XWikiException { // No PageType Object prepared -> Default PageType is RichText expect(mockWiki.exists(eq(TEST_PAGE_TYPE_FN), eq(context))).andReturn(true); XWikiDocument templateDoc = new XWikiDocument(); - expect(mockWiki.getDocument(eq(TEST_PAGE_TYPE_FN), eq(context))).andReturn( - templateDoc).anyTimes(); + expect(mockWiki.getDocument(eq(TEST_PAGE_TYPE_FN), eq(context))).andReturn(templateDoc) + .anyTimes(); // missing page_type_properties object may not lead to NPE // this is the tests focus. expect(request.get(eq("template"))).andReturn("").anyTimes(); @@ -113,8 +113,8 @@ public void testGetRenderTemplateForRenderMode_missing_properties() throws XWiki // No PageType Object prepared -> Default PageType is RichText expect(mockWiki.exists(eq(TEST_PAGE_TYPE_FN), eq(context))).andReturn(true); XWikiDocument templateDoc = new XWikiDocument(); - expect(mockWiki.getDocument(eq(TEST_PAGE_TYPE_FN), eq(context))).andReturn( - templateDoc).anyTimes(); + expect(mockWiki.getDocument(eq(TEST_PAGE_TYPE_FN), eq(context))).andReturn(templateDoc) + .anyTimes(); // missing page_type_properties object may not lead to NPE // this is the tests focus. expect(request.get(eq("template"))).andReturn("").anyTimes(); @@ -166,8 +166,8 @@ public void testGetRenderTemplateForRenderMode_celements2webTemplate() throws XW // missing page_type_properties object may not lead to NPE // this is the tests focus. expect(mockWiki.exists(eq(ptViewTemplate), eq(context))).andReturn(false).anyTimes(); - expect(mockWiki.exists(eq("celements2web:" + ptViewTemplate), eq(context))).andReturn( - true).anyTimes(); + expect(mockWiki.exists(eq("celements2web:" + ptViewTemplate), eq(context))).andReturn(true) + .anyTimes(); expect(request.get(eq("template"))).andReturn("").anyTimes(); replayAll(); String templName = pageType.getRenderTemplateForRenderMode("view", context); @@ -194,8 +194,8 @@ public void testGetRenderTemplateForRenderMode_diskTemplate() throws XWikiExcept // missing page_type_properties object may not lead to NPE // this is the tests focus. expect(mockWiki.exists(eq(ptViewTemplate), eq(context))).andReturn(false).anyTimes(); - expect(mockWiki.exists(eq("celements2web:" + ptViewTemplate), eq(context))).andReturn( - false).anyTimes(); + expect(mockWiki.exists(eq("celements2web:" + ptViewTemplate), eq(context))).andReturn(false) + .anyTimes(); expect(request.get(eq("template"))).andReturn("").anyTimes(); replayAll(); String templName = pageType.getRenderTemplateForRenderMode("view", context); @@ -263,8 +263,8 @@ public void testGetCategoryString_missing_properties() throws XWikiException { // No PageType Object prepared -> Default PageType is RichText expect(mockWiki.exists(eq(TEST_PAGE_TYPE_FN), eq(context))).andReturn(true); XWikiDocument templateDoc = new XWikiDocument(); - expect(mockWiki.getDocument(eq(TEST_PAGE_TYPE_FN), eq(context))).andReturn( - templateDoc).anyTimes(); + expect(mockWiki.getDocument(eq(TEST_PAGE_TYPE_FN), eq(context))).andReturn(templateDoc) + .anyTimes(); // missing page_type_properties object may not lead to NPE // this is the tests focus. expect(request.get(eq("template"))).andReturn("").anyTimes(); @@ -284,8 +284,8 @@ public void testGetCategoryString() throws XWikiException { doc.setObject(PageTypeCommand.PAGE_TYPE_CLASSNAME, 0, pageTypeObj); expect(mockWiki.exists(eq(TEST_PAGE_TYPE_FN), eq(context))).andReturn(true).anyTimes(); XWikiDocument testPageTypeDoc = new XWikiDocument(); - expect(mockWiki.getDocument(eq(TEST_PAGE_TYPE_FN), eq(context))).andReturn( - testPageTypeDoc).anyTimes(); + expect(mockWiki.getDocument(eq(TEST_PAGE_TYPE_FN), eq(context))).andReturn(testPageTypeDoc) + .anyTimes(); BaseObject paeTypePropObj = new BaseObject(); paeTypePropObj.setStringValue("category", "myCat"); testPageTypeDoc.setObject(PageTypeClasses.PAGE_TYPE_PROPERTIES_CLASS, 0, paeTypePropObj); @@ -302,8 +302,8 @@ public void testGetCategories_missing_properties() throws XWikiException { // No PageType Object prepared -> Default PageType is RichText expect(mockWiki.exists(eq(TEST_PAGE_TYPE_FN), eq(context))).andReturn(true).anyTimes(); XWikiDocument templateDoc = new XWikiDocument(); - expect(mockWiki.getDocument(eq(TEST_PAGE_TYPE_FN), eq(context))).andReturn( - templateDoc).anyTimes(); + expect(mockWiki.getDocument(eq(TEST_PAGE_TYPE_FN), eq(context))).andReturn(templateDoc) + .anyTimes(); // missing page_type_properties object may not lead to NPE // this is the tests focus. expect(request.get(eq("template"))).andReturn("").anyTimes(); @@ -322,8 +322,8 @@ public void testGetCategories_oneCat() throws XWikiException { doc.setObject(PageTypeCommand.PAGE_TYPE_CLASSNAME, 0, pageTypeObj); expect(mockWiki.exists(eq(TEST_PAGE_TYPE_FN), eq(context))).andReturn(true).anyTimes(); XWikiDocument testPageTypeDoc = new XWikiDocument(); - expect(mockWiki.getDocument(eq(TEST_PAGE_TYPE_FN), eq(context))).andReturn( - testPageTypeDoc).anyTimes(); + expect(mockWiki.getDocument(eq(TEST_PAGE_TYPE_FN), eq(context))).andReturn(testPageTypeDoc) + .anyTimes(); BaseObject paeTypePropObj = new BaseObject(); paeTypePropObj.setStringValue("category", "myCat"); testPageTypeDoc.setObject(PageTypeClasses.PAGE_TYPE_PROPERTIES_CLASS, 0, paeTypePropObj); @@ -343,8 +343,8 @@ public void testGetCategories_multipleCat() throws XWikiException { doc.setObject(PageTypeCommand.PAGE_TYPE_CLASSNAME, 0, pageTypeObj); expect(mockWiki.exists(eq(TEST_PAGE_TYPE_FN), eq(context))).andReturn(true).anyTimes(); XWikiDocument testPageTypeDoc = new XWikiDocument(); - expect(mockWiki.getDocument(eq(TEST_PAGE_TYPE_FN), eq(context))).andReturn( - testPageTypeDoc).anyTimes(); + expect(mockWiki.getDocument(eq(TEST_PAGE_TYPE_FN), eq(context))).andReturn(testPageTypeDoc) + .anyTimes(); BaseObject paeTypePropObj = new BaseObject(); paeTypePropObj.setStringValue("category", "myCat,secondCat"); testPageTypeDoc.setObject(PageTypeClasses.PAGE_TYPE_PROPERTIES_CLASS, 0, paeTypePropObj); @@ -364,8 +364,8 @@ public void testGetPrettyName() throws Exception { doc.setObject(PageTypeCommand.PAGE_TYPE_CLASSNAME, 0, pageTypeObj); expect(mockWiki.exists(eq(TEST_PAGE_TYPE_FN), eq(context))).andReturn(true).anyTimes(); XWikiDocument testPageTypeDoc = new XWikiDocument(); - expect(mockWiki.getDocument(eq(TEST_PAGE_TYPE_FN), eq(context))).andReturn( - testPageTypeDoc).anyTimes(); + expect(mockWiki.getDocument(eq(TEST_PAGE_TYPE_FN), eq(context))).andReturn(testPageTypeDoc) + .anyTimes(); BaseObject paeTypePropObj = new BaseObject(); paeTypePropObj.setStringValue("type_name", "myPrettyTypeName"); testPageTypeDoc.setObject(PageTypeClasses.PAGE_TYPE_PROPERTIES_CLASS, 0, paeTypePropObj); @@ -385,8 +385,8 @@ public void testGetPrettyName_noPropertyObj() throws Exception { doc.setObject(PageTypeCommand.PAGE_TYPE_CLASSNAME, 0, pageTypeObj); expect(mockWiki.exists(eq(TEST_PAGE_TYPE_FN), eq(context))).andReturn(true).anyTimes(); XWikiDocument testPageTypeDoc = new XWikiDocument(); - expect(mockWiki.getDocument(eq(TEST_PAGE_TYPE_FN), eq(context))).andReturn( - testPageTypeDoc).anyTimes(); + expect(mockWiki.getDocument(eq(TEST_PAGE_TYPE_FN), eq(context))).andReturn(testPageTypeDoc) + .anyTimes(); expect(request.get(eq("template"))).andReturn("").anyTimes(); replayAll(); assertEquals("", pageType.getPrettyName(context)); @@ -398,8 +398,8 @@ public void testHasPageTitle_npe() throws Exception { expect(mockWiki.exists(eq(TEST_PAGE_TYPE_FN), same(context))).andReturn(false); DocumentReference testPageTypeCentralDocRef = new DocumentReference("celements2web", TEST_PAGE_TYPE_SPACE, TEST_PAGE_TYPE_DOC); - expect(mockWiki.getDocument(eq("celements2web:" + TEST_PAGE_TYPE_FN), same(context))).andReturn( - new XWikiDocument(testPageTypeCentralDocRef)); + expect(mockWiki.getDocument(eq("celements2web:" + TEST_PAGE_TYPE_FN), same(context))) + .andReturn(new XWikiDocument(testPageTypeCentralDocRef)); replayAll(); assertFalse(pageType.hasPageTitle(context)); verifyAll(); diff --git a/src/test/java/com/celements/pagetype/classes/PageTypeClassPackageTest.java b/src/test/java/com/celements/pagetype/classes/PageTypeClassPackageTest.java index 71d1063b5..d4c7f193a 100644 --- a/src/test/java/com/celements/pagetype/classes/PageTypeClassPackageTest.java +++ b/src/test/java/com/celements/pagetype/classes/PageTypeClassPackageTest.java @@ -48,10 +48,10 @@ public void getNameTest() { @Test public void getClassDefinitionsTest() { assertEquals(2, pageTypeClassPackage.getClassDefinitions().size()); - assertTrue(pageTypeClassPackage.getClassDefinitions().contains(Utils.getComponent( - ClassDefinition.class, PageTypeClass.CLASS_DEF_HINT))); - assertTrue(pageTypeClassPackage.getClassDefinitions().contains(Utils.getComponent( - ClassDefinition.class, PageTypePropertiesClass.CLASS_DEF_HINT))); + assertTrue(pageTypeClassPackage.getClassDefinitions() + .contains(Utils.getComponent(ClassDefinition.class, PageTypeClass.CLASS_DEF_HINT))); + assertTrue(pageTypeClassPackage.getClassDefinitions().contains( + Utils.getComponent(ClassDefinition.class, PageTypePropertiesClass.CLASS_DEF_HINT))); } } diff --git a/src/test/java/com/celements/pagetype/cmd/GetPageTypesCommandTest.java b/src/test/java/com/celements/pagetype/cmd/GetPageTypesCommandTest.java index e73660d9b..ac3295fa2 100644 --- a/src/test/java/com/celements/pagetype/cmd/GetPageTypesCommandTest.java +++ b/src/test/java/com/celements/pagetype/cmd/GetPageTypesCommandTest.java @@ -60,8 +60,8 @@ public void setUp_GetPageTypesCommandTest() throws Exception { @Test public void testGetPThql() { - String pThql = gptCmd.getPThql(new HashSet<>(Arrays.asList("myCat", "pageTypeCat", - "CelCat")), false); + String pThql = gptCmd.getPThql(new HashSet<>(Arrays.asList("myCat", "pageTypeCat", "CelCat")), + false); assertTrue(pThql.startsWith("select doc.fullName ")); assertTrue(pThql.contains(" from XWikiDocument as doc")); assertTrue(pThql.contains(", BaseObject as obj")); @@ -108,8 +108,8 @@ public void testGetPThql_emptyList() { @Test public void testGetPThql_onlyVisible() { - String pThql = gptCmd.getPThql(new HashSet<>(Arrays.asList("myCat", "pageTypeCat", - "CelCat")), true); + String pThql = gptCmd.getPThql(new HashSet<>(Arrays.asList("myCat", "pageTypeCat", "CelCat")), + true); assertTrue(pThql.startsWith("select doc.fullName ")); assertTrue(pThql.contains(" from XWikiDocument as doc")); assertTrue(pThql.contains(", BaseObject as obj")); @@ -153,8 +153,7 @@ public void testGetPThql_emptyList_onlyVisible() { @Test public void testGetPThql_emptyCategoryDefault() { - String pThql = gptCmd.getPThql(new HashSet<>(Arrays.asList("", "pageTypeCat")), false) - + " "; + String pThql = gptCmd.getPThql(new HashSet<>(Arrays.asList("", "pageTypeCat")), false) + " "; assertTrue(pThql.startsWith("select doc.fullName ")); assertTrue(pThql.contains(" from XWikiDocument as doc")); assertTrue(pThql.contains(", BaseObject as obj")); @@ -178,8 +177,8 @@ public void testGetPThql_emptyCategoryDefault() { public void testGetPageTypesForCategories() throws XWikiException { List expectedList = Arrays.asList("PageTypes.RichText", "PageTypes.Code"); Set catList = new HashSet<>(Arrays.asList("pageTypeCat")); - expect(xwiki.search(eq(gptCmd.getPThql(catList, false)), same(context))).andReturn( - expectedList).times(2); + expect(xwiki.search(eq(gptCmd.getPThql(catList, false)), same(context))).andReturn(expectedList) + .times(2); replayDefault(); List resultList = gptCmd.getPageTypesForCategories(catList, false, context); assertEquals(expectedList, resultList); @@ -191,8 +190,8 @@ public void testGetPageTypesForCategories() throws XWikiException { public void testGetPageTypesForCategories_emptyCategoryDefault() throws XWikiException { List allPTList = Arrays.asList("PageTypes.RichText", "PageTypes.Code"); Set catList = new HashSet<>(Arrays.asList("")); - expect(xwiki.search(eq(gptCmd.getPThql(catList, false)), same(context))).andReturn( - allPTList).times(2); + expect(xwiki.search(eq(gptCmd.getPThql(catList, false)), same(context))).andReturn(allPTList) + .times(2); expect(xwiki.exists(eq("PageTypes.RichText"), same(context))).andReturn(true).anyTimes(); expect(xwiki.exists(eq("PageTypes.Code"), same(context))).andReturn(true).anyTimes(); XWikiDocument ptRTE = new XWikiDocument(); @@ -219,8 +218,8 @@ public void testGetPageTypesForCategories_emptyCategoryDefault() throws XWikiExc public void testGetPageTypesForCategories_emptyCategory_nullValue() throws XWikiException { List allPTList = Arrays.asList("PageTypes.RichText", "PageTypes.Code"); Set catList = new HashSet<>(Arrays.asList("")); - expect(xwiki.search(eq(gptCmd.getPThql(catList, false)), same(context))).andReturn( - allPTList).times(2); + expect(xwiki.search(eq(gptCmd.getPThql(catList, false)), same(context))).andReturn(allPTList) + .times(2); expect(xwiki.exists(eq("PageTypes.RichText"), same(context))).andReturn(true).anyTimes(); expect(xwiki.exists(eq("PageTypes.Code"), same(context))).andReturn(true).anyTimes(); XWikiDocument ptRTE = new XWikiDocument(); @@ -245,8 +244,8 @@ public void testGetPageTypesForCategories_emptyCategory_nullValue() throws XWiki @Test public void testGetPageTypesForCategories_Exception() throws XWikiException { Set catList = new HashSet<>(Arrays.asList("pageTypeCat")); - expect(xwiki.search(eq(gptCmd.getPThql(catList, false)), same(context))).andThrow( - new XWikiException()).atLeastOnce(); + expect(xwiki.search(eq(gptCmd.getPThql(catList, false)), same(context))) + .andThrow(new XWikiException()).atLeastOnce(); replayDefault(); try { List resultList = gptCmd.getPageTypesForCategories(catList, false, context); diff --git a/src/test/java/com/celements/pagetype/java/DefaultPageTypeConfigTest.java b/src/test/java/com/celements/pagetype/java/DefaultPageTypeConfigTest.java index 289f9595c..08674ea7a 100644 --- a/src/test/java/com/celements/pagetype/java/DefaultPageTypeConfigTest.java +++ b/src/test/java/com/celements/pagetype/java/DefaultPageTypeConfigTest.java @@ -126,12 +126,12 @@ public void testDisplayInFrameLayout_true() { public void testGetRenderTemplateForRenderMode_view() { String templateName = "ImageStatsView"; String expectedViewTemplates = "Templates." + templateName; - expect(pageTypeImplMock.getRenderTemplateForRenderMode(eq("view"))).andReturn( - templateName).anyTimes(); + expect(pageTypeImplMock.getRenderTemplateForRenderMode(eq("view"))).andReturn(templateName) + .anyTimes(); DocumentReference localTemplateDocRef = new DocumentReference(context.getDatabase(), "Templates", templateName); - expect(webUtilsMock.getInheritedTemplatedPath(eq(localTemplateDocRef))).andReturn( - expectedViewTemplates); + expect(webUtilsMock.getInheritedTemplatedPath(eq(localTemplateDocRef))) + .andReturn(expectedViewTemplates); replayDefault(); assertEquals(expectedViewTemplates, testPageType.getRenderTemplateForRenderMode("view")); verifyDefault(); @@ -141,12 +141,12 @@ public void testGetRenderTemplateForRenderMode_view() { public void testGetRenderTemplateForRenderMode_edit() { String templateName = "ImageStatsEdit"; String expectedEditTemplates = "Templates." + templateName; - expect(pageTypeImplMock.getRenderTemplateForRenderMode(eq("edit"))).andReturn( - templateName).anyTimes(); + expect(pageTypeImplMock.getRenderTemplateForRenderMode(eq("edit"))).andReturn(templateName) + .anyTimes(); DocumentReference localTemplateDocRef = new DocumentReference(context.getDatabase(), "Templates", templateName); - expect(webUtilsMock.getInheritedTemplatedPath(eq(localTemplateDocRef))).andReturn( - expectedEditTemplates); + expect(webUtilsMock.getInheritedTemplatedPath(eq(localTemplateDocRef))) + .andReturn(expectedEditTemplates); replayDefault(); assertEquals(expectedEditTemplates, testPageType.getRenderTemplateForRenderMode("edit")); verifyDefault(); diff --git a/src/test/java/com/celements/pagetype/service/PageTypeResolverServiceTest.java b/src/test/java/com/celements/pagetype/service/PageTypeResolverServiceTest.java index fe8c08c66..e35f394d4 100644 --- a/src/test/java/com/celements/pagetype/service/PageTypeResolverServiceTest.java +++ b/src/test/java/com/celements/pagetype/service/PageTypeResolverServiceTest.java @@ -66,22 +66,22 @@ public void prepareTest() throws Exception { modelStrategyMock = registerComponentMock(IModelAccessFacade.class); pageTypeServiceMock = registerComponentMock(IPageTypeRole.class); richTextPTref = new PageTypeReference("RichText", "xObjectProvider", Arrays.asList("")); - expect(pageTypeServiceMock.getPageTypeReference(eq("RichText"))).andReturn(Optional.of( - richTextPTref)).anyTimes(); - expect(pageTypeServiceMock.getPageTypeReference("")).andReturn( - Optional.absent()).anyTimes(); + expect(pageTypeServiceMock.getPageTypeReference(eq("RichText"))) + .andReturn(Optional.of(richTextPTref)).anyTimes(); + expect(pageTypeServiceMock.getPageTypeReference("")) + .andReturn(Optional.absent()).anyTimes(); docRef = new DocumentReference(getContext().getDatabase(), "MySpace", "MyDocument"); doc = new XWikiDocument(docRef); webPrefDocRef = new DocumentReference(getContext().getDatabase(), docRef.getLastSpaceReference().getName(), "WebPreferences"); webPrefDoc = new XWikiDocument(webPrefDocRef); - expect(getWikiMock().getDocument(eq(webPrefDocRef), same(getContext()))).andReturn( - webPrefDoc).anyTimes(); + expect(getWikiMock().getDocument(eq(webPrefDocRef), same(getContext()))).andReturn(webPrefDoc) + .anyTimes(); xwikiPrefDocRef = new DocumentReference(getContext().getDatabase(), "XWiki", "XWikiPreferences"); xwikiPrefDoc = new XWikiDocument(xwikiPrefDocRef); - expect(getWikiMock().getDocument(eq(xwikiPrefDocRef), same(getContext()))).andReturn( - xwikiPrefDoc).anyTimes(); + expect(getWikiMock().getDocument(eq(xwikiPrefDocRef), same(getContext()))) + .andReturn(xwikiPrefDoc).anyTimes(); pageTypeResolver = (PageTypeResolverService) Utils.getComponent(IPageTypeResolverRole.class); } @@ -183,8 +183,8 @@ public void test_resolvePageTypeReferenceWithDefault_docRef() throws Exception { doc.addXObject(pageTypeObj); PageTypeReference myPTref = new PageTypeReference("MyPageType", "xObjectProvider", Arrays.asList("")); - expect(pageTypeServiceMock.getPageTypeReference(eq("MyPageType"))).andReturn(Optional.of( - myPTref)); + expect(pageTypeServiceMock.getPageTypeReference(eq("MyPageType"))) + .andReturn(Optional.of(myPTref)); replayDefault(); // No PageType Object prepared -> Default PageType is RichText PageTypeReference pageTypeRef = pageTypeResolver.resolvePageTypeReferenceWithDefault(docRef); @@ -195,8 +195,8 @@ public void test_resolvePageTypeReferenceWithDefault_docRef() throws Exception { @Test public void test_resolvePageTypeReferenceWithDefault_docRef_Exception() throws Exception { expectDoc(docRef); - expect(getWikiMock().getDocument(eq(docRef), same(getContext()))).andThrow( - new XWikiException()); + expect(getWikiMock().getDocument(eq(docRef), same(getContext()))) + .andThrow(new XWikiException()); replayDefault(); // No PageType Object prepared -> Default PageType is RichText PageTypeReference pageTypeRef = pageTypeResolver.resolvePageTypeReferenceWithDefault(docRef); @@ -208,8 +208,8 @@ public void test_resolvePageTypeReferenceWithDefault_docRef_Exception() throws E public void test_resolvePageTypeReferenceWithDefault_null_doc() throws Exception { replayDefault(); // No PageType Object prepared -> Default PageType is RichText - PageTypeReference pageTypeRef = pageTypeResolver.resolvePageTypeReferenceWithDefault( - (XWikiDocument) null); + PageTypeReference pageTypeRef = pageTypeResolver + .resolvePageTypeReferenceWithDefault((XWikiDocument) null); verifyDefault(); assertEquals(richTextPTref, pageTypeRef); } @@ -255,8 +255,8 @@ public void test_resolvePageTypeReferenceWithDefault_NewDocFromTemplate() throws expect(request.get(eq("template"))).andReturn("Blog.ArticleTemplate").atLeastOnce(); PageTypeReference articlePTref = new PageTypeReference("Article", "xObjectProvider", Arrays.asList("")); - expect(pageTypeServiceMock.getPageTypeReference("Article")).andReturn(Optional.of( - articlePTref)); + expect(pageTypeServiceMock.getPageTypeReference("Article")) + .andReturn(Optional.of(articlePTref)); replayDefault(); PageTypeReference pageTypeRef = pageTypeResolver.resolvePageTypeReferenceWithDefault(doc); verifyDefault(); @@ -291,8 +291,8 @@ public void test_resolveDefaultPageTypeReference_WebPrefs() throws Exception { xwikiPtObj.setXClassReference(getPageTypeClassRef(getContext().getDatabase())); xwikiPtObj.setStringValue(FIELD_PAGE_TYPE.getName(), "myXWikiPrefDefPageType"); xwikiPrefDoc.addXObject(xwikiPtObj); - expect(pageTypeServiceMock.getPageTypeReference(eq(webPrefPageTypeName))).andReturn(Optional.of( - createPTRef(webPrefPageTypeName))); + expect(pageTypeServiceMock.getPageTypeReference(eq(webPrefPageTypeName))) + .andReturn(Optional.of(createPTRef(webPrefPageTypeName))); replayDefault(); PageTypeReference pageTypeRef = pageTypeResolver.resolveDefaultPageTypeReference(docRef); verifyDefault(); @@ -307,8 +307,8 @@ public void test_resolveDefaultPageTypeReference_XWikiPrefs() throws Exception { String xwikiPrefPageTypeName = "myXWikiPrefDefPageType"; xwikiPtObj.setStringValue(FIELD_PAGE_TYPE.getName(), xwikiPrefPageTypeName); xwikiPrefDoc.addXObject(xwikiPtObj); - expect(pageTypeServiceMock.getPageTypeReference(eq(xwikiPrefPageTypeName))).andReturn( - Optional.of(createPTRef(xwikiPrefPageTypeName))); + expect(pageTypeServiceMock.getPageTypeReference(eq(xwikiPrefPageTypeName))) + .andReturn(Optional.of(createPTRef(xwikiPrefPageTypeName))); replayDefault(); PageTypeReference pageTypeRef = pageTypeResolver.resolveDefaultPageTypeReference(docRef); verifyDefault(); @@ -346,8 +346,8 @@ private PageTypeReference createPTRef(String name) { } private ClassReference getPageTypeClassRef(String wikiName) { - return Utils.getComponent(ClassDefinition.class, - PageTypeClass.CLASS_DEF_HINT).getClassReference(); + return Utils.getComponent(ClassDefinition.class, PageTypeClass.CLASS_DEF_HINT) + .getClassReference(); } } diff --git a/src/test/java/com/celements/pagetype/service/PageTypeServiceTest.java b/src/test/java/com/celements/pagetype/service/PageTypeServiceTest.java index 417fba552..813b5e99e 100644 --- a/src/test/java/com/celements/pagetype/service/PageTypeServiceTest.java +++ b/src/test/java/com/celements/pagetype/service/PageTypeServiceTest.java @@ -128,8 +128,8 @@ public void testGetPageTypeRefsForCategories_cat_visible() throws Exception { testPageTypePropObj.setXClassReference(pageTypePropClassRef); testPageTypeDoc.addXObject(testPageTypePropObj); testPageTypePropObj.setIntValue("visible", 1); - expect(getWikiMock().getDocument(eq("PageTypes.TestPageType"), same(getContext()))).andReturn( - testPageTypeDoc); + expect(getWikiMock().getDocument(eq("PageTypes.TestPageType"), same(getContext()))) + .andReturn(testPageTypeDoc); replayDefault(); List pageTypeRefs = ptService.getPageTypeRefsForCategories(catList, true); assertTrue(pageTypeRefs.size() == 1); @@ -156,8 +156,8 @@ public void testGetPageTypeRefsForCategories_cat_NOTvisible() throws Exception { testPageTypePropObj.setXClassReference(pageTypePropClassRef); testPageTypeDoc.addXObject(testPageTypePropObj); testPageTypePropObj.setIntValue("visible", 0); - expect(getWikiMock().getDocument(eq("PageTypes.TestPageType"), same(getContext()))).andReturn( - testPageTypeDoc); + expect(getWikiMock().getDocument(eq("PageTypes.TestPageType"), same(getContext()))) + .andReturn(testPageTypeDoc); replayDefault(); List pageTypeRefs = ptService.getPageTypeRefsForCategories(catList, true); assertTrue(pageTypeRefs.isEmpty()); @@ -180,8 +180,8 @@ public void testGetPageTypeRefsByConfigNames() { @Test public void testGetPageTypeRefsForCategories_cat_emptyType() { Set catList = new HashSet<>(Arrays.asList("", "PageTypes")); - PageTypeReference richTextRef = new PageTypeReference("RichText", MOCK_PROVIDER, Arrays.asList( - "")); + PageTypeReference richTextRef = new PageTypeReference("RichText", MOCK_PROVIDER, + Arrays.asList("")); PageTypeReference testCellTypeRef = new PageTypeReference("testCellPageType", MOCK_PROVIDER, Arrays.asList("cellType")); expect(providerMock.getPageTypes()).andReturn(Arrays.asList(richTextRef, testCellTypeRef)); @@ -195,8 +195,8 @@ public void testGetPageTypeRefsForCategories_cat_emptyType() { @Test public void testGetPageTypeRefsForCategories_cat_PageTypes() { Set catList = new HashSet<>(Arrays.asList("", "PageTypes")); - PageTypeReference richTextRef = new PageTypeReference("RichText", MOCK_PROVIDER, Arrays.asList( - "PageTypes")); + PageTypeReference richTextRef = new PageTypeReference("RichText", MOCK_PROVIDER, + Arrays.asList("PageTypes")); PageTypeReference testCellTypeRef = new PageTypeReference("testCellPageType", MOCK_PROVIDER, Arrays.asList("cellType")); expect(providerMock.getPageTypes()).andReturn(Arrays.asList(richTextRef, testCellTypeRef)); @@ -217,16 +217,16 @@ public void test_setPageType_get() throws Exception { doc.addXObject(obj); BaseClass bClass = createBaseClassMock(getPageTypeClassRef()); - expect(bClass.get(eq(IPageTypeClassConfig.PAGE_TYPE_FIELD))).andReturn( - new StringClass()).once(); + expect(bClass.get(eq(IPageTypeClassConfig.PAGE_TYPE_FIELD))).andReturn(new StringClass()) + .once(); replayDefault(); assertTrue(ptService.setPageType(doc, testPageTypeRef)); verifyDefault(); assertSame(obj, doc.getXObject(getPageTypeClassRef())); - assertEquals(testPageTypeRef.getConfigName(), obj.getStringValue( - IPageTypeClassConfig.PAGE_TYPE_FIELD)); + assertEquals(testPageTypeRef.getConfigName(), + obj.getStringValue(IPageTypeClassConfig.PAGE_TYPE_FIELD)); } @Test @@ -236,16 +236,16 @@ public void test_setPageType_create() throws Exception { Arrays.asList("")); BaseClass bClass = expectNewBaseObject(getPageTypeClassRef()); - expect(bClass.get(eq(IPageTypeClassConfig.PAGE_TYPE_FIELD))).andReturn( - new StringClass()).once(); + expect(bClass.get(eq(IPageTypeClassConfig.PAGE_TYPE_FIELD))).andReturn(new StringClass()) + .once(); replayDefault(); assertTrue(ptService.setPageType(doc, testPageTypeRef)); verifyDefault(); assertNotNull(doc.getXObject(getPageTypeClassRef())); - assertEquals(testPageTypeRef.getConfigName(), doc.getXObject( - getPageTypeClassRef()).getStringValue(IPageTypeClassConfig.PAGE_TYPE_FIELD)); + assertEquals(testPageTypeRef.getConfigName(), + doc.getXObject(getPageTypeClassRef()).getStringValue(IPageTypeClassConfig.PAGE_TYPE_FIELD)); } @Test @@ -263,8 +263,8 @@ public void test_setPageType_alreadySet() throws Exception { verifyDefault(); assertSame(obj, doc.getXObject(getPageTypeClassRef())); - assertEquals(testPageTypeRef.getConfigName(), obj.getStringValue( - IPageTypeClassConfig.PAGE_TYPE_FIELD)); + assertEquals(testPageTypeRef.getConfigName(), + obj.getStringValue(IPageTypeClassConfig.PAGE_TYPE_FIELD)); } @Test diff --git a/src/test/java/com/celements/pagetype/xobject/XObjectPageTypeCacheTest.java b/src/test/java/com/celements/pagetype/xobject/XObjectPageTypeCacheTest.java index a8a998154..874fc09df 100644 --- a/src/test/java/com/celements/pagetype/xobject/XObjectPageTypeCacheTest.java +++ b/src/test/java/com/celements/pagetype/xobject/XObjectPageTypeCacheTest.java @@ -71,7 +71,8 @@ public void testInvalidateCacheForWiki_celements2web() { @Test public void testInvalidateCacheForWiki() { - Map> pageTypeRefCache = xObjPageTypeCache.getPageTypeRefCache(); + Map> pageTypeRefCache = xObjPageTypeCache + .getPageTypeRefCache(); assertNotNull(pageTypeRefCache); PageTypeReference pageTypeRefMack = createDefaultMock(PageTypeReference.class); pageTypeRefCache.put(wikiRef, Arrays.asList(pageTypeRefMack)); @@ -91,8 +92,8 @@ public void testGetPageTypesRefsForWiki() throws Exception { DocumentReference centralRichTextPTdocRef = new DocumentReference("celements2web", "PageTypes", "RichText"); XWikiDocument centralRichTextPTdoc = new XWikiDocument(centralRichTextPTdocRef); - expect(xwiki.getDocument(eq("celements2web:PageTypes.RichText"), same(context))).andReturn( - centralRichTextPTdoc).anyTimes(); + expect(xwiki.getDocument(eq("celements2web:PageTypes.RichText"), same(context))) + .andReturn(centralRichTextPTdoc).anyTimes(); replayDefault(); List allPageTypes = xObjPageTypeCache.getPageTypesRefsForWiki(wikiRef); assertFalse("expecting RichtText page type reference.", allPageTypes.isEmpty()); diff --git a/src/test/java/com/celements/pagetype/xobject/XObjectPageTypeConfigTest.java b/src/test/java/com/celements/pagetype/xobject/XObjectPageTypeConfigTest.java index b215975f4..cbfc7d447 100644 --- a/src/test/java/com/celements/pagetype/xobject/XObjectPageTypeConfigTest.java +++ b/src/test/java/com/celements/pagetype/xobject/XObjectPageTypeConfigTest.java @@ -121,8 +121,8 @@ public void testHasPageTitle_no() { @Test public void testGetRenderTemplateForRenderMode_view() throws Exception { String expectedRenderTemplate = "Templates.TestPageTypeView"; - expect(pageTypeMock.getRenderTemplate(eq("view"), same(context))).andReturn( - expectedRenderTemplate); + expect(pageTypeMock.getRenderTemplate(eq("view"), same(context))) + .andReturn(expectedRenderTemplate); replayDefault(); assertEquals(expectedRenderTemplate, xObjPTconfig.getRenderTemplateForRenderMode("view")); verifyDefault(); @@ -131,8 +131,8 @@ public void testGetRenderTemplateForRenderMode_view() throws Exception { @Test public void testGetRenderTemplateForRenderMode_edit() throws Exception { String expectedRenderTemplate = "Templates.TestPageTypeEdit"; - expect(pageTypeMock.getRenderTemplate(eq("edit"), same(context))).andReturn( - expectedRenderTemplate); + expect(pageTypeMock.getRenderTemplate(eq("edit"), same(context))) + .andReturn(expectedRenderTemplate); replayDefault(); assertEquals(expectedRenderTemplate, xObjPTconfig.getRenderTemplateForRenderMode("edit")); verifyDefault(); @@ -188,8 +188,8 @@ public void test_getTagName_present() { IPageTypeClassConfig.PAGE_TYPE_PROPERTIES_CLASS_DOC); testPageTypePropObj.setXClassReference(pageTypePropClassRef); testPageTypePropObj.setStringValue(IPageTypeClassConfig.PAGETYPE_PROP_TAG_NAME, tagName); - expect(pageTypeMock.getPageTypeProperties(same(context))).andReturn( - testPageTypePropObj).atLeastOnce(); + expect(pageTypeMock.getPageTypeProperties(same(context))).andReturn(testPageTypePropObj) + .atLeastOnce(); replayDefault(); assertTrue(xObjPTconfig.defaultTagName().isPresent()); assertEquals(tagName, xObjPTconfig.defaultTagName().get()); @@ -225,8 +225,8 @@ public void test_InlineEditorMode_present_false() { IPageTypeClassConfig.PAGE_TYPE_PROPERTIES_CLASS_DOC); testPageTypePropObj.setXClassReference(pageTypePropClassRef); testPageTypePropObj.setIntValue(IPageTypeClassConfig.PAGETYPE_PROP_INLINE_EDITOR_MODE, 0); - expect(pageTypeMock.getPageTypeProperties(same(context))).andReturn( - testPageTypePropObj).atLeastOnce(); + expect(pageTypeMock.getPageTypeProperties(same(context))).andReturn(testPageTypePropObj) + .atLeastOnce(); replayDefault(); assertFalse(xObjPTconfig.useInlineEditorMode()); verifyDefault(); @@ -240,8 +240,8 @@ public void test_InlineEditorMode_present_true() { IPageTypeClassConfig.PAGE_TYPE_PROPERTIES_CLASS_DOC); testPageTypePropObj.setXClassReference(pageTypePropClassRef); testPageTypePropObj.setIntValue(IPageTypeClassConfig.PAGETYPE_PROP_INLINE_EDITOR_MODE, 1); - expect(pageTypeMock.getPageTypeProperties(same(context))).andReturn( - testPageTypePropObj).atLeastOnce(); + expect(pageTypeMock.getPageTypeProperties(same(context))).andReturn(testPageTypePropObj) + .atLeastOnce(); replayDefault(); assertTrue(xObjPTconfig.useInlineEditorMode()); verifyDefault(); diff --git a/src/test/java/com/celements/pagetype/xobject/XObjectPageTypeProviderTest.java b/src/test/java/com/celements/pagetype/xobject/XObjectPageTypeProviderTest.java index 8c9486d20..16525cb0e 100644 --- a/src/test/java/com/celements/pagetype/xobject/XObjectPageTypeProviderTest.java +++ b/src/test/java/com/celements/pagetype/xobject/XObjectPageTypeProviderTest.java @@ -61,8 +61,8 @@ public void setUp_XObjectPageTypeProviderTest() throws Exception { @Test public void testComponentRegistration() { - assertNotNull(Utils.getComponent(IPageTypeProviderRole.class, - "com.celements.XObjectPageTypeProvider")); + assertNotNull( + Utils.getComponent(IPageTypeProviderRole.class, "com.celements.XObjectPageTypeProvider")); } @Test @@ -72,8 +72,8 @@ public void testGetPageTypeByReference() { DocumentReference pTdocRef = new DocumentReference(context.getDatabase(), XObjectPageTypeProvider.DEFAULT_PAGE_TYPES_SPACE, "TestPageTypeRef"); replayDefault(); - XObjectPageTypeConfig ptObj = (XObjectPageTypeConfig) xObjPTprovider.getPageTypeByReference( - testPTref); + XObjectPageTypeConfig ptObj = (XObjectPageTypeConfig) xObjPTprovider + .getPageTypeByReference(testPTref); assertNotNull(ptObj); assertEquals("TestPageTypeRef", ptObj.getName()); assertEquals(pTdocRef, ptObj.pageType.getDocumentReference()); @@ -87,11 +87,11 @@ public void testGetPageTypes() throws Exception { DocumentReference centralRichTextPTdocRef = new DocumentReference("celements2web", "PageTypes", "RichText"); XWikiDocument centralRichTextPTdoc = new XWikiDocument(centralRichTextPTdocRef); - expect(xwiki.getDocument(eq("celements2web:PageTypes.RichText"), same(context))).andReturn( - centralRichTextPTdoc).anyTimes(); + expect(xwiki.getDocument(eq("celements2web:PageTypes.RichText"), same(context))) + .andReturn(centralRichTextPTdoc).anyTimes(); List pageTypeString = Arrays.asList("PageTypes.RichText"); - expect(xwiki.search(isA(String.class), same(context))).andReturn(pageTypeString).times( - 2); + expect(xwiki.search(isA(String.class), same(context))).andReturn(pageTypeString) + .times(2); replayDefault(); List allPageTypes = xObjPTprovider.getPageTypes(); assertFalse("expecting RichtText page type reference.", allPageTypes.isEmpty()); diff --git a/src/test/java/com/celements/pagetype/xobject/listener/XObjectPageTypeDocumentCreatedListenerTest.java b/src/test/java/com/celements/pagetype/xobject/listener/XObjectPageTypeDocumentCreatedListenerTest.java index cff366ba1..53b00169e 100644 --- a/src/test/java/com/celements/pagetype/xobject/listener/XObjectPageTypeDocumentCreatedListenerTest.java +++ b/src/test/java/com/celements/pagetype/xobject/listener/XObjectPageTypeDocumentCreatedListenerTest.java @@ -55,8 +55,8 @@ public void testGetName() { @Test public void testGetEvents() { - List expectedEventClassList = Arrays.asList( - new DocumentCreatedEvent().getClass().getName()); + List expectedEventClassList = Arrays + .asList(new DocumentCreatedEvent().getClass().getName()); replayDefault(); List actualEventList = eventListener.getEvents(); assertEquals(expectedEventClassList.size(), actualEventList.size()); diff --git a/src/test/java/com/celements/pagetype/xobject/listener/XObjectPageTypeDocumentUpdatedListenerTest.java b/src/test/java/com/celements/pagetype/xobject/listener/XObjectPageTypeDocumentUpdatedListenerTest.java index 5f3755718..76b34eac2 100644 --- a/src/test/java/com/celements/pagetype/xobject/listener/XObjectPageTypeDocumentUpdatedListenerTest.java +++ b/src/test/java/com/celements/pagetype/xobject/listener/XObjectPageTypeDocumentUpdatedListenerTest.java @@ -70,8 +70,8 @@ public void testGetName() { @Test public void testGetEvents() { - List expectedEventClassList = Arrays.asList( - new DocumentUpdatedEvent().getClass().getName()); + List expectedEventClassList = Arrays + .asList(new DocumentUpdatedEvent().getClass().getName()); replayDefault(); List actualEventList = eventListener.getEvents(); assertEquals(expectedEventClassList.size(), actualEventList.size()); @@ -278,8 +278,8 @@ public void testIsPageTypePropertiesUpdated_noChanges() { } private DocumentReference getPageTypePropertiesClassRef() { - return Utils.getComponent(IPageTypeClassConfig.class).getPageTypePropertiesClassRef( - new WikiReference(context.getDatabase())); + return Utils.getComponent(IPageTypeClassConfig.class) + .getPageTypePropertiesClassRef(new WikiReference(context.getDatabase())); } private XObjectPageTypeDocumentUpdatedListener getXObjPageTypeDocUpdatedListener() { diff --git a/src/test/java/com/celements/parents/DocumentParentsListerTest.java b/src/test/java/com/celements/parents/DocumentParentsListerTest.java index 1417f78dd..ce3176bd0 100644 --- a/src/test/java/com/celements/parents/DocumentParentsListerTest.java +++ b/src/test/java/com/celements/parents/DocumentParentsListerTest.java @@ -81,15 +81,14 @@ public void testGetDocumentParentsList_not_include() throws Exception { @Test public void testGetDocumentParentsList_not_include_testProvider_empty() throws Exception { - IDocParentProviderRole testProviderMock = createDefaultMock( - IDocParentProviderRole.class); + IDocParentProviderRole testProviderMock = createDefaultMock(IDocParentProviderRole.class); docParentsLister.docParentProviderMap.put("TestProvider", testProviderMock); DocumentReference docRef = new DocumentReference(context.getDatabase(), "mySpace", "myDoc"); XWikiDocument doc = new XWikiDocument(docRef); expect(xwiki.getDocument(eq(docRef), same(context))).andReturn(doc).once(); - expect(testProviderMock.getDocumentParentsList(eq(docRef))).andReturn( - Collections.emptyList()).once(); + expect(testProviderMock.getDocumentParentsList(eq(docRef))) + .andReturn(Collections.emptyList()).once(); List docParentsList = Collections.emptyList(); replayDefault(); assertEquals(docParentsList, docParentsLister.getDocumentParentsList(docRef, false)); @@ -98,8 +97,7 @@ public void testGetDocumentParentsList_not_include_testProvider_empty() throws E @Test public void testGetDocumentParentsList_not_include_testProvider_hasParent() throws Exception { - IDocParentProviderRole testProviderMock = createDefaultMock( - IDocParentProviderRole.class); + IDocParentProviderRole testProviderMock = createDefaultMock(IDocParentProviderRole.class); docParentsLister.docParentProviderMap.put("TestProvider", testProviderMock); DocumentReference docRef = new DocumentReference(context.getDatabase(), "mySpace", "myDoc"); @@ -109,15 +107,15 @@ public void testGetDocumentParentsList_not_include_testProvider_hasParent() thro DocumentReference testProviderParentRef = new DocumentReference(context.getDatabase(), "MySpaceTest", "TestProviderDoc"); XWikiDocument testProviderParentDoc = new XWikiDocument(testProviderParentRef); - expect(xwiki.getDocument(eq(testProviderParentRef), same(context))).andReturn( - testProviderParentDoc).once(); + expect(xwiki.getDocument(eq(testProviderParentRef), same(context))) + .andReturn(testProviderParentDoc).once(); expect(xwiki.exists(eq(testProviderParentRef), same(context))).andReturn(true).anyTimes(); - expect(testProviderMock.getDocumentParentsList(eq(docRef))).andReturn(Arrays.asList( - testProviderParentRef)).once(); + expect(testProviderMock.getDocumentParentsList(eq(docRef))) + .andReturn(Arrays.asList(testProviderParentRef)).once(); expectParentPageType(testProviderParentRef, true); - expect(testProviderMock.getDocumentParentsList(eq(testProviderParentRef))).andReturn( - Collections.emptyList()).once(); + expect(testProviderMock.getDocumentParentsList(eq(testProviderParentRef))) + .andReturn(Collections.emptyList()).once(); List docParentsList = Arrays.asList(testProviderParentRef); replayDefault(); @@ -154,8 +152,7 @@ public void testGetDocumentParentsList_includeDoc() throws Exception { @Test public void testGetDocumentParentsList_includeDoc_testProvider() throws Exception { - IDocParentProviderRole testProviderMock = createDefaultMock( - IDocParentProviderRole.class); + IDocParentProviderRole testProviderMock = createDefaultMock(IDocParentProviderRole.class); docParentsLister.docParentProviderMap.put("TestProvider", testProviderMock); DocumentReference docRef = new DocumentReference(context.getDatabase(), "mySpace", "myDoc"); @@ -182,16 +179,16 @@ public void testGetDocumentParentsList_includeDoc_testProvider() throws Exceptio DocumentReference testProviderParentRef2 = new DocumentReference(context.getDatabase(), "MySpaceTest", "TestProviderDoc2"); XWikiDocument testProviderParentDoc = new XWikiDocument(testProviderParentRef); - expect(xwiki.getDocument(eq(testProviderParentRef), same(context))).andReturn( - testProviderParentDoc).once(); + expect(xwiki.getDocument(eq(testProviderParentRef), same(context))) + .andReturn(testProviderParentDoc).once(); expect(xwiki.exists(eq(testProviderParentRef), same(context))).andReturn(false).anyTimes(); - expect(testProviderMock.getDocumentParentsList(eq(parentRef2))).andReturn(Arrays.asList( - testProviderParentRef, testProviderParentRef2)).once(); + expect(testProviderMock.getDocumentParentsList(eq(parentRef2))) + .andReturn(Arrays.asList(testProviderParentRef, testProviderParentRef2)).once(); expectParentPageType(testProviderParentRef, true); expectParentPageType(testProviderParentRef2, true); - expect(testProviderMock.getDocumentParentsList(eq(testProviderParentRef))).andReturn( - Collections.emptyList()).once(); + expect(testProviderMock.getDocumentParentsList(eq(testProviderParentRef))) + .andReturn(Collections.emptyList()).once(); List docParentsList = Arrays.asList(docRef, parentRef1, parentRef2, testProviderParentRef); @@ -217,8 +214,7 @@ public void testGetDocumentParentsList_includeDoc_notexist() throws Exception { @Test public void testGetDocumentParentsList_includeDoc_notexist_testProvider() throws Exception { - IDocParentProviderRole testProviderMock = createDefaultMock( - IDocParentProviderRole.class); + IDocParentProviderRole testProviderMock = createDefaultMock(IDocParentProviderRole.class); docParentsLister.docParentProviderMap.put("TestProvider", testProviderMock); DocumentReference docRef = new DocumentReference(context.getDatabase(), "mySpace", "myDoc"); @@ -229,15 +225,15 @@ public void testGetDocumentParentsList_includeDoc_notexist_testProvider() throws DocumentReference testProviderParentRef = new DocumentReference(context.getDatabase(), "MySpaceTest", "TestProviderDoc"); XWikiDocument testProviderParentDoc = new XWikiDocument(testProviderParentRef); - expect(xwiki.getDocument(eq(testProviderParentRef), same(context))).andReturn( - testProviderParentDoc).once(); + expect(xwiki.getDocument(eq(testProviderParentRef), same(context))) + .andReturn(testProviderParentDoc).once(); expect(xwiki.exists(eq(testProviderParentRef), same(context))).andReturn(false).anyTimes(); - expect(testProviderMock.getDocumentParentsList(eq(docRef))).andReturn(Arrays.asList( - testProviderParentRef)).once(); + expect(testProviderMock.getDocumentParentsList(eq(docRef))) + .andReturn(Arrays.asList(testProviderParentRef)).once(); expectParentPageType(testProviderParentRef, true); - expect(testProviderMock.getDocumentParentsList(eq(testProviderParentRef))).andReturn( - Collections.emptyList()).once(); + expect(testProviderMock.getDocumentParentsList(eq(testProviderParentRef))) + .andReturn(Collections.emptyList()).once(); List docParentsList = Arrays.asList(docRef, testProviderParentRef); replayDefault(); @@ -247,8 +243,7 @@ public void testGetDocumentParentsList_includeDoc_notexist_testProvider() throws @Test public void testGetDocumentParentsList_notParentPageType() throws Exception { - IDocParentProviderRole testProviderMock = createDefaultMock( - IDocParentProviderRole.class); + IDocParentProviderRole testProviderMock = createDefaultMock(IDocParentProviderRole.class); docParentsLister.docParentProviderMap.put("TestProvider", testProviderMock); DocumentReference docRef = new DocumentReference(context.getDatabase(), "mySpace", "myDoc"); @@ -259,8 +254,8 @@ public void testGetDocumentParentsList_notParentPageType() throws Exception { DocumentReference testProviderParentRef = new DocumentReference(context.getDatabase(), "MySpaceTest", "TestProviderDoc"); - expect(testProviderMock.getDocumentParentsList(eq(docRef))).andReturn(Arrays.asList( - testProviderParentRef)).once(); + expect(testProviderMock.getDocumentParentsList(eq(docRef))) + .andReturn(Arrays.asList(testProviderParentRef)).once(); expectParentPageType(testProviderParentRef, false); List docParentsList = Arrays.asList(docRef); @@ -271,8 +266,7 @@ public void testGetDocumentParentsList_notParentPageType() throws Exception { @Test public void testGetDocumentParentsList_includeDoc_testProvider_recursive() throws Exception { - IDocParentProviderRole testProviderMock = createDefaultMock( - IDocParentProviderRole.class); + IDocParentProviderRole testProviderMock = createDefaultMock(IDocParentProviderRole.class); docParentsLister.docParentProviderMap.put("TestProvider", testProviderMock); DocumentReference docRef = new DocumentReference(context.getDatabase(), "mySpace", "myDoc"); @@ -282,13 +276,13 @@ public void testGetDocumentParentsList_includeDoc_testProvider_recursive() throw DocumentReference testProviderParentRef = new DocumentReference(context.getDatabase(), "MySpaceTest", "TestProviderDoc"); - expect(testProviderMock.getDocumentParentsList(eq(docRef))).andReturn(Arrays.asList( - testProviderParentRef)).once(); + expect(testProviderMock.getDocumentParentsList(eq(docRef))) + .andReturn(Arrays.asList(testProviderParentRef)).once(); expectParentPageType(testProviderParentRef, true); XWikiDocument testProviderParentDoc = new XWikiDocument(testProviderParentRef); testProviderParentDoc.setParentReference((EntityReference) docRef); - expect(xwiki.getDocument(eq(testProviderParentRef), same(context))).andReturn( - testProviderParentDoc).once(); + expect(xwiki.getDocument(eq(testProviderParentRef), same(context))) + .andReturn(testProviderParentDoc).once(); expect(xwiki.exists(eq(testProviderParentRef), same(context))).andReturn(true).anyTimes(); List docParentsList = Arrays.asList(docRef, testProviderParentRef); @@ -300,11 +294,11 @@ public void testGetDocumentParentsList_includeDoc_testProvider_recursive() throw private void expectParentPageType(DocumentReference docRef, boolean isParent) { PageTypeReference pageTypeRef = new PageTypeReference("pagetype-" + docRef, "", Collections.emptyList()); - expect(docParentsLister.pageTypeResolver.getPageTypeRefForDocWithDefault(eq(docRef))).andReturn( - pageTypeRef).once(); + expect(docParentsLister.pageTypeResolver.getPageTypeRefForDocWithDefault(eq(docRef))) + .andReturn(pageTypeRef).once(); IPageTypeConfig confMock = createDefaultMock(IPageTypeConfig.class); - expect(docParentsLister.pageTypeProvider.getPageTypeByReference(same(pageTypeRef))).andReturn( - confMock).once(); + expect(docParentsLister.pageTypeProvider.getPageTypeByReference(same(pageTypeRef))) + .andReturn(confMock).once(); expect(confMock.isUnconnectedParent()).andReturn(isParent).once(); } diff --git a/src/test/java/com/celements/parents/NavigationParentsTest.java b/src/test/java/com/celements/parents/NavigationParentsTest.java index d8b15252e..b282044bb 100644 --- a/src/test/java/com/celements/parents/NavigationParentsTest.java +++ b/src/test/java/com/celements/parents/NavigationParentsTest.java @@ -41,16 +41,16 @@ public void tearDown_NavigationParentsTest() { public void testGetDocumentParentsList() throws Exception { WikiReference wikiRef = new WikiReference("db"); DocumentReference docRef = new DocumentReference("myDoc", new SpaceReference("space", wikiRef)); - DocumentReference parentLocal = new DocumentReference("parent", new SpaceReference( - "parentSpace", wikiRef)); + DocumentReference parentLocal = new DocumentReference("parent", + new SpaceReference("parentSpace", wikiRef)); WikiReference centralWikiRef = new WikiReference("celements2web"); - DocumentReference parentCentral = new DocumentReference("parent", new SpaceReference( - "parentSpace", centralWikiRef)); + DocumentReference parentCentral = new DocumentReference("parent", + new SpaceReference("parentSpace", centralWikiRef)); - expect(navParents.navCache.getCachedDocRefs(eq(wikiRef), eq("space"))).andReturn( - ImmutableSet.of(parentLocal)).once(); - expect(navParents.navCache.getCachedDocRefs(eq(centralWikiRef), eq("space"))).andReturn( - ImmutableSet.of(parentCentral)).once(); + expect(navParents.navCache.getCachedDocRefs(eq(wikiRef), eq("space"))) + .andReturn(ImmutableSet.of(parentLocal)).once(); + expect(navParents.navCache.getCachedDocRefs(eq(centralWikiRef), eq("space"))) + .andReturn(ImmutableSet.of(parentCentral)).once(); List docParentsList = Arrays.asList(parentLocal, parentCentral); replayDefault(); diff --git a/src/test/java/com/celements/rendering/RenderCommandTest.java b/src/test/java/com/celements/rendering/RenderCommandTest.java index 54e4767f8..4c1495173 100644 --- a/src/test/java/com/celements/rendering/RenderCommandTest.java +++ b/src/test/java/com/celements/rendering/RenderCommandTest.java @@ -76,8 +76,8 @@ public void setUp_RenderCommandTest() throws Exception { cellDockApiMock = createDefaultMock(Document.class); velocityContext.put("celldoc", cellDockApiMock); context.put("vcontext", velocityContext); - currentDoc = new XWikiDocument(new DocumentReference(context.getDatabase(), "Content", - "MyPage")); + currentDoc = new XWikiDocument( + new DocumentReference(context.getDatabase(), "Content", "MyPage")); context.setDoc(currentDoc); renderCmd = new RenderCommand(); mockPageTypeService = registerComponentMock(IPageTypeRole.class); @@ -95,12 +95,13 @@ public void testGetRenderingEngine() throws Exception { expect(xwiki.Param(isA(String.class), eq("0"))).andReturn("0").anyTimes(); expect(xwiki.Param(isA(String.class), eq("1"))).andReturn("1").anyTimes(); expect(xwiki.Param(eq("xwiki.render.cache.capacity"))).andReturn(null).anyTimes(); - expect(xwiki.getXWikiPreference(eq("macros_languages"), eq("velocity,groovy"), same( - context))).andReturn("velocity,groovy").anyTimes(); - expect(xwiki.getXWikiPreference(eq("macros_velocity"), eq("XWiki.VelocityMacros"), same( - context))).andReturn("XWiki.VelocityMacros").anyTimes(); - expect(xwiki.getXWikiPreference(eq("macros_groovy"), eq("XWiki.GroovyMacros"), same( - context))).andReturn("XWiki.GroovyMacros").anyTimes(); + expect(xwiki.getXWikiPreference(eq("macros_languages"), eq("velocity,groovy"), same(context))) + .andReturn("velocity,groovy").anyTimes(); + expect( + xwiki.getXWikiPreference(eq("macros_velocity"), eq("XWiki.VelocityMacros"), same(context))) + .andReturn("XWiki.VelocityMacros").anyTimes(); + expect(xwiki.getXWikiPreference(eq("macros_groovy"), eq("XWiki.GroovyMacros"), same(context))) + .andReturn("XWiki.GroovyMacros").anyTimes(); expect(xwiki.getMacroList(same(context))).andReturn("").anyTimes(); CacheFactory cacheFactory = createMock(CacheFactory.class); expect(xwiki.getCacheFactory()).andReturn(cacheFactory); @@ -112,10 +113,10 @@ public void testGetRenderingEngine() throws Exception { assertSame("Expecting singleton.", renderCmd.getRenderingEngine(), renderCmd.getRenderingEngine()); List rendererNames = renderCmd.getRenderingEngine().getRendererNames(); - assertTrue("expecting that velocity renderer is activated by default", rendererNames.contains( - "velocity")); - assertTrue("expecting that groovy renderer is activated by default", rendererNames.contains( - "groovy")); + assertTrue("expecting that velocity renderer is activated by default", + rendererNames.contains("velocity")); + assertTrue("expecting that groovy renderer is activated by default", + rendererNames.contains("groovy")); assertEquals("expecting only groovy and velocity renderer by default", 2, rendererNames.size()); verifyDefault(); } @@ -133,8 +134,8 @@ public void testSetRenderingEngine() throws Exception { @Test public void testGetRenderTemplatePath_NoCellType() throws Exception { String cellDocFN = "xwikidb:MyLayout.Cell12"; - XWikiDocument cellDoc = new XWikiDocument(new DocumentReference( - context.getDatabase(), "MyLayout", "Cell12")); + XWikiDocument cellDoc = new XWikiDocument( + new DocumentReference(context.getDatabase(), "MyLayout", "Cell12")); expect(mockPageTypeResolver.resolvePageTypeReference(same(cellDoc))) .andReturn(Optional.absent()); @@ -151,8 +152,8 @@ public void testGetRenderTemplatePath_NoViewTemplate_empty() throws Exception { expect(mockPageTypeService.getPageTypeConfigForPageTypeRef(same(ptRefMock))).andReturn(ptMock); expect(ptMock.getRenderTemplateForRenderMode(eq("view"))).andReturn("").anyTimes(); expect(ptMock.getName()).andReturn("CelementsCell").anyTimes(); - XWikiDocument cellDoc = new XWikiDocument(new DocumentReference( - context.getDatabase(), "MyLayout", "Cell12")); + XWikiDocument cellDoc = new XWikiDocument( + new DocumentReference(context.getDatabase(), "MyLayout", "Cell12")); expect(mockPageTypeResolver.resolvePageTypeReference(same(cellDoc))) .andReturn(Optional.of(ptRefMock)); replayDefault(); @@ -168,8 +169,8 @@ public void testGetRenderTemplatePath_NoViewTemplate_null() throws Exception { expect(mockPageTypeService.getPageTypeConfigForPageTypeRef(same(ptRefMock))).andReturn(ptMock); expect(ptMock.getRenderTemplateForRenderMode(eq("view"))).andReturn(null).anyTimes(); expect(ptMock.getName()).andReturn("CelementsCell").anyTimes(); - XWikiDocument cellDoc = new XWikiDocument(new DocumentReference( - context.getDatabase(), "MyLayout", "Cell12")); + XWikiDocument cellDoc = new XWikiDocument( + new DocumentReference(context.getDatabase(), "MyLayout", "Cell12")); expect(mockPageTypeResolver.resolvePageTypeReference(same(cellDoc))) .andReturn(Optional.of(ptRefMock)); replayDefault(); @@ -179,8 +180,8 @@ public void testGetRenderTemplatePath_NoViewTemplate_null() throws Exception { @Test public void testGetTranslatedContent() throws Exception { - XWikiDocument templateDoc = new XWikiDocument(new DocumentReference( - context.getDatabase(), "MySpace", "myDoc")); + XWikiDocument templateDoc = new XWikiDocument( + new DocumentReference(context.getDatabase(), "MySpace", "myDoc")); templateDoc.setDefaultLanguage("de"); String expectedContent = "do something and velocity macro...\n"; String transContent = "{pre}\n" + expectedContent + "{/pre}"; @@ -194,14 +195,14 @@ public void testGetTranslatedContent() throws Exception { @Test public void testGetTranslatedContent_wikiRenderer() throws Exception { - XWikiDocument templateDoc = new XWikiDocument(new DocumentReference( - context.getDatabase(), "MySpace", "myDoc")); + XWikiDocument templateDoc = new XWikiDocument( + new DocumentReference(context.getDatabase(), "MySpace", "myDoc")); templateDoc.setDefaultLanguage("fr"); String expectedContent = "do something and velocity macro...\n"; String transContent = "{pre}\n" + expectedContent + "{/pre}"; templateDoc.setContent(transContent); - expect(renderingEngineMock.getRendererNames()).andReturn(Arrays.asList("velocity", "groovy", - "xwiki")); + expect(renderingEngineMock.getRendererNames()) + .andReturn(Arrays.asList("velocity", "groovy", "xwiki")); replayDefault(); assertEquals("expected removing pre-tags", "{pre}\n" + expectedContent + "{/pre}", renderCmd.getTranslatedContent(templateDoc, "fr")); @@ -214,17 +215,16 @@ public void test_renderCelementsDocument_elemDocRef_renderMode() throws Exceptio DocumentReference myDocRef = new DocumentReference(context.getDatabase(), "Content", "myPage"); XWikiDocument myDoc = new XWikiDocument(myDocRef); myDoc.setDefaultLanguage("de"); - expect(mockPageTypeResolver.resolvePageTypeReference(same(myDoc))) - .andReturn(Optional.absent()); + expect(mockPageTypeResolver.resolvePageTypeReference(same(myDoc))).andReturn(Optional.absent()); expect(modelAccessMock.getOrCreateDocument(eq(myDocRef))).andReturn(myDoc); expect(modelAccessMock.getDocumentOpt(eq(myDocRef))).andReturn(java.util.Optional.of(myDoc)); String expectedContent = "expected Content $doc.fullName"; myDoc.setContent(expectedContent); - expect(renderingEngineMock.renderText(eq(expectedContent), same(myDoc), same(currentDoc), same( - context))).andReturn(expectedRenderedContent); + expect(renderingEngineMock.renderText(eq(expectedContent), same(myDoc), same(currentDoc), + same(context))).andReturn(expectedRenderedContent); expect(renderingEngineMock.getRendererNames()).andReturn(Arrays.asList("velocity", "groovy")); - expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq( - "xwikidb:Content.myPage"), same(context))).andReturn(true).once(); + expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), + eq("xwikidb:Content.myPage"), same(context))).andReturn(true).once(); replayDefault(); assertEquals(expectedRenderedContent, renderCmd.renderCelementsDocument(myDocRef, "view")); verifyDefault(); @@ -236,21 +236,20 @@ public void test_renderCelementsDocument_celldoc_preserved() throws Exception { DocumentReference myDocRef = new DocumentReference(context.getDatabase(), "Content", "myPage"); XWikiDocument myDoc = new XWikiDocument(myDocRef); myDoc.setDefaultLanguage("de"); - expect(mockPageTypeResolver.resolvePageTypeReference(same(myDoc))) - .andReturn(Optional.absent()); + expect(mockPageTypeResolver.resolvePageTypeReference(same(myDoc))).andReturn(Optional.absent()); expect(modelAccessMock.getOrCreateDocument(eq(myDocRef))).andReturn(myDoc); expect(modelAccessMock.getDocumentOpt(eq(myDocRef))).andReturn(java.util.Optional.of(myDoc)); String expectedContent = "expected Content $doc.fullName"; myDoc.setContent(expectedContent); - expect(renderingEngineMock.renderText(eq(expectedContent), same(myDoc), same(currentDoc), same( - context))).andAnswer(() -> { + expect(renderingEngineMock.renderText(eq(expectedContent), same(myDoc), same(currentDoc), + same(context))).andAnswer(() -> { assertEquals("expecting celldoc to be set to the rendered cell document.", myDocRef, ((Document) velocityContext.get("celldoc")).getDocumentReference()); return expectedRenderedContent; }); expect(renderingEngineMock.getRendererNames()).andReturn(Arrays.asList("velocity", "groovy")); - expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq( - "xwikidb:Content.myPage"), same(context))).andReturn(true).once(); + expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), + eq("xwikidb:Content.myPage"), same(context))).andReturn(true).once(); replayDefault(); assertEquals(expectedRenderedContent, renderCmd.renderCelementsDocument(myDocRef, "view")); verifyDefault(); @@ -268,11 +267,11 @@ public void test_renderCelementsDocument_noCellType_default() throws Exception { expect(modelAccessMock.getDocumentOpt(eq(myDocRef))).andReturn(java.util.Optional.of(myDoc)); String expectedContent = "expected Content $doc.fullName"; myDoc.setContent(expectedContent); - expect(renderingEngineMock.renderText(eq(expectedContent), same(myDoc), same(currentDoc), same( - context))).andReturn(expectedRenderedContent); + expect(renderingEngineMock.renderText(eq(expectedContent), same(myDoc), same(currentDoc), + same(context))).andReturn(expectedRenderedContent); expect(renderingEngineMock.getRendererNames()).andReturn(Arrays.asList("velocity", "groovy")); - expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq( - "xwikidb:Content.myPage"), same(context))).andReturn(true).once(); + expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), + eq("xwikidb:Content.myPage"), same(context))).andReturn(true).once(); replayDefault(); assertEquals(expectedRenderedContent, renderCmd.renderCelementsDocument(myDoc, "view")); verifyDefault(); @@ -289,11 +288,11 @@ public void test_renderCelementsDocument_noCellType_setDefault_null() throws Exc expect(modelAccessMock.getDocumentOpt(eq(myDocRef))).andReturn(java.util.Optional.of(myDoc)); String expectedContent = "expected Content $doc.fullName"; myDoc.setContent(expectedContent); - expect(renderingEngineMock.renderText(eq(expectedContent), same(myDoc), same(currentDoc), same( - context))).andReturn(expectedRenderedContent); + expect(renderingEngineMock.renderText(eq(expectedContent), same(myDoc), same(currentDoc), + same(context))).andReturn(expectedRenderedContent); expect(renderingEngineMock.getRendererNames()).andReturn(Arrays.asList("velocity", "groovy")); - expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq( - "xwikidb:Content.myPage"), same(context))).andReturn(true).once(); + expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), + eq("xwikidb:Content.myPage"), same(context))).andReturn(true).once(); replayDefault(); assertEquals(expectedRenderedContent, renderCmd.renderCelementsDocument(myDoc, "view")); verifyDefault(); @@ -310,12 +309,12 @@ public void test_renderCelementsDocument_access_denied() throws Exception { expect(modelAccessMock.getOrCreateDocument(eq(myDocRef))).andReturn(myDoc).anyTimes(); String expectedContent = "expected Content $doc.fullName"; myDoc.setContent(expectedContent); - expect(renderingEngineMock.renderText(eq(expectedContent), same(myDoc), same(currentDoc), same( - context))).andReturn("Topic Content.MyPage does not exist").anyTimes(); - expect(renderingEngineMock.getRendererNames()).andReturn(Arrays.asList("velocity", - "groovy")).anyTimes(); - expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq( - "xwikidb:Content.myPage"), same(context))).andReturn(false).once(); + expect(renderingEngineMock.renderText(eq(expectedContent), same(myDoc), same(currentDoc), + same(context))).andReturn("Topic Content.MyPage does not exist").anyTimes(); + expect(renderingEngineMock.getRendererNames()).andReturn(Arrays.asList("velocity", "groovy")) + .anyTimes(); + expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), + eq("xwikidb:Content.myPage"), same(context))).andReturn(false).once(); replayDefault(); assertEquals("expecting empty because no access rights to template", "", renderCmd.renderCelementsDocument(myDoc, "de", "view")); @@ -337,17 +336,17 @@ public void test_renderCelementsDocument_preserveVelocityContext() throws Except String expectedRenderedContent = "expected rendered content of Content.MyPage"; expect(renderingEngineMock.renderText(eq(expectedContent), same(myDoc), same(currentDoc), notSameVcontext(context))).andReturn(expectedRenderedContent); - expect(renderingEngineMock.getRendererNames()).andReturn(Arrays.asList("velocity", - "groovy")).anyTimes(); - expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq( - "xwikidb:Content.myPage"), same(context))).andReturn(true).once(); + expect(renderingEngineMock.getRendererNames()).andReturn(Arrays.asList("velocity", "groovy")) + .anyTimes(); + expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), + eq("xwikidb:Content.myPage"), same(context))).andReturn(true).once(); VelocityContext expectedVContext = (VelocityContext) context.get("vcontext"); replayDefault(); assertNotNull(expectedVContext); assertNotNull(getExecutionContext().getProperty("velocityContext")); assertSame(expectedVContext, getExecutionContext().getProperty("velocityContext")); - assertEquals(expectedRenderedContent, renderCmd.renderCelementsDocumentPreserveVelocityContext( - myDocRef, "de", "view")); + assertEquals(expectedRenderedContent, + renderCmd.renderCelementsDocumentPreserveVelocityContext(myDocRef, "de", "view")); assertSame(expectedVContext, context.get("vcontext")); assertSame(expectedVContext, getExecutionContext().getProperty("velocityContext")); verifyDefault(); @@ -387,8 +386,8 @@ public void test_renderCelementsCell_noCellType_setDefault_RichText_deprecated() expect(renderingEngineMock.renderText(eq(expectedContent), same(templDoc), same(currentDoc), same(context))).andReturn(expectedRenderedContent); expect(renderingEngineMock.getRendererNames()).andReturn(Arrays.asList("velocity", "groovy")); - expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq( - "xwikidb:MyLayout.Cell15"), same(context))).andReturn(true).once(); + expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), + eq("xwikidb:MyLayout.Cell15"), same(context))).andReturn(true).once(); replayDefault(); assertEquals(expectedRenderedContent, renderCmd.renderCelementsCell(elementFullName)); verifyDefault(); @@ -410,8 +409,8 @@ public void test_renderCelementsCell_noCellType_setDefault_RichText() throws Exc expect(modelAccessMock.getOrCreateDocument(eq(elementDocRef))).andReturn(cellDoc); DocumentReference renderTemplateDocRef = new DocumentReference("celements2web", "Templates", "CellTypeView"); - expect(ptMock.getRenderTemplateForRenderMode(eq("view"))).andReturn( - "celements2web:Templates.CellTypeView"); + expect(ptMock.getRenderTemplateForRenderMode(eq("view"))) + .andReturn("celements2web:Templates.CellTypeView"); XWikiDocument templDoc = new XWikiDocument(renderTemplateDocRef); templDoc.setDefaultLanguage("de"); expect(modelAccessMock.getDocumentOpt(eq(renderTemplateDocRef))) @@ -423,8 +422,8 @@ public void test_renderCelementsCell_noCellType_setDefault_RichText() throws Exc expect(renderingEngineMock.renderText(eq(expectedContent), same(templDoc), same(currentDoc), same(context))).andReturn(expectedRenderedContent); expect(renderingEngineMock.getRendererNames()).andReturn(Arrays.asList("velocity", "groovy")); - expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq( - "xwikidb:MyLayout.Cell15"), same(context))).andReturn(true).once(); + expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), + eq("xwikidb:MyLayout.Cell15"), same(context))).andReturn(true).once(); replayDefault(); assertEquals(expectedRenderedContent, renderCmd.renderCelementsCell(elementDocRef)); verifyDefault(); @@ -446,8 +445,8 @@ public void test_renderCelementsCell_databaseDoc_deprecated() throws XWikiExcept String renderTemplateFN = "celements2web:Templates.CellTypeView"; DocumentReference renderTemplateDocRef = new DocumentReference("celements2web", "Templates", "CellTypeView"); - expect(ptMock.getRenderTemplateForRenderMode(eq("view"))).andReturn( - renderTemplateFN).anyTimes(); + expect(ptMock.getRenderTemplateForRenderMode(eq("view"))).andReturn(renderTemplateFN) + .anyTimes(); XWikiDocument templDoc = new XWikiDocument(renderTemplateDocRef); templDoc.setDefaultLanguage("de"); expect(modelAccessMock.getDocumentOpt(eq(renderTemplateDocRef))) @@ -459,8 +458,8 @@ public void test_renderCelementsCell_databaseDoc_deprecated() throws XWikiExcept expect(renderingEngineMock.renderText(eq(expectedContent), same(templDoc), same(currentDoc), same(context))).andReturn(expectedRenderedContent); expect(renderingEngineMock.getRendererNames()).andReturn(Arrays.asList("velocity", "groovy")); - expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq( - "xwikidb:MyLayout.Cell15"), same(context))).andReturn(true).once(); + expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), + eq("xwikidb:MyLayout.Cell15"), same(context))).andReturn(true).once(); replayDefault(); assertEquals(expectedRenderedContent, renderCmd.renderCelementsCell(elementFullName)); verifyDefault(); @@ -480,8 +479,8 @@ public void test_renderCelementsCell_databaseDoc() throws XWikiException { String renderTemplateFN = "celements2web:Templates.CellTypeView"; DocumentReference renderTemplateDocRef = new DocumentReference("celements2web", "Templates", "CellTypeView"); - expect(ptMock.getRenderTemplateForRenderMode(eq("view"))).andReturn( - renderTemplateFN).anyTimes(); + expect(ptMock.getRenderTemplateForRenderMode(eq("view"))).andReturn(renderTemplateFN) + .anyTimes(); XWikiDocument templDoc = new XWikiDocument(renderTemplateDocRef); templDoc.setDefaultLanguage("de"); expect(modelAccessMock.getDocumentOpt(eq(renderTemplateDocRef))) @@ -493,8 +492,8 @@ public void test_renderCelementsCell_databaseDoc() throws XWikiException { expect(renderingEngineMock.renderText(eq(expectedContent), same(templDoc), same(currentDoc), same(context))).andReturn(expectedRenderedContent); expect(renderingEngineMock.getRendererNames()).andReturn(Arrays.asList("velocity", "groovy")); - expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq( - "xwikidb:MyLayout.Cell15"), same(context))).andReturn(true).once(); + expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), + eq("xwikidb:MyLayout.Cell15"), same(context))).andReturn(true).once(); replayDefault(); assertEquals(expectedRenderedContent, renderCmd.renderCelementsCell(elementDocRef)); verifyDefault(); @@ -519,11 +518,11 @@ public void test_renderCelementsCell_templateDoc_deprecated() throws Exception { expect(mockPageTypeService.getPageTypeConfigForPageTypeRef(same(ptRefMock))).andReturn(ptMock); expect(modelAccessMock.getOrCreateDocument(eq(elementDocRef))).andReturn(cellDoc); String renderTemplatePath = ":Templates.CellTypeView"; - expect(ptMock.getRenderTemplateForRenderMode(eq("view"))).andReturn( - renderTemplatePath).anyTimes(); + expect(ptMock.getRenderTemplateForRenderMode(eq("view"))).andReturn(renderTemplatePath) + .anyTimes(); String templatePath_lang = "celTemplates/CellTypeView_de.vm"; - expect(xwiki.getResourceContent(eq("/templates/" + templatePath_lang))).andThrow( - new IOException()); + expect(xwiki.getResourceContent(eq("/templates/" + templatePath_lang))) + .andThrow(new IOException()); String templatePath = "celTemplates/CellTypeView.vm"; expect(ptMock.getName()).andReturn("CelementsContentPageCell").anyTimes(); String expectedContent = "Expected Template Content Content.MyPage"; @@ -531,8 +530,8 @@ public void test_renderCelementsCell_templateDoc_deprecated() throws Exception { String expectedRenderedContent = "Expected Template Content Content.MyPage"; expect(renderingEngineMock.renderText(eq(expectedContent), same(currentDoc), same(currentDoc), same(context))).andReturn(expectedRenderedContent); - expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq( - "xwikidb:MyLayout.Cell15"), same(context))).andReturn(true).once(); + expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), + eq("xwikidb:MyLayout.Cell15"), same(context))).andReturn(true).once(); replayDefault(); assertEquals(expectedRenderedContent, renderCmd.renderCelementsCell(elementFullName)); verifyDefault(); @@ -555,11 +554,11 @@ public void test_renderCelementsCell_templateDoc() throws Exception { expect(mockPageTypeService.getPageTypeConfigForPageTypeRef(same(ptRefMock))).andReturn(ptMock); expect(modelAccessMock.getOrCreateDocument(eq(elementDocRef))).andReturn(cellDoc); String renderTemplatePath = ":Templates.CellTypeView"; - expect(ptMock.getRenderTemplateForRenderMode(eq("view"))).andReturn( - renderTemplatePath).anyTimes(); + expect(ptMock.getRenderTemplateForRenderMode(eq("view"))).andReturn(renderTemplatePath) + .anyTimes(); String templatePath_lang = "celTemplates/CellTypeView_de.vm"; - expect(xwiki.getResourceContent(eq("/templates/" + templatePath_lang))).andThrow( - new IOException()); + expect(xwiki.getResourceContent(eq("/templates/" + templatePath_lang))) + .andThrow(new IOException()); String templatePath = "celTemplates/CellTypeView.vm"; expect(ptMock.getName()).andReturn("CelementsContentPageCell").anyTimes(); String expectedContent = "Expected Template Content Content.MyPage"; @@ -567,8 +566,8 @@ public void test_renderCelementsCell_templateDoc() throws Exception { String expectedRenderedContent = "Expected Template Content Content.MyPage"; expect(renderingEngineMock.renderText(eq(expectedContent), same(currentDoc), same(currentDoc), same(context))).andReturn(expectedRenderedContent); - expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq( - "xwikidb:MyLayout.Cell15"), same(context))).andReturn(true).once(); + expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), + eq("xwikidb:MyLayout.Cell15"), same(context))).andReturn(true).once(); replayDefault(); assertEquals(expectedRenderedContent, renderCmd.renderCelementsCell(elementDocRef)); verifyDefault(); @@ -591,18 +590,18 @@ public void test_renderCelementsCell_templateDoc_lang() throws Exception { expect(mockPageTypeService.getPageTypeConfigForPageTypeRef(same(ptRefMock))).andReturn(ptMock); expect(modelAccessMock.getOrCreateDocument(eq(elementDocRef))).andReturn(cellDoc); String renderTemplatePath = ":Templates.CellTypeView"; - expect(ptMock.getRenderTemplateForRenderMode(eq("view"))).andReturn( - renderTemplatePath).anyTimes(); + expect(ptMock.getRenderTemplateForRenderMode(eq("view"))).andReturn(renderTemplatePath) + .anyTimes(); String templatePath_lang = "celTemplates/CellTypeView_de.vm"; expect(ptMock.getName()).andReturn("CelementsContentPageCell").anyTimes(); String expectedContent = "Expected Template Content Content.MyPage"; - expect(xwiki.getResourceContent(eq("/templates/" + templatePath_lang))).andReturn( - expectedContent); + expect(xwiki.getResourceContent(eq("/templates/" + templatePath_lang))) + .andReturn(expectedContent); String expectedRenderedContent = "Expected Template Content Content.MyPage"; expect(renderingEngineMock.renderText(eq(expectedContent), same(currentDoc), same(currentDoc), same(context))).andReturn(expectedRenderedContent); - expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq( - "xwikidb:MyLayout.Cell15"), same(context))).andReturn(true).once(); + expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), + eq("xwikidb:MyLayout.Cell15"), same(context))).andReturn(true).once(); replayDefault(); assertEquals(expectedRenderedContent, renderCmd.renderCelementsCell(elementDocRef)); verifyDefault(); @@ -622,17 +621,17 @@ public void test_renderCelementsCell_templateDoc_ioException_deprecated() throws expect(mockPageTypeService.getPageTypeConfigForPageTypeRef(same(ptRefMock))).andReturn(ptMock); expect(modelAccessMock.getOrCreateDocument(eq(elementDocRef))).andReturn(cellDoc); String renderTemplatePath = ":Templates.CellTypeView"; - expect(ptMock.getRenderTemplateForRenderMode(eq("view"))).andReturn( - renderTemplatePath).anyTimes(); + expect(ptMock.getRenderTemplateForRenderMode(eq("view"))).andReturn(renderTemplatePath) + .anyTimes(); String templatePath_lang = "celTemplates/CellTypeView_de.vm"; - expect(xwiki.getResourceContent(eq("/templates/" + templatePath_lang))).andThrow( - new IOException()); + expect(xwiki.getResourceContent(eq("/templates/" + templatePath_lang))) + .andThrow(new IOException()); String templatePath = "celTemplates/CellTypeView.vm"; expect(ptMock.getName()).andReturn("CelementsContentPageCell").anyTimes(); - expect(xwiki.getResourceContent(eq("/templates/" + templatePath))).andThrow( - new IOException()).anyTimes(); - expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq( - "xwikidb:MyLayout.Cell15"), same(context))).andReturn(true).once(); + expect(xwiki.getResourceContent(eq("/templates/" + templatePath))).andThrow(new IOException()) + .anyTimes(); + expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), + eq("xwikidb:MyLayout.Cell15"), same(context))).andReturn(true).once(); replayDefault(); assertEquals("", renderCmd.renderCelementsCell(elementFullName)); verifyDefault(); @@ -650,17 +649,17 @@ public void test_renderCelementsCell_templateDoc_ioException() throws Exception expect(mockPageTypeService.getPageTypeConfigForPageTypeRef(same(ptRefMock))).andReturn(ptMock); expect(modelAccessMock.getOrCreateDocument(eq(elementDocRef))).andReturn(cellDoc); String renderTemplatePath = ":Templates.CellTypeView"; - expect(ptMock.getRenderTemplateForRenderMode(eq("view"))).andReturn( - renderTemplatePath).anyTimes(); + expect(ptMock.getRenderTemplateForRenderMode(eq("view"))).andReturn(renderTemplatePath) + .anyTimes(); String templatePath_lang = "celTemplates/CellTypeView_de.vm"; - expect(xwiki.getResourceContent(eq("/templates/" + templatePath_lang))).andThrow( - new IOException()); + expect(xwiki.getResourceContent(eq("/templates/" + templatePath_lang))) + .andThrow(new IOException()); String templatePath = "celTemplates/CellTypeView.vm"; expect(ptMock.getName()).andReturn("CelementsContentPageCell").anyTimes(); - expect(xwiki.getResourceContent(eq("/templates/" + templatePath))).andThrow( - new IOException()).anyTimes(); - expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq( - "xwikidb:MyLayout.Cell15"), same(context))).andReturn(true).once(); + expect(xwiki.getResourceContent(eq("/templates/" + templatePath))).andThrow(new IOException()) + .anyTimes(); + expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), + eq("xwikidb:MyLayout.Cell15"), same(context))).andReturn(true).once(); replayDefault(); assertEquals("", renderCmd.renderCelementsCell(elementDocRef)); verifyDefault(); @@ -668,10 +667,10 @@ public void test_renderCelementsCell_templateDoc_ioException() throws Exception @Test public void testGetTemplatePathOnDisk() { - assertEquals("/templates/celTemplates/CellPageContentView.vm", renderCmd.getTemplatePathOnDisk( - ":Templates.CellPageContentView")); - assertEquals("/templates/celTemplates/CellPageContentView.vm", renderCmd.getTemplatePathOnDisk( - ":CellPageContentView")); + assertEquals("/templates/celTemplates/CellPageContentView.vm", + renderCmd.getTemplatePathOnDisk(":Templates.CellPageContentView")); + assertEquals("/templates/celTemplates/CellPageContentView.vm", + renderCmd.getTemplatePathOnDisk(":CellPageContentView")); } @Test @@ -679,8 +678,8 @@ public void test_renderTemplatePath_null_lang() throws Exception { String renderTemplatePath = ":Templates.CellTypeView"; String templatePath = "celTemplates/CellTypeView.vm"; String expectedContent = "Expected Template Content Content.MyPage"; - expect(xwiki.getResourceContent(eq("/templates/" + templatePath))).andReturn( - expectedContent).once(); + expect(xwiki.getResourceContent(eq("/templates/" + templatePath))).andReturn(expectedContent) + .once(); String expectedRenderedContent = "Expected Template Content Content.MyPage"; expect(renderingEngineMock.renderText(eq(expectedContent), same(currentDoc), same(currentDoc), same(context))).andReturn(expectedRenderedContent); @@ -694,14 +693,14 @@ public void test_renderTemplatePath_lang() throws Exception { String renderTemplatePath = ":Templates.CellTypeView"; String templatePath_lang = "celTemplates/CellTypeView_de.vm"; String expectedContent = "Expected Template Content Content.MyPage"; - expect(xwiki.getResourceContent(eq("/templates/" + templatePath_lang))).andReturn( - expectedContent).once(); + expect(xwiki.getResourceContent(eq("/templates/" + templatePath_lang))) + .andReturn(expectedContent).once(); String expectedRenderedContent = "Expected Template Content Content.MyPage"; expect(renderingEngineMock.renderText(eq(expectedContent), same(currentDoc), same(currentDoc), same(context))).andReturn(expectedRenderedContent); replayDefault(); - assertEquals(expectedRenderedContent, renderCmd.renderTemplatePath( - renderTemplatePath, "de", "")); + assertEquals(expectedRenderedContent, + renderCmd.renderTemplatePath(renderTemplatePath, "de", "")); verifyDefault(); } @@ -709,18 +708,18 @@ public void test_renderTemplatePath_lang() throws Exception { public void test_renderTemplatePath_langNotFound_deflang() throws Exception { String renderTemplatePath = ":Templates.CellTypeView"; String templatePath_lang = "celTemplates/CellTypeView_de.vm"; - expect(xwiki.getResourceContent(eq("/templates/" + templatePath_lang))).andThrow( - new IOException()).once(); + expect(xwiki.getResourceContent(eq("/templates/" + templatePath_lang))) + .andThrow(new IOException()).once(); String templatePath_deflang = "celTemplates/CellTypeView_en.vm"; String expectedContent = "Expected Template Content Content.MyPage"; - expect(xwiki.getResourceContent(eq("/templates/" + templatePath_deflang))).andReturn( - expectedContent).once(); + expect(xwiki.getResourceContent(eq("/templates/" + templatePath_deflang))) + .andReturn(expectedContent).once(); String expectedRenderedContent = "Expected Template Content Content.MyPage"; expect(renderingEngineMock.renderText(eq(expectedContent), same(currentDoc), same(currentDoc), same(context))).andReturn(expectedRenderedContent); replayDefault(); - assertEquals(expectedRenderedContent, renderCmd.renderTemplatePath(renderTemplatePath, "de", - "en")); + assertEquals(expectedRenderedContent, + renderCmd.renderTemplatePath(renderTemplatePath, "de", "en")); verifyDefault(); } @@ -728,21 +727,21 @@ public void test_renderTemplatePath_langNotFound_deflang() throws Exception { public void test_renderTemplatePath_langNotFound_deflangNotFound() throws Exception { String renderTemplatePath = ":Templates.CellTypeView"; String templatePath_lang = "celTemplates/CellTypeView_de.vm"; - expect(xwiki.getResourceContent(eq("/templates/" + templatePath_lang))).andThrow( - new IOException()).once(); + expect(xwiki.getResourceContent(eq("/templates/" + templatePath_lang))) + .andThrow(new IOException()).once(); String templatePath_deflang = "celTemplates/CellTypeView_en.vm"; - expect(xwiki.getResourceContent(eq("/templates/" + templatePath_deflang))).andThrow( - new IOException()).once(); + expect(xwiki.getResourceContent(eq("/templates/" + templatePath_deflang))) + .andThrow(new IOException()).once(); String templatePath = "celTemplates/CellTypeView.vm"; String expectedContent = "Expected Template Content Content.MyPage"; - expect(xwiki.getResourceContent(eq("/templates/" + templatePath))).andReturn( - expectedContent).once(); + expect(xwiki.getResourceContent(eq("/templates/" + templatePath))).andReturn(expectedContent) + .once(); String expectedRenderedContent = "Expected Template Content Content.MyPage"; expect(renderingEngineMock.renderText(eq(expectedContent), same(currentDoc), same(currentDoc), same(context))).andReturn(expectedRenderedContent); replayDefault(); - assertEquals(expectedRenderedContent, renderCmd.renderTemplatePath(renderTemplatePath, "de", - "en")); + assertEquals(expectedRenderedContent, + renderCmd.renderTemplatePath(renderTemplatePath, "de", "en")); verifyDefault(); } @@ -751,14 +750,14 @@ public void test_renderTemplatePath_langNotFound_deflangNotFound_defaultNotFound throws Exception { String renderTemplatePath = ":Templates.CellTypeView"; String templatePath_lang = "celTemplates/CellTypeView_de.vm"; - expect(xwiki.getResourceContent(eq("/templates/" + templatePath_lang))).andThrow( - new IOException()).once(); + expect(xwiki.getResourceContent(eq("/templates/" + templatePath_lang))) + .andThrow(new IOException()).once(); String templatePath_deflang = "celTemplates/CellTypeView_en.vm"; - expect(xwiki.getResourceContent(eq("/templates/" + templatePath_deflang))).andThrow( - new IOException()).once(); + expect(xwiki.getResourceContent(eq("/templates/" + templatePath_deflang))) + .andThrow(new IOException()).once(); String templatePath = "celTemplates/CellTypeView.vm"; - expect(xwiki.getResourceContent(eq("/templates/" + templatePath))).andThrow( - new IOException()).once(); + expect(xwiki.getResourceContent(eq("/templates/" + templatePath))).andThrow(new IOException()) + .once(); replayDefault(); assertEquals("", renderCmd.renderTemplatePath(renderTemplatePath, "de", "en")); verifyDefault(); @@ -773,18 +772,18 @@ public void test_renderTemplatePath_langNotFound_deflangNotFound_defaultNotFound public void test_renderTemplatePath_deflang_equals_lang_notFound() throws Exception { String renderTemplatePath = ":Templates.CellTypeView"; String templatePath_lang = "celTemplates/CellTypeView_en.vm"; - expect(xwiki.getResourceContent(eq("/templates/" + templatePath_lang))).andThrow( - new IOException()).once(); + expect(xwiki.getResourceContent(eq("/templates/" + templatePath_lang))) + .andThrow(new IOException()).once(); String expectedContent = "Expected Template Content Content.MyPage"; String templatePath = "celTemplates/CellTypeView.vm"; - expect(xwiki.getResourceContent(eq("/templates/" + templatePath))).andReturn( - expectedContent).once(); + expect(xwiki.getResourceContent(eq("/templates/" + templatePath))).andReturn(expectedContent) + .once(); String expectedRenderedContent = "Expected Template Content Content.MyPage"; expect(renderingEngineMock.renderText(eq(expectedContent), same(currentDoc), same(currentDoc), same(context))).andReturn(expectedRenderedContent); replayDefault(); - assertEquals(expectedRenderedContent, renderCmd.renderTemplatePath(renderTemplatePath, "en", - "en")); + assertEquals(expectedRenderedContent, + renderCmd.renderTemplatePath(renderTemplatePath, "en", "en")); verifyDefault(); } @@ -798,8 +797,8 @@ public void test_renderDocument() throws Exception { String contentEN = "english script $test"; cellDoc.setContent(contentEN); expect(renderingEngineMock.getRendererNames()).andReturn(Arrays.asList("velocity", "groovy")); - expect(renderingEngineMock.renderText(eq(contentEN), same(cellDoc), same(currentDoc), same( - context))).andReturn(expectedRenderedContent); + expect(renderingEngineMock.renderText(eq(contentEN), same(cellDoc), same(currentDoc), + same(context))).andReturn(expectedRenderedContent); replayDefault(); assertEquals(expectedRenderedContent, renderCmd.renderDocument(cellDoc, null, "en")); verifyDefault(); @@ -818,8 +817,8 @@ public void test_renderDocument_includingDoc() throws Exception { DocumentReference includeDocRef = new DocumentReference(context.getDatabase(), "Includeing", "TheIncludingDocumentName"); XWikiDocument includeDoc = new XWikiDocument(includeDocRef); - expect(renderingEngineMock.renderText(eq(contentEN), same(cellDoc), same(includeDoc), same( - context))).andReturn(expectedRenderedContent); + expect(renderingEngineMock.renderText(eq(contentEN), same(cellDoc), same(includeDoc), + same(context))).andReturn(expectedRenderedContent); replayDefault(); assertEquals(expectedRenderedContent, renderCmd.renderDocument(cellDoc, includeDoc, "en")); verifyDefault(); @@ -835,8 +834,8 @@ public void test_renderDocument_docref() throws Exception { String contentEN = "english script $test"; cellDoc.setContent(contentEN); expect(renderingEngineMock.getRendererNames()).andReturn(Arrays.asList("velocity", "groovy")); - expect(renderingEngineMock.renderText(eq(contentEN), same(cellDoc), same(currentDoc), same( - context))).andReturn(expectedRenderedContent); + expect(renderingEngineMock.renderText(eq(contentEN), same(cellDoc), same(currentDoc), + same(context))).andReturn(expectedRenderedContent); expect(modelAccessMock.getOrCreateDocument(elementDocRef)).andReturn(cellDoc).atLeastOnce(); replayDefault(); assertEquals(expectedRenderedContent, renderCmd.renderDocument(elementDocRef, "en")); @@ -856,13 +855,13 @@ public void test_renderDocument_docref_docref() throws Exception { DocumentReference includeDocRef = new DocumentReference(context.getDatabase(), "Includeing", "TheIncludingDocumentName"); XWikiDocument includeDoc = new XWikiDocument(includeDocRef); - expect(renderingEngineMock.renderText(eq(contentEN), same(cellDoc), same(includeDoc), same( - context))).andReturn(expectedRenderedContent); + expect(renderingEngineMock.renderText(eq(contentEN), same(cellDoc), same(includeDoc), + same(context))).andReturn(expectedRenderedContent); expect(modelAccessMock.getOrCreateDocument(elementDocRef)).andReturn(cellDoc).atLeastOnce(); expect(modelAccessMock.getOrCreateDocument(includeDocRef)).andReturn(includeDoc).atLeastOnce(); replayDefault(); - assertEquals(expectedRenderedContent, renderCmd.renderDocument(elementDocRef, includeDocRef, - "en")); + assertEquals(expectedRenderedContent, + renderCmd.renderDocument(elementDocRef, includeDocRef, "en")); verifyDefault(); } @@ -872,17 +871,17 @@ public void test_renderCelementsDocument_vContext_null() throws Exception { DocumentReference myDocRef = new DocumentReference(context.getDatabase(), "Content", "myPage"); XWikiDocument myDoc = new XWikiDocument(myDocRef); myDoc.setDefaultLanguage("de"); - expect(mockPageTypeResolver.resolvePageTypeReference(same(myDoc))) - .andReturn(Optional.absent()).anyTimes(); + expect(mockPageTypeResolver.resolvePageTypeReference(same(myDoc))).andReturn(Optional.absent()) + .anyTimes(); expect(modelAccessMock.getOrCreateDocument(eq(myDocRef))).andReturn(myDoc).anyTimes(); String expectedContent = "expected Content $doc.fullName"; myDoc.setContent(expectedContent); - expect(renderingEngineMock.renderText(eq(expectedContent), same(myDoc), same(currentDoc), same( - context))).andReturn("Topic Content.MyPage does not exist").anyTimes(); - expect(renderingEngineMock.getRendererNames()).andReturn(Arrays.asList("velocity", - "groovy")).anyTimes(); - expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq( - "xwikidb:Content.myPage"), same(context))).andReturn(true).anyTimes(); + expect(renderingEngineMock.renderText(eq(expectedContent), same(myDoc), same(currentDoc), + same(context))).andReturn("Topic Content.MyPage does not exist").anyTimes(); + expect(renderingEngineMock.getRendererNames()).andReturn(Arrays.asList("velocity", "groovy")) + .anyTimes(); + expect(mockRightService.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), + eq("xwikidb:Content.myPage"), same(context))).andReturn(true).anyTimes(); context.remove("vcontext"); replayDefault(); assertEquals("expecting empty because velocity context is null.", "", @@ -911,8 +910,8 @@ public void appendTo(StringBuffer buffer) { public boolean matches(Object argument) { if (argument instanceof XWikiContext) { XWikiContext theContext = (XWikiContext) argument; - VelocityContext execVcontext = (VelocityContext) getExecutionContext().getProperty( - "velocityContext"); + VelocityContext execVcontext = (VelocityContext) getExecutionContext() + .getProperty("velocityContext"); if (theContext != null) { VelocityContext vContext = (VelocityContext) theContext.get("vcontext"); return (initVcontext != vContext) && (vContext == execVcontext); diff --git a/src/test/java/com/celements/rights/CelementsRightServiceImplTest.java b/src/test/java/com/celements/rights/CelementsRightServiceImplTest.java index 1e7ff4afe..5848f2d4c 100644 --- a/src/test/java/com/celements/rights/CelementsRightServiceImplTest.java +++ b/src/test/java/com/celements/rights/CelementsRightServiceImplTest.java @@ -42,21 +42,22 @@ public void testCheckRight_publishNotActive() throws XWikiRightNotFoundException expect(xwiki.getGroupService(same(getContext()))).andReturn(gs).anyTimes(); Collection groupsList = new ArrayList<>(); groupsList.add(new DocumentReference(getContext().getDatabase(), "XWiki", "XWikiAllGroup")); - expect(gs.getAllGroupsReferencesForMember(eq(new DocumentReference(getContext().getDatabase(), - "XWiki", "user")), eq(0), eq(0), same(getContext()))).andReturn(groupsList).anyTimes(); + expect(gs.getAllGroupsReferencesForMember( + eq(new DocumentReference(getContext().getDatabase(), "XWiki", "user")), eq(0), eq(0), + same(getContext()))).andReturn(groupsList).anyTimes(); Collection emptyGroupsList = Collections.emptyList(); - expect(gs.getAllGroupsReferencesForMember(eq(new DocumentReference(getContext().getDatabase(), - "XWiki", "XWikiAllGroup")), eq(0), eq(0), same(getContext()))).andReturn( - emptyGroupsList).anyTimes(); + expect(gs.getAllGroupsReferencesForMember( + eq(new DocumentReference(getContext().getDatabase(), "XWiki", "XWikiAllGroup")), eq(0), + eq(0), same(getContext()))).andReturn(emptyGroupsList).anyTimes(); expect(xwiki.isVirtualMode()).andReturn(true).anyTimes(); - XWikiDocument doc = new XWikiDocument(new DocumentReference(getContext().getDatabase(), - "TestSpace", "TestDoc")); + XWikiDocument doc = new XWikiDocument( + new DocumentReference(getContext().getDatabase(), "TestSpace", "TestDoc")); getContext().setDoc(doc); - expect(xwiki.getSpacePreference(eq("publishdate_active"), eq("TestSpace"), eq("-1"), same( - getContext()))).andReturn("0").anyTimes(); + expect(xwiki.getSpacePreference(eq("publishdate_active"), eq("TestSpace"), eq("-1"), + same(getContext()))).andReturn("0").anyTimes(); BaseObject rightObj = new BaseObject(); - rightObj.setXClassReference(new DocumentReference(getContext().getDatabase(), "XWiki", - "XWikiRights")); + rightObj.setXClassReference( + new DocumentReference(getContext().getDatabase(), "XWiki", "XWikiRights")); rightObj.setStringValue("users", "XWiki.user"); rightObj.setStringValue("levels", "view,edit"); rightObj.setIntValue("allow", 1); @@ -67,27 +68,28 @@ public void testCheckRight_publishNotActive() throws XWikiRightNotFoundException } @Test - public void testCheckRight_publishActive_defaultNoObject() throws XWikiRightNotFoundException, - XWikiException { + public void testCheckRight_publishActive_defaultNoObject() + throws XWikiRightNotFoundException, XWikiException { XWikiGroupService gs = createMock(XWikiGroupService.class); expect(xwiki.getGroupService(same(getContext()))).andReturn(gs).anyTimes(); Collection groupsList = new ArrayList<>(); groupsList.add(new DocumentReference(getContext().getDatabase(), "XWiki", "XWikiAllGroup")); - expect(gs.getAllGroupsReferencesForMember(eq(new DocumentReference(getContext().getDatabase(), - "XWiki", "user")), eq(0), eq(0), same(getContext()))).andReturn(groupsList).anyTimes(); + expect(gs.getAllGroupsReferencesForMember( + eq(new DocumentReference(getContext().getDatabase(), "XWiki", "user")), eq(0), eq(0), + same(getContext()))).andReturn(groupsList).anyTimes(); Collection emptyGroupsList = Collections.emptyList(); - expect(gs.getAllGroupsReferencesForMember(eq(new DocumentReference(getContext().getDatabase(), - "XWiki", "XWikiAllGroup")), eq(0), eq(0), same(getContext()))).andReturn( - emptyGroupsList).anyTimes(); + expect(gs.getAllGroupsReferencesForMember( + eq(new DocumentReference(getContext().getDatabase(), "XWiki", "XWikiAllGroup")), eq(0), + eq(0), same(getContext()))).andReturn(emptyGroupsList).anyTimes(); expect(xwiki.isVirtualMode()).andReturn(true).anyTimes(); - expect(xwiki.getSpacePreference(eq("publishdate_active"), eq("TestSpace"), eq("-1"), same( - getContext()))).andReturn("1").anyTimes(); - XWikiDocument doc = new XWikiDocument(new DocumentReference(getContext().getDatabase(), - "TestSpace", "TestDoc")); + expect(xwiki.getSpacePreference(eq("publishdate_active"), eq("TestSpace"), eq("-1"), + same(getContext()))).andReturn("1").anyTimes(); + XWikiDocument doc = new XWikiDocument( + new DocumentReference(getContext().getDatabase(), "TestSpace", "TestDoc")); getContext().setDoc(doc); BaseObject rightObj = new BaseObject(); - rightObj.setXClassReference(new DocumentReference(getContext().getDatabase(), "XWiki", - "XWikiRights")); + rightObj.setXClassReference( + new DocumentReference(getContext().getDatabase(), "XWiki", "XWikiRights")); rightObj.setStringValue("users", "XWiki.user"); rightObj.setStringValue("levels", "view"); rightObj.setIntValue("allow", 1); @@ -98,27 +100,28 @@ public void testCheckRight_publishActive_defaultNoObject() throws XWikiRightNotF } @Test - public void testCheckRight_publishActive_unpublished() throws XWikiRightNotFoundException, - XWikiException { + public void testCheckRight_publishActive_unpublished() + throws XWikiRightNotFoundException, XWikiException { XWikiGroupService gs = createMock(XWikiGroupService.class); expect(xwiki.getGroupService(same(getContext()))).andReturn(gs).anyTimes(); Collection groupsList = new ArrayList<>(); groupsList.add(new DocumentReference(getContext().getDatabase(), "XWiki", "XWikiAllGroup")); - expect(gs.getAllGroupsReferencesForMember(eq(new DocumentReference(getContext().getDatabase(), - "XWiki", "user")), eq(0), eq(0), same(getContext()))).andReturn(groupsList).anyTimes(); + expect(gs.getAllGroupsReferencesForMember( + eq(new DocumentReference(getContext().getDatabase(), "XWiki", "user")), eq(0), eq(0), + same(getContext()))).andReturn(groupsList).anyTimes(); Collection emptyGroupsList = Collections.emptyList(); - expect(gs.getAllGroupsReferencesForMember(eq(new DocumentReference(getContext().getDatabase(), - "XWiki", "XWikiAllGroup")), eq(0), eq(0), same(getContext()))).andReturn( - emptyGroupsList).anyTimes(); + expect(gs.getAllGroupsReferencesForMember( + eq(new DocumentReference(getContext().getDatabase(), "XWiki", "XWikiAllGroup")), eq(0), + eq(0), same(getContext()))).andReturn(emptyGroupsList).anyTimes(); expect(xwiki.isVirtualMode()).andReturn(true).anyTimes(); - expect(xwiki.getSpacePreference(eq("publishdate_active"), eq("TestSpace"), eq("-1"), same( - getContext()))).andReturn("1").anyTimes(); - XWikiDocument doc = new XWikiDocument(new DocumentReference(getContext().getDatabase(), - "TestSpace", "TestDoc")); + expect(xwiki.getSpacePreference(eq("publishdate_active"), eq("TestSpace"), eq("-1"), + same(getContext()))).andReturn("1").anyTimes(); + XWikiDocument doc = new XWikiDocument( + new DocumentReference(getContext().getDatabase(), "TestSpace", "TestDoc")); getContext().setDoc(doc); BaseObject rightObj = new BaseObject(); - rightObj.setXClassReference(new DocumentReference(getContext().getDatabase(), "XWiki", - "XWikiRights")); + rightObj.setXClassReference( + new DocumentReference(getContext().getDatabase(), "XWiki", "XWikiRights")); rightObj.setStringValue("users", "XWiki.user"); rightObj.setStringValue("levels", "view"); rightObj.setIntValue("allow", 1); @@ -130,33 +133,34 @@ public void testCheckRight_publishActive_unpublished() throws XWikiRightNotFound obj.setXClassReference(getPublicationClassReference()); doc.addXObject(obj); replay(gs, xwiki); - assertFalse(rightService.checkRight("XWiki.user", doc, "view", true, true, false, - getContext())); + assertFalse( + rightService.checkRight("XWiki.user", doc, "view", true, true, false, getContext())); verify(gs, xwiki); } @Test - public void testCheckRight_publishActive_published() throws XWikiRightNotFoundException, - XWikiException { + public void testCheckRight_publishActive_published() + throws XWikiRightNotFoundException, XWikiException { XWikiGroupService gs = createMock(XWikiGroupService.class); expect(xwiki.getGroupService(same(getContext()))).andReturn(gs).anyTimes(); Collection groupsList = new ArrayList<>(); groupsList.add(new DocumentReference(getContext().getDatabase(), "XWiki", "XWikiAllGroup")); - expect(gs.getAllGroupsReferencesForMember(eq(new DocumentReference(getContext().getDatabase(), - "XWiki", "user")), eq(0), eq(0), same(getContext()))).andReturn(groupsList).anyTimes(); + expect(gs.getAllGroupsReferencesForMember( + eq(new DocumentReference(getContext().getDatabase(), "XWiki", "user")), eq(0), eq(0), + same(getContext()))).andReturn(groupsList).anyTimes(); Collection emptyGroupsList = Collections.emptyList(); - expect(gs.getAllGroupsReferencesForMember(eq(new DocumentReference(getContext().getDatabase(), - "XWiki", "XWikiAllGroup")), eq(0), eq(0), same(getContext()))).andReturn( - emptyGroupsList).anyTimes(); + expect(gs.getAllGroupsReferencesForMember( + eq(new DocumentReference(getContext().getDatabase(), "XWiki", "XWikiAllGroup")), eq(0), + eq(0), same(getContext()))).andReturn(emptyGroupsList).anyTimes(); expect(xwiki.isVirtualMode()).andReturn(true).anyTimes(); - expect(xwiki.getSpacePreference(eq("publishdate_active"), eq("TestSpace"), eq("-1"), same( - getContext()))).andReturn("1").anyTimes(); - XWikiDocument doc = new XWikiDocument(new DocumentReference(getContext().getDatabase(), - "TestSpace", "TestDoc")); + expect(xwiki.getSpacePreference(eq("publishdate_active"), eq("TestSpace"), eq("-1"), + same(getContext()))).andReturn("1").anyTimes(); + XWikiDocument doc = new XWikiDocument( + new DocumentReference(getContext().getDatabase(), "TestSpace", "TestDoc")); getContext().setDoc(doc); BaseObject rightObj = new BaseObject(); - rightObj.setXClassReference(new DocumentReference(getContext().getDatabase(), "XWiki", - "XWikiRights")); + rightObj.setXClassReference( + new DocumentReference(getContext().getDatabase(), "XWiki", "XWikiRights")); rightObj.setStringValue("users", "XWiki.user"); rightObj.setStringValue("levels", "view"); rightObj.setIntValue("allow", 1); diff --git a/src/test/java/com/celements/rights/publication/PublicationServiceTest.java b/src/test/java/com/celements/rights/publication/PublicationServiceTest.java index 395d9ec91..2ccfedbf1 100644 --- a/src/test/java/com/celements/rights/publication/PublicationServiceTest.java +++ b/src/test/java/com/celements/rights/publication/PublicationServiceTest.java @@ -28,15 +28,15 @@ public void setUp_PublicationServiceTest() throws Exception { @Test public void testGetPublishObject_null() { - XWikiDocument doc = new XWikiDocument(new DocumentReference(getContext().getDatabase(), "Space", - "Doc")); + XWikiDocument doc = new XWikiDocument( + new DocumentReference(getContext().getDatabase(), "Space", "Doc")); assertNotNull(pubService.getPublishObjects(doc)); } @Test public void testGetPublishObject_hasObj() { - XWikiDocument doc = new XWikiDocument(new DocumentReference(getContext().getDatabase(), "Space", - "Doc")); + XWikiDocument doc = new XWikiDocument( + new DocumentReference(getContext().getDatabase(), "Space", "Doc")); BaseObject obj = new BaseObject(); obj.setXClassReference(pubService.getPublicationClassReference()); doc.addXObject(obj); @@ -45,8 +45,8 @@ public void testGetPublishObject_hasObj() { @Test public void testGetPublishObject_hasObjs() { - XWikiDocument doc = new XWikiDocument(new DocumentReference(getContext().getDatabase(), "Space", - "Doc")); + XWikiDocument doc = new XWikiDocument( + new DocumentReference(getContext().getDatabase(), "Space", "Doc")); BaseObject obj1 = new BaseObject(); obj1.setXClassReference(pubService.getPublicationClassReference()); doc.addXObject(obj1); @@ -58,8 +58,8 @@ public void testGetPublishObject_hasObjs() { @Test public void testGetPublishObject_nullObjs() { - XWikiDocument doc = new XWikiDocument(new DocumentReference(getContext().getDatabase(), "Space", - "Doc")); + XWikiDocument doc = new XWikiDocument( + new DocumentReference(getContext().getDatabase(), "Space", "Doc")); BaseObject obj = new BaseObject(); obj.setXClassReference(pubService.getPublicationClassReference()); doc.setXObject(3, obj); @@ -69,15 +69,15 @@ public void testGetPublishObject_nullObjs() { @Test public void testIsPublished_noLimits() { assertTrue("null document", pubService.isPublished(null)); - XWikiDocument doc = new XWikiDocument(new DocumentReference(getContext().getDatabase(), "Space", - "Doc")); + XWikiDocument doc = new XWikiDocument( + new DocumentReference(getContext().getDatabase(), "Space", "Doc")); assertTrue("document without objects", pubService.isPublished(doc)); } @Test public void testIsPublished_noLimits_umpublished() { - XWikiDocument doc = new XWikiDocument(new DocumentReference(getContext().getDatabase(), "Space", - "Doc")); + XWikiDocument doc = new XWikiDocument( + new DocumentReference(getContext().getDatabase(), "Space", "Doc")); BaseObject obj1 = new BaseObject(); Calendar gc = Calendar.getInstance(); gc.add(Calendar.HOUR, 1); @@ -97,8 +97,8 @@ public void testIsPublished_noLimits_umpublished() { @Test public void testIsPublished_noLimits_published() { - XWikiDocument doc = new XWikiDocument(new DocumentReference(getContext().getDatabase(), "Space", - "Doc")); + XWikiDocument doc = new XWikiDocument( + new DocumentReference(getContext().getDatabase(), "Space", "Doc")); BaseObject obj1 = new BaseObject(); obj1.setXClassReference(pubService.getPublicationClassReference()); BaseObject obj3 = new BaseObject(); @@ -125,8 +125,8 @@ public void testIsPublished_noLimits_published() { public void testIsPublishActive_docNull() { expect(getWikiMock().getSpacePreference(eq("publishdate_active"), same((String) null), eq("-1"), same(getContext()))).andReturn("-1").once(); - expect(getWikiMock().getXWikiPreference(eq("publishdate_active"), eq( - "celements.publishdate.active"), eq("0"), same(getContext()))).andReturn("0").once(); + expect(getWikiMock().getXWikiPreference(eq("publishdate_active"), + eq("celements.publishdate.active"), eq("0"), same(getContext()))).andReturn("0").once(); replayDefault(); assertEquals(false, pubService.isPublishActive()); verifyDefault(); @@ -136,10 +136,10 @@ public void testIsPublishActive_docNull() { public void testIsPublishActive_notSet() { expect(getWikiMock().getSpacePreference(eq("publishdate_active"), eq("TestSpace"), eq("-1"), same(getContext()))).andReturn("-1").once(); - expect(getWikiMock().getXWikiPreference(eq("publishdate_active"), eq( - "celements.publishdate.active"), eq("0"), same(getContext()))).andReturn("0").once(); - XWikiDocument doc = new XWikiDocument(new DocumentReference(getContext().getDatabase(), - "TestSpace", "TestDoc")); + expect(getWikiMock().getXWikiPreference(eq("publishdate_active"), + eq("celements.publishdate.active"), eq("0"), same(getContext()))).andReturn("0").once(); + XWikiDocument doc = new XWikiDocument( + new DocumentReference(getContext().getDatabase(), "TestSpace", "TestDoc")); getContext().setDoc(doc); replayDefault(); assertEquals(false, pubService.isPublishActive()); @@ -150,8 +150,8 @@ public void testIsPublishActive_notSet() { public void testIsPublishActive_false() { expect(getWikiMock().getSpacePreference(eq("publishdate_active"), eq("TestSpace"), eq("-1"), same(getContext()))).andReturn("0").once(); - XWikiDocument doc = new XWikiDocument(new DocumentReference(getContext().getDatabase(), - "TestSpace", "TestDoc")); + XWikiDocument doc = new XWikiDocument( + new DocumentReference(getContext().getDatabase(), "TestSpace", "TestDoc")); getContext().setDoc(doc); replayDefault(); assertEquals(false, pubService.isPublishActive()); @@ -162,8 +162,8 @@ public void testIsPublishActive_false() { public void testIsPublishActive_true() { expect(getWikiMock().getSpacePreference(eq("publishdate_active"), eq("TestSpace"), eq("-1"), same(getContext()))).andReturn("1").once(); - XWikiDocument doc = new XWikiDocument(new DocumentReference(getContext().getDatabase(), - "TestSpace", "TestDoc")); + XWikiDocument doc = new XWikiDocument( + new DocumentReference(getContext().getDatabase(), "TestSpace", "TestDoc")); getContext().setDoc(doc); replayDefault(); assertEquals(true, pubService.isPublishActive()); @@ -298,15 +298,15 @@ public void testIsUnpubOverride_pub() { @Test public void test_overridePubUnpub_PUBLISHED() { pubService.overridePubUnpub(EPubUnpub.PUBLISHED); - assertEquals(EPubUnpub.PUBLISHED, getExecutionContext().getProperty( - IPublicationServiceRole.OVERRIDE_PUB_CHECK)); + assertEquals(EPubUnpub.PUBLISHED, + getExecutionContext().getProperty(IPublicationServiceRole.OVERRIDE_PUB_CHECK)); } @Test public void test_overridePubUnpub_UNPUBLISHED() { pubService.overridePubUnpub(EPubUnpub.UNPUBLISHED); - assertEquals(EPubUnpub.UNPUBLISHED, getExecutionContext().getProperty( - IPublicationServiceRole.OVERRIDE_PUB_CHECK)); + assertEquals(EPubUnpub.UNPUBLISHED, + getExecutionContext().getProperty(IPublicationServiceRole.OVERRIDE_PUB_CHECK)); } private ExecutionContext getExecutionContext() { diff --git a/src/test/java/com/celements/sajson/JsonBuilderTest.java b/src/test/java/com/celements/sajson/JsonBuilderTest.java index 0b80fd286..37c82a86e 100644 --- a/src/test/java/com/celements/sajson/JsonBuilderTest.java +++ b/src/test/java/com/celements/sajson/JsonBuilderTest.java @@ -51,8 +51,8 @@ public void test_create_clone() { builder.openProperty("k"); JsonBuilder clone = new JsonBuilder(builder); assertNotSame(builder.getCommandStack(), clone.getCommandStack()); - assertEquals(new ArrayList<>(builder.getCommandStack()), new ArrayList<>( - clone.getCommandStack())); + assertEquals(new ArrayList<>(builder.getCommandStack()), + new ArrayList<>(clone.getCommandStack())); assertEquals(builder.getJSONWithoutCheck(), clone.getJSONWithoutCheck()); assertEquals(builder.isOnFirstElement(), clone.isOnFirstElement()); @@ -94,9 +94,9 @@ public void test_openArray_notFirstElement() { @Test public void test_openDictionary() { builder.openDictionary(); - assertEquals("Expecting after openDictionary topmost element on stack" - + " must be openDictionary.", ECommand.DICTIONARY_COMMAND, - builder.getCommandStack().peek()); + assertEquals( + "Expecting after openDictionary topmost element on stack" + " must be openDictionary.", + ECommand.DICTIONARY_COMMAND, builder.getCommandStack().peek()); assertTrue("openArray must add '{' to the json expression.", builder.getJSONWithoutCheck().endsWith("{")); assertFalse("openArray may not add ',' to the json expression.", @@ -108,9 +108,9 @@ public void test_openDictionary() { public void test_openDictionary_notFirstElement() { builder.setOnFirstElement(false); builder.openDictionary(); - assertEquals("Expecting after openDictionary topmost element on stack" - + " must be openDictionary.", ECommand.DICTIONARY_COMMAND, - builder.getCommandStack().peek()); + assertEquals( + "Expecting after openDictionary topmost element on stack" + " must be openDictionary.", + ECommand.DICTIONARY_COMMAND, builder.getCommandStack().peek()); assertTrue("openArray must add ', {' to the json expression.", builder.getJSONWithoutCheck().endsWith(", {")); assertTrue("After openDictionary firstElement must be true.", builder.isOnFirstElement()); @@ -137,8 +137,9 @@ public void test_openProperty_notFirstElement() { assertEquals("Expecting after openProperty topmost element on stack" + " must be openProperty.", ECommand.PROPERTY_COMMAND, builder.getCommandStack().peek()); String unfinishedJson = builder.getJSONWithoutCheck(); - assertTrue("openProperty must add a leading ',' and the key with" - + " a colon-separator to the json expression. '" + unfinishedJson + "'", + assertTrue( + "openProperty must add a leading ',' and the key with" + + " a colon-separator to the json expression. '" + unfinishedJson + "'", unfinishedJson.endsWith(", \"key\" : ")); assertTrue("After openProperty firstElement must be true.", builder.isOnFirstElement()); } @@ -352,8 +353,8 @@ public void test_toJsonString_null() { @Test public void test_toJsonString_EscapeQuotes() { - assertEquals("String must be capselled in Quotes.", "\"aasdf38z6 ljb\"", builder.toJsonString( - "aasdf38z6 ljb")); + assertEquals("String must be capselled in Quotes.", "\"aasdf38z6 ljb\"", + builder.toJsonString("aasdf38z6 ljb")); assertEquals("Double Quotes must be escaped.", "\"a\\\"b\"", builder.toJsonString("a\"b")); } @@ -371,8 +372,8 @@ public void test_toJsonString_EscapeCarriageReturn() { @Test public void test_toJsonString_EscapeTabs() { - assertEquals("Tabs must be escaped with \\t.", "\"aasdf38z6\\t ljb\"", builder.toJsonString( - "aasdf38z6\t ljb")); + assertEquals("Tabs must be escaped with \\t.", "\"aasdf38z6\\t ljb\"", + builder.toJsonString("aasdf38z6\t ljb")); } @Test @@ -503,8 +504,9 @@ public void test_addValue_number_notFirstElement() { public void test_addValue_long() { builder.addValue(234098763455237134L); String unfinishedJSON = builder.getJSONWithoutCheck(); - assertTrue("addValue must add '234098763455237134L' to the json expression. '" + unfinishedJSON - + "'", unfinishedJSON.endsWith("234098763455237134")); + assertTrue( + "addValue must add '234098763455237134L' to the json expression. '" + unfinishedJSON + "'", + unfinishedJSON.endsWith("234098763455237134")); assertFalse("After addNull firstElement must be false.", builder.isOnFirstElement()); } diff --git a/src/test/java/com/celements/sajson/LexicalParserTest.java b/src/test/java/com/celements/sajson/LexicalParserTest.java index deab42172..01c30658e 100644 --- a/src/test/java/com/celements/sajson/LexicalParserTest.java +++ b/src/test/java/com/celements/sajson/LexicalParserTest.java @@ -290,6 +290,7 @@ private void verifyAll(Object... mocks) { } private enum ERulesLiteral implements IGenericLiteral { + OBJECT_VALUE(ECommand.VALUE_COMMAND), RULE_ATTRIBUTE(OBJECT_VALUE, "name", "*"), CON_OR_ACT_ATTRIBUTE(OBJECT_VALUE, "type"), @@ -371,12 +372,12 @@ private Map getPropertyNameMap() { private void checkPropertyLiteral(ERulesLiteral literal) { if (literal.getCommand() != ECommand.PROPERTY_COMMAND) { - throw new IllegalStateException("expecting only property literal inside" - + " dictionary but found [" + literal + "]."); + throw new IllegalStateException( + "expecting only property literal inside" + " dictionary but found [" + literal + "]."); } if (literal.getNames() == null) { - throw new IllegalStateException("missing property names for property literal [" + literal - + "]"); + throw new IllegalStateException( + "missing property names for property literal [" + literal + "]"); } } diff --git a/src/test/java/com/celements/validation/FormValidationServiceTest.java b/src/test/java/com/celements/validation/FormValidationServiceTest.java index f578c6394..1308d023e 100644 --- a/src/test/java/com/celements/validation/FormValidationServiceTest.java +++ b/src/test/java/com/celements/validation/FormValidationServiceTest.java @@ -34,18 +34,17 @@ public class FormValidationServiceTest extends AbstractComponentTest { @Before public void prepare() throws Exception { - getContext().setDoc(new XWikiDocument(new DocumentReference( - getContext().getDatabase(), "space", "doc"))); + getContext().setDoc( + new XWikiDocument(new DocumentReference(getContext().getDatabase(), "space", "doc"))); reqRule1 = createDefaultMock(IRequestValidationRule.class); reqRule2 = createDefaultMock(IRequestValidationRule.class); legReqRule1 = createDefaultMock(IRequestValidationRuleRole.class); legReqRule2 = createDefaultMock(IRequestValidationRuleRole.class); fieldRule1 = createDefaultMock(IFieldValidationRuleRole.class); fieldRUle2 = createDefaultMock(IFieldValidationRuleRole.class); - formValidationService = (FormValidationService) Utils.getComponent( - IFormValidationServiceRole.class); - formValidationService.injectValidationRules( - ImmutableMap.of("1", reqRule1, "2", reqRule2), + formValidationService = (FormValidationService) Utils + .getComponent(IFormValidationServiceRole.class); + formValidationService.injectValidationRules(ImmutableMap.of("1", reqRule1, "2", reqRule2), ImmutableMap.of("1", legReqRule1, "2", legReqRule2), ImmutableMap.of("1", fieldRule1, "2", fieldRUle2)); } @@ -81,8 +80,8 @@ public void testValidateMap_invalid() { innerMap.put(ValidationType.ERROR, set); map.put("asdf", innerMap); - expect(reqRule1.validate(anyObject(List.class))).andReturn(ImmutableList.of( - new ValidationResult(ValidationType.ERROR, "asdf", "invalid"))); + expect(reqRule1.validate(anyObject(List.class))) + .andReturn(ImmutableList.of(new ValidationResult(ValidationType.ERROR, "asdf", "invalid"))); expect(reqRule2.validate(anyObject(List.class))).andReturn(Collections.emptyList()); expect(legReqRule1.validateRequest(anyObject(Map.class))).andReturn(getEmptyRetMap()); expect(legReqRule2.validateRequest(anyObject(Map.class))).andReturn(getEmptyRetMap()); @@ -169,8 +168,8 @@ public void testValidateField_valid() { .andReturn(new HashMap>()); replayDefault(); - Map> validationSet = formValidationService - .validateField(className, fieldName, value); + Map> validationSet = formValidationService.validateField(className, + fieldName, value); verifyDefault(); assertNotNull(validationSet); assertEquals(0, validationSet.size()); @@ -191,8 +190,8 @@ public void testValidateField_invalid() { .andReturn(new HashMap>()); replayDefault(); - Map> validationMap = formValidationService - .validateField(className, fieldName, value); + Map> validationMap = formValidationService.validateField(className, + fieldName, value); verifyDefault(); assertNotNull(validationMap); @@ -221,8 +220,8 @@ public void testValidateField_invalid_both() { expect(fieldRUle2.validateField(eq(className), eq(fieldName), eq(value))).andReturn(map2); replayDefault(); - Map> validationMap = formValidationService - .validateField(className, fieldName, value); + Map> validationMap = formValidationService.validateField(className, + fieldName, value); verifyDefault(); assertNotNull(validationMap); diff --git a/src/test/java/com/celements/validation/XClassRegexRuleTest.java b/src/test/java/com/celements/validation/XClassRegexRuleTest.java index 0f29a2855..4ee06d070 100644 --- a/src/test/java/com/celements/validation/XClassRegexRuleTest.java +++ b/src/test/java/com/celements/validation/XClassRegexRuleTest.java @@ -36,8 +36,8 @@ public void prepare() throws Exception { xClassRegexRule = (XClassRegexRule) Utils.getComponent(IRequestValidationRule.class, "XClassRegexValidation"); bclassDocRef = new DocumentReference(getContext().getDatabase(), "Test", "TestClass"); - parser = new DocFormRequestKeyParser(new DocumentReference(getContext().getDatabase(), - "space", "default")); + parser = new DocFormRequestKeyParser( + new DocumentReference(getContext().getDatabase(), "space", "default")); } @Test @@ -46,8 +46,8 @@ public void test_validate_empty() throws XWikiException { List result = xClassRegexRule.validate(ImmutableList.of()); verifyDefault(); - assertTrue("Successful validation should result in an empty map", (result != null) - && result.isEmpty()); + assertTrue("Successful validation should result in an empty map", + (result != null) && result.isEmpty()); } @Test @@ -76,8 +76,8 @@ public void test_validate_valid() throws XWikiException { List result = xClassRegexRule.validate(parser.parseParameterMap(requestMap)); verifyDefault(); - assertTrue("Successful validation should result in an empty map", (result != null) - && result.isEmpty()); + assertTrue("Successful validation should result in an empty map", + (result != null) && result.isEmpty()); } @Test @@ -129,8 +129,8 @@ public void test_validate_illegalType() throws XWikiException { List result = xClassRegexRule.validate(parser.parseParameterMap(requestMap)); verifyDefault(); - assertTrue("Successful validation should result in an empty map", (result != null) - && result.isEmpty()); + assertTrue("Successful validation should result in an empty map", + (result != null) && result.isEmpty()); } @Test @@ -205,8 +205,9 @@ public void test_validateField_invalidKey_notIgnore() throws XWikiException { XWikiDocument doc = new XWikiDocument(bclassDocRef); expect(getWikiMock().getDocument(eq(bclassDocRef), same(getContext()))).andReturn(doc).once(); - expect(xClassRegexRule.configSrc.getProperty(eq( - "celements.validation.xClassRegex.ignoreInvalidKey"), eq(true))).andReturn(false).once(); + expect(xClassRegexRule.configSrc + .getProperty(eq("celements.validation.xClassRegex.ignoreInvalidKey"), eq(true))) + .andReturn(false).once(); replayDefault(); Map> result = xClassRegexRule.validateField("Test.TestClass", @@ -217,8 +218,8 @@ public void test_validateField_invalidKey_notIgnore() throws XWikiException { assertEquals(1, result.size()); assertTrue(result.containsKey(ValidationType.ERROR)); assertEquals(1, result.get(ValidationType.ERROR).size()); - assertEquals("cel_validation_xclassregex_invalidkey", result.get( - ValidationType.ERROR).iterator().next()); + assertEquals("cel_validation_xclassregex_invalidkey", + result.get(ValidationType.ERROR).iterator().next()); xClassRegexRule.configSrc = Utils.getComponent(ConfigurationSource.class); } @@ -232,8 +233,8 @@ public void test_validate_docField() throws XWikiException { List result = xClassRegexRule.validate(parser.parseParameterMap(requestMap)); verifyDefault(); - assertTrue("Successful validation should result in an empty map", (result != null) - && result.isEmpty()); + assertTrue("Successful validation should result in an empty map", + (result != null) && result.isEmpty()); } private BaseClass getBaseClass(String fieldName) { diff --git a/src/test/java/com/celements/web/comparators/BaseObjectComparatorTest.java b/src/test/java/com/celements/web/comparators/BaseObjectComparatorTest.java index 3ac40ac69..5fa081508 100644 --- a/src/test/java/com/celements/web/comparators/BaseObjectComparatorTest.java +++ b/src/test/java/com/celements/web/comparators/BaseObjectComparatorTest.java @@ -22,10 +22,8 @@ public class BaseObjectComparatorTest extends AbstractComponentTest { @Before public void setUp_BaseObjectComparatorTest() throws Exception { - compAsc = BaseObjectComparator.create("x") - .thenComparing(BaseObjectComparator.create("y")); - compDesc = BaseObjectComparator.reversed("x") - .thenComparing(BaseObjectComparator.reversed("y")); + compAsc = BaseObjectComparator.create("x").thenComparing(BaseObjectComparator.create("y")); + compDesc = BaseObjectComparator.reversed("x").thenComparing(BaseObjectComparator.reversed("y")); } @Test diff --git a/src/test/java/com/celements/web/contextmenu/ContextMenuItemTest.java b/src/test/java/com/celements/web/contextmenu/ContextMenuItemTest.java index f5159a260..698806e2f 100644 --- a/src/test/java/com/celements/web/contextmenu/ContextMenuItemTest.java +++ b/src/test/java/com/celements/web/contextmenu/ContextMenuItemTest.java @@ -96,14 +96,15 @@ private ContextMenuItem createCMI(String elementId) { } private void expectEvaluate() throws XWikiVelocityException { - expect(veloService.evaluateVelocityText(eq("link"), anyObject( - VelocityContextModifier.class))).andReturn("link"); - expect(veloService.evaluateVelocityText(eq("Test Menu Item"), anyObject( - VelocityContextModifier.class))).andReturn("Test Menu Item"); - expect(veloService.evaluateVelocityText(eq("shortcut"), anyObject( - VelocityContextModifier.class))).andReturn("shortcut"); - expect(veloService.evaluateVelocityText(eq(""), anyObject( - VelocityContextModifier.class))).andReturn(""); + expect(veloService.evaluateVelocityText(eq("link"), anyObject(VelocityContextModifier.class))) + .andReturn("link"); + expect(veloService.evaluateVelocityText(eq("Test Menu Item"), + anyObject(VelocityContextModifier.class))).andReturn("Test Menu Item"); + expect( + veloService.evaluateVelocityText(eq("shortcut"), anyObject(VelocityContextModifier.class))) + .andReturn("shortcut"); + expect(veloService.evaluateVelocityText(eq(""), anyObject(VelocityContextModifier.class))) + .andReturn(""); } } diff --git a/src/test/java/com/celements/web/contextmenu/TestRequestHandler.java b/src/test/java/com/celements/web/contextmenu/TestRequestHandler.java index 8d30365ad..f9820c8b3 100644 --- a/src/test/java/com/celements/web/contextmenu/TestRequestHandler.java +++ b/src/test/java/com/celements/web/contextmenu/TestRequestHandler.java @@ -29,22 +29,17 @@ public class TestRequestHandler extends AbstractEventHandler { /** * @param requestLiteralTest */ - public TestRequestHandler() { - } + public TestRequestHandler() {} @Override - public void closeEvent(ERequestLiteral literal) { - } + public void closeEvent(ERequestLiteral literal) {} @Override - public void openEvent(ERequestLiteral literal) { - } + public void openEvent(ERequestLiteral literal) {} @Override - public void readPropertyKey(String key) { - } + public void readPropertyKey(String key) {} @Override - public void stringEvent(String value) { - } + public void stringEvent(String value) {} } diff --git a/src/test/java/com/celements/web/css/CSSBaseObjectTest.java b/src/test/java/com/celements/web/css/CSSBaseObjectTest.java index 8ca310d5e..dd1b2497a 100644 --- a/src/test/java/com/celements/web/css/CSSBaseObjectTest.java +++ b/src/test/java/com/celements/web/css/CSSBaseObjectTest.java @@ -102,8 +102,8 @@ public void testGetCSS() { CSSBaseObject cssFile = new CSSBaseObject(bo, context); AttachmentURLCommand attURLcmd = createDefaultMock(AttachmentURLCommand.class); cssFile.testInjectAttURLcmd(attURLcmd); - expect(attURLcmd.getAttachmentURL(eq(context.getDatabase() + ":" + attLink), same( - context))).andReturn(url).once(); + expect(attURLcmd.getAttachmentURL(eq(context.getDatabase() + ":" + attLink), same(context))) + .andReturn(url).once(); replayDefault(); assertEquals(url, cssFile.getCSS(context)); verifyDefault(); @@ -178,8 +178,8 @@ public void testGetAttachment() throws Exception { XWikiRightService rightSerivce = createDefaultMock(XWikiRightService.class); expect(getWikiMock().getRightService()).andReturn(rightSerivce); String fullName = getContext().getDatabase() + ":XWiki.XWikiPreferences"; - expect(rightSerivce.hasAccessLevel(eq("view"), eq(getContext().getUser()), eq(fullName), same( - getContext()))).andReturn(true); + expect(rightSerivce.hasAccessLevel(eq("view"), eq(getContext().getUser()), eq(fullName), + same(getContext()))).andReturn(true); replayDefault(); assertNotNull("attachment must not be null", cssFile.getAttachment()); verifyDefault(); @@ -228,8 +228,8 @@ public void testGetAttachment_centralDb() throws Exception { XWikiRightService rightSerivce = createDefaultMock(XWikiRightService.class); expect(getWikiMock().getRightService()).andReturn(rightSerivce); String fullName = "celements2web:XWiki.XWikiPreferences"; - expect(rightSerivce.hasAccessLevel(eq("view"), eq(getContext().getUser()), eq(fullName), same( - getContext()))).andReturn(true); + expect(rightSerivce.hasAccessLevel(eq("view"), eq(getContext().getUser()), eq(fullName), + same(getContext()))).andReturn(true); replayDefault(); assertNotNull("attachment must not be null", cssFile.getAttachment()); verifyDefault(); diff --git a/src/test/java/com/celements/web/css/CSSEngineTest.java b/src/test/java/com/celements/web/css/CSSEngineTest.java index 7303073fb..c0d63482a 100644 --- a/src/test/java/com/celements/web/css/CSSEngineTest.java +++ b/src/test/java/com/celements/web/css/CSSEngineTest.java @@ -65,11 +65,11 @@ public void testIncludeCSS_nullObject() { List cssList = cssEngine.includeCSS("", "", baseCSSList, context); - assertFalse("includeCSS must not add null objects to the css list.", cssListContains(cssList, - null)); + assertFalse("includeCSS must not add null objects to the css list.", + cssListContains(cssList, null)); assertTrue("includeCSS must add cssObj to the css list.", cssListContains(cssList, cssObj)); - assertTrue("includeCSS must not add cssObj1 to the css list.", cssListContains(cssList, - cssObj1)); + assertTrue("includeCSS must not add cssObj1 to the css list.", + cssListContains(cssList, cssObj1)); } @Test @@ -78,11 +78,8 @@ public void testIncludeCSS_frontend() { expect(getMock(FrontendResourceResolver.class).isFrontendSource(eq(sourcePath))) .andReturn(true); expect(getMock(FrontendResourceResolver.class).get(eq(sourcePath))) - .andReturn(Optional.of(new FrontendResource( - "dist/vue-poc.BOsmCSyo.mjs", - Arrays.asList( - "dist/assets/vue-poc-ahBOTvOT.css", - "dist/assets/shared.Df9z3kSS.css")))); + .andReturn(Optional.of(new FrontendResource("dist/vue-poc.BOsmCSyo.mjs", + Arrays.asList("dist/assets/vue-poc-ahBOTvOT.css", "dist/assets/shared.Df9z3kSS.css")))); replayDefault(); @@ -119,9 +116,8 @@ public void testIncludeCSS_frontend_noCss() { String sourcePath = ":frontend/progon/eventview/main.ts"; expect(getMock(FrontendResourceResolver.class).isFrontendSource(eq(sourcePath))) .andReturn(true); - expect(getMock(FrontendResourceResolver.class).get(eq(sourcePath))) - .andReturn(Optional.of(new FrontendResource("dist/eventview.Cq6C1_9z.mjs", - Collections.emptyList()))); + expect(getMock(FrontendResourceResolver.class).get(eq(sourcePath))).andReturn( + Optional.of(new FrontendResource("dist/eventview.Cq6C1_9z.mjs", Collections.emptyList()))); replayDefault(); diff --git a/src/test/java/com/celements/web/css/CSSStringTest.java b/src/test/java/com/celements/web/css/CSSStringTest.java index 83342a76f..46f659215 100644 --- a/src/test/java/com/celements/web/css/CSSStringTest.java +++ b/src/test/java/com/celements/web/css/CSSStringTest.java @@ -132,8 +132,8 @@ public void test_getAttachment() throws Exception { expect(getWikiMock().getDocument(eq(docRef), same(getContext()))).andReturn(doc); XWikiRightService rightSerivce = createDefaultMock(XWikiRightService.class); expect(getWikiMock().getRightService()).andReturn(rightSerivce); - expect(rightSerivce.hasAccessLevel(eq("view"), eq(getContext().getUser()), eq( - getContext().getDatabase() + ":" + fullName), same(getContext()))).andReturn(true); + expect(rightSerivce.hasAccessLevel(eq("view"), eq(getContext().getUser()), + eq(getContext().getDatabase() + ":" + fullName), same(getContext()))).andReturn(true); replayDefault(); assertNotNull("attachment must not be null", cssFile.getAttachment()); verifyDefault(); diff --git a/src/test/java/com/celements/web/css/CSSTest.java b/src/test/java/com/celements/web/css/CSSTest.java index 1732bca5d..8e4f377cd 100644 --- a/src/test/java/com/celements/web/css/CSSTest.java +++ b/src/test/java/com/celements/web/css/CSSTest.java @@ -77,8 +77,8 @@ public void testDisplayInclude_null_URL() { expect(cssMock.getCSS(same(context))).andReturn(url); expect(cssMock.getCssBasePath()).andReturn(basePath); replayDefault(); - assertEquals("\n", css.displayInclude( - context)); + assertEquals("\n", + css.displayInclude(context)); verifyDefault(); } diff --git a/src/test/java/com/celements/web/medialib/JSONExporterTest.java b/src/test/java/com/celements/web/medialib/JSONExporterTest.java index ce6e9a7c0..3cefb09e0 100644 --- a/src/test/java/com/celements/web/medialib/JSONExporterTest.java +++ b/src/test/java/com/celements/web/medialib/JSONExporterTest.java @@ -25,8 +25,7 @@ public class JSONExporterTest { @Before - public void prepareTest() throws Exception { - } + public void prepareTest() throws Exception {} @Test public void testExport() { diff --git a/src/test/java/com/celements/web/medialib/datafields/BooleanTest.java b/src/test/java/com/celements/web/medialib/datafields/BooleanTest.java index 797ce12fa..7a6470148 100644 --- a/src/test/java/com/celements/web/medialib/datafields/BooleanTest.java +++ b/src/test/java/com/celements/web/medialib/datafields/BooleanTest.java @@ -25,8 +25,7 @@ public class BooleanTest { @Before - public void prepareTest() throws Exception { - } + public void prepareTest() throws Exception {} @Test public void testGetColumnId() { diff --git a/src/test/java/com/celements/web/medialib/datafields/DateTest.java b/src/test/java/com/celements/web/medialib/datafields/DateTest.java index 558d00e4c..59a53b9f5 100644 --- a/src/test/java/com/celements/web/medialib/datafields/DateTest.java +++ b/src/test/java/com/celements/web/medialib/datafields/DateTest.java @@ -25,8 +25,7 @@ public class DateTest { @Before - public void prepareTest() throws Exception { - } + public void prepareTest() throws Exception {} @Test public void testGetColumnId() { diff --git a/src/test/java/com/celements/web/medialib/datafields/DefaultTest.java b/src/test/java/com/celements/web/medialib/datafields/DefaultTest.java index cb40bd0f4..3230af253 100644 --- a/src/test/java/com/celements/web/medialib/datafields/DefaultTest.java +++ b/src/test/java/com/celements/web/medialib/datafields/DefaultTest.java @@ -25,8 +25,7 @@ public class DefaultTest { @Before - public void prepareTest() throws Exception { - } + public void prepareTest() throws Exception {} @Test public void testGetColumnId() { diff --git a/src/test/java/com/celements/web/medialib/datafields/JSONDataFieldRowTest.java b/src/test/java/com/celements/web/medialib/datafields/JSONDataFieldRowTest.java index ca00ba1d0..7fc92a2ab 100644 --- a/src/test/java/com/celements/web/medialib/datafields/JSONDataFieldRowTest.java +++ b/src/test/java/com/celements/web/medialib/datafields/JSONDataFieldRowTest.java @@ -25,8 +25,7 @@ public class JSONDataFieldRowTest { @Before - public void prepareTest() throws Exception { - } + public void prepareTest() throws Exception {} @Test public void testHasNext() { diff --git a/src/test/java/com/celements/web/medialib/datafields/NumberTest.java b/src/test/java/com/celements/web/medialib/datafields/NumberTest.java index 372b8f6e3..5a451cced 100644 --- a/src/test/java/com/celements/web/medialib/datafields/NumberTest.java +++ b/src/test/java/com/celements/web/medialib/datafields/NumberTest.java @@ -25,8 +25,7 @@ public class NumberTest { @Before - public void prepareTest() throws Exception { - } + public void prepareTest() throws Exception {} @Test public void testGetColumnId() { diff --git a/src/test/java/com/celements/web/medialib/datafields/StringTest.java b/src/test/java/com/celements/web/medialib/datafields/StringTest.java index 8476df22f..784b63b73 100644 --- a/src/test/java/com/celements/web/medialib/datafields/StringTest.java +++ b/src/test/java/com/celements/web/medialib/datafields/StringTest.java @@ -25,8 +25,7 @@ public class StringTest { @Before - public void prepareTest() throws Exception { - } + public void prepareTest() throws Exception {} @Test public void testGetColumnId() { diff --git a/src/test/java/com/celements/web/plugin/cmd/AddTranslationCommandTest.java b/src/test/java/com/celements/web/plugin/cmd/AddTranslationCommandTest.java index 2b477d7be..f52e05e85 100644 --- a/src/test/java/com/celements/web/plugin/cmd/AddTranslationCommandTest.java +++ b/src/test/java/com/celements/web/plugin/cmd/AddTranslationCommandTest.java @@ -63,8 +63,8 @@ public void testAddTranslation_noDoc() { expect(xwiki.exists(eq(docRef), same(getContext()))).andReturn(false); getContext().setWiki(xwiki); replayDefault(xwiki); - assertFalse("expecting true if translation successfully created", addTransCmd.addTranslation( - docRef, "fr")); + assertFalse("expecting true if translation successfully created", + addTransCmd.addTranslation(docRef, "fr")); verifyDefault(xwiki); } @@ -78,8 +78,8 @@ public void testAddTranslation_noDoc_deprecated() { expect(xwiki.exists(eq(docRef), same(getContext()))).andReturn(false); getContext().setWiki(xwiki); replayDefault(xwiki); - assertFalse("expecting true if translation successfully created", addTransCmd.addTranslation( - fullName, "fr", getContext())); + assertFalse("expecting true if translation successfully created", + addTransCmd.addTranslation(fullName, "fr", getContext())); verifyDefault(xwiki); } @@ -103,8 +103,8 @@ public void testAddTranslation_already_exists() throws XWikiException { expectLastCall(); getContext().setWiki(xwiki); replayDefault(xwiki, mainDoc); - assertFalse("expecting false if no new translation was created", addTransCmd.addTranslation( - docRef, "fr")); + assertFalse("expecting false if no new translation was created", + addTransCmd.addTranslation(docRef, "fr")); verifyDefault(xwiki, mainDoc); } @@ -130,8 +130,8 @@ public void testAddTranslation_already_exists_deprecated() throws XWikiException expectLastCall(); getContext().setWiki(xwiki); replayDefault(xwiki, mainDoc); - assertFalse("expecting false if no new translation was created", addTransCmd.addTranslation( - fullName, "fr", getContext())); + assertFalse("expecting false if no new translation was created", + addTransCmd.addTranslation(fullName, "fr", getContext())); verifyDefault(xwiki, mainDoc); } @@ -155,8 +155,8 @@ public void testAddTranslation_create_translation() throws XWikiException { xwiki.saveDocument(same(transDoc), same(getContext())); getContext().setWiki(xwiki); replayDefault(xwiki, mainDoc); - assertTrue("expecting true if translation successfully created", addTransCmd.addTranslation( - docRef, "fr")); + assertTrue("expecting true if translation successfully created", + addTransCmd.addTranslation(docRef, "fr")); assertEquals("expecting document language to be set.", "fr", transDoc.getLanguage()); assertEquals("expecting document default language to be untouched", "default", transDoc.getDefaultLanguage()); @@ -188,8 +188,8 @@ public void testAddTranslation_create_translation_deprecated() throws XWikiExcep xwiki.saveDocument(same(transDoc), same(getContext())); getContext().setWiki(xwiki); replayDefault(xwiki, mainDoc); - assertTrue("expecting true if translation successfully created", addTransCmd.addTranslation( - fullName, "fr", getContext())); + assertTrue("expecting true if translation successfully created", + addTransCmd.addTranslation(fullName, "fr", getContext())); assertEquals("expecting document language to be set.", "fr", transDoc.getLanguage()); assertEquals("expecting document default language to be untouched", "default", transDoc.getDefaultLanguage()); diff --git a/src/test/java/com/celements/web/plugin/cmd/AttachmentURLCommandTest.java b/src/test/java/com/celements/web/plugin/cmd/AttachmentURLCommandTest.java index d1d4239b5..cb544e647 100644 --- a/src/test/java/com/celements/web/plugin/cmd/AttachmentURLCommandTest.java +++ b/src/test/java/com/celements/web/plugin/cmd/AttachmentURLCommandTest.java @@ -54,33 +54,31 @@ public class AttachmentURLCommandTest extends AbstractComponentTest { @Before public void setUp_AttachmentURLCommandTest() throws Exception { - registerComponentMocks( - IAttachmentServiceRole.class, - UrlService.class, + registerComponentMocks(IAttachmentServiceRole.class, UrlService.class, FrontendResourceResolver.class); context = getXContext(); wiki = getMock(XWiki.class); attUrlCmd = new AttachmentURLCommand(); mockURLFactory = createDefaultMock(XWikiURLFactory.class); context.setURLFactory(mockURLFactory); - expect(wiki.getXWikiPreference(eq("celdefaultAttAction"), eq( - "celements.attachmenturl.defaultaction"), eq("file"), same(context))) - .andReturn("file").anyTimes(); + expect(wiki.getXWikiPreference(eq("celdefaultAttAction"), + eq("celements.attachmenturl.defaultaction"), eq("file"), same(context))).andReturn("file") + .anyTimes(); } @Test public void test_getAttachmentURL_fullURL() { replayDefault(); - assertEquals("http://www.bla.com/bla.txt", attUrlCmd.getAttachmentURL( - "http://www.bla.com/bla.txt", context)); + assertEquals("http://www.bla.com/bla.txt", + attUrlCmd.getAttachmentURL("http://www.bla.com/bla.txt", context)); verifyDefault(); } @Test public void test_getAttachmentURL_partURL() { replayDefault(); - assertEquals("/xwiki/bin/download/A/B/bla.txt", attUrlCmd.getAttachmentURL( - "/xwiki/bin/download/A/B/bla.txt", context)); + assertEquals("/xwiki/bin/download/A/B/bla.txt", + attUrlCmd.getAttachmentURL("/xwiki/bin/download/A/B/bla.txt", context)); verifyDefault(); } @@ -95,8 +93,8 @@ public void test_getAttachmentURL_dynamicParamURL() throws MalformedURLException URL viewURL = new URL("http://localhost/mySpace/myDoc"); expect(getMock(UrlService.class).getURL(myDocRef, "view")).andReturn(viewURL.getPath()); replayDefault(); - assertEquals("/mySpace/myDoc?xpage=bla&bli=blu", attUrlCmd.getAttachmentURL( - "?xpage=bla&bli=blu", context)); + assertEquals("/mySpace/myDoc?xpage=bla&bli=blu", + attUrlCmd.getAttachmentURL("?xpage=bla&bli=blu", context)); verifyDefault(); } @@ -110,8 +108,7 @@ public void test_getAttachmentURL_fullInternalLink() throws Exception { XWikiAttachment blaAtt = new XWikiAttachment(); blaAtt.setFilename("bla.txt"); expect(getMock(IAttachmentServiceRole.class) - .getAttachmentNameEqual(anyObject(AttachmentReference.class))) - .andReturn(blaAtt); + .getAttachmentNameEqual(anyObject(AttachmentReference.class))).andReturn(blaAtt); replayDefault(); String attachmentURL = attUrlCmd.getAttachmentURL("celements2web:A.B;bla.txt", context); verifyDefault(); @@ -127,8 +124,7 @@ public void test_getAttachmentURL_partInternalLink() throws Exception { XWikiAttachment blaAtt = new XWikiAttachment(); blaAtt.setFilename(attRef.getName()); expect(getMock(IAttachmentServiceRole.class) - .getAttachmentNameEqual(anyObject(AttachmentReference.class))) - .andReturn(blaAtt); + .getAttachmentNameEqual(anyObject(AttachmentReference.class))).andReturn(blaAtt); replayDefault(); String attachmentURL = attUrlCmd.getAttachmentURL("A.B;bla.txt", context); verifyDefault(); @@ -141,7 +137,7 @@ public void test_getAttachmentURL_partInternalLink_notExists() throws Exception new DocumentReference(context.getDatabase(), "A", "B")); expect(getMock(IAttachmentServiceRole.class) .getAttachmentNameEqual(anyObject(AttachmentReference.class))) - .andThrow(new AttachmentNotExistsException(attRef)); + .andThrow(new AttachmentNotExistsException(attRef)); replayDefault(); assertNull(attUrlCmd.getAttachmentURL("A.B;bla.txt", context)); verifyDefault(); @@ -152,10 +148,9 @@ public void test_getAttachmentURL_onDiskLink() { var input = ":celJS/bla.js"; String resultURL = "/appname/skin/resources/celJS/bla.js"; expect(wiki.getSkinFile(eq("celJS/bla.js"), eq(true), same(context))).andReturn(resultURL); - expect(wiki.getResourceLastModificationDate(eq("resources/celJS/bla.js"))).andReturn( - new Date()); - expect(getMock(FrontendResourceResolver.class).get(eq(input))) - .andReturn(Optional.empty()); + expect(wiki.getResourceLastModificationDate(eq("resources/celJS/bla.js"))) + .andReturn(new Date()); + expect(getMock(FrontendResourceResolver.class).get(eq(input))).andReturn(Optional.empty()); replayDefault(); String attachmentURL = attUrlCmd.getAttachmentURL(input, context); String expectedURL = "/appname/file/resources/celJS/bla.js"; @@ -182,8 +177,8 @@ public void test_getAttachmentURL_query() { String url = "http://www.bla.com/bla.mjs"; String query = "version=1234"; replayDefault(); - assertEquals(url + "?" + query, attUrlCmd.getAttachmentURL(url, "file", query) - .get().toUriString()); + assertEquals(url + "?" + query, + attUrlCmd.getAttachmentURL(url, "file", query).get().toUriString()); verifyDefault(); } @@ -248,8 +243,8 @@ public void testIsOnDiskLink_false() { @Test public void test_getAttachmentURLPrefix() throws Exception { - expect(mockURLFactory.createResourceURL(eq(""), eq(true), same(context))).andReturn(new URL( - "http://test.fabian.dev:10080/skin/resources/")); + expect(mockURLFactory.createResourceURL(eq(""), eq(true), same(context))) + .andReturn(new URL("http://test.fabian.dev:10080/skin/resources/")); replayDefault(); assertEquals("http://test.fabian.dev:10080/file/resources/", attUrlCmd.getAttachmentURLPrefix()); diff --git a/src/test/java/com/celements/web/plugin/cmd/CelMailConfigurationTest.java b/src/test/java/com/celements/web/plugin/cmd/CelMailConfigurationTest.java index d42c51a8a..573c81337 100644 --- a/src/test/java/com/celements/web/plugin/cmd/CelMailConfigurationTest.java +++ b/src/test/java/com/celements/web/plugin/cmd/CelMailConfigurationTest.java @@ -53,9 +53,9 @@ public void testGetHost_internal_default() { @Test public void testGetDefaultAdminSenderAddress() { - expect(xwiki.getXWikiPreference(eq("admin_email"), eq( - CelMailConfiguration.MAIL_DEFAULT_ADMIN_EMAIL_KEY), eq(""), same(context))).andReturn( - "test@unit.test"); + expect(xwiki.getXWikiPreference(eq("admin_email"), + eq(CelMailConfiguration.MAIL_DEFAULT_ADMIN_EMAIL_KEY), eq(""), same(context))) + .andReturn("test@unit.test"); replayDefault(); assertEquals("test@unit.test", celMailConfiguration.getDefaultAdminSenderAddress()); verifyDefault(); @@ -63,9 +63,9 @@ public void testGetDefaultAdminSenderAddress() { @Test public void testGetDefaultGeneralSenderAddress() { - expect(xwiki.getXWikiPreference(eq("smtp_from"), eq( - CelMailConfiguration.MAIL_DEFAULT_SMTP_FROM_KEY), eq(""), same(context))).andReturn( - "test@unit.test"); + expect(xwiki.getXWikiPreference(eq("smtp_from"), + eq(CelMailConfiguration.MAIL_DEFAULT_SMTP_FROM_KEY), eq(""), same(context))) + .andReturn("test@unit.test"); replayDefault(); assertEquals("test@unit.test", celMailConfiguration.getDefaultGeneralSenderAddress()); verifyDefault(); @@ -73,9 +73,9 @@ public void testGetDefaultGeneralSenderAddress() { @Test public void testGetFrom() { - expect(xwiki.getXWikiPreference(eq("smtp_from"), eq( - CelMailConfiguration.MAIL_DEFAULT_SMTP_FROM_KEY), eq(""), same(context))).andReturn( - "test@unit.test").once(); + expect(xwiki.getXWikiPreference(eq("smtp_from"), + eq(CelMailConfiguration.MAIL_DEFAULT_SMTP_FROM_KEY), eq(""), same(context))) + .andReturn("test@unit.test").once(); replayDefault(); assertEquals("test@unit.test", celMailConfiguration.getFrom()); assertEquals("multiple reads must not lead to multiple config reads.", "test@unit.test", @@ -85,9 +85,9 @@ public void testGetFrom() { @Test public void testGetFrom_setBackToEmpty() { - expect(xwiki.getXWikiPreference(eq("smtp_from"), eq( - CelMailConfiguration.MAIL_DEFAULT_SMTP_FROM_KEY), eq(""), same(context))).andReturn( - "test@unit.test").times(2); + expect(xwiki.getXWikiPreference(eq("smtp_from"), + eq(CelMailConfiguration.MAIL_DEFAULT_SMTP_FROM_KEY), eq(""), same(context))) + .andReturn("test@unit.test").times(2); replayDefault(); assertEquals("test@unit.test", celMailConfiguration.getFrom()); celMailConfiguration.setFrom(""); @@ -98,9 +98,9 @@ public void testGetFrom_setBackToEmpty() { @Test public void testGetFrom_overwrittenBy_setFrom() { - expect(xwiki.getXWikiPreference(eq("smtp_from"), eq( - CelMailConfiguration.MAIL_DEFAULT_SMTP_FROM_KEY), eq(""), same(context))).andReturn( - "test@unit.test").anyTimes(); + expect(xwiki.getXWikiPreference(eq("smtp_from"), + eq(CelMailConfiguration.MAIL_DEFAULT_SMTP_FROM_KEY), eq(""), same(context))) + .andReturn("test@unit.test").anyTimes(); replayDefault(); celMailConfiguration.setFrom("myTest@specialUnit.test"); assertEquals("myTest@specialUnit.test", celMailConfiguration.getFrom()); @@ -109,12 +109,12 @@ public void testGetFrom_overwrittenBy_setFrom() { @Test public void testGetFrom_fallbackToAdminEmailAdress() { - expect(xwiki.getXWikiPreference(eq("smtp_from"), eq( - CelMailConfiguration.MAIL_DEFAULT_SMTP_FROM_KEY), eq(""), same(context))).andReturn( - "").once(); - expect(xwiki.getXWikiPreference(eq("admin_email"), eq( - CelMailConfiguration.MAIL_DEFAULT_ADMIN_EMAIL_KEY), eq(""), same(context))).andReturn( - "test@unit.test").once(); + expect(xwiki.getXWikiPreference(eq("smtp_from"), + eq(CelMailConfiguration.MAIL_DEFAULT_SMTP_FROM_KEY), eq(""), same(context))).andReturn("") + .once(); + expect(xwiki.getXWikiPreference(eq("admin_email"), + eq(CelMailConfiguration.MAIL_DEFAULT_ADMIN_EMAIL_KEY), eq(""), same(context))) + .andReturn("test@unit.test").once(); replayDefault(); assertEquals("test@unit.test", celMailConfiguration.getFrom()); assertEquals("multiple reads must not lead to multiple config reads.", "test@unit.test", @@ -216,16 +216,16 @@ public void testSetExtraProperties() { @Test public void testReadServerDefaultHostConfiguration() { - expect(xwiki.Param(eq("celements.mail.default.smtp_server"), eq(""))).andReturn( - "smtp.unit.test").anyTimes(); - expect(xwiki.ParamAsLong(eq("celements.mail.default.smtp_port"), eq(-1L))).andReturn( - 567L).anyTimes(); - expect(xwiki.Param(eq("celements.mail.default.javamail_extra_props"), eq(""))).andReturn( - "testProp=testValue,prop2=value2").anyTimes(); - expect(xwiki.Param(eq("celements.mail.default.smtp_server_password"), eq(""))).andReturn( - "myServerPassword").anyTimes(); - expect(xwiki.Param(eq("celements.mail.default.smtp_server_username"), eq(""))).andReturn( - "mySmtpUserName").anyTimes(); + expect(xwiki.Param(eq("celements.mail.default.smtp_server"), eq(""))) + .andReturn("smtp.unit.test").anyTimes(); + expect(xwiki.ParamAsLong(eq("celements.mail.default.smtp_port"), eq(-1L))).andReturn(567L) + .anyTimes(); + expect(xwiki.Param(eq("celements.mail.default.javamail_extra_props"), eq(""))) + .andReturn("testProp=testValue,prop2=value2").anyTimes(); + expect(xwiki.Param(eq("celements.mail.default.smtp_server_password"), eq(""))) + .andReturn("myServerPassword").anyTimes(); + expect(xwiki.Param(eq("celements.mail.default.smtp_server_username"), eq(""))) + .andReturn("mySmtpUserName").anyTimes(); replayDefault(); celMailConfiguration.readServerDefaultHostConfiguration(); assertEquals("mySmtpUserName", celMailConfiguration.getSmtpUsername_internal()); @@ -242,24 +242,24 @@ public void testReadServerDefaultHostConfiguration() { @Test public void testGetSmtpUsername_fallbackToDefault_completeConfig() { expect(xwiki.getXWikiPreference(eq("smtp_server"), same(context))).andReturn("").anyTimes(); - expect(xwiki.getXWikiPreferenceAsInt(eq("smtp_port"), eq(-1), same(context))).andReturn( - -1).anyTimes(); - expect(xwiki.getXWikiPreference(eq("javamail_extra_props"), same(context))).andReturn( - "").anyTimes(); - expect(xwiki.getXWikiPreference(eq("smtp_server_password"), same(context))).andReturn( - "").anyTimes(); - expect(xwiki.getXWikiPreference(eq("smtp_server_username"), same(context))).andReturn( - "").anyTimes(); - expect(xwiki.Param(eq("celements.mail.default.smtp_server"), eq(""))).andReturn( - "smtp.unit.test").once(); - expect(xwiki.ParamAsLong(eq("celements.mail.default.smtp_port"), eq(-1L))).andReturn( - 567L).once(); - expect(xwiki.Param(eq("celements.mail.default.javamail_extra_props"), eq(""))).andReturn( - "testProp=testValue,prop2=value2").once(); - expect(xwiki.Param(eq("celements.mail.default.smtp_server_password"), eq(""))).andReturn( - "myServerPassword").once(); - expect(xwiki.Param(eq("celements.mail.default.smtp_server_username"), eq(""))).andReturn( - "mySmtpUserName").once(); + expect(xwiki.getXWikiPreferenceAsInt(eq("smtp_port"), eq(-1), same(context))).andReturn(-1) + .anyTimes(); + expect(xwiki.getXWikiPreference(eq("javamail_extra_props"), same(context))).andReturn("") + .anyTimes(); + expect(xwiki.getXWikiPreference(eq("smtp_server_password"), same(context))).andReturn("") + .anyTimes(); + expect(xwiki.getXWikiPreference(eq("smtp_server_username"), same(context))).andReturn("") + .anyTimes(); + expect(xwiki.Param(eq("celements.mail.default.smtp_server"), eq(""))) + .andReturn("smtp.unit.test").once(); + expect(xwiki.ParamAsLong(eq("celements.mail.default.smtp_port"), eq(-1L))).andReturn(567L) + .once(); + expect(xwiki.Param(eq("celements.mail.default.javamail_extra_props"), eq(""))) + .andReturn("testProp=testValue,prop2=value2").once(); + expect(xwiki.Param(eq("celements.mail.default.smtp_server_password"), eq(""))) + .andReturn("myServerPassword").once(); + expect(xwiki.Param(eq("celements.mail.default.smtp_server_username"), eq(""))) + .andReturn("mySmtpUserName").once(); replayDefault(); assertEquals("mySmtpUserName", celMailConfiguration.getSmtpUsername()); assertEquals("myServerPassword", celMailConfiguration.getSmtpPassword()); @@ -275,24 +275,24 @@ public void testGetSmtpUsername_fallbackToDefault_completeConfig() { @Test public void testGetSmtpUsername_fallbackToDefault_onlyUsername() { expect(xwiki.getXWikiPreference(eq("smtp_server"), same(context))).andReturn("").once(); - expect(xwiki.getXWikiPreferenceAsInt(eq("smtp_port"), eq(-1), same(context))).andReturn( - -1).once(); - expect(xwiki.getXWikiPreference(eq("javamail_extra_props"), same(context))).andReturn( - "").once(); - expect(xwiki.getXWikiPreference(eq("smtp_server_password"), same(context))).andReturn( - "").once(); - expect(xwiki.getXWikiPreference(eq("smtp_server_username"), same(context))).andReturn( - "myLocalUsername").once(); - expect(xwiki.Param(eq("celements.mail.default.smtp_server"), eq(""))).andReturn( - "smtp.unit.test").once(); - expect(xwiki.ParamAsLong(eq("celements.mail.default.smtp_port"), eq(-1L))).andReturn( - 567L).once(); - expect(xwiki.Param(eq("celements.mail.default.javamail_extra_props"), eq(""))).andReturn( - "testProp=testValue,prop2=value2").once(); - expect(xwiki.Param(eq("celements.mail.default.smtp_server_password"), eq(""))).andReturn( - "myServerPassword").once(); - expect(xwiki.Param(eq("celements.mail.default.smtp_server_username"), eq(""))).andReturn( - "mySmtpUserName").once(); + expect(xwiki.getXWikiPreferenceAsInt(eq("smtp_port"), eq(-1), same(context))).andReturn(-1) + .once(); + expect(xwiki.getXWikiPreference(eq("javamail_extra_props"), same(context))).andReturn("") + .once(); + expect(xwiki.getXWikiPreference(eq("smtp_server_password"), same(context))).andReturn("") + .once(); + expect(xwiki.getXWikiPreference(eq("smtp_server_username"), same(context))) + .andReturn("myLocalUsername").once(); + expect(xwiki.Param(eq("celements.mail.default.smtp_server"), eq(""))) + .andReturn("smtp.unit.test").once(); + expect(xwiki.ParamAsLong(eq("celements.mail.default.smtp_port"), eq(-1L))).andReturn(567L) + .once(); + expect(xwiki.Param(eq("celements.mail.default.javamail_extra_props"), eq(""))) + .andReturn("testProp=testValue,prop2=value2").once(); + expect(xwiki.Param(eq("celements.mail.default.smtp_server_password"), eq(""))) + .andReturn("myServerPassword").once(); + expect(xwiki.Param(eq("celements.mail.default.smtp_server_username"), eq(""))) + .andReturn("mySmtpUserName").once(); replayDefault(); assertEquals("mySmtpUserName", celMailConfiguration.getSmtpUsername()); assertEquals("myServerPassword", celMailConfiguration.getSmtpPassword()); @@ -308,24 +308,24 @@ public void testGetSmtpUsername_fallbackToDefault_onlyUsername() { @Test public void testGetSmtpUsername_fallbackToDefault_onlyPassword() { expect(xwiki.getXWikiPreference(eq("smtp_server"), same(context))).andReturn("").once(); - expect(xwiki.getXWikiPreferenceAsInt(eq("smtp_port"), eq(-1), same(context))).andReturn( - -1).once(); - expect(xwiki.getXWikiPreference(eq("javamail_extra_props"), same(context))).andReturn( - "").once(); - expect(xwiki.getXWikiPreference(eq("smtp_server_password"), same(context))).andReturn( - "myLocalPassword").once(); - expect(xwiki.getXWikiPreference(eq("smtp_server_username"), same(context))).andReturn( - "").once(); - expect(xwiki.Param(eq("celements.mail.default.smtp_server"), eq(""))).andReturn( - "smtp.unit.test").once(); - expect(xwiki.ParamAsLong(eq("celements.mail.default.smtp_port"), eq(-1L))).andReturn( - 567L).once(); - expect(xwiki.Param(eq("celements.mail.default.javamail_extra_props"), eq(""))).andReturn( - "testProp=testValue,prop2=value2").once(); - expect(xwiki.Param(eq("celements.mail.default.smtp_server_password"), eq(""))).andReturn( - "myServerPassword").once(); - expect(xwiki.Param(eq("celements.mail.default.smtp_server_username"), eq(""))).andReturn( - "mySmtpUserName").once(); + expect(xwiki.getXWikiPreferenceAsInt(eq("smtp_port"), eq(-1), same(context))).andReturn(-1) + .once(); + expect(xwiki.getXWikiPreference(eq("javamail_extra_props"), same(context))).andReturn("") + .once(); + expect(xwiki.getXWikiPreference(eq("smtp_server_password"), same(context))) + .andReturn("myLocalPassword").once(); + expect(xwiki.getXWikiPreference(eq("smtp_server_username"), same(context))).andReturn("") + .once(); + expect(xwiki.Param(eq("celements.mail.default.smtp_server"), eq(""))) + .andReturn("smtp.unit.test").once(); + expect(xwiki.ParamAsLong(eq("celements.mail.default.smtp_port"), eq(-1L))).andReturn(567L) + .once(); + expect(xwiki.Param(eq("celements.mail.default.javamail_extra_props"), eq(""))) + .andReturn("testProp=testValue,prop2=value2").once(); + expect(xwiki.Param(eq("celements.mail.default.smtp_server_password"), eq(""))) + .andReturn("myServerPassword").once(); + expect(xwiki.Param(eq("celements.mail.default.smtp_server_username"), eq(""))) + .andReturn("mySmtpUserName").once(); replayDefault(); assertEquals("mySmtpUserName", celMailConfiguration.getSmtpUsername()); assertEquals("myServerPassword", celMailConfiguration.getSmtpPassword()); @@ -340,26 +340,26 @@ public void testGetSmtpUsername_fallbackToDefault_onlyPassword() { @Test public void testGetSmtpUsername_localHost() { - expect(xwiki.getXWikiPreference(eq("smtp_server"), same(context))).andReturn( - "myLocalHost").once(); - expect(xwiki.getXWikiPreferenceAsInt(eq("smtp_port"), eq(-1), same(context))).andReturn( - -1).once(); - expect(xwiki.getXWikiPreference(eq("javamail_extra_props"), same(context))).andReturn( - "").once(); - expect(xwiki.getXWikiPreference(eq("smtp_server_password"), same(context))).andReturn( - "").once(); - expect(xwiki.getXWikiPreference(eq("smtp_server_username"), same(context))).andReturn( - "").once(); - expect(xwiki.Param(eq("celements.mail.default.smtp_server"), eq(""))).andReturn( - "smtp.unit.test").anyTimes(); - expect(xwiki.ParamAsLong(eq("celements.mail.default.smtp_port"), eq(-1L))).andReturn( - 567L).anyTimes(); - expect(xwiki.Param(eq("celements.mail.default.javamail_extra_props"), eq(""))).andReturn( - "testProp=testValue,prop2=value2").anyTimes(); - expect(xwiki.Param(eq("celements.mail.default.smtp_server_password"), eq(""))).andReturn( - "myServerPassword").anyTimes(); - expect(xwiki.Param(eq("celements.mail.default.smtp_server_username"), eq(""))).andReturn( - "mySmtpUserName").anyTimes(); + expect(xwiki.getXWikiPreference(eq("smtp_server"), same(context))).andReturn("myLocalHost") + .once(); + expect(xwiki.getXWikiPreferenceAsInt(eq("smtp_port"), eq(-1), same(context))).andReturn(-1) + .once(); + expect(xwiki.getXWikiPreference(eq("javamail_extra_props"), same(context))).andReturn("") + .once(); + expect(xwiki.getXWikiPreference(eq("smtp_server_password"), same(context))).andReturn("") + .once(); + expect(xwiki.getXWikiPreference(eq("smtp_server_username"), same(context))).andReturn("") + .once(); + expect(xwiki.Param(eq("celements.mail.default.smtp_server"), eq(""))) + .andReturn("smtp.unit.test").anyTimes(); + expect(xwiki.ParamAsLong(eq("celements.mail.default.smtp_port"), eq(-1L))).andReturn(567L) + .anyTimes(); + expect(xwiki.Param(eq("celements.mail.default.javamail_extra_props"), eq(""))) + .andReturn("testProp=testValue,prop2=value2").anyTimes(); + expect(xwiki.Param(eq("celements.mail.default.smtp_server_password"), eq(""))) + .andReturn("myServerPassword").anyTimes(); + expect(xwiki.Param(eq("celements.mail.default.smtp_server_username"), eq(""))) + .andReturn("mySmtpUserName").anyTimes(); replayDefault(); assertNull(celMailConfiguration.getSmtpUsername()); assertNull(celMailConfiguration.getSmtpPassword()); @@ -374,24 +374,24 @@ public void testGetSmtpUsername_localHost() { @Test public void testGetSmtpUsername_localPort() { expect(xwiki.getXWikiPreference(eq("smtp_server"), same(context))).andReturn("").once(); - expect(xwiki.getXWikiPreferenceAsInt(eq("smtp_port"), eq(-1), same(context))).andReturn( - 567).once(); - expect(xwiki.getXWikiPreference(eq("javamail_extra_props"), same(context))).andReturn( - "").once(); - expect(xwiki.getXWikiPreference(eq("smtp_server_password"), same(context))).andReturn( - "").once(); - expect(xwiki.getXWikiPreference(eq("smtp_server_username"), same(context))).andReturn( - "").once(); - expect(xwiki.Param(eq("celements.mail.default.smtp_server"), eq(""))).andReturn( - "smtp.unit.test").anyTimes(); - expect(xwiki.ParamAsLong(eq("celements.mail.default.smtp_port"), eq(-1L))).andReturn( - 567L).anyTimes(); - expect(xwiki.Param(eq("celements.mail.default.javamail_extra_props"), eq(""))).andReturn( - "testProp=testValue,prop2=value2").anyTimes(); - expect(xwiki.Param(eq("celements.mail.default.smtp_server_password"), eq(""))).andReturn( - "myServerPassword").anyTimes(); - expect(xwiki.Param(eq("celements.mail.default.smtp_server_username"), eq(""))).andReturn( - "mySmtpUserName").anyTimes(); + expect(xwiki.getXWikiPreferenceAsInt(eq("smtp_port"), eq(-1), same(context))).andReturn(567) + .once(); + expect(xwiki.getXWikiPreference(eq("javamail_extra_props"), same(context))).andReturn("") + .once(); + expect(xwiki.getXWikiPreference(eq("smtp_server_password"), same(context))).andReturn("") + .once(); + expect(xwiki.getXWikiPreference(eq("smtp_server_username"), same(context))).andReturn("") + .once(); + expect(xwiki.Param(eq("celements.mail.default.smtp_server"), eq(""))) + .andReturn("smtp.unit.test").anyTimes(); + expect(xwiki.ParamAsLong(eq("celements.mail.default.smtp_port"), eq(-1L))).andReturn(567L) + .anyTimes(); + expect(xwiki.Param(eq("celements.mail.default.javamail_extra_props"), eq(""))) + .andReturn("testProp=testValue,prop2=value2").anyTimes(); + expect(xwiki.Param(eq("celements.mail.default.smtp_server_password"), eq(""))) + .andReturn("myServerPassword").anyTimes(); + expect(xwiki.Param(eq("celements.mail.default.smtp_server_username"), eq(""))) + .andReturn("mySmtpUserName").anyTimes(); replayDefault(); assertNull(celMailConfiguration.getSmtpUsername()); assertNull(celMailConfiguration.getSmtpPassword()); @@ -406,24 +406,24 @@ public void testGetSmtpUsername_localPort() { @Test public void testGetSmtpUsername_localExtraProps() { expect(xwiki.getXWikiPreference(eq("smtp_server"), same(context))).andReturn("").once(); - expect(xwiki.getXWikiPreferenceAsInt(eq("smtp_port"), eq(-1), same(context))).andReturn( - -1).once(); - expect(xwiki.getXWikiPreference(eq("javamail_extra_props"), same(context))).andReturn( - "testLocalProp=testLocalValue,localProp2=valueLocal2").once(); - expect(xwiki.getXWikiPreference(eq("smtp_server_password"), same(context))).andReturn( - "").once(); - expect(xwiki.getXWikiPreference(eq("smtp_server_username"), same(context))).andReturn( - "").once(); - expect(xwiki.Param(eq("celements.mail.default.smtp_server"), eq(""))).andReturn( - "smtp.unit.test").anyTimes(); - expect(xwiki.ParamAsLong(eq("celements.mail.default.smtp_port"), eq(-1L))).andReturn( - 567L).anyTimes(); - expect(xwiki.Param(eq("celements.mail.default.javamail_extra_props"), eq(""))).andReturn( - "testProp=testValue,prop2=value2").anyTimes(); - expect(xwiki.Param(eq("celements.mail.default.smtp_server_password"), eq(""))).andReturn( - "myServerPassword").anyTimes(); - expect(xwiki.Param(eq("celements.mail.default.smtp_server_username"), eq(""))).andReturn( - "mySmtpUserName").anyTimes(); + expect(xwiki.getXWikiPreferenceAsInt(eq("smtp_port"), eq(-1), same(context))).andReturn(-1) + .once(); + expect(xwiki.getXWikiPreference(eq("javamail_extra_props"), same(context))) + .andReturn("testLocalProp=testLocalValue,localProp2=valueLocal2").once(); + expect(xwiki.getXWikiPreference(eq("smtp_server_password"), same(context))).andReturn("") + .once(); + expect(xwiki.getXWikiPreference(eq("smtp_server_username"), same(context))).andReturn("") + .once(); + expect(xwiki.Param(eq("celements.mail.default.smtp_server"), eq(""))) + .andReturn("smtp.unit.test").anyTimes(); + expect(xwiki.ParamAsLong(eq("celements.mail.default.smtp_port"), eq(-1L))).andReturn(567L) + .anyTimes(); + expect(xwiki.Param(eq("celements.mail.default.javamail_extra_props"), eq(""))) + .andReturn("testProp=testValue,prop2=value2").anyTimes(); + expect(xwiki.Param(eq("celements.mail.default.smtp_server_password"), eq(""))) + .andReturn("myServerPassword").anyTimes(); + expect(xwiki.Param(eq("celements.mail.default.smtp_server_username"), eq(""))) + .andReturn("mySmtpUserName").anyTimes(); replayDefault(); assertNull(celMailConfiguration.getSmtpUsername()); assertNull(celMailConfiguration.getSmtpPassword()); @@ -441,24 +441,24 @@ public void testGetSmtpUsername_localExtraProps() { @Test public void testGetSmtpUsername_localUsernameAndPassword() { expect(xwiki.getXWikiPreference(eq("smtp_server"), same(context))).andReturn("").once(); - expect(xwiki.getXWikiPreferenceAsInt(eq("smtp_port"), eq(-1), same(context))).andReturn( - -1).once(); - expect(xwiki.getXWikiPreference(eq("javamail_extra_props"), same(context))).andReturn( - "").once(); - expect(xwiki.getXWikiPreference(eq("smtp_server_password"), same(context))).andReturn( - "myLocalPassword").once(); - expect(xwiki.getXWikiPreference(eq("smtp_server_username"), same(context))).andReturn( - "myLocalUsername").once(); - expect(xwiki.Param(eq("celements.mail.default.smtp_server"), eq(""))).andReturn( - "smtp.unit.test").anyTimes(); - expect(xwiki.ParamAsLong(eq("celements.mail.default.smtp_port"), eq(-1L))).andReturn( - 567L).anyTimes(); - expect(xwiki.Param(eq("celements.mail.default.javamail_extra_props"), eq(""))).andReturn( - "testProp=testValue,prop2=value2").anyTimes(); - expect(xwiki.Param(eq("celements.mail.default.smtp_server_password"), eq(""))).andReturn( - "myServerPassword").anyTimes(); - expect(xwiki.Param(eq("celements.mail.default.smtp_server_username"), eq(""))).andReturn( - "mySmtpUserName").anyTimes(); + expect(xwiki.getXWikiPreferenceAsInt(eq("smtp_port"), eq(-1), same(context))).andReturn(-1) + .once(); + expect(xwiki.getXWikiPreference(eq("javamail_extra_props"), same(context))).andReturn("") + .once(); + expect(xwiki.getXWikiPreference(eq("smtp_server_password"), same(context))) + .andReturn("myLocalPassword").once(); + expect(xwiki.getXWikiPreference(eq("smtp_server_username"), same(context))) + .andReturn("myLocalUsername").once(); + expect(xwiki.Param(eq("celements.mail.default.smtp_server"), eq(""))) + .andReturn("smtp.unit.test").anyTimes(); + expect(xwiki.ParamAsLong(eq("celements.mail.default.smtp_port"), eq(-1L))).andReturn(567L) + .anyTimes(); + expect(xwiki.Param(eq("celements.mail.default.javamail_extra_props"), eq(""))) + .andReturn("testProp=testValue,prop2=value2").anyTimes(); + expect(xwiki.Param(eq("celements.mail.default.smtp_server_password"), eq(""))) + .andReturn("myServerPassword").anyTimes(); + expect(xwiki.Param(eq("celements.mail.default.smtp_server_username"), eq(""))) + .andReturn("mySmtpUserName").anyTimes(); replayDefault(); assertEquals("myLocalUsername", celMailConfiguration.getSmtpUsername()); assertEquals("myLocalPassword", celMailConfiguration.getSmtpPassword()); @@ -474,22 +474,22 @@ public void testGetSmtpUsername_localUsernameAndPassword() { public void testGetSmtpUsername_fallbackToDefault_onlyUsername_NoPassword() { expect(xwiki.getXWikiPreference(eq("smtp_server"), same(context))).andReturn("").anyTimes(); expect(xwiki.Param(eq("celements.mail.default.smtp_server"), eq(""))).andReturn("").anyTimes(); - expect(xwiki.getXWikiPreferenceAsInt(eq("smtp_port"), eq(-1), same(context))).andReturn( - -1).anyTimes(); - expect(xwiki.ParamAsLong(eq("celements.mail.default.smtp_port"), eq(-1L))).andReturn( - -1L).anyTimes(); - expect(xwiki.getXWikiPreference(eq("javamail_extra_props"), same(context))).andReturn( - "").anyTimes(); - expect(xwiki.Param(eq("celements.mail.default.javamail_extra_props"), eq(""))).andReturn( - "").anyTimes(); - expect(xwiki.getXWikiPreference(eq("smtp_server_password"), same(context))).andReturn( - "").anyTimes(); - expect(xwiki.Param(eq("celements.mail.default.smtp_server_password"), eq(""))).andReturn( - "").anyTimes(); - expect(xwiki.getXWikiPreference(eq("smtp_server_username"), same(context))).andReturn( - "").anyTimes(); - expect(xwiki.Param(eq("celements.mail.default.smtp_server_username"), eq(""))).andReturn( - "mySmtpAuthUserName").atLeastOnce(); + expect(xwiki.getXWikiPreferenceAsInt(eq("smtp_port"), eq(-1), same(context))).andReturn(-1) + .anyTimes(); + expect(xwiki.ParamAsLong(eq("celements.mail.default.smtp_port"), eq(-1L))).andReturn(-1L) + .anyTimes(); + expect(xwiki.getXWikiPreference(eq("javamail_extra_props"), same(context))).andReturn("") + .anyTimes(); + expect(xwiki.Param(eq("celements.mail.default.javamail_extra_props"), eq(""))).andReturn("") + .anyTimes(); + expect(xwiki.getXWikiPreference(eq("smtp_server_password"), same(context))).andReturn("") + .anyTimes(); + expect(xwiki.Param(eq("celements.mail.default.smtp_server_password"), eq(""))).andReturn("") + .anyTimes(); + expect(xwiki.getXWikiPreference(eq("smtp_server_username"), same(context))).andReturn("") + .anyTimes(); + expect(xwiki.Param(eq("celements.mail.default.smtp_server_username"), eq(""))) + .andReturn("mySmtpAuthUserName").atLeastOnce(); replayDefault(); assertNull(celMailConfiguration.getSmtpUsername()); verifyDefault(); @@ -499,22 +499,22 @@ public void testGetSmtpUsername_fallbackToDefault_onlyUsername_NoPassword() { public void testGetSmtpUsername_fallbackToDefault_usernameAndPassword() { expect(xwiki.getXWikiPreference(eq("smtp_server"), same(context))).andReturn("").anyTimes(); expect(xwiki.Param(eq("celements.mail.default.smtp_server"), eq(""))).andReturn("").anyTimes(); - expect(xwiki.getXWikiPreferenceAsInt(eq("smtp_port"), eq(-1), same(context))).andReturn( - -1).anyTimes(); - expect(xwiki.ParamAsLong(eq("celements.mail.default.smtp_port"), eq(-1L))).andReturn( - -1L).anyTimes(); - expect(xwiki.getXWikiPreference(eq("javamail_extra_props"), same(context))).andReturn( - "").anyTimes(); - expect(xwiki.Param(eq("celements.mail.default.javamail_extra_props"), eq(""))).andReturn( - "").anyTimes(); - expect(xwiki.getXWikiPreference(eq("smtp_server_password"), same(context))).andReturn( - "").anyTimes(); - expect(xwiki.Param(eq("celements.mail.default.smtp_server_password"), eq(""))).andReturn( - "myNotSecurePassword").once(); - expect(xwiki.getXWikiPreference(eq("smtp_server_username"), same(context))).andReturn( - "").anyTimes(); - expect(xwiki.Param(eq("celements.mail.default.smtp_server_username"), eq(""))).andReturn( - "mySmtpAuthUserName").once(); + expect(xwiki.getXWikiPreferenceAsInt(eq("smtp_port"), eq(-1), same(context))).andReturn(-1) + .anyTimes(); + expect(xwiki.ParamAsLong(eq("celements.mail.default.smtp_port"), eq(-1L))).andReturn(-1L) + .anyTimes(); + expect(xwiki.getXWikiPreference(eq("javamail_extra_props"), same(context))).andReturn("") + .anyTimes(); + expect(xwiki.Param(eq("celements.mail.default.javamail_extra_props"), eq(""))).andReturn("") + .anyTimes(); + expect(xwiki.getXWikiPreference(eq("smtp_server_password"), same(context))).andReturn("") + .anyTimes(); + expect(xwiki.Param(eq("celements.mail.default.smtp_server_password"), eq(""))) + .andReturn("myNotSecurePassword").once(); + expect(xwiki.getXWikiPreference(eq("smtp_server_username"), same(context))).andReturn("") + .anyTimes(); + expect(xwiki.Param(eq("celements.mail.default.smtp_server_username"), eq(""))) + .andReturn("mySmtpAuthUserName").once(); replayDefault(); assertEquals("mySmtpAuthUserName", celMailConfiguration.getSmtpUsername()); assertTrue("after setting server_username usesAuthentication_localConfig must be" + " true.", @@ -532,22 +532,22 @@ public void testGetSmtpUsername_fallbackToDefault_usernameAndPassword() { public void testGetSmtpPassword_fallbackToDefault_usernameAndPassword() { expect(xwiki.getXWikiPreference(eq("smtp_server"), same(context))).andReturn("").anyTimes(); expect(xwiki.Param(eq("celements.mail.default.smtp_server"), eq(""))).andReturn("").anyTimes(); - expect(xwiki.getXWikiPreferenceAsInt(eq("smtp_port"), eq(-1), same(context))).andReturn( - -1).anyTimes(); - expect(xwiki.ParamAsLong(eq("celements.mail.default.smtp_port"), eq(-1L))).andReturn( - -1L).anyTimes(); - expect(xwiki.getXWikiPreference(eq("javamail_extra_props"), same(context))).andReturn( - "").anyTimes(); - expect(xwiki.Param(eq("celements.mail.default.javamail_extra_props"), eq(""))).andReturn( - "").anyTimes(); - expect(xwiki.getXWikiPreference(eq("smtp_server_password"), same(context))).andReturn( - "").anyTimes(); - expect(xwiki.Param(eq("celements.mail.default.smtp_server_password"), eq(""))).andReturn( - "myNotSecurePassword").once(); - expect(xwiki.getXWikiPreference(eq("smtp_server_username"), same(context))).andReturn( - "").anyTimes(); - expect(xwiki.Param(eq("celements.mail.default.smtp_server_username"), eq(""))).andReturn( - "mySmtpAuthUserName").once(); + expect(xwiki.getXWikiPreferenceAsInt(eq("smtp_port"), eq(-1), same(context))).andReturn(-1) + .anyTimes(); + expect(xwiki.ParamAsLong(eq("celements.mail.default.smtp_port"), eq(-1L))).andReturn(-1L) + .anyTimes(); + expect(xwiki.getXWikiPreference(eq("javamail_extra_props"), same(context))).andReturn("") + .anyTimes(); + expect(xwiki.Param(eq("celements.mail.default.javamail_extra_props"), eq(""))).andReturn("") + .anyTimes(); + expect(xwiki.getXWikiPreference(eq("smtp_server_password"), same(context))).andReturn("") + .anyTimes(); + expect(xwiki.Param(eq("celements.mail.default.smtp_server_password"), eq(""))) + .andReturn("myNotSecurePassword").once(); + expect(xwiki.getXWikiPreference(eq("smtp_server_username"), same(context))).andReturn("") + .anyTimes(); + expect(xwiki.Param(eq("celements.mail.default.smtp_server_username"), eq(""))) + .andReturn("mySmtpAuthUserName").once(); replayDefault(); assertEquals("myNotSecurePassword", celMailConfiguration.getSmtpPassword()); assertTrue("after setting server_username usesAuthentication_localConfig must be" + " true.", @@ -565,50 +565,51 @@ public void testGetSmtpPassword_fallbackToDefault_usernameAndPassword() { public void testGetSmtpPassword_fallbackToDefault_only_password_NoUsername() { expect(xwiki.getXWikiPreference(eq("smtp_server"), same(context))).andReturn("").anyTimes(); expect(xwiki.Param(eq("celements.mail.default.smtp_server"), eq(""))).andReturn("").anyTimes(); - expect(xwiki.getXWikiPreferenceAsInt(eq("smtp_port"), eq(-1), same(context))).andReturn( - -1).anyTimes(); - expect(xwiki.ParamAsLong(eq("celements.mail.default.smtp_port"), eq(-1L))).andReturn( - -1L).anyTimes(); - expect(xwiki.getXWikiPreference(eq("javamail_extra_props"), same(context))).andReturn( - "").anyTimes(); - expect(xwiki.Param(eq("celements.mail.default.javamail_extra_props"), eq(""))).andReturn( - "").anyTimes(); - expect(xwiki.getXWikiPreference(eq("smtp_server_password"), same(context))).andReturn( - "").anyTimes(); - expect(xwiki.Param(eq("celements.mail.default.smtp_server_password"), eq(""))).andReturn( - "myNotSecurePassword").once(); - expect(xwiki.getXWikiPreference(eq("smtp_server_username"), same(context))).andReturn( - "").anyTimes(); - expect(xwiki.Param(eq("celements.mail.default.smtp_server_username"), eq(""))).andReturn( - "").once(); + expect(xwiki.getXWikiPreferenceAsInt(eq("smtp_port"), eq(-1), same(context))).andReturn(-1) + .anyTimes(); + expect(xwiki.ParamAsLong(eq("celements.mail.default.smtp_port"), eq(-1L))).andReturn(-1L) + .anyTimes(); + expect(xwiki.getXWikiPreference(eq("javamail_extra_props"), same(context))).andReturn("") + .anyTimes(); + expect(xwiki.Param(eq("celements.mail.default.javamail_extra_props"), eq(""))).andReturn("") + .anyTimes(); + expect(xwiki.getXWikiPreference(eq("smtp_server_password"), same(context))).andReturn("") + .anyTimes(); + expect(xwiki.Param(eq("celements.mail.default.smtp_server_password"), eq(""))) + .andReturn("myNotSecurePassword").once(); + expect(xwiki.getXWikiPreference(eq("smtp_server_username"), same(context))).andReturn("") + .anyTimes(); + expect(xwiki.Param(eq("celements.mail.default.smtp_server_username"), eq(""))).andReturn("") + .once(); replayDefault(); assertNull(celMailConfiguration.getSmtpPassword()); - assertFalse("after setting only server_username usesAuthentication_localConfig must" - + " be false.", celMailConfiguration.usesAuthentication_localConfig()); + assertFalse( + "after setting only server_username usesAuthentication_localConfig must" + " be false.", + celMailConfiguration.usesAuthentication_localConfig()); verifyDefault(); } @Test public void testGetHost_fallbackToDefault() { expect(xwiki.getXWikiPreference(eq("smtp_server"), same(context))).andReturn("").anyTimes(); - expect(xwiki.Param(eq("celements.mail.default.smtp_server"), eq(""))).andReturn( - "smtp.unit.test").once(); - expect(xwiki.getXWikiPreferenceAsInt(eq("smtp_port"), eq(-1), same(context))).andReturn( - -1).anyTimes(); - expect(xwiki.ParamAsLong(eq("celements.mail.default.smtp_port"), eq(-1L))).andReturn( - -1L).anyTimes(); - expect(xwiki.getXWikiPreference(eq("javamail_extra_props"), same(context))).andReturn( - "").anyTimes(); - expect(xwiki.Param(eq("celements.mail.default.javamail_extra_props"), eq(""))).andReturn( - "").anyTimes(); - expect(xwiki.getXWikiPreference(eq("smtp_server_password"), same(context))).andReturn( - "").anyTimes(); - expect(xwiki.Param(eq("celements.mail.default.smtp_server_password"), eq(""))).andReturn( - "").anyTimes(); - expect(xwiki.getXWikiPreference(eq("smtp_server_username"), same(context))).andReturn( - "").anyTimes(); - expect(xwiki.Param(eq("celements.mail.default.smtp_server_username"), eq(""))).andReturn( - "").anyTimes(); + expect(xwiki.Param(eq("celements.mail.default.smtp_server"), eq(""))) + .andReturn("smtp.unit.test").once(); + expect(xwiki.getXWikiPreferenceAsInt(eq("smtp_port"), eq(-1), same(context))).andReturn(-1) + .anyTimes(); + expect(xwiki.ParamAsLong(eq("celements.mail.default.smtp_port"), eq(-1L))).andReturn(-1L) + .anyTimes(); + expect(xwiki.getXWikiPreference(eq("javamail_extra_props"), same(context))).andReturn("") + .anyTimes(); + expect(xwiki.Param(eq("celements.mail.default.javamail_extra_props"), eq(""))).andReturn("") + .anyTimes(); + expect(xwiki.getXWikiPreference(eq("smtp_server_password"), same(context))).andReturn("") + .anyTimes(); + expect(xwiki.Param(eq("celements.mail.default.smtp_server_password"), eq(""))).andReturn("") + .anyTimes(); + expect(xwiki.getXWikiPreference(eq("smtp_server_username"), same(context))).andReturn("") + .anyTimes(); + expect(xwiki.Param(eq("celements.mail.default.smtp_server_username"), eq(""))).andReturn("") + .anyTimes(); replayDefault(); assertEquals("smtp.unit.test", celMailConfiguration.getHost()); assertEquals("multiple reads must not lead to multiple config reads.", "smtp.unit.test", @@ -620,27 +621,28 @@ public void testGetHost_fallbackToDefault() { public void testGetHost_fallbackToDefault_noDefaultHost_usingLocalhost() { expect(xwiki.getXWikiPreference(eq("smtp_server"), same(context))).andReturn("").anyTimes(); expect(xwiki.Param(eq("celements.mail.default.smtp_server"), eq(""))).andReturn("").anyTimes(); - expect(xwiki.getXWikiPreferenceAsInt(eq("smtp_port"), eq(-1), same(context))).andReturn( - -1).anyTimes(); - expect(xwiki.ParamAsLong(eq("celements.mail.default.smtp_port"), eq(-1L))).andReturn( - -1L).anyTimes(); - expect(xwiki.getXWikiPreference(eq("javamail_extra_props"), same(context))).andReturn( - "").anyTimes(); - expect(xwiki.Param(eq("celements.mail.default.javamail_extra_props"), eq(""))).andReturn( - "").anyTimes(); - expect(xwiki.getXWikiPreference(eq("smtp_server_password"), same(context))).andReturn( - "").anyTimes(); - expect(xwiki.Param(eq("celements.mail.default.smtp_server_password"), eq(""))).andReturn( - "").anyTimes(); - expect(xwiki.getXWikiPreference(eq("smtp_server_username"), same(context))).andReturn( - "").anyTimes(); - expect(xwiki.Param(eq("celements.mail.default.smtp_server_username"), eq(""))).andReturn( - "").anyTimes(); + expect(xwiki.getXWikiPreferenceAsInt(eq("smtp_port"), eq(-1), same(context))).andReturn(-1) + .anyTimes(); + expect(xwiki.ParamAsLong(eq("celements.mail.default.smtp_port"), eq(-1L))).andReturn(-1L) + .anyTimes(); + expect(xwiki.getXWikiPreference(eq("javamail_extra_props"), same(context))).andReturn("") + .anyTimes(); + expect(xwiki.Param(eq("celements.mail.default.javamail_extra_props"), eq(""))).andReturn("") + .anyTimes(); + expect(xwiki.getXWikiPreference(eq("smtp_server_password"), same(context))).andReturn("") + .anyTimes(); + expect(xwiki.Param(eq("celements.mail.default.smtp_server_password"), eq(""))).andReturn("") + .anyTimes(); + expect(xwiki.getXWikiPreference(eq("smtp_server_username"), same(context))).andReturn("") + .anyTimes(); + expect(xwiki.Param(eq("celements.mail.default.smtp_server_username"), eq(""))).andReturn("") + .anyTimes(); replayDefault(); assertEquals("localhost", celMailConfiguration.getHost()); assertEquals(25, celMailConfiguration.getPort()); - assertTrue("after not setting any smtp-server configuration noHostConfig must still" - + " be true.", celMailConfiguration.noHostConfig()); + assertTrue( + "after not setting any smtp-server configuration noHostConfig must still" + " be true.", + celMailConfiguration.noHostConfig()); verifyDefault(); } @@ -648,22 +650,22 @@ public void testGetHost_fallbackToDefault_noDefaultHost_usingLocalhost() { public void testGetHost_fallbackToDefault_deactivatedDefaultHost() { expect(xwiki.getXWikiPreference(eq("smtp_server"), same(context))).andReturn("").anyTimes(); expect(xwiki.Param(eq("celements.mail.default.smtp_server"), eq(""))).andReturn("-").once(); - expect(xwiki.getXWikiPreferenceAsInt(eq("smtp_port"), eq(-1), same(context))).andReturn( - -1).anyTimes(); - expect(xwiki.ParamAsLong(eq("celements.mail.default.smtp_port"), eq(-1L))).andReturn( - -1L).anyTimes(); - expect(xwiki.getXWikiPreference(eq("javamail_extra_props"), same(context))).andReturn( - "").anyTimes(); - expect(xwiki.Param(eq("celements.mail.default.javamail_extra_props"), eq(""))).andReturn( - "").anyTimes(); - expect(xwiki.getXWikiPreference(eq("smtp_server_password"), same(context))).andReturn( - "").anyTimes(); - expect(xwiki.Param(eq("celements.mail.default.smtp_server_password"), eq(""))).andReturn( - "").anyTimes(); - expect(xwiki.getXWikiPreference(eq("smtp_server_username"), same(context))).andReturn( - "").anyTimes(); - expect(xwiki.Param(eq("celements.mail.default.smtp_server_username"), eq(""))).andReturn( - "").anyTimes(); + expect(xwiki.getXWikiPreferenceAsInt(eq("smtp_port"), eq(-1), same(context))).andReturn(-1) + .anyTimes(); + expect(xwiki.ParamAsLong(eq("celements.mail.default.smtp_port"), eq(-1L))).andReturn(-1L) + .anyTimes(); + expect(xwiki.getXWikiPreference(eq("javamail_extra_props"), same(context))).andReturn("") + .anyTimes(); + expect(xwiki.Param(eq("celements.mail.default.javamail_extra_props"), eq(""))).andReturn("") + .anyTimes(); + expect(xwiki.getXWikiPreference(eq("smtp_server_password"), same(context))).andReturn("") + .anyTimes(); + expect(xwiki.Param(eq("celements.mail.default.smtp_server_password"), eq(""))).andReturn("") + .anyTimes(); + expect(xwiki.getXWikiPreference(eq("smtp_server_username"), same(context))).andReturn("") + .anyTimes(); + expect(xwiki.Param(eq("celements.mail.default.smtp_server_username"), eq(""))).andReturn("") + .anyTimes(); replayDefault(); assertEquals("empty string defaults to 'localhost' in javamail!", "-", celMailConfiguration.getHost()); @@ -676,22 +678,22 @@ public void testGetHost_fallbackToDefault_deactivatedDefaultHost() { public void testGetPort_fallbackToDefault() { expect(xwiki.getXWikiPreference(eq("smtp_server"), same(context))).andReturn("").anyTimes(); expect(xwiki.Param(eq("celements.mail.default.smtp_server"), eq(""))).andReturn("").anyTimes(); - expect(xwiki.getXWikiPreferenceAsInt(eq("smtp_port"), eq(-1), same(context))).andReturn( - -1).anyTimes(); - expect(xwiki.ParamAsLong(eq("celements.mail.default.smtp_port"), eq(-1L))).andReturn( - 567L).once(); - expect(xwiki.getXWikiPreference(eq("javamail_extra_props"), same(context))).andReturn( - "").anyTimes(); - expect(xwiki.Param(eq("celements.mail.default.javamail_extra_props"), eq(""))).andReturn( - "").anyTimes(); - expect(xwiki.getXWikiPreference(eq("smtp_server_password"), same(context))).andReturn( - "").anyTimes(); - expect(xwiki.Param(eq("celements.mail.default.smtp_server_password"), eq(""))).andReturn( - "").anyTimes(); - expect(xwiki.getXWikiPreference(eq("smtp_server_username"), same(context))).andReturn( - "").anyTimes(); - expect(xwiki.Param(eq("celements.mail.default.smtp_server_username"), eq(""))).andReturn( - "").anyTimes(); + expect(xwiki.getXWikiPreferenceAsInt(eq("smtp_port"), eq(-1), same(context))).andReturn(-1) + .anyTimes(); + expect(xwiki.ParamAsLong(eq("celements.mail.default.smtp_port"), eq(-1L))).andReturn(567L) + .once(); + expect(xwiki.getXWikiPreference(eq("javamail_extra_props"), same(context))).andReturn("") + .anyTimes(); + expect(xwiki.Param(eq("celements.mail.default.javamail_extra_props"), eq(""))).andReturn("") + .anyTimes(); + expect(xwiki.getXWikiPreference(eq("smtp_server_password"), same(context))).andReturn("") + .anyTimes(); + expect(xwiki.Param(eq("celements.mail.default.smtp_server_password"), eq(""))).andReturn("") + .anyTimes(); + expect(xwiki.getXWikiPreference(eq("smtp_server_username"), same(context))).andReturn("") + .anyTimes(); + expect(xwiki.Param(eq("celements.mail.default.smtp_server_username"), eq(""))).andReturn("") + .anyTimes(); replayDefault(); assertEquals(567, celMailConfiguration.getPort()); assertEquals("multiple reads must not lead to multiple config reads.", 567, @@ -703,26 +705,27 @@ public void testGetPort_fallbackToDefault() { public void testGetPort_fallbackToDefault_noDefaultPort() { expect(xwiki.getXWikiPreference(eq("smtp_server"), same(context))).andReturn("").anyTimes(); expect(xwiki.Param(eq("celements.mail.default.smtp_server"), eq(""))).andReturn("").anyTimes(); - expect(xwiki.getXWikiPreferenceAsInt(eq("smtp_port"), eq(-1), same(context))).andReturn( - -1).anyTimes(); - expect(xwiki.ParamAsLong(eq("celements.mail.default.smtp_port"), eq(-1L))).andReturn( - -1L).anyTimes(); - expect(xwiki.getXWikiPreference(eq("javamail_extra_props"), same(context))).andReturn( - "").anyTimes(); - expect(xwiki.Param(eq("celements.mail.default.javamail_extra_props"), eq(""))).andReturn( - "").anyTimes(); - expect(xwiki.getXWikiPreference(eq("smtp_server_password"), same(context))).andReturn( - "").anyTimes(); - expect(xwiki.Param(eq("celements.mail.default.smtp_server_password"), eq(""))).andReturn( - "").anyTimes(); - expect(xwiki.getXWikiPreference(eq("smtp_server_username"), same(context))).andReturn( - "").anyTimes(); - expect(xwiki.Param(eq("celements.mail.default.smtp_server_username"), eq(""))).andReturn( - "").anyTimes(); + expect(xwiki.getXWikiPreferenceAsInt(eq("smtp_port"), eq(-1), same(context))).andReturn(-1) + .anyTimes(); + expect(xwiki.ParamAsLong(eq("celements.mail.default.smtp_port"), eq(-1L))).andReturn(-1L) + .anyTimes(); + expect(xwiki.getXWikiPreference(eq("javamail_extra_props"), same(context))).andReturn("") + .anyTimes(); + expect(xwiki.Param(eq("celements.mail.default.javamail_extra_props"), eq(""))).andReturn("") + .anyTimes(); + expect(xwiki.getXWikiPreference(eq("smtp_server_password"), same(context))).andReturn("") + .anyTimes(); + expect(xwiki.Param(eq("celements.mail.default.smtp_server_password"), eq(""))).andReturn("") + .anyTimes(); + expect(xwiki.getXWikiPreference(eq("smtp_server_username"), same(context))).andReturn("") + .anyTimes(); + expect(xwiki.Param(eq("celements.mail.default.smtp_server_username"), eq(""))).andReturn("") + .anyTimes(); replayDefault(); assertEquals(25, celMailConfiguration.getPort()); - assertTrue("after not setting any smtp-server configuration noHostConfig must still" - + " be true.", celMailConfiguration.noHostConfig()); + assertTrue( + "after not setting any smtp-server configuration noHostConfig must still" + " be true.", + celMailConfiguration.noHostConfig()); verifyDefault(); } @@ -730,22 +733,22 @@ public void testGetPort_fallbackToDefault_noDefaultPort() { public void testSetProps_fallbackToDefault() { expect(xwiki.getXWikiPreference(eq("smtp_server"), same(context))).andReturn("").anyTimes(); expect(xwiki.Param(eq("celements.mail.default.smtp_server"), eq(""))).andReturn("").anyTimes(); - expect(xwiki.getXWikiPreferenceAsInt(eq("smtp_port"), eq(-1), same(context))).andReturn( - -1).anyTimes(); - expect(xwiki.ParamAsLong(eq("celements.mail.default.smtp_port"), eq(-1L))).andReturn( - -1L).anyTimes(); - expect(xwiki.getXWikiPreference(eq("javamail_extra_props"), same(context))).andReturn( - "").anyTimes(); - expect(xwiki.Param(eq("celements.mail.default.javamail_extra_props"), eq(""))).andReturn( - "testProp=testValue,prop2=value2").once(); - expect(xwiki.getXWikiPreference(eq("smtp_server_password"), same(context))).andReturn( - "").anyTimes(); - expect(xwiki.Param(eq("celements.mail.default.smtp_server_password"), eq(""))).andReturn( - "").anyTimes(); - expect(xwiki.getXWikiPreference(eq("smtp_server_username"), same(context))).andReturn( - "").anyTimes(); - expect(xwiki.Param(eq("celements.mail.default.smtp_server_username"), eq(""))).andReturn( - "").anyTimes(); + expect(xwiki.getXWikiPreferenceAsInt(eq("smtp_port"), eq(-1), same(context))).andReturn(-1) + .anyTimes(); + expect(xwiki.ParamAsLong(eq("celements.mail.default.smtp_port"), eq(-1L))).andReturn(-1L) + .anyTimes(); + expect(xwiki.getXWikiPreference(eq("javamail_extra_props"), same(context))).andReturn("") + .anyTimes(); + expect(xwiki.Param(eq("celements.mail.default.javamail_extra_props"), eq(""))) + .andReturn("testProp=testValue,prop2=value2").once(); + expect(xwiki.getXWikiPreference(eq("smtp_server_password"), same(context))).andReturn("") + .anyTimes(); + expect(xwiki.Param(eq("celements.mail.default.smtp_server_password"), eq(""))).andReturn("") + .anyTimes(); + expect(xwiki.getXWikiPreference(eq("smtp_server_username"), same(context))).andReturn("") + .anyTimes(); + expect(xwiki.Param(eq("celements.mail.default.smtp_server_username"), eq(""))).andReturn("") + .anyTimes(); replayDefault(); Properties extProps = new Properties(); celMailConfiguration.appendExtraPropertiesTo(extProps, true); @@ -763,28 +766,29 @@ public void testSetProps_fallbackToDefault() { public void testSetProps_fallbackToDefault_noDefaultProps() { expect(xwiki.getXWikiPreference(eq("smtp_server"), same(context))).andReturn("").anyTimes(); expect(xwiki.Param(eq("celements.mail.default.smtp_server"), eq(""))).andReturn("").anyTimes(); - expect(xwiki.getXWikiPreferenceAsInt(eq("smtp_port"), eq(-1), same(context))).andReturn( - -1).anyTimes(); - expect(xwiki.ParamAsLong(eq("celements.mail.default.smtp_port"), eq(-1L))).andReturn( - -1L).anyTimes(); - expect(xwiki.getXWikiPreference(eq("javamail_extra_props"), same(context))).andReturn( - "").anyTimes(); - expect(xwiki.Param(eq("celements.mail.default.javamail_extra_props"), eq(""))).andReturn( - "").anyTimes(); - expect(xwiki.getXWikiPreference(eq("smtp_server_password"), same(context))).andReturn( - "").anyTimes(); - expect(xwiki.Param(eq("celements.mail.default.smtp_server_password"), eq(""))).andReturn( - "").anyTimes(); - expect(xwiki.getXWikiPreference(eq("smtp_server_username"), same(context))).andReturn( - "").anyTimes(); - expect(xwiki.Param(eq("celements.mail.default.smtp_server_username"), eq(""))).andReturn( - "").anyTimes(); + expect(xwiki.getXWikiPreferenceAsInt(eq("smtp_port"), eq(-1), same(context))).andReturn(-1) + .anyTimes(); + expect(xwiki.ParamAsLong(eq("celements.mail.default.smtp_port"), eq(-1L))).andReturn(-1L) + .anyTimes(); + expect(xwiki.getXWikiPreference(eq("javamail_extra_props"), same(context))).andReturn("") + .anyTimes(); + expect(xwiki.Param(eq("celements.mail.default.javamail_extra_props"), eq(""))).andReturn("") + .anyTimes(); + expect(xwiki.getXWikiPreference(eq("smtp_server_password"), same(context))).andReturn("") + .anyTimes(); + expect(xwiki.Param(eq("celements.mail.default.smtp_server_password"), eq(""))).andReturn("") + .anyTimes(); + expect(xwiki.getXWikiPreference(eq("smtp_server_username"), same(context))).andReturn("") + .anyTimes(); + expect(xwiki.Param(eq("celements.mail.default.smtp_server_username"), eq(""))).andReturn("") + .anyTimes(); replayDefault(); Properties extProps = new Properties(); celMailConfiguration.appendExtraPropertiesTo(extProps, true); assertTrue(extProps.isEmpty()); - assertTrue("after not setting any smtp-server configuration noHostConfig must still" - + " be true.", celMailConfiguration.noHostConfig()); + assertTrue( + "after not setting any smtp-server configuration noHostConfig must still" + " be true.", + celMailConfiguration.noHostConfig()); verifyDefault(); } diff --git a/src/test/java/com/celements/web/plugin/cmd/CelSendMailTest.java b/src/test/java/com/celements/web/plugin/cmd/CelSendMailTest.java index 803705d6b..7e1e13313 100644 --- a/src/test/java/com/celements/web/plugin/cmd/CelSendMailTest.java +++ b/src/test/java/com/celements/web/plugin/cmd/CelSendMailTest.java @@ -183,21 +183,21 @@ public void testSendMail() { expect(xwiki.getPluginApi(eq("mailsender"), same(context))).andReturn(mailPlugin); expect(mailPlugin.sendMail(isA(Mail.class), isA(CelMailConfiguration.class))).andReturn(1); sendMail.injectMail(new Mail()); - expect(xwiki.getXWikiPreference(eq("smtp_server"), eq("celements.mail.default.smtp_server"), eq( - ""), same(context))).andReturn("").anyTimes(); + expect(xwiki.getXWikiPreference(eq("smtp_server"), eq("celements.mail.default.smtp_server"), + eq(""), same(context))).andReturn("").anyTimes(); expect(xwiki.getXWikiPreferenceAsInt(eq("smtp_port"), eq("celements.mail.default.smtp_port"), eq(25), same(context))).andReturn(25).anyTimes(); - expect(xwiki.getXWikiPreference(eq("admin_email"), eq("celements.mail.default.admin_email"), eq( - ""), same(context))).andReturn("").anyTimes(); - expect(xwiki.getXWikiPreference(eq("smtp_server_username"), eq( - "celements.mail.default.smtp_server_username"), eq(""), same(context))).andReturn( - "").anyTimes(); - expect(xwiki.getXWikiPreference(eq("smtp_server_password"), eq( - "celements.mail.default.smtp_server_password"), eq(""), same(context))).andReturn( - "").anyTimes(); - expect(xwiki.getXWikiPreference(eq("javamail_extra_props"), eq( - "celements.mail.default.javamail_extra_props"), eq(""), same(context))).andReturn( - "").anyTimes(); + expect(xwiki.getXWikiPreference(eq("admin_email"), eq("celements.mail.default.admin_email"), + eq(""), same(context))).andReturn("").anyTimes(); + expect(xwiki.getXWikiPreference(eq("smtp_server_username"), + eq("celements.mail.default.smtp_server_username"), eq(""), same(context))).andReturn("") + .anyTimes(); + expect(xwiki.getXWikiPreference(eq("smtp_server_password"), + eq("celements.mail.default.smtp_server_password"), eq(""), same(context))).andReturn("") + .anyTimes(); + expect(xwiki.getXWikiPreference(eq("javamail_extra_props"), + eq("celements.mail.default.javamail_extra_props"), eq(""), same(context))).andReturn("") + .anyTimes(); replayDefault(); assertEquals(1, sendMail.sendMail()); verifyDefault(); diff --git a/src/test/java/com/celements/web/plugin/cmd/CelementsRightsCommandTest.java b/src/test/java/com/celements/web/plugin/cmd/CelementsRightsCommandTest.java index a17c65cb9..30804ae43 100644 --- a/src/test/java/com/celements/web/plugin/cmd/CelementsRightsCommandTest.java +++ b/src/test/java/com/celements/web/plugin/cmd/CelementsRightsCommandTest.java @@ -199,8 +199,8 @@ public void testIsCelementsRights_oneValidUser_validLevel_delObject() throws XWi rightsObj.setLargeStringValue("users", users); String levels = "view"; rightsObj.setLargeStringValue("levels", levels); - testDoc.setXObjects(xwikiRightsClassRef, Arrays.asList((BaseObject) null, - rightsObj)); + testDoc.setXObjects(xwikiRightsClassRef, + Arrays.asList((BaseObject) null, rightsObj)); String fullName = "MySpace.TestDoc"; expect(xwiki.getDocument(eq(fullName), same(context))).andReturn(testDoc).once(); replay(xwiki); diff --git a/src/test/java/com/celements/web/plugin/cmd/ContextMenuCSSClassesCommandTest.java b/src/test/java/com/celements/web/plugin/cmd/ContextMenuCSSClassesCommandTest.java index 367961cb8..e1dff10a1 100644 --- a/src/test/java/com/celements/web/plugin/cmd/ContextMenuCSSClassesCommandTest.java +++ b/src/test/java/com/celements/web/plugin/cmd/ContextMenuCSSClassesCommandTest.java @@ -58,8 +58,8 @@ public void testGetCMhql() { assertTrue(hql.contains(" obj.name = doc.fullName ")); assertTrue(hql.contains(" doc.space = 'CelementsContextMenu' ")); assertTrue(hql.contains(" obj.className = 'Celements2.ContextMenuItemClass' ")); - assertTrue(hql.matches("select doc.name from \\w.*?(, \\w.*?)*" - + " where \\w.*?( and \\w.*?)*")); + assertTrue( + hql.matches("select doc.name from \\w.*?(, \\w.*?)*" + " where \\w.*?( and \\w.*?)*")); } @Test @@ -75,8 +75,8 @@ public void testGetCMcssClassesOneDB() throws Exception { @Test public void testGetCMcssClassesOneDB_preventDouplicates() throws Exception { - List cmStringList = new ArrayList(Arrays.asList("abcClass", "secondClass", - "abcClass", "secondClass", "thirdClass")); + List cmStringList = new ArrayList( + Arrays.asList("abcClass", "secondClass", "abcClass", "secondClass", "thirdClass")); expect(xwiki.search(isA(String.class), same(context))).andReturn(cmStringList); replay(xwiki); Set resultSet = cmCssClassesCmd.getCMcssClassesOneDB(context); @@ -104,8 +104,8 @@ public void testGetCM_CSSclasses() throws Exception { context.setDatabase("mycelements"); List cmStringList = new ArrayList(Arrays.asList("abcClass", "secondClass")); expect(xwiki.search(isA(String.class), same(context))).andReturn(cmStringList); - List cmStringList2 = new ArrayList(Arrays.asList("abcClass", "secondClass", - "abcClass", "secondClass", "thirdClass")); + List cmStringList2 = new ArrayList( + Arrays.asList("abcClass", "secondClass", "abcClass", "secondClass", "thirdClass")); expect(xwiki.search(isA(String.class), same(context))).andReturn(cmStringList2); replay(xwiki); List resultSet = cmCssClassesCmd.getCM_CSSclasses(context); diff --git a/src/test/java/com/celements/web/plugin/cmd/CreateDocumentCommandTest.java b/src/test/java/com/celements/web/plugin/cmd/CreateDocumentCommandTest.java index c85684102..065b4345d 100644 --- a/src/test/java/com/celements/web/plugin/cmd/CreateDocumentCommandTest.java +++ b/src/test/java/com/celements/web/plugin/cmd/CreateDocumentCommandTest.java @@ -63,8 +63,8 @@ public void testCreateDocument_exists() throws Exception { expect(getMock(IModelAccessFacade.class).createDocument(docRef)) .andThrow(new DocumentAlreadyExistsException(docRef)); replayDefault(); - assertNull("only create document if NOT exists.", createDocumentCmd.createDocument(docRef, - pageType)); + assertNull("only create document if NOT exists.", + createDocumentCmd.createDocument(docRef, pageType)); verifyDefault(); } diff --git a/src/test/java/com/celements/web/plugin/cmd/CssCommandTest.java b/src/test/java/com/celements/web/plugin/cmd/CssCommandTest.java index 0163b342e..1dd25d043 100644 --- a/src/test/java/com/celements/web/plugin/cmd/CssCommandTest.java +++ b/src/test/java/com/celements/web/plugin/cmd/CssCommandTest.java @@ -25,9 +25,7 @@ public class CssCommandTest extends AbstractComponentTest { @Before public void setUp_CssCommandTest() throws Exception { - registerComponentMocks( - FrontendResourceResolver.class, - IModelAccessFacade.class, + registerComponentMocks(FrontendResourceResolver.class, IModelAccessFacade.class, LayoutServiceRole.class); } @@ -54,8 +52,8 @@ public void test_includeApplicationDefaultCSS_registerMockComponent_emptyList() @Test public void test_includeApplicationDefaultCSS_registerMockComponent_oneElem() throws Exception { ICssExtensionRole testCssExtMock = registerComponentMock(ICssExtensionRole.class, "testCssExt"); - expect(testCssExtMock.getCssList()).andReturn(Arrays.asList(new CSSString( - ":celRes/test.css", getContext()))).once(); + expect(testCssExtMock.getCssList()) + .andReturn(Arrays.asList(new CSSString(":celRes/test.css", getContext()))).once(); cssCommand = getBeanFactory().getBean(CssCommand.class); replayDefault(); List cssList = cssCommand.includeApplicationDefaultCSS(); diff --git a/src/test/java/com/celements/web/plugin/cmd/DocHeaderTitleCommandTest.java b/src/test/java/com/celements/web/plugin/cmd/DocHeaderTitleCommandTest.java index f7c3e4b9b..b0841f991 100644 --- a/src/test/java/com/celements/web/plugin/cmd/DocHeaderTitleCommandTest.java +++ b/src/test/java/com/celements/web/plugin/cmd/DocHeaderTitleCommandTest.java @@ -44,10 +44,10 @@ public void testGetDocHeaderTitle_doc_theDoc_sameSpace() throws XWikiException { expect(doc.getXObject(eq(objRef))).andReturn(obj); MultilingualMenuNameCommand mmnc = createMock(MultilingualMenuNameCommand.class); command.menuNameCmd = mmnc; - expect(mmnc.getMultilingualMenuNameOnly(eq("Content.Home"), eq("de"), eq(false), same( - getContext()))).andReturn("Home"); - expect(wiki.getSpacePreference(eq("title"), eq(docRef.getLastSpaceReference().getName()), eq( - ""), same(getContext()))).andReturn(spacePrefTitle).anyTimes(); + expect(mmnc.getMultilingualMenuNameOnly(eq("Content.Home"), eq("de"), eq(false), + same(getContext()))).andReturn("Home"); + expect(wiki.getSpacePreference(eq("title"), eq(docRef.getLastSpaceReference().getName()), + eq(""), same(getContext()))).andReturn(spacePrefTitle).anyTimes(); expect(wiki.parseContent(eq(spacePrefTitle), same(getContext()))).andReturn(spacePrefTitle); replay(doc, mmnc, wiki); assertEquals(docRef.getName() + spacePrefTitle, command.getDocHeaderTitle(docRef)); @@ -69,10 +69,10 @@ public void testGetDocHeaderTitle_doc_theDoc_differentSpace() throws XWikiExcept expect(theDoc.getXObject(eq(objRef))).andReturn(obj); MultilingualMenuNameCommand mmnc = createMock(MultilingualMenuNameCommand.class); command.menuNameCmd = mmnc; - expect(mmnc.getMultilingualMenuNameOnly(eq("TheDocSpace.TheDoc"), eq("de"), eq(false), same( - getContext()))).andReturn("TheDoc"); - expect(wiki.getSpacePreference(eq("title"), eq(theDocRef.getLastSpaceReference().getName()), eq( - ""), same(getContext()))).andReturn(spacePrefTitle).anyTimes(); + expect(mmnc.getMultilingualMenuNameOnly(eq("TheDocSpace.TheDoc"), eq("de"), eq(false), + same(getContext()))).andReturn("TheDoc"); + expect(wiki.getSpacePreference(eq("title"), eq(theDocRef.getLastSpaceReference().getName()), + eq(""), same(getContext()))).andReturn(spacePrefTitle).anyTimes(); expect(wiki.parseContent(eq(spacePrefTitle), same(getContext()))).andReturn(spacePrefTitle); replay(doc, mmnc, theDoc, wiki); assertEquals(theDocRef.getName() + " - TheDocSpace", command.getDocHeaderTitle(theDocRef)); @@ -92,14 +92,14 @@ public void testGetDocHeaderTitle_fullName() throws XWikiException { expect(doc.getXObject(eq(objRef))).andReturn(obj); MultilingualMenuNameCommand mmnc = createMock(MultilingualMenuNameCommand.class); command.menuNameCmd = mmnc; - expect(mmnc.getMultilingualMenuNameOnly(eq("Content.Home"), eq("de"), eq(false), same( - getContext()))).andReturn("Home"); - expect(wiki.getSpacePreference(eq("title"), eq(docRef.getLastSpaceReference().getName()), eq( - ""), same(getContext()))).andReturn(spacePrefTitle).anyTimes(); + expect(mmnc.getMultilingualMenuNameOnly(eq("Content.Home"), eq("de"), eq(false), + same(getContext()))).andReturn("Home"); + expect(wiki.getSpacePreference(eq("title"), eq(docRef.getLastSpaceReference().getName()), + eq(""), same(getContext()))).andReturn(spacePrefTitle).anyTimes(); expect(wiki.parseContent(eq(spacePrefTitle), same(getContext()))).andReturn(spacePrefTitle); replay(doc, mmnc, wiki); - assertEquals(docRef.getName() + spacePrefTitle, command.getDocHeaderTitle("Content.Home", - getContext())); + assertEquals(docRef.getName() + spacePrefTitle, + command.getDocHeaderTitle("Content.Home", getContext())); verify(doc, mmnc, wiki); } } diff --git a/src/test/java/com/celements/web/plugin/cmd/EmptyCheckCommandTest.java b/src/test/java/com/celements/web/plugin/cmd/EmptyCheckCommandTest.java index ebfe03b22..30e3c78da 100644 --- a/src/test/java/com/celements/web/plugin/cmd/EmptyCheckCommandTest.java +++ b/src/test/java/com/celements/web/plugin/cmd/EmptyCheckCommandTest.java @@ -135,9 +135,9 @@ public void testIsEmptyRTEDocument_nbsp() { emptyChildCheckCmd.isEmptyRTEDocument(getTestDoc(" "))); assertTrue("Non breaking spaces in a paragraph should be treated as empty", emptyChildCheckCmd.isEmptyRTEDocument(getTestDoc("

     

    "))); - assertTrue("Non breaking spaces in a paragraph with white spaces" - + " should be treated as empty", emptyChildCheckCmd.isEmptyRTEDocument(getTestDoc( - "

     

    "))); + assertTrue( + "Non breaking spaces in a paragraph with white spaces" + " should be treated as empty", + emptyChildCheckCmd.isEmptyRTEDocument(getTestDoc("

     

    "))); assertFalse("Regular Text should not be treated as empty.", emptyChildCheckCmd.isEmptyRTEDocument(getTestDoc("

    adsf  

    "))); } @@ -150,9 +150,9 @@ public void testGetNextNonEmptyChildren_notEmpty() throws Exception { XWikiDocument myXdoc = new XWikiDocument(documentRef); myXdoc.setContent("test content not empty"); expect(xwiki.getDocument(eq(documentRef), same(context))).andReturn(myXdoc).once(); - expect(xwiki.getXWikiPreference(eq(IEmptyCheckRole.EMPTYCHECK_MODULS_PREF_NAME), eq( - "celements.emptycheckModuls"), eq("default"), same(context))).andReturn( - "default").anyTimes(); + expect(xwiki.getXWikiPreference(eq(IEmptyCheckRole.EMPTYCHECK_MODULS_PREF_NAME), + eq("celements.emptycheckModuls"), eq("default"), same(context))).andReturn("default") + .anyTimes(); replayDefault(); assertEquals(documentRef, emptyChildCheckCmd.getNextNonEmptyChildren(documentRef)); verifyDefault(); @@ -165,11 +165,11 @@ public void testGetNextNonEmptyChildren_empty_but_noChildren() throws Exception "MyEmptyDoc"); createEmptyDoc(emptyDocRef); List noChildrenList = Collections.emptyList(); - expect(treeNodeService.getSubNodesForParent(eq(emptyDocRef), eq(""))).andReturn( - noChildrenList).once(); - expect(xwiki.getXWikiPreference(eq(IEmptyCheckRole.EMPTYCHECK_MODULS_PREF_NAME), eq( - "celements.emptycheckModuls"), eq("default"), same(context))).andReturn( - "default").anyTimes(); + expect(treeNodeService.getSubNodesForParent(eq(emptyDocRef), eq(""))).andReturn(noChildrenList) + .once(); + expect(xwiki.getXWikiPreference(eq(IEmptyCheckRole.EMPTYCHECK_MODULS_PREF_NAME), + eq("celements.emptycheckModuls"), eq("default"), same(context))).andReturn("default") + .anyTimes(); replayDefault(); assertEquals(emptyDocRef, emptyChildCheckCmd.getNextNonEmptyChildren(emptyDocRef)); verifyDefault(); @@ -181,19 +181,21 @@ public void testGetNextNonEmptyChildren_empty_with_nonEmptyChildren() throws Exc DocumentReference emptyDocRef = new DocumentReference(context.getDatabase(), "mySpace", "MyEmptyDoc"); createEmptyDoc(emptyDocRef); - List childrenList = Arrays.asList(new TreeNode(new DocumentReference( - context.getDatabase(), "mySpace", "myChild"), emptyDocRef, 0), new TreeNode( - new DocumentReference(context.getDatabase(), "mySpace", "myChild2"), emptyDocRef, 1)); - expect(treeNodeService.getSubNodesForParent(eq(emptyDocRef), eq(""))).andReturn( - childrenList).once(); + List childrenList = Arrays.asList( + new TreeNode(new DocumentReference(context.getDatabase(), "mySpace", "myChild"), + emptyDocRef, 0), + new TreeNode(new DocumentReference(context.getDatabase(), "mySpace", "myChild2"), + emptyDocRef, 1)); + expect(treeNodeService.getSubNodesForParent(eq(emptyDocRef), eq(""))).andReturn(childrenList) + .once(); DocumentReference expectedChildDocRef = new DocumentReference(context.getDatabase(), "mySpace", "myChild"); XWikiDocument childXdoc = new XWikiDocument(expectedChildDocRef); childXdoc.setContent("non empty child content"); expect(xwiki.getDocument(eq(expectedChildDocRef), same(context))).andReturn(childXdoc).once(); - expect(xwiki.getXWikiPreference(eq(IEmptyCheckRole.EMPTYCHECK_MODULS_PREF_NAME), eq( - "celements.emptycheckModuls"), eq("default"), same(context))).andReturn( - "default").anyTimes(); + expect(xwiki.getXWikiPreference(eq(IEmptyCheckRole.EMPTYCHECK_MODULS_PREF_NAME), + eq("celements.emptycheckModuls"), eq("default"), same(context))).andReturn("default") + .anyTimes(); replayDefault(); assertEquals(expectedChildDocRef, emptyChildCheckCmd.getNextNonEmptyChildren(emptyDocRef)); verifyDefault(); @@ -205,29 +207,32 @@ public void testGetNextNonEmptyChildren_empty_recurse_on_EmptyChildren() throws DocumentReference emptyDocRef = new DocumentReference(context.getDatabase(), "mySpace", "MyEmptyDoc"); createEmptyDoc(emptyDocRef); - List childrenList = Arrays.asList(new TreeNode(new DocumentReference( - context.getDatabase(), "mySpace", "myChild"), emptyDocRef, 0), new TreeNode( - new DocumentReference(context.getDatabase(), "mySpace", "myChild2"), emptyDocRef, 1)); - expect(treeNodeService.getSubNodesForParent(eq(emptyDocRef), eq(""))).andReturn( - childrenList).once(); + List childrenList = Arrays.asList( + new TreeNode(new DocumentReference(context.getDatabase(), "mySpace", "myChild"), + emptyDocRef, 0), + new TreeNode(new DocumentReference(context.getDatabase(), "mySpace", "myChild2"), + emptyDocRef, 1)); + expect(treeNodeService.getSubNodesForParent(eq(emptyDocRef), eq(""))).andReturn(childrenList) + .once(); DocumentReference childDocRef = new DocumentReference(context.getDatabase(), "mySpace", "myChild"); createEmptyDoc(childDocRef); - List childrenList2 = Arrays.asList(new TreeNode(new DocumentReference( - context.getDatabase(), "mySpace", "myChildChild"), emptyDocRef, 0), new TreeNode( - new DocumentReference(context.getDatabase(), "mySpace", "myChildChild2"), emptyDocRef, - 1)); - expect(treeNodeService.getSubNodesForParent(eq(childDocRef), eq(""))).andReturn( - childrenList2).once(); + List childrenList2 = Arrays.asList( + new TreeNode(new DocumentReference(context.getDatabase(), "mySpace", "myChildChild"), + emptyDocRef, 0), + new TreeNode(new DocumentReference(context.getDatabase(), "mySpace", "myChildChild2"), + emptyDocRef, 1)); + expect(treeNodeService.getSubNodesForParent(eq(childDocRef), eq(""))).andReturn(childrenList2) + .once(); DocumentReference expectedChildDocRef = new DocumentReference(context.getDatabase(), "mySpace", "myChildChild"); XWikiDocument childChildXdoc = new XWikiDocument(expectedChildDocRef); childChildXdoc.setContent("non empty child content"); - expect(xwiki.getDocument(eq(expectedChildDocRef), same(context))).andReturn( - childChildXdoc).once(); - expect(xwiki.getXWikiPreference(eq(IEmptyCheckRole.EMPTYCHECK_MODULS_PREF_NAME), eq( - "celements.emptycheckModuls"), eq("default"), same(context))).andReturn( - "default").anyTimes(); + expect(xwiki.getDocument(eq(expectedChildDocRef), same(context))).andReturn(childChildXdoc) + .once(); + expect(xwiki.getXWikiPreference(eq(IEmptyCheckRole.EMPTYCHECK_MODULS_PREF_NAME), + eq("celements.emptycheckModuls"), eq("default"), same(context))).andReturn("default") + .anyTimes(); replayDefault(); assertEquals(expectedChildDocRef, emptyChildCheckCmd.getNextNonEmptyChildren(emptyDocRef)); verifyDefault(); @@ -249,8 +254,8 @@ public void testGetNextNonEmptyChildren_empty_recurse_on_EmptyChildren_reconize_ List childrenList = Arrays.asList(new TreeNode(childDocRef, emptyDocRef, 0), new TreeNode(child2DocRef, emptyDocRef, 1)); // if called more than once the recursion detection is very likely broken! - expect(treeNodeService.getSubNodesForParent(eq(emptyDocRef), eq(""))).andReturn( - childrenList).once(); + expect(treeNodeService.getSubNodesForParent(eq(emptyDocRef), eq(""))).andReturn(childrenList) + .once(); DocumentReference childChildDocRef = new DocumentReference(context.getDatabase(), "mySpace", "myChildChild"); createEmptyDoc(childChildDocRef); @@ -259,19 +264,19 @@ public void testGetNextNonEmptyChildren_empty_recurse_on_EmptyChildren_reconize_ createEmptyDoc(childChild2DocRef); List childrenList2 = Arrays.asList(new TreeNode(childChildDocRef, emptyDocRef, 0), new TreeNode(childChild2DocRef, emptyDocRef, 1)); - expect(treeNodeService.getSubNodesForParent(eq(childDocRef), eq(""))).andReturn( - childrenList2).once(); - List childrenList3 = Arrays.asList(new TreeNode(new DocumentReference( - context.getDatabase(), "mySpace", "MyEmptyDoc"), emptyDocRef, 0)); - expect(treeNodeService.getSubNodesForParent(eq(childChildDocRef), eq(""))).andReturn( - childrenList3).once(); - expect(treeNodeService.getSubNodesForParent(eq(child2DocRef), eq(""))).andReturn( - Collections.emptyList()).once(); - expect(treeNodeService.getSubNodesForParent(eq(childChild2DocRef), eq(""))).andReturn( - Collections.emptyList()).once(); - expect(xwiki.getXWikiPreference(eq(IEmptyCheckRole.EMPTYCHECK_MODULS_PREF_NAME), eq( - "celements.emptycheckModuls"), eq("default"), same(context))).andReturn( - "default").anyTimes(); + expect(treeNodeService.getSubNodesForParent(eq(childDocRef), eq(""))).andReturn(childrenList2) + .once(); + List childrenList3 = Arrays.asList(new TreeNode( + new DocumentReference(context.getDatabase(), "mySpace", "MyEmptyDoc"), emptyDocRef, 0)); + expect(treeNodeService.getSubNodesForParent(eq(childChildDocRef), eq(""))) + .andReturn(childrenList3).once(); + expect(treeNodeService.getSubNodesForParent(eq(child2DocRef), eq(""))) + .andReturn(Collections.emptyList()).once(); + expect(treeNodeService.getSubNodesForParent(eq(childChild2DocRef), eq(""))) + .andReturn(Collections.emptyList()).once(); + expect(xwiki.getXWikiPreference(eq(IEmptyCheckRole.EMPTYCHECK_MODULS_PREF_NAME), + eq("celements.emptycheckModuls"), eq("default"), same(context))).andReturn("default") + .anyTimes(); replayDefault(); assertEquals(emptyDocRef, emptyChildCheckCmd.getNextNonEmptyChildren(emptyDocRef)); verifyDefault(); diff --git a/src/test/java/com/celements/web/plugin/cmd/ExternalJavaScriptFilesCommandTest.java b/src/test/java/com/celements/web/plugin/cmd/ExternalJavaScriptFilesCommandTest.java index 34639ea82..8be4cec36 100644 --- a/src/test/java/com/celements/web/plugin/cmd/ExternalJavaScriptFilesCommandTest.java +++ b/src/test/java/com/celements/web/plugin/cmd/ExternalJavaScriptFilesCommandTest.java @@ -85,9 +85,8 @@ public void test_addExtJSfileOnce_beforeGetAll() { expect(attUrlCmd.isAttachmentLink(eq(file))).andReturn(false).atLeastOnce(); expect(attUrlCmd.isOnDiskLink(eq(file))).andReturn(true).atLeastOnce(); replayDefault(); - assertEquals("", command.addExtJSfileOnce(new ExtJsFileParameter.Builder() - .setJsFile(file) - .build())); + assertEquals("", + command.addExtJSfileOnce(new ExtJsFileParameter.Builder().setJsFile(file).build())); verifyDefault(); } @@ -101,9 +100,8 @@ public void test_addExtJSfileOnce_beforeGetAll_fileNotFound() { expect(attUrlCmd.isAttachmentLink(eq(fileNotFound))).andReturn(true).atLeastOnce(); expect(attUrlCmd.isOnDiskLink(eq(fileNotFound))).andReturn(false).anyTimes(); replayDefault(); - assertEquals("", command.addExtJSfileOnce(new ExtJsFileParameter.Builder() - .setJsFile(fileNotFound) - .build())); + assertEquals("", + command.addExtJSfileOnce(new ExtJsFileParameter.Builder().setJsFile(fileNotFound).build())); verifyDefault(); } @@ -126,15 +124,9 @@ public void test_streamExtJsFiles() { replayDefault(); - command.addExtJSfileOnce(new ExtJsFileParameter.Builder() - .setJsFile(frontendFile) - .build()); - command.addExtJSfileOnce(new ExtJsFileParameter.Builder() - .setJsFile(legacyFile) - .build()); - command.addExtJSfileOnce(new ExtJsFileParameter.Builder() - .setJsFile(otherFrontendFile) - .build()); + command.addExtJSfileOnce(new ExtJsFileParameter.Builder().setJsFile(frontendFile).build()); + command.addExtJSfileOnce(new ExtJsFileParameter.Builder().setJsFile(legacyFile).build()); + command.addExtJSfileOnce(new ExtJsFileParameter.Builder().setJsFile(otherFrontendFile).build()); assertEquals(Arrays.asList(frontendFile, legacyFile, otherFrontendFile), command.streamExtJsFiles().toList()); @@ -161,14 +153,11 @@ public void test_addExtJSfileOnce_afterGetAll_frontendCss() { replayDefault(); command.injectDisplayAll(true); - String includes = command.addExtJSfileOnce(new ExtJsFileParameter.Builder() - .setJsFile(frontendFile) - .setAction("file") - .build()); + String includes = command.addExtJSfileOnce( + new ExtJsFileParameter.Builder().setJsFile(frontendFile).setAction("file").build()); assertEquals("\n" - + "", includes); + + cssUrl + "\" />\n" + "", includes); verifyDefault(); } @@ -183,8 +172,7 @@ public void test_addExtJSfileOnce_afterGetAll() { expect(attUrlCmd.isOnDiskLink(eq(file))).andReturn(false).atLeastOnce(); replayDefault(); command.injectDisplayAll(true); - final ExtJsFileParameter extJsFileParam = new ExtJsFileParameter.Builder() - .setJsFile(file) + final ExtJsFileParameter extJsFileParam = new ExtJsFileParameter.Builder().setJsFile(file) .build(); assertEquals("", command.addExtJSfileOnce(extJsFileParam)); @@ -203,10 +191,8 @@ public void test_addExtJSfileOnce_afterGetAll_action() { expect(attUrlCmd.isOnDiskLink(eq(file))).andReturn(false).atLeastOnce(); replayDefault(); command.injectDisplayAll(true); - final ExtJsFileParameter extJsFile = new ExtJsFileParameter.Builder() - .setJsFile(file) - .setAction("file") - .build(); + final ExtJsFileParameter extJsFile = new ExtJsFileParameter.Builder().setJsFile(file) + .setAction("file").build(); assertEquals("", command.addExtJSfileOnce(extJsFile)); assertEquals("", command.addExtJSfileOnce(extJsFile)); @@ -225,16 +211,10 @@ public void test_addExtJSfileOnce_afterGetAll_action_params() { replayDefault(); command.injectDisplayAll(true); assertEquals("", - command.addExtJSfileOnce(new ExtJsFileParameter.Builder() - .setJsFile(file) - .setAction("file") - .setQueryString("me=blu") - .build())); - assertEquals("", command.addExtJSfileOnce(new ExtJsFileParameter.Builder() - .setJsFile(file) - .setAction("file") - .setQueryString("me=blu") - .build())); + command.addExtJSfileOnce(new ExtJsFileParameter.Builder().setJsFile(file).setAction("file") + .setQueryString("me=blu").build())); + assertEquals("", command.addExtJSfileOnce(new ExtJsFileParameter.Builder().setJsFile(file) + .setAction("file").setQueryString("me=blu").build())); verifyDefault(); } @@ -250,11 +230,8 @@ public void test_addExtJSfileOnce_afterGetAll_action_params_onDisk() { expect(attUrlCmd.isOnDiskLink(eq(file))).andReturn(true).atLeastOnce(); replayDefault(); command.injectDisplayAll(true); - final ExtJsFileParameter extJsFileParam = new ExtJsFileParameter.Builder() - .setJsFile(file) - .setAction("file") - .setQueryString("me=blu") - .build(); + final ExtJsFileParameter extJsFileParam = new ExtJsFileParameter.Builder().setJsFile(file) + .setAction("file").setQueryString("me=blu").build(); assertEquals("", command.addExtJSfileOnce(extJsFileParam)); assertEquals("", command.addExtJSfileOnce(extJsFileParam)); @@ -273,12 +250,9 @@ public void test_addExtJSfileOnce_afterGetAll_versioning() { replayDefault(); command.injectDisplayAll(true); assertEquals("", - command.addExtJSfileOnce(new ExtJsFileParameter.Builder() - .setJsFile(file) - .build())); - assertEquals("", command.addExtJSfileOnce(new ExtJsFileParameter.Builder() - .setJsFile(file) - .build())); + command.addExtJSfileOnce(new ExtJsFileParameter.Builder().setJsFile(file).build())); + assertEquals("", + command.addExtJSfileOnce(new ExtJsFileParameter.Builder().setJsFile(file).build())); verifyDefault(); } @@ -363,8 +337,8 @@ public void test_getAllRteContentJsFiles_Both() throws Exception { simpleLayoutDoc.addXObject(extJsFileObj); expect(modelAccessMock.getDocument(eq(simpleLayoutDocRef))).andReturn(simpleLayoutDoc) .atLeastOnce(); - expect(pageLayoutCmdMock.getLayoutPropDocRefForCurrentDoc()).andReturn(Optional.of( - simpleLayoutDocRef)).atLeastOnce(); + expect(pageLayoutCmdMock.getLayoutPropDocRefForCurrentDoc()) + .andReturn(Optional.of(simpleLayoutDocRef)).atLeastOnce(); DocumentReference xwikiPrefDocRef = new DocumentReference(context.getDatabase(), "XWiki", "XWikiPreferences"); XWikiDocument xwikiPrefDoc = new XWikiDocument(xwikiPrefDocRef); @@ -404,8 +378,8 @@ public void test_getAllRteContentJsFiles_only() throws Exception { simpleLayoutDoc.addXObject(extJsFileObj); expect(modelAccessMock.getDocument(eq(simpleLayoutDocRef))).andReturn(simpleLayoutDoc) .atLeastOnce(); - expect(pageLayoutCmdMock.getLayoutPropDocRefForCurrentDoc()).andReturn(Optional.of( - simpleLayoutDocRef)).atLeastOnce(); + expect(pageLayoutCmdMock.getLayoutPropDocRefForCurrentDoc()) + .andReturn(Optional.of(simpleLayoutDocRef)).atLeastOnce(); DocumentReference xwikiPrefDocRef = new DocumentReference(context.getDatabase(), "XWiki", "XWikiPreferences"); XWikiDocument xwikiPrefDoc = new XWikiDocument(xwikiPrefDocRef); @@ -445,8 +419,8 @@ public void test_getAllRteContentJsFiles_No() throws Exception { simpleLayoutDoc.addXObject(extJsFileObj); expect(modelAccessMock.getDocument(eq(simpleLayoutDocRef))).andReturn(simpleLayoutDoc) .atLeastOnce(); - expect(pageLayoutCmdMock.getLayoutPropDocRefForCurrentDoc()).andReturn(Optional.of( - simpleLayoutDocRef)).atLeastOnce(); + expect(pageLayoutCmdMock.getLayoutPropDocRefForCurrentDoc()) + .andReturn(Optional.of(simpleLayoutDocRef)).atLeastOnce(); DocumentReference xwikiPrefDocRef = new DocumentReference(context.getDatabase(), "XWiki", "XWikiPreferences"); XWikiDocument xwikiPrefDoc = new XWikiDocument(xwikiPrefDocRef); @@ -476,12 +450,9 @@ public void test_addExtJSfileOnce_afterGetAll_fileNotFound_url() { replayDefault(); command.injectDisplayAll(true); assertEquals("", - command.addExtJSfileOnce(new ExtJsFileParameter.Builder() - .setJsFile(fileNotFound) - .build())); - assertEquals("", command.addExtJSfileOnce(new ExtJsFileParameter.Builder() - .setJsFile(fileNotFound) - .build())); + command.addExtJSfileOnce(new ExtJsFileParameter.Builder().setJsFile(fileNotFound).build())); + assertEquals("", + command.addExtJSfileOnce(new ExtJsFileParameter.Builder().setJsFile(fileNotFound).build())); verifyDefault(); } @@ -497,12 +468,9 @@ public void test_addExtJSfileOnce_afterGetAll_fileNotFound_attUrl() { replayDefault(); command.injectDisplayAll(true); assertEquals("", - command.addExtJSfileOnce(new ExtJsFileParameter.Builder() - .setJsFile(fileNotFound) - .build())); - assertEquals("", command.addExtJSfileOnce(new ExtJsFileParameter.Builder() - .setJsFile(fileNotFound) - .build())); + command.addExtJSfileOnce(new ExtJsFileParameter.Builder().setJsFile(fileNotFound).build())); + assertEquals("", + command.addExtJSfileOnce(new ExtJsFileParameter.Builder().setJsFile(fileNotFound).build())); verifyDefault(); } @@ -537,9 +505,7 @@ public void test_addAllExtJSfilesFromDocRef_sync() throws Exception { replayDefault(); command.addAllExtJSfilesFromDocRef(contextDocRef); assertEquals("must be already added by addAllExtJSfilesFromDocRef", "", - command.addExtJSfileOnce(new ExtJsFileParameter.Builder() - .setJsFile(filePath) - .build())); + command.addExtJSfileOnce(new ExtJsFileParameter.Builder().setJsFile(filePath).build())); verifyDefault(); } @@ -565,10 +531,8 @@ public void test_addAllExtJSfilesFromDocRef_defer() throws Exception { replayDefault(); command.addAllExtJSfilesFromDocRef(contextDocRef); assertEquals("must be already added by addAllExtJSfilesFromDocRef", "", - command.addExtJSfileOnce(new ExtJsFileParameter.Builder() - .setJsFile(filePath) - .setLoadMode(loadMode) - .build())); + command.addExtJSfileOnce( + new ExtJsFileParameter.Builder().setJsFile(filePath).setLoadMode(loadMode).build())); verifyDefault(); } @@ -594,10 +558,8 @@ public void test_addAllExtJSfilesFromDocRef_async() throws Exception { replayDefault(); command.addAllExtJSfilesFromDocRef(contextDocRef); assertEquals("must be already added by addAllExtJSfilesFromDocRef", "", - command.addExtJSfileOnce(new ExtJsFileParameter.Builder() - .setJsFile(filePath) - .setLoadMode(loadMode) - .build())); + command.addExtJSfileOnce( + new ExtJsFileParameter.Builder().setJsFile(filePath).setLoadMode(loadMode).build())); verifyDefault(); } @@ -655,14 +617,11 @@ public void test_addExtJSfileOnce_beforeGetAll_double() throws Exception { XWikiDocument simpleLayoutDoc = new XWikiDocument(simpleLayoutDocRef); expect(modelAccessMock.getDocument(eq(simpleLayoutDocRef))).andReturn(simpleLayoutDoc) .atLeastOnce(); - expect(pageLayoutCmdMock.getLayoutPropDocRefForCurrentDoc()).andReturn(Optional.of( - simpleLayoutDocRef)).atLeastOnce(); - final ExtJsFileParameter fileParams = new ExtJsFileParameter.Builder() - .setJsFile(file) - .build(); + expect(pageLayoutCmdMock.getLayoutPropDocRefForCurrentDoc()) + .andReturn(Optional.of(simpleLayoutDocRef)).atLeastOnce(); + final ExtJsFileParameter fileParams = new ExtJsFileParameter.Builder().setJsFile(file).build(); final ExtJsFileParameter fileNotFoundParams = new ExtJsFileParameter.Builder() - .setJsFile(fileNotFound) - .build(); + .setJsFile(fileNotFound).build(); replayDefault(); assertEquals("", command.addExtJSfileOnce(fileParams)); assertEquals("", command.addExtJSfileOnce(fileParams)); @@ -721,20 +680,14 @@ public void test_addExtJSfileOnce_beforeGetAll_explicitAndImplicit_double() thro XWikiDocument simpleLayoutDoc = new XWikiDocument(simpleLayoutDocRef); expect(modelAccessMock.getDocument(eq(simpleLayoutDocRef))).andReturn(simpleLayoutDoc) .atLeastOnce(); - expect(pageLayoutCmdMock.getLayoutPropDocRefForCurrentDoc()).andReturn(Optional.of( - simpleLayoutDocRef)).atLeastOnce(); + expect(pageLayoutCmdMock.getLayoutPropDocRefForCurrentDoc()) + .andReturn(Optional.of(simpleLayoutDocRef)).atLeastOnce(); replayDefault(); - assertEquals("", command.addExtJSfileOnce(new ExtJsFileParameter.Builder() - .setJsFile(attFileURL) - .setAction("file") - .build())); + assertEquals("", command.addExtJSfileOnce( + new ExtJsFileParameter.Builder().setJsFile(attFileURL).setAction("file").build())); Builder paramBuilder = new ExtJsFileParameter.Builder(); - assertEquals("", command.addExtJSfileOnce(paramBuilder - .setJsFile(attFileURL) - .build())); - assertEquals("", command.addExtJSfileOnce(paramBuilder - .setJsFile(fileNotFound) - .build())); + assertEquals("", command.addExtJSfileOnce(paramBuilder.setJsFile(attFileURL).build())); + assertEquals("", command.addExtJSfileOnce(paramBuilder.setJsFile(fileNotFound).build())); String allStr = command.getAllExternalJavaScriptFiles(); assertEquals("\n" @@ -750,11 +703,8 @@ public void test_addLazyExtJSfile() { .andReturn(Optional.of(fromUriString(jsFileURL).build())); replayDefault(); assertEquals( - "" - + "", - command.getLazyLoadTag(new ExtJsFileParameter.Builder() - .setJsFile(jsFile) - .build())); + "" + "", + command.getLazyLoadTag(new ExtJsFileParameter.Builder().setJsFile(jsFile).build())); verifyDefault(); } @@ -766,12 +716,10 @@ public void test_addLazyExtJSfile_action() { expect(attUrlCmd.getAttachmentURL(jsFile, action, (String) null)) .andReturn(Optional.of(fromUriString(jsFileURL).build())); replayDefault(); - assertEquals("" - + "", - command.getLazyLoadTag(new ExtJsFileParameter.Builder() - .setJsFile(jsFile) - .setAction(action) - .build())); + assertEquals( + "" + "", + command.getLazyLoadTag( + new ExtJsFileParameter.Builder().setJsFile(jsFile).setAction(action).build())); verifyDefault(); } @@ -783,13 +731,11 @@ public void test_addLazyExtJSfile_action_params() { expect(attUrlCmd.getAttachmentURL(jsFile, action, "me=blu")) .andReturn(Optional.of(fromUriString(jsFileURL).queryParam("me", "blu").build())); replayDefault(); - assertEquals("" - + "", - command.getLazyLoadTag(new ExtJsFileParameter.Builder() - .setJsFile(jsFile) - .setAction(action) - .setQueryString("me=blu") - .build())); + assertEquals( + "" + + "", + command.getLazyLoadTag(new ExtJsFileParameter.Builder().setJsFile(jsFile).setAction(action) + .setQueryString("me=blu").build())); verifyDefault(); } @@ -802,13 +748,10 @@ public void test_addLazyExtJSfile_action_params_onDisk() { expect(attUrlCmd.getAttachmentURL(jsFile, action, "me=blu")) .andReturn(Optional.of(fromUriString(jsFileURL).queryParam("me", "blu").build())); replayDefault(); - assertEquals("", - command.getLazyLoadTag(new ExtJsFileParameter.Builder() - .setJsFile(jsFile) - .setAction(action) - .setQueryString("me=blu") - .build())); + assertEquals( + "", + command.getLazyLoadTag(new ExtJsFileParameter.Builder().setJsFile(jsFile).setAction(action) + .setQueryString("me=blu").build())); verifyDefault(); } diff --git a/src/test/java/com/celements/web/plugin/cmd/FileBaseTagsCmdTest.java b/src/test/java/com/celements/web/plugin/cmd/FileBaseTagsCmdTest.java index bbf33eb02..8045644f4 100644 --- a/src/test/java/com/celements/web/plugin/cmd/FileBaseTagsCmdTest.java +++ b/src/test/java/com/celements/web/plugin/cmd/FileBaseTagsCmdTest.java @@ -74,8 +74,8 @@ public void prepareTest() throws Exception { @Test public void testGetTagSpaceName() { String celFileBaseName = "Content_attachments.FileBaseDoc"; - expect(xwiki.getSpacePreference(eq("cel_centralfilebase"), eq(""), same(context))).andReturn( - celFileBaseName); + expect(xwiki.getSpacePreference(eq("cel_centralfilebase"), eq(""), same(context))) + .andReturn(celFileBaseName); replayDefault(); assertEquals("Content_attachments", fileBaseTagCmd.getTagSpaceName(context)); verifyDefault(); @@ -85,8 +85,8 @@ public void testGetTagSpaceName() { @Test public void testGetTagSpaceName_onlySpaceName() { String celFileBaseName = "Content_attachments"; - expect(xwiki.getSpacePreference(eq("cel_centralfilebase"), eq(""), same(context))).andReturn( - celFileBaseName); + expect(xwiki.getSpacePreference(eq("cel_centralfilebase"), eq(""), same(context))) + .andReturn(celFileBaseName); replayDefault(); assertEquals("Content_attachments", fileBaseTagCmd.getTagSpaceName(context)); verifyDefault(); @@ -96,8 +96,8 @@ public void testGetTagSpaceName_onlySpaceName() { public void testGetTagSpaceRef() { context.setDatabase("mywiki"); String celFileBaseName = "Content_attachments.FileBaseDoc"; - expect(xwiki.getSpacePreference(eq("cel_centralfilebase"), eq(""), same(context))).andReturn( - celFileBaseName); + expect(xwiki.getSpacePreference(eq("cel_centralfilebase"), eq(""), same(context))) + .andReturn(celFileBaseName); replayDefault(); SpaceReference tagSpaceRef = fileBaseTagCmd.getTagSpaceRef(); assertEquals("Content_attachments", tagSpaceRef.getName()); @@ -110,10 +110,10 @@ public void testGetTagSpaceRef_emptyString() throws Exception { ConfigurationSource xwikiPropConfigMock = registerComponentMock(ConfigurationSource.class, "xwikiproperties"); context.setDatabase("mywiki"); - expect(xwikiPropConfigMock.getProperty(eq("model.reference.default.space"), eq( - "Main"))).andReturn("DefaultSpace").anyTimes(); - expect(xwiki.getSpacePreference(eq("cel_centralfilebase"), eq(""), same(context))).andReturn( - ""); + expect(xwikiPropConfigMock.getProperty(eq("model.reference.default.space"), eq("Main"))) + .andReturn("DefaultSpace").anyTimes(); + expect(xwiki.getSpacePreference(eq("cel_centralfilebase"), eq(""), same(context))) + .andReturn(""); replayDefault(); SpaceReference tagSpaceRef = fileBaseTagCmd.getTagSpaceRef(); assertEquals("DefaultSpace_attachments", tagSpaceRef.getName()); @@ -125,8 +125,8 @@ public void testGetTagSpaceRef_emptyString() throws Exception { public void testGetTagSpaceRef_onlySpaceName() { context.setDatabase("mywiki"); String celFileBaseName = "Content_attachments"; - expect(xwiki.getSpacePreference(eq("cel_centralfilebase"), eq(""), same(context))).andReturn( - celFileBaseName); + expect(xwiki.getSpacePreference(eq("cel_centralfilebase"), eq(""), same(context))) + .andReturn(celFileBaseName); replayDefault(); SpaceReference tagSpaceRef = fileBaseTagCmd.getTagSpaceRef(); assertEquals("Content_attachments", tagSpaceRef.getName()); @@ -139,21 +139,22 @@ public void testGetTagSpaceRef_onlySpaceName() { public void testGetTagDocument_docExists_without_MenuItem() throws Exception { context.setDatabase("mywiki"); String celFileBaseName = "Content_attachments"; - SpaceReference celFileBaseRef = new SpaceReference(celFileBaseName, new WikiReference( - context.getDatabase())); - expect(xwiki.getSpacePreference(eq("cel_centralfilebase"), eq(""), same(context))).andReturn( - celFileBaseName).anyTimes(); - XWikiDocument tagDoc = new XWikiDocument(new DocumentReference(context.getDatabase(), - celFileBaseName, "tag0")); + SpaceReference celFileBaseRef = new SpaceReference(celFileBaseName, + new WikiReference(context.getDatabase())); + expect(xwiki.getSpacePreference(eq("cel_centralfilebase"), eq(""), same(context))) + .andReturn(celFileBaseName).anyTimes(); + XWikiDocument tagDoc = new XWikiDocument( + new DocumentReference(context.getDatabase(), celFileBaseName, "tag0")); tagDoc.setNew(false); - expect(mockTreeNodeSrv.getSubNodesForParent(eq(celFileBaseRef), isA( - InternalRightsFilter.class))).andReturn(Collections.emptyList()); + expect( + mockTreeNodeSrv.getSubNodesForParent(eq(celFileBaseRef), isA(InternalRightsFilter.class))) + .andReturn(Collections.emptyList()); expect(getMock(IModelAccessFacade.class).exists(tagDoc.getDocumentReference())).andReturn(true); expect(getMock(IModelAccessFacade.class).getDocument(tagDoc.getDocumentReference())) .andReturn(tagDoc); replayDefault(); - assertNotNull("docAlready exists: expecting existing doc", fileBaseTagCmd.getTagDocument("tag0", - false, context)); + assertNotNull("docAlready exists: expecting existing doc", + fileBaseTagCmd.getTagDocument("tag0", false, context)); verifyDefault(); } @@ -162,15 +163,16 @@ public void testGetTagDocument_docExists_without_MenuItem() throws Exception { public void testGetTagDocument_docExists() throws Exception { context.setDatabase("mywiki"); String celFileBaseName = "Content_attachments"; - SpaceReference celFileBaseRef = new SpaceReference(celFileBaseName, new WikiReference( - context.getDatabase())); - expect(xwiki.getSpacePreference(eq("cel_centralfilebase"), eq(""), same(context))).andReturn( - celFileBaseName).anyTimes(); + SpaceReference celFileBaseRef = new SpaceReference(celFileBaseName, + new WikiReference(context.getDatabase())); + expect(xwiki.getSpacePreference(eq("cel_centralfilebase"), eq(""), same(context))) + .andReturn(celFileBaseName).anyTimes(); DocumentReference tagDocRef = new DocumentReference(context.getDatabase(), celFileBaseName, "tag0"); expect(getMock(IModelAccessFacade.class).exists(tagDocRef)).andReturn(true); - expect(mockTreeNodeSrv.getSubNodesForParent(eq(celFileBaseRef), isA( - InternalRightsFilter.class))).andReturn(Arrays.asList(new TreeNode(tagDocRef, null, 2))); + expect( + mockTreeNodeSrv.getSubNodesForParent(eq(celFileBaseRef), isA(InternalRightsFilter.class))) + .andReturn(Arrays.asList(new TreeNode(tagDocRef, null, 2))); XWikiDocument existingTagDoc = new XWikiDocument(tagDocRef); existingTagDoc.setNew(false); BaseObject expectedMenuItemObj = new BaseObject(); @@ -185,8 +187,8 @@ public void testGetTagDocument_docExists() throws Exception { assertFalse("docAlready exists: expecting existing doc not new", tagDocument.isNew()); BaseObject menuItemObj = tagDocument.getXObject(navClassConfig.getMenuItemClassRef()); assertNotNull("expecting attached object", menuItemObj); - assertEquals("expecting attached object", 2, menuItemObj.getIntValue( - INavigationClassConfig.MENU_POSITION_FIELD)); + assertEquals("expecting attached object", 2, + menuItemObj.getIntValue(INavigationClassConfig.MENU_POSITION_FIELD)); verifyDefault(); } @@ -195,23 +197,23 @@ public void testGetTagDocument_docExists() throws Exception { public void testGetTagDocument_docExists_addingMenuItem() throws Exception { context.setDatabase("mywiki"); String celFileBaseName = "Content_attachments"; - SpaceReference celFileBaseRef = new SpaceReference(celFileBaseName, new WikiReference( - context.getDatabase())); - expect(xwiki.getSpacePreference(eq("cel_centralfilebase"), eq(""), same(context))).andReturn( - celFileBaseName).anyTimes(); + SpaceReference celFileBaseRef = new SpaceReference(celFileBaseName, + new WikiReference(context.getDatabase())); + expect(xwiki.getSpacePreference(eq("cel_centralfilebase"), eq(""), same(context))) + .andReturn(celFileBaseName).anyTimes(); DocumentReference tagDocRef = new DocumentReference(context.getDatabase(), celFileBaseName, "tag0"); expect(getMock(IModelAccessFacade.class).exists(tagDocRef)).andReturn(true); DocumentReference tagDocRef2 = new DocumentReference(context.getDatabase(), celFileBaseName, "tag1"); - expect(mockTreeNodeSrv.getSubNodesForParent(eq(celFileBaseRef), isA( - InternalRightsFilter.class))).andReturn(Arrays.asList(new TreeNode(tagDocRef2, null, - 0))).atLeastOnce(); + expect( + mockTreeNodeSrv.getSubNodesForParent(eq(celFileBaseRef), isA(InternalRightsFilter.class))) + .andReturn(Arrays.asList(new TreeNode(tagDocRef2, null, 0))).atLeastOnce(); XWikiDocument existingTagDoc = new XWikiDocument(tagDocRef); existingTagDoc.setNew(false); BaseClass menuItemBaseClass = createDefaultMock(BaseClass.class); - expect(xwiki.getXClass(eq(navClassConfig.getMenuItemClassRef()), same(context))).andReturn( - menuItemBaseClass).once(); + expect(xwiki.getXClass(eq(navClassConfig.getMenuItemClassRef()), same(context))) + .andReturn(menuItemBaseClass).once(); BaseObject expectedMenuItemObj = new BaseObject(); expectedMenuItemObj.setXClassReference(navClassConfig.getMenuItemClassRef()); expect(menuItemBaseClass.newCustomClassInstance(same(context))).andReturn(expectedMenuItemObj); @@ -228,8 +230,8 @@ public void testGetTagDocument_docExists_addingMenuItem() throws Exception { XWikiDocument savedTagDocument = savedDocCapture.getValue(); BaseObject menuItemObj = savedTagDocument.getXObject(navClassConfig.getMenuItemClassRef()); assertNotNull("expecting attached object", menuItemObj); - assertEquals("expecting attached object", 1, menuItemObj.getIntValue( - INavigationClassConfig.MENU_POSITION_FIELD)); + assertEquals("expecting attached object", 1, + menuItemObj.getIntValue(INavigationClassConfig.MENU_POSITION_FIELD)); verifyDefault(); } @@ -237,15 +239,16 @@ public void testGetTagDocument_docExists_addingMenuItem() throws Exception { public void testGetOrCreateTagDocument_docExists_without_MenuItem() throws Exception { context.setDatabase("mywiki"); String celFileBaseName = "Content_attachments"; - SpaceReference celFileBaseRef = new SpaceReference(celFileBaseName, new WikiReference( - context.getDatabase())); - expect(xwiki.getSpacePreference(eq("cel_centralfilebase"), eq(""), same(context))).andReturn( - celFileBaseName).anyTimes(); - XWikiDocument tagDoc = new XWikiDocument(new DocumentReference(context.getDatabase(), - celFileBaseName, "tag0")); + SpaceReference celFileBaseRef = new SpaceReference(celFileBaseName, + new WikiReference(context.getDatabase())); + expect(xwiki.getSpacePreference(eq("cel_centralfilebase"), eq(""), same(context))) + .andReturn(celFileBaseName).anyTimes(); + XWikiDocument tagDoc = new XWikiDocument( + new DocumentReference(context.getDatabase(), celFileBaseName, "tag0")); tagDoc.setNew(false); - expect(mockTreeNodeSrv.getSubNodesForParent(eq(celFileBaseRef), isA( - InternalRightsFilter.class))).andReturn(Collections.emptyList()); + expect( + mockTreeNodeSrv.getSubNodesForParent(eq(celFileBaseRef), isA(InternalRightsFilter.class))) + .andReturn(Collections.emptyList()); expect(getMock(IModelAccessFacade.class).exists(tagDoc.getDocumentReference())).andReturn(true); expect(getMock(IModelAccessFacade.class).getDocument(tagDoc.getDocumentReference())) .andReturn(tagDoc); @@ -259,15 +262,16 @@ public void testGetOrCreateTagDocument_docExists_without_MenuItem() throws Excep public void testGetOrCreateTagDocument_docExists() throws Exception { context.setDatabase("mywiki"); String celFileBaseName = "Content_attachments"; - SpaceReference celFileBaseRef = new SpaceReference(celFileBaseName, new WikiReference( - context.getDatabase())); - expect(xwiki.getSpacePreference(eq("cel_centralfilebase"), eq(""), same(context))).andReturn( - celFileBaseName).anyTimes(); + SpaceReference celFileBaseRef = new SpaceReference(celFileBaseName, + new WikiReference(context.getDatabase())); + expect(xwiki.getSpacePreference(eq("cel_centralfilebase"), eq(""), same(context))) + .andReturn(celFileBaseName).anyTimes(); DocumentReference tagDocRef = new DocumentReference(context.getDatabase(), celFileBaseName, "tag0"); expect(getMock(IModelAccessFacade.class).exists(tagDocRef)).andReturn(true); - expect(mockTreeNodeSrv.getSubNodesForParent(eq(celFileBaseRef), isA( - InternalRightsFilter.class))).andReturn(Arrays.asList(new TreeNode(tagDocRef, null, 0))); + expect( + mockTreeNodeSrv.getSubNodesForParent(eq(celFileBaseRef), isA(InternalRightsFilter.class))) + .andReturn(Arrays.asList(new TreeNode(tagDocRef, null, 0))); XWikiDocument existingTagDoc = new XWikiDocument(tagDocRef); existingTagDoc.setNew(false); BaseObject expectedMenuItemObj = new BaseObject(); @@ -282,8 +286,8 @@ public void testGetOrCreateTagDocument_docExists() throws Exception { assertFalse("docAlready exists: expecting existing doc not new", tagDocument.isNew()); BaseObject menuItemObj = tagDocument.getXObject(navClassConfig.getMenuItemClassRef()); assertNotNull("expecting attached object", menuItemObj); - assertEquals("expecting attached object", 2, menuItemObj.getIntValue( - INavigationClassConfig.MENU_POSITION_FIELD)); + assertEquals("expecting attached object", 2, + menuItemObj.getIntValue(INavigationClassConfig.MENU_POSITION_FIELD)); verifyDefault(); } @@ -291,23 +295,23 @@ public void testGetOrCreateTagDocument_docExists() throws Exception { public void testGetOrCreateTagDocument_docExists_addingMenuItem() throws Exception { context.setDatabase("mywiki"); String celFileBaseName = "Content_attachments"; - SpaceReference celFileBaseRef = new SpaceReference(celFileBaseName, new WikiReference( - context.getDatabase())); - expect(xwiki.getSpacePreference(eq("cel_centralfilebase"), eq(""), same(context))).andReturn( - celFileBaseName).anyTimes(); + SpaceReference celFileBaseRef = new SpaceReference(celFileBaseName, + new WikiReference(context.getDatabase())); + expect(xwiki.getSpacePreference(eq("cel_centralfilebase"), eq(""), same(context))) + .andReturn(celFileBaseName).anyTimes(); DocumentReference tagDocRef = new DocumentReference(context.getDatabase(), celFileBaseName, "tag0"); expect(getMock(IModelAccessFacade.class).exists(tagDocRef)).andReturn(true); DocumentReference tagDocRef2 = new DocumentReference(context.getDatabase(), celFileBaseName, "tag1"); - expect(mockTreeNodeSrv.getSubNodesForParent(eq(celFileBaseRef), isA( - InternalRightsFilter.class))).andReturn(Arrays.asList(new TreeNode(tagDocRef2, null, - 0))).atLeastOnce(); + expect( + mockTreeNodeSrv.getSubNodesForParent(eq(celFileBaseRef), isA(InternalRightsFilter.class))) + .andReturn(Arrays.asList(new TreeNode(tagDocRef2, null, 0))).atLeastOnce(); XWikiDocument existingTagDoc = new XWikiDocument(tagDocRef); existingTagDoc.setNew(false); BaseClass menuItemBaseClass = createDefaultMock(BaseClass.class); - expect(xwiki.getXClass(eq(navClassConfig.getMenuItemClassRef()), same(context))).andReturn( - menuItemBaseClass).once(); + expect(xwiki.getXClass(eq(navClassConfig.getMenuItemClassRef()), same(context))) + .andReturn(menuItemBaseClass).once(); BaseObject expectedMenuItemObj = new BaseObject(); expectedMenuItemObj.setXClassReference(navClassConfig.getMenuItemClassRef()); expect(menuItemBaseClass.newCustomClassInstance(same(context))).andReturn(expectedMenuItemObj); @@ -324,8 +328,8 @@ public void testGetOrCreateTagDocument_docExists_addingMenuItem() throws Excepti XWikiDocument savedTagDocument = savedDocCapture.getValue(); BaseObject menuItemObj = savedTagDocument.getXObject(navClassConfig.getMenuItemClassRef()); assertNotNull("expecting attached object", menuItemObj); - assertEquals("expecting attached object", 1, menuItemObj.getIntValue( - INavigationClassConfig.MENU_POSITION_FIELD)); + assertEquals("expecting attached object", 1, + menuItemObj.getIntValue(INavigationClassConfig.MENU_POSITION_FIELD)); verifyDefault(); } @@ -333,10 +337,10 @@ public void testGetOrCreateTagDocument_docExists_addingMenuItem() throws Excepti public void testGetOrCreateTagDocument_docNotExists_Exception() throws Exception { context.setDatabase("mywiki"); String celFileBaseName = "Content_attachments"; - SpaceReference celFileBaseRef = new SpaceReference(celFileBaseName, new WikiReference( - context.getDatabase())); - expect(xwiki.getSpacePreference(eq("cel_centralfilebase"), eq(""), same(context))).andReturn( - celFileBaseName).anyTimes(); + SpaceReference celFileBaseRef = new SpaceReference(celFileBaseName, + new WikiReference(context.getDatabase())); + expect(xwiki.getSpacePreference(eq("cel_centralfilebase"), eq(""), same(context))) + .andReturn(celFileBaseName).anyTimes(); DocumentReference tagDocRef = new DocumentReference(context.getDatabase(), celFileBaseName, "tag0"); XWikiDocument inExistTagDoc = new XWikiDocument(tagDocRef); @@ -347,12 +351,12 @@ public void testGetOrCreateTagDocument_docNotExists_Exception() throws Exception .andThrow(new DocumentNotExistsException(tagDocRef)); DocumentReference tagDocRef2 = new DocumentReference(context.getDatabase(), celFileBaseName, "tag1"); - expect(mockTreeNodeSrv.getSubNodesForParent(eq(celFileBaseRef), isA( - InternalRightsFilter.class))).andReturn(Arrays.asList(new TreeNode(tagDocRef2, null, - 0))).atLeastOnce(); + expect( + mockTreeNodeSrv.getSubNodesForParent(eq(celFileBaseRef), isA(InternalRightsFilter.class))) + .andReturn(Arrays.asList(new TreeNode(tagDocRef2, null, 0))).atLeastOnce(); BaseClass menuItemBaseClass = createDefaultMock(BaseClass.class); - expect(xwiki.getXClass(eq(navClassConfig.getMenuItemClassRef()), same(context))).andReturn( - menuItemBaseClass).once(); + expect(xwiki.getXClass(eq(navClassConfig.getMenuItemClassRef()), same(context))) + .andReturn(menuItemBaseClass).once(); BaseObject expectedMenuItemObj = new BaseObject(); expectedMenuItemObj.setXClassReference(navClassConfig.getMenuItemClassRef()); expect(menuItemBaseClass.newCustomClassInstance(same(context))).andReturn(expectedMenuItemObj); @@ -368,8 +372,8 @@ public void testGetOrCreateTagDocument_docNotExists_Exception() throws Exception XWikiDocument savedTagDocument = savedDocCapture.getValue(); BaseObject menuItemObj = savedTagDocument.getXObject(navClassConfig.getMenuItemClassRef()); assertNotNull("expecting attached object", menuItemObj); - assertEquals("expecting attached object", 1, menuItemObj.getIntValue( - INavigationClassConfig.MENU_POSITION_FIELD)); + assertEquals("expecting attached object", 1, + menuItemObj.getIntValue(INavigationClassConfig.MENU_POSITION_FIELD)); verifyDefault(); } diff --git a/src/test/java/com/celements/web/plugin/cmd/GetCellDocumentTest.java b/src/test/java/com/celements/web/plugin/cmd/GetCellDocumentTest.java index cfddd0fef..55c772a0a 100644 --- a/src/test/java/com/celements/web/plugin/cmd/GetCellDocumentTest.java +++ b/src/test/java/com/celements/web/plugin/cmd/GetCellDocumentTest.java @@ -64,8 +64,8 @@ public void testGetCellDoc_FromContext() throws XWikiException { paramList.add("field"); paramList.add("value"); expect(xwiki.getStore()).andReturn(store).anyTimes(); - expect(store.searchDocuments((String) anyObject(), eq(paramList), same(context))).andReturn( - docList).once(); + expect(store.searchDocuments((String) anyObject(), eq(paramList), same(context))) + .andReturn(docList).once(); XWikiDocument lDoc = new XWikiDocument("Space", "Name"); expect(plc.getLayoutPropDoc()).andReturn(lDoc).once(); replay(plc, store, xwiki); @@ -86,8 +86,8 @@ public void testGetCellDoc() throws XWikiException { paramList.add("field"); paramList.add("value"); expect(xwiki.getStore()).andReturn(store).anyTimes(); - expect(store.searchDocuments((String) anyObject(), eq(paramList), same(context))).andReturn( - docList).once(); + expect(store.searchDocuments((String) anyObject(), eq(paramList), same(context))) + .andReturn(docList).once(); replay(store, xwiki); XWikiDocument result = cmd.getCellDoc("Space", "Class.Name", "field", "value", context); verify(store, xwiki); diff --git a/src/test/java/com/celements/web/plugin/cmd/PageLayoutCommandTest.java b/src/test/java/com/celements/web/plugin/cmd/PageLayoutCommandTest.java index 8faad9fe1..05064d1b8 100644 --- a/src/test/java/com/celements/web/plugin/cmd/PageLayoutCommandTest.java +++ b/src/test/java/com/celements/web/plugin/cmd/PageLayoutCommandTest.java @@ -136,8 +136,8 @@ public void test_getLayoutPropDoc_proxyCheck() throws Exception { DocumentReference webHomeDocRef = new DocumentReference(context.getDatabase(), "MyPageLayout", "WebHome"); XWikiDocument webHomeDoc = new XWikiDocument(webHomeDocRef); - expect(layoutServiceMock.getLayoutPropDocRefForCurrentDoc()).andReturn(Optional.of( - webHomeDocRef)); + expect(layoutServiceMock.getLayoutPropDocRefForCurrentDoc()) + .andReturn(Optional.of(webHomeDocRef)); expect(modelAccessMock.getDocument(eq(webHomeDocRef))).andReturn(webHomeDoc); replayDefault(); assertSame(webHomeDoc, plCmd.getLayoutPropDoc()); @@ -148,8 +148,8 @@ public void test_getLayoutPropDoc_proxyCheck() throws Exception { public void test_getLayoutPropDoc_proxyCheck_DocNotExist() throws Exception { DocumentReference webHomeDocRef = new DocumentReference(context.getDatabase(), "MyPageLayout", "WebHome"); - expect(layoutServiceMock.getLayoutPropDocRefForCurrentDoc()).andReturn(Optional.of( - webHomeDocRef)); + expect(layoutServiceMock.getLayoutPropDocRefForCurrentDoc()) + .andReturn(Optional.of(webHomeDocRef)); expect(modelAccessMock.getDocument(eq(webHomeDocRef))) .andThrow(new DocumentNotExistsException(webHomeDocRef)).anyTimes(); replayDefault(); @@ -175,8 +175,8 @@ public void test_getLayoutPropDoc_SpaceReference_proxyCheck() throws Exception { expect(layoutServiceMock.getLayoutPropDocRef(layoutSpaceRef)) .andReturn(Optional.of(webHomeDocRef)); expect(modelAccessMock.getDocument(eq(webHomeDocRef))).andReturn(webHomeDoc); - expect(layoutServiceMock.getLayoutPropertyObj(layoutSpaceRef)).andReturn( - Optional.of(new BaseObject())); + expect(layoutServiceMock.getLayoutPropertyObj(layoutSpaceRef)) + .andReturn(Optional.of(new BaseObject())); replayDefault(); assertSame(webHomeDoc, plCmd.getLayoutPropDoc(layoutSpaceRef)); verifyDefault(); @@ -214,8 +214,8 @@ public void test_getLayoutPropDoc_SpaceReference_proxyCheck_DocNotExist() throws @Test public void test_deleteLayout() throws Exception { String layoutName = "delLayout"; - SpaceReference layoutSpaceRef = new SpaceReference(layoutName, new WikiReference( - context.getDatabase())); + SpaceReference layoutSpaceRef = new SpaceReference(layoutName, + new WikiReference(context.getDatabase())); expect(layoutServiceMock.deleteLayout(eq(layoutSpaceRef))).andReturn(true); replayDefault(); assertTrue(plCmd.deleteLayout(layoutSpaceRef)); @@ -241,8 +241,8 @@ public void test_layoutEditorAvailable_notavailable() throws Exception { @Test public void test_canRenderLayout_true() throws Exception { String layoutName = "TestLayout"; - SpaceReference layoutSpaceRef = new SpaceReference(layoutName, new WikiReference( - context.getDatabase())); + SpaceReference layoutSpaceRef = new SpaceReference(layoutName, + new WikiReference(context.getDatabase())); expect(layoutServiceMock.canRenderLayout(layoutSpaceRef)).andReturn(true); replayDefault(); assertTrue(plCmd.canRenderLayout(layoutSpaceRef)); @@ -252,8 +252,8 @@ public void test_canRenderLayout_true() throws Exception { @Test public void test_canRenderLayout_false() throws Exception { String layoutName = "TestLayout"; - SpaceReference layoutSpaceRef = new SpaceReference(layoutName, new WikiReference( - context.getDatabase())); + SpaceReference layoutSpaceRef = new SpaceReference(layoutName, + new WikiReference(context.getDatabase())); expect(layoutServiceMock.canRenderLayout(layoutSpaceRef)).andReturn(false); replayDefault(); assertFalse(plCmd.canRenderLayout(layoutSpaceRef)); @@ -263,8 +263,8 @@ public void test_canRenderLayout_false() throws Exception { @Test public void test_layoutExists_true() throws Exception { String layoutName = "TestLayout"; - SpaceReference layoutSpaceRef = new SpaceReference(layoutName, new WikiReference( - context.getDatabase())); + SpaceReference layoutSpaceRef = new SpaceReference(layoutName, + new WikiReference(context.getDatabase())); expect(layoutServiceMock.existsLayout(layoutSpaceRef)).andReturn(true); replayDefault(); assertTrue(plCmd.layoutExists(layoutSpaceRef)); @@ -274,8 +274,8 @@ public void test_layoutExists_true() throws Exception { @Test public void test_layoutExists_false() throws Exception { String layoutName = "TestLayout"; - SpaceReference layoutSpaceRef = new SpaceReference(layoutName, new WikiReference( - context.getDatabase())); + SpaceReference layoutSpaceRef = new SpaceReference(layoutName, + new WikiReference(context.getDatabase())); expect(layoutServiceMock.existsLayout(layoutSpaceRef)).andReturn(false); replayDefault(); assertFalse(plCmd.layoutExists(layoutSpaceRef)); @@ -284,8 +284,8 @@ public void test_layoutExists_false() throws Exception { @Test public void test_createNew_proxyCheck() throws Exception { - SpaceReference layoutSpaceRef = new SpaceReference( - PageLayoutCommand.CEL_LAYOUT_EDITOR_PL_NAME, getWikiRef()); + SpaceReference layoutSpaceRef = new SpaceReference(PageLayoutCommand.CEL_LAYOUT_EDITOR_PL_NAME, + getWikiRef()); @NotNull boolean response = true; expect(layoutServiceMock.createLayout(eq(layoutSpaceRef))).andReturn(response); @@ -298,11 +298,11 @@ public void test_createNew_proxyCheck() throws Exception { @Test public void test_getLayoutPropertyObj_proxyCheck() throws Exception { - SpaceReference layoutSpaceRef = new SpaceReference( - PageLayoutCommand.CEL_LAYOUT_EDITOR_PL_NAME, getWikiRef()); + SpaceReference layoutSpaceRef = new SpaceReference(PageLayoutCommand.CEL_LAYOUT_EDITOR_PL_NAME, + getWikiRef()); BaseObject propObj = new BaseObject(); - expect(layoutServiceMock.getLayoutPropertyObj(eq(layoutSpaceRef))).andReturn(Optional.of( - propObj)); + expect(layoutServiceMock.getLayoutPropertyObj(eq(layoutSpaceRef))) + .andReturn(Optional.of(propObj)); replayDefault(); BaseObject ret = plCmd.getLayoutPropertyObj(layoutSpaceRef); verifyDefault(); @@ -312,8 +312,8 @@ public void test_getLayoutPropertyObj_proxyCheck() throws Exception { @Test public void test_resolveValidLayoutSpace_proxyCheck() throws Exception { - SpaceReference layoutSpaceRef = new SpaceReference( - PageLayoutCommand.CEL_LAYOUT_EDITOR_PL_NAME, getWikiRef()); + SpaceReference layoutSpaceRef = new SpaceReference(PageLayoutCommand.CEL_LAYOUT_EDITOR_PL_NAME, + getWikiRef()); SpaceReference centralLayoutSpaceRef = new SpaceReference( PageLayoutCommand.CEL_LAYOUT_EDITOR_PL_NAME, centralWikiRef); expect(layoutServiceMock.resolveValidLayoutSpace(eq(layoutSpaceRef))) @@ -327,8 +327,8 @@ public void test_resolveValidLayoutSpace_proxyCheck() throws Exception { @Test public void test_resolveValidLayoutSpace_absent() throws Exception { - SpaceReference layoutSpaceRef = new SpaceReference( - PageLayoutCommand.CEL_LAYOUT_EDITOR_PL_NAME, getWikiRef()); + SpaceReference layoutSpaceRef = new SpaceReference(PageLayoutCommand.CEL_LAYOUT_EDITOR_PL_NAME, + getWikiRef()); expect(layoutServiceMock.resolveValidLayoutSpace(eq(layoutSpaceRef))) .andReturn(Optional.empty()); replayDefault(); @@ -340,8 +340,8 @@ public void test_resolveValidLayoutSpace_absent() throws Exception { @Test public void test_standardPropDocRef() throws Exception { - SpaceReference layoutSpaceRef = new SpaceReference( - PageLayoutCommand.CEL_LAYOUT_EDITOR_PL_NAME, getWikiRef()); + SpaceReference layoutSpaceRef = new SpaceReference(PageLayoutCommand.CEL_LAYOUT_EDITOR_PL_NAME, + getWikiRef()); DocumentReference ret = plCmd.standardPropDocRef(layoutSpaceRef); assertNotNull(ret); assertEquals(layoutSpaceRef, ret.getParent()); @@ -350,8 +350,8 @@ public void test_standardPropDocRef() throws Exception { @Test public void test_getHTMLType_XHTML_proxyCheck() throws Exception { - SpaceReference layoutRef = new SpaceReference("MyPageLayout", new WikiReference( - context.getDatabase())); + SpaceReference layoutRef = new SpaceReference("MyPageLayout", + new WikiReference(context.getDatabase())); expect(layoutServiceMock.getHTMLType(eq(layoutRef))).andReturn(HtmlDoctype.XHTML); replayDefault(); assertEquals(HtmlDoctype.XHTML, plCmd.getHTMLType(layoutRef)); @@ -360,8 +360,8 @@ public void test_getHTMLType_XHTML_proxyCheck() throws Exception { @Test public void test_getHTMLType_HTML5_proxyCheck() throws Exception { - SpaceReference layoutRef = new SpaceReference("MyPageLayout", new WikiReference( - context.getDatabase())); + SpaceReference layoutRef = new SpaceReference("MyPageLayout", + new WikiReference(context.getDatabase())); expect(layoutServiceMock.getHTMLType(eq(layoutRef))).andReturn(HtmlDoctype.HTML5); replayDefault(); assertEquals(HtmlDoctype.HTML5, plCmd.getHTMLType(layoutRef)); diff --git a/src/test/java/com/celements/web/plugin/cmd/ParseObjStoreCommandTest.java b/src/test/java/com/celements/web/plugin/cmd/ParseObjStoreCommandTest.java index e4e823369..31dfe711b 100644 --- a/src/test/java/com/celements/web/plugin/cmd/ParseObjStoreCommandTest.java +++ b/src/test/java/com/celements/web/plugin/cmd/ParseObjStoreCommandTest.java @@ -95,8 +95,8 @@ public void testGetObjStoreOptionsMap_aRadio() { @Test public void testGetObjStoreOptionsMap_mixedCheckboxesAndRadio() { - Map map = cmd.getObjStoreOptionsMap("member:Isch bin!;10;20;;0;;3" - + "\nHi\nthen\n\n \n", context); + Map map = cmd + .getObjStoreOptionsMap("member:Isch bin!;10;20;;0;;3" + "\nHi\nthen\n\n \n", context); assertTrue(map.containsKey("member:3")); assertTrue(map.containsValue("Isch bin!")); assertTrue(map.containsKey("Hi")); diff --git a/src/test/java/com/celements/web/plugin/cmd/PasswordRecoveryAndEmailValidationCommandTest.java b/src/test/java/com/celements/web/plugin/cmd/PasswordRecoveryAndEmailValidationCommandTest.java index a2e96c6f1..b3c6717cd 100644 --- a/src/test/java/com/celements/web/plugin/cmd/PasswordRecoveryAndEmailValidationCommandTest.java +++ b/src/test/java/com/celements/web/plugin/cmd/PasswordRecoveryAndEmailValidationCommandTest.java @@ -96,8 +96,8 @@ public void testGetValidationEmailContent() throws Exception { DocumentReference defaultAccountActivation = new DocumentReference(getContext().getDatabase(), "Mails", "AccountActivationMail"); String expectedRenderedContent = "expectedRenderedContent"; - expect(webUtilsMock.renderInheritableDocument(eq(defaultAccountActivation), eq("de"), eq( - "en"))).andReturn(expectedRenderedContent); + expect(webUtilsMock.renderInheritableDocument(eq(defaultAccountActivation), eq("de"), eq("en"))) + .andReturn(expectedRenderedContent); replayDefault(); assertEquals(expectedRenderedContent, cmd.getValidationEmailContent(null, "de", "en")); verifyDefault(); @@ -109,9 +109,9 @@ public void testGetActivationLink_Contentlogin_notRestricted() throws Exception String validkey = "1j392k347"; String expectedActivationLink = "http://www.unit-test.test/login" + "?email=mytest%40unit.test&ac=" + validkey; - expect(getWikiMock().getExternalURL(eq("Content.login"), eq("view"), eq( - "email=mytest%40unit.test&ac=" + validkey), same(getContext()))).andReturn( - expectedActivationLink); + expect(getWikiMock().getExternalURL(eq("Content.login"), eq("view"), + eq("email=mytest%40unit.test&ac=" + validkey), same(getContext()))) + .andReturn(expectedActivationLink); expect(rightServiceMock.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq("Content.login"), same(getContext()))).andReturn(true).atLeastOnce(); replayDefault(); @@ -125,9 +125,9 @@ public void testGetActivationLink_Contentlogin_restricted() throws Exception { String validkey = "1j392k347"; String expectedActivationLink = "http://www.unit-test.test/login/XWiki/XWikiLogin" + "?email=mytest%40unit.test&ac=" + validkey; - expect(getWikiMock().getExternalURL(eq("XWiki.XWikiLogin"), eq("login"), eq( - "email=mytest%40unit.test&ac=" + validkey), same(getContext()))).andReturn( - expectedActivationLink); + expect(getWikiMock().getExternalURL(eq("XWiki.XWikiLogin"), eq("login"), + eq("email=mytest%40unit.test&ac=" + validkey), same(getContext()))) + .andReturn(expectedActivationLink); expect(rightServiceMock.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq("Content.login"), same(getContext()))).andReturn(false).atLeastOnce(); replayDefault(); @@ -158,8 +158,8 @@ public void testGetValidationEmailSubject_defLang() throws Exception { dictSubjectValue); XWikiMessageTool mockMessageTool = createDefaultMock(XWikiMessageTool.class); expect(webUtilsMock.getMessageTool(eq("de"))).andReturn(mockMessageTool); - expect(mockMessageTool.get(eq(dicMailSubjectKey), isA(List.class))).andReturn( - dicMailSubjectKey); + expect(mockMessageTool.get(eq(dicMailSubjectKey), isA(List.class))) + .andReturn(dicMailSubjectKey); expect(webUtilsMock.getMessageTool(eq("en"))).andReturn(getContext().getMessageTool()); expect(requestMock.getHeader(eq("host"))).andReturn("www.unit.test").anyTimes(); replayDefault(); @@ -172,8 +172,8 @@ public void testGetValidationEmailSubject_defLang_null() throws Exception { String dicMailSubjectKey = PasswordRecoveryAndEmailValidationCommand.CEL_ACOUNT_ACTIVATION_MAIL_SUBJECT_KEY; XWikiMessageTool mockMessageTool = createDefaultMock(XWikiMessageTool.class); expect(webUtilsMock.getMessageTool(eq("de"))).andReturn(mockMessageTool); - expect(mockMessageTool.get(eq(dicMailSubjectKey), isA(List.class))).andReturn( - dicMailSubjectKey); + expect(mockMessageTool.get(eq(dicMailSubjectKey), isA(List.class))) + .andReturn(dicMailSubjectKey); expect(webUtilsMock.getMessageTool((String) isNull())).andReturn(null).anyTimes(); expect(requestMock.getHeader(eq("host"))).andReturn("www.unit.test").anyTimes(); replayDefault(); @@ -185,9 +185,9 @@ public void testGetValidationEmailSubject_defLang_null() throws Exception { public void testGetFromEmailAdr_null() { String sender = ""; String from = "from@mail.com"; - expect(getWikiMock().getXWikiPreference(eq("admin_email"), eq( - CelMailConfiguration.MAIL_DEFAULT_ADMIN_EMAIL_KEY), eq(""), same(getContext()))).andReturn( - from); + expect(getWikiMock().getXWikiPreference(eq("admin_email"), + eq(CelMailConfiguration.MAIL_DEFAULT_ADMIN_EMAIL_KEY), eq(""), same(getContext()))) + .andReturn(from); replayDefault(); sender = cmd.getFromEmailAdr(sender, null); assertEquals(from, sender); @@ -201,8 +201,9 @@ public void testSetValidationInfoInContext() throws Exception { String to = "to@mail.com"; String validkey = "validkey123"; String expectedLink = "http://myserver.ch/login?email=to%40mail.com&ac=" + validkey; - expect(getWikiMock().getExternalURL(eq("Content.login"), eq("view"), eq( - "email=to%40mail.com&ac=" + validkey), same(getContext()))).andReturn(expectedLink).once(); + expect(getWikiMock().getExternalURL(eq("Content.login"), eq("view"), + eq("email=to%40mail.com&ac=" + validkey), same(getContext()))).andReturn(expectedLink) + .once(); expect(rightServiceMock.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq("Content.login"), same(getContext()))).andReturn(true).atLeastOnce(); replayDefault(); @@ -222,8 +223,8 @@ public void test_createNewValidationTokenForUser() throws Exception { XWikiDocument userDoc = new XWikiDocument(userDocRef); expect(user.getDocument()).andReturn(userDoc); expect(authServiceMock.getUniqueValidationKey()).andReturn(token); - expect(modelAccessMock.setProperty(userDoc, XWikiUsersClass.FIELD_VALID_KEY, token)).andReturn( - true); + expect(modelAccessMock.setProperty(userDoc, XWikiUsersClass.FIELD_VALID_KEY, token)) + .andReturn(true); modelAccessMock.saveDocument(same(userDoc), anyObject(String.class)); expectLastCall(); @@ -279,8 +280,8 @@ public void test_createNewValidationTokenForUser_DocumentSaveException() throws XWikiDocument userDoc = new XWikiDocument(userDocRef); expect(user.getDocument()).andReturn(userDoc); expect(authServiceMock.getUniqueValidationKey()).andReturn(token); - expect(modelAccessMock.setProperty(userDoc, XWikiUsersClass.FIELD_VALID_KEY, token)).andReturn( - true); + expect(modelAccessMock.setProperty(userDoc, XWikiUsersClass.FIELD_VALID_KEY, token)) + .andReturn(true); modelAccessMock.saveDocument(same(userDoc), anyObject(String.class)); expectLastCall().andThrow(cause); @@ -306,16 +307,16 @@ public void testSendValidationMessage_deprecated() throws Exception { String contentDoc = "Tools.ActivationMail"; DocumentReference contentDocRef = new DocumentReference(getContext().getDatabase(), "Tools", "ActivationMail"); - expect(webUtilsMock.resolveDocumentReference(eq(contentDoc))).andReturn( - contentDocRef).anyTimes(); + expect(webUtilsMock.resolveDocumentReference(eq(contentDoc))).andReturn(contentDocRef) + .anyTimes(); String content = "This is the mail content."; String noHTML = ""; String title = "the title"; VelocityContext vcontext = new VelocityContext(); getContext().put("vcontext", vcontext); - expect(getWikiMock().getXWikiPreference(eq("admin_email"), eq( - CelMailConfiguration.MAIL_DEFAULT_ADMIN_EMAIL_KEY), eq(""), same(getContext()))).andReturn( - from); + expect(getWikiMock().getXWikiPreference(eq("admin_email"), + eq(CelMailConfiguration.MAIL_DEFAULT_ADMIN_EMAIL_KEY), eq(""), same(getContext()))) + .andReturn(from); expect(modelAccessMock.exists(eq(contentDocRef))).andReturn(true); XWikiDocument doc = createDefaultMock(XWikiDocument.class); expect(modelAccessMock.getDocument(eq(contentDocRef))).andReturn(doc); @@ -323,8 +324,9 @@ public void testSendValidationMessage_deprecated() throws Exception { expect(doc.getTranslatedDocument(eq(adminLang), same(getContext()))).andReturn(doc).anyTimes(); expect(doc.getRenderedContent(same(getContext()))).andReturn(content); expect(doc.getTitle()).andReturn(title); - expect(doc.getXObject(eq(new DocumentReference(getContext().getDatabase(), "Celements2", - "FormMailClass")))).andReturn(null); + expect(doc.getXObject( + eq(new DocumentReference(getContext().getDatabase(), "Celements2", "FormMailClass")))) + .andReturn(null); expect(rendererMock.interpretText(eq(title), same(doc), same(getContext()))).andReturn(title); celSendMailMock.setFrom(eq(from)); expectLastCall(); @@ -348,8 +350,9 @@ public void testSendValidationMessage_deprecated() throws Exception { expectLastCall(); expect(celSendMailMock.sendMail()).andReturn(1); String expectedLink = "http://myserver.ch/login?email=to%40mail.com&ac=" + validkey; - expect(getWikiMock().getExternalURL(eq("Content.login"), eq("view"), eq( - "email=to%40mail.com&ac=" + validkey), same(getContext()))).andReturn(expectedLink).once(); + expect(getWikiMock().getExternalURL(eq("Content.login"), eq("view"), + eq("email=to%40mail.com&ac=" + validkey), same(getContext()))).andReturn(expectedLink) + .once(); expect(webUtilsMock.getDefaultAdminLanguage()).andReturn(adminLang).anyTimes(); expect(rightServiceMock.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq("Content.login"), same(getContext()))).andReturn(true).atLeastOnce(); @@ -375,17 +378,18 @@ public void testSendValidationMessage() throws Exception { String title = "the title"; VelocityContext vcontext = new VelocityContext(); getContext().put("vcontext", vcontext); - expect(getWikiMock().getXWikiPreference(eq("admin_email"), eq( - CelMailConfiguration.MAIL_DEFAULT_ADMIN_EMAIL_KEY), eq(""), same(getContext()))).andReturn( - from); + expect(getWikiMock().getXWikiPreference(eq("admin_email"), + eq(CelMailConfiguration.MAIL_DEFAULT_ADMIN_EMAIL_KEY), eq(""), same(getContext()))) + .andReturn(from); expect(modelAccessMock.exists(eq(contentDocRef))).andReturn(true); XWikiDocument doc = createDefaultMock(XWikiDocument.class); expect(modelAccessMock.getDocument(eq(contentDocRef))).andReturn(doc); expect(doc.getTranslatedDocument(eq("de"), same(getContext()))).andReturn(doc).anyTimes(); expect(doc.getRenderedContent(same(getContext()))).andReturn(content); expect(doc.getTitle()).andReturn(title); - expect(doc.getXObject(eq(new DocumentReference(getContext().getDatabase(), "Celements2", - "FormMailClass")))).andReturn(null); + expect(doc.getXObject( + eq(new DocumentReference(getContext().getDatabase(), "Celements2", "FormMailClass")))) + .andReturn(null); expect(rendererMock.interpretText(eq(title), same(doc), same(getContext()))).andReturn(title); celSendMailMock.setFrom(eq(from)); expectLastCall(); @@ -409,8 +413,9 @@ public void testSendValidationMessage() throws Exception { expectLastCall(); expect(celSendMailMock.sendMail()).andReturn(1); String expectedLink = "http://myserver.ch/login?email=to%40mail.com&ac=" + validkey; - expect(getWikiMock().getExternalURL(eq("Content.login"), eq("view"), eq( - "email=to%40mail.com&ac=" + validkey), same(getContext()))).andReturn(expectedLink).once(); + expect(getWikiMock().getExternalURL(eq("Content.login"), eq("view"), + eq("email=to%40mail.com&ac=" + validkey), same(getContext()))).andReturn(expectedLink) + .once(); expect(webUtilsMock.getDefaultAdminLanguage()).andReturn(adminLang).anyTimes(); expect(rightServiceMock.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq("Content.login"), same(getContext()))).andReturn(true).atLeastOnce(); @@ -432,17 +437,17 @@ public void testSendValidationMessage_fallbackToCelements2web_deprecated() throw String contentDoc = "Tools.ActivationMail"; DocumentReference contentDocRef = new DocumentReference(getContext().getDatabase(), "Tools", "ActivationMail"); - expect(webUtilsMock.resolveDocumentReference(eq(contentDoc))).andReturn( - contentDocRef).anyTimes(); + expect(webUtilsMock.resolveDocumentReference(eq(contentDoc))).andReturn(contentDocRef) + .anyTimes(); DocumentReference contentCel2WebDocRef = new DocumentReference("celements2web", "Tools", "ActivationMail"); String content = "This is the mail content."; String noHTML = ""; String title = "the title"; getContext().put("vcontext", new VelocityContext()); - expect(getWikiMock().getXWikiPreference(eq("admin_email"), eq( - CelMailConfiguration.MAIL_DEFAULT_ADMIN_EMAIL_KEY), eq(""), same(getContext()))).andReturn( - from); + expect(getWikiMock().getXWikiPreference(eq("admin_email"), + eq(CelMailConfiguration.MAIL_DEFAULT_ADMIN_EMAIL_KEY), eq(""), same(getContext()))) + .andReturn(from); expect(modelAccessMock.exists(eq(contentDocRef))).andReturn(false); expect(modelAccessMock.exists(eq(contentCel2WebDocRef))).andReturn(true); XWikiDocument doc = createDefaultMock(XWikiDocument.class); @@ -451,8 +456,9 @@ public void testSendValidationMessage_fallbackToCelements2web_deprecated() throw expect(doc.getTranslatedDocument(eq(adminLang), same(getContext()))).andReturn(doc).anyTimes(); expect(doc.getRenderedContent(same(getContext()))).andReturn(content); expect(doc.getTitle()).andReturn(title); - expect(doc.getXObject(eq(new DocumentReference(getContext().getDatabase(), "Celements2", - "FormMailClass")))).andReturn(null); + expect(doc.getXObject( + eq(new DocumentReference(getContext().getDatabase(), "Celements2", "FormMailClass")))) + .andReturn(null); expect(rendererMock.interpretText(eq(title), same(doc), same(getContext()))).andReturn(title); celSendMailMock.setFrom(eq(from)); expectLastCall(); @@ -476,8 +482,9 @@ public void testSendValidationMessage_fallbackToCelements2web_deprecated() throw expectLastCall(); expect(celSendMailMock.sendMail()).andReturn(1); String expectedLink = "http://myserver.ch/login?email=to%40mail.com&ac=" + validkey; - expect(getWikiMock().getExternalURL(eq("Content.login"), eq("view"), eq( - "email=to%40mail.com&ac=" + validkey), same(getContext()))).andReturn(expectedLink).once(); + expect(getWikiMock().getExternalURL(eq("Content.login"), eq("view"), + eq("email=to%40mail.com&ac=" + validkey), same(getContext()))).andReturn(expectedLink) + .once(); expect(webUtilsMock.getDefaultAdminLanguage()).andReturn(adminLang).anyTimes(); expect(rightServiceMock.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq("Content.login"), same(getContext()))).andReturn(true).atLeastOnce(); @@ -502,9 +509,9 @@ public void testSendValidationMessage_fallbackToCelements2web() throws Exception String noHTML = ""; String title = "the title"; getContext().put("vcontext", new VelocityContext()); - expect(getWikiMock().getXWikiPreference(eq("admin_email"), eq( - CelMailConfiguration.MAIL_DEFAULT_ADMIN_EMAIL_KEY), eq(""), same(getContext()))).andReturn( - from); + expect(getWikiMock().getXWikiPreference(eq("admin_email"), + eq(CelMailConfiguration.MAIL_DEFAULT_ADMIN_EMAIL_KEY), eq(""), same(getContext()))) + .andReturn(from); expect(modelAccessMock.exists(eq(contentDocRef))).andReturn(false); expect(modelAccessMock.exists(eq(contentCel2WebDocRef))).andReturn(true); XWikiDocument doc = createDefaultMock(XWikiDocument.class); @@ -512,8 +519,9 @@ public void testSendValidationMessage_fallbackToCelements2web() throws Exception expect(doc.getTranslatedDocument(eq("de"), same(getContext()))).andReturn(doc).anyTimes(); expect(doc.getRenderedContent(same(getContext()))).andReturn(content); expect(doc.getTitle()).andReturn(title); - expect(doc.getXObject(eq(new DocumentReference(getContext().getDatabase(), "Celements2", - "FormMailClass")))).andReturn(null); + expect(doc.getXObject( + eq(new DocumentReference(getContext().getDatabase(), "Celements2", "FormMailClass")))) + .andReturn(null); expect(rendererMock.interpretText(eq(title), same(doc), same(getContext()))).andReturn(title); celSendMailMock.setFrom(eq(from)); expectLastCall(); @@ -537,8 +545,9 @@ public void testSendValidationMessage_fallbackToCelements2web() throws Exception expectLastCall(); expect(celSendMailMock.sendMail()).andReturn(1); String expectedLink = "http://myserver.ch/login?email=to%40mail.com&ac=" + validkey; - expect(getWikiMock().getExternalURL(eq("Content.login"), eq("view"), eq( - "email=to%40mail.com&ac=" + validkey), same(getContext()))).andReturn(expectedLink).once(); + expect(getWikiMock().getExternalURL(eq("Content.login"), eq("view"), + eq("email=to%40mail.com&ac=" + validkey), same(getContext()))).andReturn(expectedLink) + .once(); expect(webUtilsMock.getDefaultAdminLanguage()).andReturn(adminLang).anyTimes(); expect(rightServiceMock.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq("Content.login"), same(getContext()))).andReturn(true).atLeastOnce(); @@ -562,9 +571,9 @@ public void testSendValidationMessage_fallbackToDisk() throws Exception { String noHTML = ""; String title = "the title"; getContext().put("vcontext", new VelocityContext()); - expect(getWikiMock().getXWikiPreference(eq("admin_email"), eq( - CelMailConfiguration.MAIL_DEFAULT_ADMIN_EMAIL_KEY), eq(""), same(getContext()))).andReturn( - from); + expect(getWikiMock().getXWikiPreference(eq("admin_email"), + eq(CelMailConfiguration.MAIL_DEFAULT_ADMIN_EMAIL_KEY), eq(""), same(getContext()))) + .andReturn(from); expect(modelAccessMock.exists(eq(contentDocRef))).andReturn(false); expect(modelAccessMock.exists(eq(contentCel2WebDocRef))).andReturn(false); celSendMailMock.setFrom(eq(from)); @@ -589,8 +598,9 @@ public void testSendValidationMessage_fallbackToDisk() throws Exception { expectLastCall(); expect(celSendMailMock.sendMail()).andReturn(1); String expectedLink = "http://myserver.ch/login?email=to%40mail.com&ac=" + validkey; - expect(getWikiMock().getExternalURL(eq("Content.login"), eq("view"), eq( - "email=to%40mail.com&ac=" + validkey), same(getContext()))).andReturn(expectedLink).once(); + expect(getWikiMock().getExternalURL(eq("Content.login"), eq("view"), + eq("email=to%40mail.com&ac=" + validkey), same(getContext()))).andReturn(expectedLink) + .once(); expect(webUtilsMock.getDefaultAdminLanguage()).andReturn(adminLang).anyTimes(); DocumentReference defaultAccountActivation = new DocumentReference(getContext().getDatabase(), "Mails", "AccountActivationMail"); @@ -617,8 +627,8 @@ public void testSendValidationMessage_overwrittenSender_deprecated() throws Exce String contentDoc = "Tools.ActivationMail"; DocumentReference contentDocRef = new DocumentReference(getContext().getDatabase(), "Tools", "ActivationMail"); - expect(webUtilsMock.resolveDocumentReference(eq(contentDoc))).andReturn( - contentDocRef).anyTimes(); + expect(webUtilsMock.resolveDocumentReference(eq(contentDoc))).andReturn(contentDocRef) + .anyTimes(); DocumentReference contentCel2WebDocRef = new DocumentReference("celements2web", "Tools", "ActivationMail"); String content = "This is the mail content."; @@ -661,8 +671,9 @@ public void testSendValidationMessage_overwrittenSender_deprecated() throws Exce expectLastCall(); expect(celSendMailMock.sendMail()).andReturn(1); String expectedLink = "http://myserver.ch/login?email=to%40mail.com&ac=" + validkey; - expect(getWikiMock().getExternalURL(eq("Content.login"), eq("view"), eq( - "email=to%40mail.com&ac=" + validkey), same(getContext()))).andReturn(expectedLink).once(); + expect(getWikiMock().getExternalURL(eq("Content.login"), eq("view"), + eq("email=to%40mail.com&ac=" + validkey), same(getContext()))).andReturn(expectedLink) + .once(); expect(webUtilsMock.getDefaultAdminLanguage()).andReturn(adminLang).anyTimes(); expect(rightServiceMock.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq("Content.login"), same(getContext()))).andReturn(true).atLeastOnce(); @@ -722,8 +733,9 @@ public void testSendValidationMessage_fallbackToCelements2web_overwrittenSender( expectLastCall(); expect(celSendMailMock.sendMail()).andReturn(1); String expectedLink = "http://myserver.ch/login?email=to%40mail.com&ac=" + validkey; - expect(getWikiMock().getExternalURL(eq("Content.login"), eq("view"), eq( - "email=to%40mail.com&ac=" + validkey), same(getContext()))).andReturn(expectedLink).once(); + expect(getWikiMock().getExternalURL(eq("Content.login"), eq("view"), + eq("email=to%40mail.com&ac=" + validkey), same(getContext()))).andReturn(expectedLink) + .once(); expect(webUtilsMock.getDefaultAdminLanguage()).andReturn(adminLang).anyTimes(); expect(rightServiceMock.hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), eq("Content.login"), same(getContext()))).andReturn(true).atLeastOnce(); diff --git a/src/test/java/com/celements/web/plugin/cmd/PossibleLoginsCommandTest.java b/src/test/java/com/celements/web/plugin/cmd/PossibleLoginsCommandTest.java index 389f890a4..84622615c 100644 --- a/src/test/java/com/celements/web/plugin/cmd/PossibleLoginsCommandTest.java +++ b/src/test/java/com/celements/web/plugin/cmd/PossibleLoginsCommandTest.java @@ -44,8 +44,7 @@ public void testGetPossibleLogins_none() { @Test public void testGetPossibleLogins_local() { expect(userServiceMock.getPossibleLoginFields()) - .andReturn(new HashSet<>(Arrays.asList("email", "loginname"))) - .atLeastOnce(); + .andReturn(new HashSet<>(Arrays.asList("email", "loginname"))).atLeastOnce(); replayDefault(); List logins = Arrays.asList(possibleLoginsCmd.getPossibleLogins().split(",")); assertTrue("email", logins.contains("email")); diff --git a/src/test/java/com/celements/web/plugin/cmd/RemoteUserValidatorTest.java b/src/test/java/com/celements/web/plugin/cmd/RemoteUserValidatorTest.java index 5a8d8c8cf..59e8dcacc 100644 --- a/src/test/java/com/celements/web/plugin/cmd/RemoteUserValidatorTest.java +++ b/src/test/java/com/celements/web/plugin/cmd/RemoteUserValidatorTest.java @@ -63,8 +63,8 @@ public void setUp_RemoteUserValidatorTest() throws Exception { xWikiAuthServiceMock = createDefaultMock(XWikiAuthService.class); expect(getWikiMock().getAuthService()).andReturn(xWikiAuthServiceMock).anyTimes(); expect(getWikiMock().isVirtualMode()).andReturn(true).anyTimes(); - expect(getWikiMock().getXWikiPreference(eq("auth_active_check"), anyObject( - XWikiContext.class))).andReturn("1").anyTimes(); + expect(getWikiMock().getXWikiPreference(eq("auth_active_check"), anyObject(XWikiContext.class))) + .andReturn("1").anyTimes(); } @Test @@ -76,8 +76,8 @@ public void test_isValidUserJSON_validationNotAllowed() { expect(httpRequest.getRemoteHost()).andReturn(" "); replayDefault(); - assertEquals("{\"access\" : \"false\", \"error\" : \"access_denied\"}", cmd.isValidUserJSON("", - "", "", null, context)); + assertEquals("{\"access\" : \"false\", \"error\" : \"access_denied\"}", + cmd.isValidUserJSON("", "", "", null, context)); verifyDefault(); } @@ -88,7 +88,8 @@ public void test_isValidUserJSON_noUser() throws XWikiException { HttpServletRequest httpRequest = createDefaultMock(HttpServletRequest.class); expect(request.getHttpServletRequest()).andReturn(httpRequest).once(); expect(httpRequest.getRemoteHost()).andReturn(" "); - expect(userServiceMock.getUserForLoginField("blabla@mail.com")).andReturn(Optional.absent()); + expect(userServiceMock.getUserForLoginField("blabla@mail.com")) + .andReturn(Optional.absent()); replayDefault(); // important only call setUser after replayDefault. In unstable-2.0 branch setUser @@ -107,9 +108,10 @@ public void test_isValidUserJSON_notAuthenticated() throws XWikiException { expect(request.getHttpServletRequest()).andReturn(httpRequest).once(); expect(httpRequest.getRemoteHost()).andReturn(" "); User userMock = createUserMock("XWiki.7sh2lya35"); - expect(userServiceMock.getUserForLoginField("blabla@mail.com")).andReturn(Optional.of(userMock)); - expect(xWikiAuthServiceMock.authenticate(eq("XWiki.7sh2lya35"), eq("pwd"), same( - context))).andReturn(null).once(); + expect(userServiceMock.getUserForLoginField("blabla@mail.com")) + .andReturn(Optional.of(userMock)); + expect(xWikiAuthServiceMock.authenticate(eq("XWiki.7sh2lya35"), eq("pwd"), same(context))) + .andReturn(null).once(); replayDefault(); // important only call setUser after replayDefault. In unstable-2.0 branch setUser @@ -128,7 +130,8 @@ public void test_isValidUserJSON_validUser_wrongGroup() throws XWikiException { expect(request.getHttpServletRequest()).andReturn(httpRequest).once(); expect(httpRequest.getRemoteHost()).andReturn(" "); User userMock = createUserMock("XWiki.7sh2lya35"); - expect(userServiceMock.getUserForLoginField("blabla@mail.com")).andReturn(Optional.of(userMock)); + expect(userServiceMock.getUserForLoginField("blabla@mail.com")) + .andReturn(Optional.of(userMock)); expectAuth("XWiki.7sh2lya35", "pwd"); expectInGroup(userMock, "grp", false); @@ -136,8 +139,8 @@ public void test_isValidUserJSON_validUser_wrongGroup() throws XWikiException { // important only call setUser after replayDefault. In unstable-2.0 branch setUser // calls xwiki.isVirtualMode context.setUser("xwiki:XWiki.superadmin"); - assertEquals("{\"access\" : \"false\", \"error\" : \"user_not_in_group\"}", cmd.isValidUserJSON( - "blabla@mail.com", "pwd", "grp", null, context)); + assertEquals("{\"access\" : \"false\", \"error\" : \"user_not_in_group\"}", + cmd.isValidUserJSON("blabla@mail.com", "pwd", "grp", null, context)); verifyDefault(); } @@ -149,7 +152,8 @@ public void test_isValidUserJSON_validUser_isInGroup_inactiveUser() throws XWiki expect(request.getHttpServletRequest()).andReturn(httpRequest).once(); expect(httpRequest.getRemoteHost()).andReturn(" "); User userMock = createUserMock("XWiki.7sh2lya35"); - expect(userServiceMock.getUserForLoginField("blabla@mail.com")).andReturn(Optional.of(userMock)); + expect(userServiceMock.getUserForLoginField("blabla@mail.com")) + .andReturn(Optional.of(userMock)); expectAuth("XWiki.7sh2lya35", "pwd"); expectInGroup(userMock, "grp", true); expect(userMock.isActive()).andReturn(false); @@ -171,7 +175,8 @@ public void testIsValidUserJSON_validUser_isInGroup_noRetGroup() throws XWikiExc expect(request.getHttpServletRequest()).andReturn(httpRequest).once(); expect(httpRequest.getRemoteHost()).andReturn(" "); User userMock = createUserMock("XWiki.7sh2lya35"); - expect(userServiceMock.getUserForLoginField("blabla@mail.com")).andReturn(Optional.of(userMock)); + expect(userServiceMock.getUserForLoginField("blabla@mail.com")) + .andReturn(Optional.of(userMock)); expectAuth("XWiki.7sh2lya35", "pwd"); expectInGroup(userMock, "grp", true); expect(userMock.isActive()).andReturn(true); @@ -180,9 +185,10 @@ public void testIsValidUserJSON_validUser_isInGroup_noRetGroup() throws XWikiExc // important only call setUser after replayDefault. In unstable-2.0 branch setUser // calls xwiki.isVirtualMode context.setUser("xwiki:XWiki.superadmin"); - assertEquals("{\"access\" : \"true\", \"username\" : \"blabla@mail.com\", " - + "\"group_membership\" : {}}", cmd.isValidUserJSON("blabla@mail.com", "pwd", "grp", null, - context)); + assertEquals( + "{\"access\" : \"true\", \"username\" : \"blabla@mail.com\", " + + "\"group_membership\" : {}}", + cmd.isValidUserJSON("blabla@mail.com", "pwd", "grp", null, context)); verifyDefault(); } @@ -199,7 +205,8 @@ public void testIsValidUserJSON_validUser_isInGroup_retGroup() throws XWikiExcep expect(context.getMessageTool()).andReturn(getMessageToolStub()).anyTimes(); User userMock = createUserMock("XWiki.7sh2lya35"); - expect(userServiceMock.getUserForLoginField("blabla@mail.com")).andReturn(Optional.of(userMock)); + expect(userServiceMock.getUserForLoginField("blabla@mail.com")) + .andReturn(Optional.of(userMock)); expectAuth("XWiki.7sh2lya35", "pwd"); expect(userMock.isActive()).andReturn(true); List returnGroups = Arrays.asList("XWiki.TestGroup1", "XWiki.TestGroup2", @@ -273,10 +280,10 @@ public void test_isGroupMember_inGroup() throws XWikiException { @Test public void test_getErrorJSON() { - assertEquals("{\"access\" : \"false\", \"error\" : \"access_denied\"}", cmd.getErrorJSON( - "access_denied")); - assertEquals("{\"access\" : \"false\", \"error\" : \"wrong_group\"}", cmd.getErrorJSON( - "wrong_group")); + assertEquals("{\"access\" : \"false\", \"error\" : \"access_denied\"}", + cmd.getErrorJSON("access_denied")); + assertEquals("{\"access\" : \"false\", \"error\" : \"wrong_group\"}", + cmd.getErrorJSON("wrong_group")); } @Test @@ -284,9 +291,10 @@ public void test_getResultJSON() throws Exception { User userMock = createUserMock("XWiki.7sh2lya35"); replayDefault(); - assertEquals("{\"access\" : \"true\", \"username\" : \"user@synventis.com\", " - + "\"group_membership\" : {}}", cmd.getResultJSON(userMock, "user@synventis.com", null, - context)); + assertEquals( + "{\"access\" : \"true\", \"username\" : \"user@synventis.com\", " + + "\"group_membership\" : {}}", + cmd.getResultJSON(userMock, "user@synventis.com", null, context)); verifyDefault(); } @@ -300,8 +308,9 @@ public void test_getResultJSON_withReturnGroups() throws Exception { expectInGroup(xUserMock, returnGroups.get(1), false); replayDefault(); - assertEquals("{\"access\" : \"true\", \"username\" : \"user@synventis.com\", " - + "\"group_membership\" : {\"TestGroup1\" : \"true\", \"TestGroup2\" : \"false\"}}", + assertEquals( + "{\"access\" : \"true\", \"username\" : \"user@synventis.com\", " + + "\"group_membership\" : {\"TestGroup1\" : \"true\", \"TestGroup2\" : \"false\"}}", cmd.getResultJSON(userMock, "user@synventis.com", returnGroups, context)); verifyDefault(); } @@ -444,15 +453,17 @@ public void test_validationAllowed_allowed() { private Principal expectAuth(String username, String password) throws XWikiException { Principal principal = createDefaultMock(Principal.class); expect(principal.getName()).andReturn(username).anyTimes(); - expect(xWikiAuthServiceMock.authenticate(eq(username), eq(password), same(context))).andReturn( - principal).once(); + expect(xWikiAuthServiceMock.authenticate(eq(username), eq(password), same(context))) + .andReturn(principal).once(); return principal; } private User createUserMock(String username) { User userMock = createDefaultMock(User.class); - expect(userMock.getDocRef()).andReturn(Utils.getComponent(ModelUtils.class).resolveRef(username, - DocumentReference.class)).anyTimes(); + expect(userMock.getDocRef()) + .andReturn( + Utils.getComponent(ModelUtils.class).resolveRef(username, DocumentReference.class)) + .anyTimes(); return userMock; } diff --git a/src/test/java/com/celements/web/plugin/cmd/RenameCommandTest.java b/src/test/java/com/celements/web/plugin/cmd/RenameCommandTest.java index cc108ae0e..959c22e00 100644 --- a/src/test/java/com/celements/web/plugin/cmd/RenameCommandTest.java +++ b/src/test/java/com/celements/web/plugin/cmd/RenameCommandTest.java @@ -149,22 +149,22 @@ public void testRenameSpace() throws Exception { String newSpaceName = "myNewSpace"; String firstDocName = "myDoc1"; XWikiDocument firstDoc = createDefaultMock(XWikiDocument.class); - expect(xwiki.exists(eq(spaceName + "." + firstDocName), same(context))).andReturn( - true).atLeastOnce(); - expect(xwiki.getDocument(eq(spaceName + "." + firstDocName), same(context))).andReturn( - firstDoc).once(); - expect(xwiki.exists(eq(newSpaceName + "." + firstDocName), same(context))).andReturn( - false).atLeastOnce(); + expect(xwiki.exists(eq(spaceName + "." + firstDocName), same(context))).andReturn(true) + .atLeastOnce(); + expect(xwiki.getDocument(eq(spaceName + "." + firstDocName), same(context))).andReturn(firstDoc) + .once(); + expect(xwiki.exists(eq(newSpaceName + "." + firstDocName), same(context))).andReturn(false) + .atLeastOnce(); firstDoc.rename(eq("myNewSpace.myDoc1"), same(context)); expectLastCall().once(); String firstDocName2 = "myDoc2"; XWikiDocument secondDoc = createDefaultMock(XWikiDocument.class); - expect(xwiki.exists(eq(spaceName + "." + firstDocName2), same(context))).andReturn( - true).atLeastOnce(); - expect(xwiki.exists(eq(newSpaceName + "." + firstDocName2), same(context))).andReturn( - false).atLeastOnce(); - expect(xwiki.getDocument(eq(spaceName + "." + firstDocName2), same(context))).andReturn( - secondDoc).once(); + expect(xwiki.exists(eq(spaceName + "." + firstDocName2), same(context))).andReturn(true) + .atLeastOnce(); + expect(xwiki.exists(eq(newSpaceName + "." + firstDocName2), same(context))).andReturn(false) + .atLeastOnce(); + expect(xwiki.getDocument(eq(spaceName + "." + firstDocName2), same(context))) + .andReturn(secondDoc).once(); secondDoc.rename(eq("myNewSpace.myDoc2"), same(context)); expectLastCall().once(); List docNames = Arrays.asList(firstDocName, firstDocName2); @@ -181,20 +181,20 @@ public void testRenameSpace_firstDocFails() throws Exception { String spaceName = "mySpace"; String newSpaceName = "myNewSpace"; String firstDocName = "myDoc1"; - expect(xwiki.exists(eq(spaceName + "." + firstDocName), same(context))).andReturn( - true).atLeastOnce(); - expect(xwiki.exists(eq(newSpaceName + "." + firstDocName), same(context))).andReturn( - false).atLeastOnce(); - expect(xwiki.getDocument(eq(spaceName + "." + firstDocName), same(context))).andThrow( - new XWikiException()); + expect(xwiki.exists(eq(spaceName + "." + firstDocName), same(context))).andReturn(true) + .atLeastOnce(); + expect(xwiki.exists(eq(newSpaceName + "." + firstDocName), same(context))).andReturn(false) + .atLeastOnce(); + expect(xwiki.getDocument(eq(spaceName + "." + firstDocName), same(context))) + .andThrow(new XWikiException()); String firstDocName2 = "myDoc2"; XWikiDocument secondDoc = createDefaultMock(XWikiDocument.class); - expect(xwiki.exists(eq(spaceName + "." + firstDocName2), same(context))).andReturn( - true).atLeastOnce(); - expect(xwiki.exists(eq(newSpaceName + "." + firstDocName2), same(context))).andReturn( - false).atLeastOnce(); - expect(xwiki.getDocument(eq(spaceName + "." + firstDocName2), same(context))).andReturn( - secondDoc).once(); + expect(xwiki.exists(eq(spaceName + "." + firstDocName2), same(context))).andReturn(true) + .atLeastOnce(); + expect(xwiki.exists(eq(newSpaceName + "." + firstDocName2), same(context))).andReturn(false) + .atLeastOnce(); + expect(xwiki.getDocument(eq(spaceName + "." + firstDocName2), same(context))) + .andReturn(secondDoc).once(); secondDoc.rename(eq("myNewSpace.myDoc2"), same(context)); expectLastCall().once(); List docNames = Arrays.asList(firstDocName, firstDocName2); @@ -222,15 +222,15 @@ public void testRenameSpace_allDocFail() throws Exception { String spaceName = "mySpace"; String newSpaceName = "myNewSpace"; String firstDocName = "myDoc1"; - expect(xwiki.exists(eq(spaceName + "." + firstDocName), same(context))).andReturn( - true).atLeastOnce(); - expect(xwiki.exists(eq(newSpaceName + "." + firstDocName), same(context))).andReturn( - true).atLeastOnce(); + expect(xwiki.exists(eq(spaceName + "." + firstDocName), same(context))).andReturn(true) + .atLeastOnce(); + expect(xwiki.exists(eq(newSpaceName + "." + firstDocName), same(context))).andReturn(true) + .atLeastOnce(); String firstDocName2 = "myDoc2"; - expect(xwiki.exists(eq(spaceName + "." + firstDocName2), same(context))).andReturn( - true).atLeastOnce(); - expect(xwiki.exists(eq(newSpaceName + "." + firstDocName2), same(context))).andReturn( - true).atLeastOnce(); + expect(xwiki.exists(eq(spaceName + "." + firstDocName2), same(context))).andReturn(true) + .atLeastOnce(); + expect(xwiki.exists(eq(newSpaceName + "." + firstDocName2), same(context))).andReturn(true) + .atLeastOnce(); List docNames = Arrays.asList(firstDocName, firstDocName2); expect(xwiki.getSpaceDocsName(eq(spaceName), same(context))).andReturn(docNames); replayDefault(); diff --git a/src/test/java/com/celements/web/plugin/cmd/UserNameForUserDataCommandTest.java b/src/test/java/com/celements/web/plugin/cmd/UserNameForUserDataCommandTest.java index 3d0c10664..d01f71783 100644 --- a/src/test/java/com/celements/web/plugin/cmd/UserNameForUserDataCommandTest.java +++ b/src/test/java/com/celements/web/plugin/cmd/UserNameForUserDataCommandTest.java @@ -48,8 +48,9 @@ public void testGetUsernameForUserData_empty() throws XWikiException { @Test public void testGetUsernameForUserData_loginname_notExists() throws XWikiException { String login = "testLogin"; - expect(userServiceMock.getUserForLoginField(login, Arrays.asList( - UserService.DEFAULT_LOGIN_FIELD))).andReturn(Optional.absent()); + expect( + userServiceMock.getUserForLoginField(login, Arrays.asList(UserService.DEFAULT_LOGIN_FIELD))) + .andReturn(Optional.absent()); replayDefault(); assertEquals("", cmd.getUsernameForUserData(login, "loginname,,", getContext())); @@ -60,8 +61,9 @@ public void testGetUsernameForUserData_loginname_notExists() throws XWikiExcepti public void testGetUsernameForUserData_loginname_exists() throws XWikiException { String login = "testLogin"; User user = createDefaultMock(User.class); - expect(userServiceMock.getUserForLoginField(login, Arrays.asList( - UserService.DEFAULT_LOGIN_FIELD))).andReturn(Optional.of(user)); + expect( + userServiceMock.getUserForLoginField(login, Arrays.asList(UserService.DEFAULT_LOGIN_FIELD))) + .andReturn(Optional.of(user)); expect(user.asXWikiUser()).andReturn(new XWikiUser("XWiki." + login)); replayDefault(); @@ -73,13 +75,13 @@ public void testGetUsernameForUserData_loginname_exists() throws XWikiException public void testGetUsernameForUserData_multiplePossibleFields() throws XWikiException { String login = "testLogin"; User user = createDefaultMock(User.class); - expect(userServiceMock.getUserForLoginField(login, Arrays.asList("email", - UserService.DEFAULT_LOGIN_FIELD))).andReturn(Optional.of(user)); + expect(userServiceMock.getUserForLoginField(login, + Arrays.asList("email", UserService.DEFAULT_LOGIN_FIELD))).andReturn(Optional.of(user)); expect(user.asXWikiUser()).andReturn(new XWikiUser("XWiki." + login)); replayDefault(); - assertEquals("XWiki." + login, cmd.getUsernameForUserData(login, "email,loginname", - getContext())); + assertEquals("XWiki." + login, + cmd.getUsernameForUserData(login, "email,loginname", getContext())); verifyDefault(); } diff --git a/src/test/java/com/celements/web/service/CaptchaServiceTest.java b/src/test/java/com/celements/web/service/CaptchaServiceTest.java index bdb8ac5d7..ac8ca5fbe 100644 --- a/src/test/java/com/celements/web/service/CaptchaServiceTest.java +++ b/src/test/java/com/celements/web/service/CaptchaServiceTest.java @@ -85,8 +85,8 @@ public void testCheckCaptcha_singleCall_true() throws Exception { expect(requestMock.get(eq("captcha_answer"))).andReturn(expectedAnwser).atLeastOnce(); expect(requestMock.get(eq("captcha_type"))).andReturn("image").atLeastOnce(); expect(requestMock.get(eq("captcha_id"))).andReturn(sessionId).atLeastOnce(); - expect(imgCaptchaVerifierMock.isAnswerCorrect(eq(sessionId), eq(expectedAnwser))).andReturn( - true).once(); + expect(imgCaptchaVerifierMock.isAnswerCorrect(eq(sessionId), eq(expectedAnwser))) + .andReturn(true).once(); replayDefault(); assertTrue(captchaService.checkCaptcha()); verifyDefault(); @@ -98,8 +98,8 @@ public void testCheckCaptcha_singleCall_false() throws Exception { expect(requestMock.get(eq("captcha_answer"))).andReturn(wrongAnwser).atLeastOnce(); expect(requestMock.get(eq("captcha_type"))).andReturn("image").atLeastOnce(); expect(requestMock.get(eq("captcha_id"))).andReturn(sessionId).atLeastOnce(); - expect(imgCaptchaVerifierMock.isAnswerCorrect(eq(sessionId), eq(wrongAnwser))).andReturn( - false).once(); + expect(imgCaptchaVerifierMock.isAnswerCorrect(eq(sessionId), eq(wrongAnwser))).andReturn(false) + .once(); replayDefault(); assertFalse(captchaService.checkCaptcha()); verifyDefault(); @@ -131,8 +131,8 @@ public void testCheckCaptcha_singleCall_exception() throws Exception { expect(requestMock.get(eq("captcha_answer"))).andReturn(wrongAnwser).atLeastOnce(); expect(requestMock.get(eq("captcha_type"))).andReturn("image").atLeastOnce(); expect(requestMock.get(eq("captcha_id"))).andReturn(sessionId).atLeastOnce(); - expect(imgCaptchaVerifierMock.isAnswerCorrect(eq(sessionId), eq(wrongAnwser))).andThrow( - new Exception()).once(); + expect(imgCaptchaVerifierMock.isAnswerCorrect(eq(sessionId), eq(wrongAnwser))) + .andThrow(new Exception()).once(); replayDefault(); assertFalse(captchaService.checkCaptcha()); verifyDefault(); @@ -144,10 +144,10 @@ public void testCheckCaptcha_doubleCall_true() throws Exception { expect(requestMock.get(eq("captcha_answer"))).andReturn(expectedAnwser).atLeastOnce(); expect(requestMock.get(eq("captcha_type"))).andReturn("image").atLeastOnce(); expect(requestMock.get(eq("captcha_id"))).andReturn(sessionId).atLeastOnce(); - expect(imgCaptchaVerifierMock.isAnswerCorrect(eq(sessionId), eq(expectedAnwser))).andReturn( - true).once(); - expect(imgCaptchaVerifierMock.isAnswerCorrect(eq(sessionId), eq(expectedAnwser))).andReturn( - false).anyTimes(); + expect(imgCaptchaVerifierMock.isAnswerCorrect(eq(sessionId), eq(expectedAnwser))) + .andReturn(true).once(); + expect(imgCaptchaVerifierMock.isAnswerCorrect(eq(sessionId), eq(expectedAnwser))) + .andReturn(false).anyTimes(); replayDefault(); assertTrue(captchaService.checkCaptcha()); // check answer caching @@ -161,10 +161,10 @@ public void testCheckCaptcha_doubleCall_false() throws Exception { expect(requestMock.get(eq("captcha_answer"))).andReturn(expectedAnwser).atLeastOnce(); expect(requestMock.get(eq("captcha_type"))).andReturn("image").atLeastOnce(); expect(requestMock.get(eq("captcha_id"))).andReturn(sessionId).atLeastOnce(); - expect(imgCaptchaVerifierMock.isAnswerCorrect(eq(sessionId), eq(expectedAnwser))).andReturn( - false).once(); - expect(imgCaptchaVerifierMock.isAnswerCorrect(eq(sessionId), eq(expectedAnwser))).andReturn( - false).anyTimes(); + expect(imgCaptchaVerifierMock.isAnswerCorrect(eq(sessionId), eq(expectedAnwser))) + .andReturn(false).once(); + expect(imgCaptchaVerifierMock.isAnswerCorrect(eq(sessionId), eq(expectedAnwser))) + .andReturn(false).anyTimes(); replayDefault(); assertFalse(captchaService.checkCaptcha()); // check answer caching diff --git a/src/test/java/com/celements/web/service/CelementsWebScriptServiceTest.java b/src/test/java/com/celements/web/service/CelementsWebScriptServiceTest.java index 3e9e3cb98..1c20be83b 100644 --- a/src/test/java/com/celements/web/service/CelementsWebScriptServiceTest.java +++ b/src/test/java/com/celements/web/service/CelementsWebScriptServiceTest.java @@ -41,8 +41,8 @@ public void setUp_CelementsWebScriptServiceTest() throws Exception { public void testDeleteMenuItem() throws Exception { DocumentReference docRef = new DocumentReference(context.getDatabase(), "mySpace", "myDocument"); - expect(mockRightService.hasAccessLevel(eq("edit"), eq("XWiki.XWikiGuest"), eq( - "mySpace.myDocument"), same(context))).andReturn(false).once(); + expect(mockRightService.hasAccessLevel(eq("edit"), eq("XWiki.XWikiGuest"), + eq("mySpace.myDocument"), same(context))).andReturn(false).once(); replayDefault(); assertFalse("expecting false because of no edit rights", celWebService.deleteMenuItem(docRef)); verifyDefault(); @@ -70,8 +70,8 @@ public void testGetHumanReadableSize_PartSize_dech() { @Test public void testGetHumanReadableSize_PartSize_de_country_CH() { context.setLanguage("de"); - String formatted = celWebService.getHumanReadableSize(1055563210, false, - celWebService.getLocal("de", "ch")) + String formatted = celWebService + .getHumanReadableSize(1055563210, false, celWebService.getLocal("de", "ch")) .replace('\'', '’'); // older java versions used different apostrophe assertEquals("de-ch", "1’006.7 MiB", formatted); assertEquals("fr", "2,6 MB", celWebService.getHumanReadableSize(2563210, true, "fr")); @@ -101,14 +101,13 @@ public void testIsAppScriptRequest_appXpage() { XWikiRequest mockRequest = createMock(XWikiRequest.class); context.setRequest(mockRequest); context.setAction("view"); - expect(mockRequest.getParameter(eq("xpage"))).andReturn( - IAppScriptService.APP_SCRIPT_XPAGE).anyTimes(); + expect(mockRequest.getParameter(eq("xpage"))).andReturn(IAppScriptService.APP_SCRIPT_XPAGE) + .anyTimes(); expect(mockRequest.getParameter(eq("s"))).andReturn("myScript").anyTimes(); expect(appScriptServiceMock.isAppScriptRequest()).andReturn(true).anyTimes(); - expect(xwiki.getXWikiPreference(eq(IAppScriptService.APP_SCRIPT_XWPREF_OVERW_DOCS), eq( - IAppScriptService.APP_SCRIPT_CONF_OVERW_DOCS), eq("-"), same(context))).andReturn( - "Content.login") - .anyTimes(); + expect(xwiki.getXWikiPreference(eq(IAppScriptService.APP_SCRIPT_XWPREF_OVERW_DOCS), + eq(IAppScriptService.APP_SCRIPT_CONF_OVERW_DOCS), eq("-"), same(context))) + .andReturn("Content.login").anyTimes(); replayDefault(mockRequest); assertTrue(celWebService.isAppScriptRequest()); verifyDefault(mockRequest); @@ -121,8 +120,8 @@ public void testGetCurrentPageURL_isAppScriptRequest() { expect(appScriptServiceMock.isAppScriptRequest()).andReturn(true).once(); expect(appScriptServiceMock.getScriptNameFromURL()).andReturn(scriptName).once(); - expect(appScriptServiceMock.getAppScriptURL(eq(scriptName), eq(queryString))).andReturn( - "theURL").once(); + expect(appScriptServiceMock.getAppScriptURL(eq(scriptName), eq(queryString))) + .andReturn("theURL").once(); replayDefault(); assertEquals("theURL", celWebService.getCurrentPageURL(queryString)); diff --git a/src/test/java/com/celements/web/service/PrepareVelocityContextServiceTest.java b/src/test/java/com/celements/web/service/PrepareVelocityContextServiceTest.java index 6b29498fa..a1987fa5a 100644 --- a/src/test/java/com/celements/web/service/PrepareVelocityContextServiceTest.java +++ b/src/test/java/com/celements/web/service/PrepareVelocityContextServiceTest.java @@ -60,15 +60,16 @@ public void prepareTest() throws Exception { expect(xwiki.getRightService()).andReturn(rightServiceMock).anyTimes(); VelocityContext vContext = new VelocityContext(); context.put("vcontext", vContext); - prepVeloContextService = (PrepareVelocityContextService) Utils.getComponent( - IPrepareVelocityContext.class); + prepVeloContextService = (PrepareVelocityContextService) Utils + .getComponent(IPrepareVelocityContext.class); skinDoc = createDefaultMock(XWikiDocument.class); expect(skinDoc.getFullName()).andReturn("XWiki.Celements2Skin").anyTimes(); - expect(skinDoc.getDocumentReference()).andReturn(new DocumentReference(context.getDatabase(), - "XWiki", "Celements2Skin")).anyTimes(); + expect(skinDoc.getDocumentReference()) + .andReturn(new DocumentReference(context.getDatabase(), "XWiki", "Celements2Skin")) + .anyTimes(); expect(skinDoc.newDocument(same(context))).andReturn(new Document(skinDoc, context)).anyTimes(); - expect(xwiki.getDocument(eq("celements2web:XWiki.Celements2Skin"), same(context))).andReturn( - skinDoc).anyTimes(); + expect(xwiki.getDocument(eq("celements2web:XWiki.Celements2Skin"), same(context))) + .andReturn(skinDoc).anyTimes(); expect(xwiki.getDocument(eq(new DocumentReference("celements2web", "XWiki", "Celements2Skin")), same(context))).andReturn(skinDoc).anyTimes(); ptServiceMock = createDefaultMock(IPageTypeRole.class); @@ -108,29 +109,29 @@ public void testPrepareVelocityContext_checkNPEs_forNull_doc() throws Exception context.setDoc(null); expect(xwiki.isMultiLingual(same(context))).andReturn(false).atLeastOnce(); expect(getMock(IWebUtilsService.class).getDefaultLanguage()).andReturn("en").atLeastOnce(); - expect(getMock(IWebUtilsService.class).getAllowedLanguages()).andReturn(Arrays.asList("en", - "de")).atLeastOnce(); + expect(getMock(IWebUtilsService.class).getAllowedLanguages()) + .andReturn(Arrays.asList("en", "de")).atLeastOnce(); expect(getMock(IWebUtilsService.class).isAdminUser()).andReturn(false).atLeastOnce(); expect(getMock(IWebUtilsService.class).isSuperAdminUser()).andReturn(false).atLeastOnce(); expect(getMock(IWebUtilsService.class).getAdminLanguage()).andReturn("en").atLeastOnce(); expect(getMock(IWebUtilsService.class).getAdminMessageTool()).andReturn(null).atLeastOnce(); - expect(xwiki.getPluginApi(eq(prepVeloContextService.getVelocityName()), same( - context))).andReturn(null).atLeastOnce(); - expect(xwiki.getUser(eq("XWiki.myTestUser"), same(context))).andReturn(new User( - context.getXWikiUser(), context)).atLeastOnce(); + expect(xwiki.getPluginApi(eq(prepVeloContextService.getVelocityName()), same(context))) + .andReturn(null).atLeastOnce(); + expect(xwiki.getUser(eq("XWiki.myTestUser"), same(context))) + .andReturn(new User(context.getXWikiUser(), context)).atLeastOnce(); // if context doc is null -> getPageTypeRefForCurrentDoc returns null expect(ptResolverMock.getPageTypeRefForCurrentDoc()).andReturn(null).atLeastOnce(); expect(xwiki.exists(eq("PageTypes.RichText"), same(context))).andReturn(true).atLeastOnce(); - expect(xwiki.getDocument(eq("PageTypes.RichText"), same(context))).andReturn( - new XWikiDocument()).atLeastOnce(); - expect(xwiki.getSpacePreference(eq("editbox_width"), same(context))).andReturn( - "123").anyTimes(); + expect(xwiki.getDocument(eq("PageTypes.RichText"), same(context))) + .andReturn(new XWikiDocument()).atLeastOnce(); + expect(xwiki.getSpacePreference(eq("editbox_width"), same(context))).andReturn("123") + .anyTimes(); expect(ptResolverMock.getPageTypeObject(getContext().getDoc())).andReturn(null).atLeastOnce(); expect(configSourceMock.getProperty(eq("editbox_height"))).andReturn("432").anyTimes(); - expect(xwiki.getSpacePreference(eq("showRightPanels"), same(context))).andReturn( - null).atLeastOnce(); - expect(xwiki.getSpacePreference(eq("showLeftPanels"), same(context))).andReturn( - null).atLeastOnce(); + expect(xwiki.getSpacePreference(eq("showRightPanels"), same(context))).andReturn(null) + .atLeastOnce(); + expect(xwiki.getSpacePreference(eq("showLeftPanels"), same(context))).andReturn(null) + .atLeastOnce(); replayDefault(); // context.setUser calls xwiki.isVirtualMode in xwiki version 4.5 thus why it must be // set after calling replay @@ -208,23 +209,23 @@ public void testFixLanguagePreference() throws Exception { XWikiRequest requestMock = createDefaultMock(XWikiRequest.class); context.setRequest(requestMock); expect(xwiki.isMultiLingual(same(context))).andReturn(true).atLeastOnce(); - expect(xwiki.getUserPreferenceFromCookie(eq("language"), same(context))).andReturn( - "").atLeastOnce(); + expect(xwiki.getUserPreferenceFromCookie(eq("language"), same(context))).andReturn("") + .atLeastOnce(); DocumentReference userDocRef = new DocumentReference(context.getDatabase(), "XWiki", "myTestUser"); - expect(xwiki.getDocument(eq(userDocRef), same(context))).andReturn(new XWikiDocument( - userDocRef)).atLeastOnce(); + expect(xwiki.getDocument(eq(userDocRef), same(context))) + .andReturn(new XWikiDocument(userDocRef)).atLeastOnce(); expect(xwiki.Param(eq("xwiki.language.preferDefault"), eq("0"))).andReturn("0").atLeastOnce(); - expect(xwiki.getSpacePreference(eq("preferDefaultLanguage"), eq("0"), same(context))).andReturn( - "0").atLeastOnce(); + expect(xwiki.getSpacePreference(eq("preferDefaultLanguage"), eq("0"), same(context))) + .andReturn("0").atLeastOnce(); expect(requestMock.getParameter(eq("language"))).andReturn("").atLeastOnce(); expect(requestMock.getHeader(eq("Accept-Language"))).andReturn("en,de").atLeastOnce(); - Enumeration testEnum = new Vector<>(Arrays.asList(new Locale("en"), new Locale( - "de"))).elements(); + Enumeration testEnum = new Vector<>(Arrays.asList(new Locale("en"), new Locale("de"))) + .elements(); expect(requestMock.getLocales()).andReturn(testEnum).atLeastOnce(); expect(xwiki.Param(eq("xwiki.language.forceSupported"), eq("0"))).andReturn("1").atLeastOnce(); - expect(getMock(IWebUtilsService.class).getAllowedLanguages()).andReturn(Arrays.asList("en", - "de", "fr")).atLeastOnce(); + expect(getMock(IWebUtilsService.class).getAllowedLanguages()) + .andReturn(Arrays.asList("en", "de", "fr")).atLeastOnce(); replayDefault(); // context.setUser calls xwiki.isVirtualMode in xwiki version 4.5 thus why it must be // set after calling replay @@ -244,17 +245,17 @@ public void testFixLanguagePreference_noAcceptLanguageValid() throws Exception { context.setRequest(requestMock); expect(xwiki.isMultiLingual(same(context))).andReturn(true).atLeastOnce(); expect(getMock(IWebUtilsService.class).getDefaultLanguage()).andReturn("en").atLeastOnce(); - expect(getMock(IWebUtilsService.class).getAllowedLanguages()).andReturn(Arrays.asList( - "en")).atLeastOnce(); - expect(xwiki.getUserPreferenceFromCookie(eq("language"), same(context))).andReturn( - "").atLeastOnce(); + expect(getMock(IWebUtilsService.class).getAllowedLanguages()).andReturn(Arrays.asList("en")) + .atLeastOnce(); + expect(xwiki.getUserPreferenceFromCookie(eq("language"), same(context))).andReturn("") + .atLeastOnce(); DocumentReference userDocRef = new DocumentReference(context.getDatabase(), "XWiki", "myTestUser"); - expect(xwiki.getDocument(eq(userDocRef), same(context))).andReturn(new XWikiDocument( - userDocRef)).atLeastOnce(); + expect(xwiki.getDocument(eq(userDocRef), same(context))) + .andReturn(new XWikiDocument(userDocRef)).atLeastOnce(); expect(xwiki.Param(eq("xwiki.language.preferDefault"), eq("0"))).andReturn("0").atLeastOnce(); - expect(xwiki.getSpacePreference(eq("preferDefaultLanguage"), eq("0"), same(context))).andReturn( - "0").atLeastOnce(); + expect(xwiki.getSpacePreference(eq("preferDefaultLanguage"), eq("0"), same(context))) + .andReturn("0").atLeastOnce(); expect(requestMock.getParameter(eq("language"))).andReturn("").atLeastOnce(); expect(requestMock.getHeader(eq("Accept-Language"))).andReturn("de").atLeastOnce(); Enumeration testEnum = new Vector<>(Arrays.asList(new Locale("de"))).elements(); @@ -278,22 +279,22 @@ public void testFixLanguagePreference_invalidLanguageFromCookie() throws Excepti XWikiRequest requestMock = createDefaultMock(XWikiRequest.class); context.setRequest(requestMock); expect(xwiki.isMultiLingual(same(context))).andReturn(true).atLeastOnce(); - expect(xwiki.getUserPreferenceFromCookie(eq("language"), same(context))).andReturn( - "ru").atLeastOnce(); // test invalid language from cookie + expect(xwiki.getUserPreferenceFromCookie(eq("language"), same(context))).andReturn("ru") + .atLeastOnce(); // test invalid language from cookie DocumentReference userDocRef = new DocumentReference(context.getDatabase(), "XWiki", "myTestUser"); - expect(xwiki.getDocument(eq(userDocRef), same(context))).andReturn(new XWikiDocument( - userDocRef)).atLeastOnce(); + expect(xwiki.getDocument(eq(userDocRef), same(context))) + .andReturn(new XWikiDocument(userDocRef)).atLeastOnce(); expect(xwiki.Param(eq("xwiki.language.preferDefault"), eq("0"))).andReturn("0").atLeastOnce(); - expect(xwiki.getSpacePreference(eq("preferDefaultLanguage"), eq("0"), same(context))).andReturn( - "0").atLeastOnce(); + expect(xwiki.getSpacePreference(eq("preferDefaultLanguage"), eq("0"), same(context))) + .andReturn("0").atLeastOnce(); expect(requestMock.getParameter(eq("language"))).andReturn("").atLeastOnce(); expect(requestMock.getHeader(eq("Accept-Language"))).andReturn("de").atLeastOnce(); Enumeration testEnum = new Vector<>(Arrays.asList(new Locale("de"))).elements(); expect(requestMock.getLocales()).andReturn(testEnum).atLeastOnce(); expect(xwiki.Param(eq("xwiki.language.forceSupported"), eq("0"))).andReturn("1").atLeastOnce(); - expect(getMock(IWebUtilsService.class).getAllowedLanguages()).andReturn(Arrays.asList( - "en")).atLeastOnce(); + expect(getMock(IWebUtilsService.class).getAllowedLanguages()).andReturn(Arrays.asList("en")) + .atLeastOnce(); expect(getMock(IWebUtilsService.class).getDefaultLanguage()).andReturn("en").anyTimes(); replayDefault(); // context.setUser calls xwiki.isVirtualMode in xwiki version 4.5 thus why it must be @@ -315,14 +316,14 @@ public void testFixLanguagePreference_addCookieOnlyOnce() throws Exception { XWikiResponse responseMock = createDefaultMock(XWikiResponse.class); context.setResponse(responseMock); expect(xwiki.isMultiLingual(same(context))).andReturn(true).atLeastOnce(); - expect(xwiki.getXWikiPreference(eq("celSuppressInvalidLang"), eq( - "celements.language.suppressInvalid"), eq("0"), same(context))).andReturn( - "1").atLeastOnce(); + expect(xwiki.getXWikiPreference(eq("celSuppressInvalidLang"), + eq("celements.language.suppressInvalid"), eq("0"), same(context))).andReturn("1") + .atLeastOnce(); responseMock.addCookie(isA(Cookie.class)); expectLastCall().once(); expect(requestMock.getParameter(eq("language"))).andReturn("fr").atLeastOnce(); - expect(getMock(IWebUtilsService.class).getAllowedLanguages()).andReturn(Arrays.asList("en", - "de", "fr")).atLeastOnce(); + expect(getMock(IWebUtilsService.class).getAllowedLanguages()) + .andReturn(Arrays.asList("en", "de", "fr")).atLeastOnce(); replayDefault(); // context.setUser calls xwiki.isVirtualMode in xwiki version 4.5 thus why it must be // set after calling replay @@ -331,8 +332,8 @@ public void testFixLanguagePreference_addCookieOnlyOnce() throws Exception { vContext.put("language", "de"); prepVeloContextService.fixLanguagePreference(vContext); ExecutionContext execContext = prepVeloContextService.execution.getContext(); - Object addCookieBefore = execContext.getProperty( - IPrepareVelocityContext.ADD_LANGUAGE_COOKIE_DONE); + Object addCookieBefore = execContext + .getProperty(IPrepareVelocityContext.ADD_LANGUAGE_COOKIE_DONE); assertNotNull(addCookieBefore); assertTrue((Boolean) addCookieBefore); // check addCookie is only called once @@ -350,11 +351,11 @@ public void testIsInvalidLanguageOrDefault_default() { @Test public void testIsInvalidLanguageOrDefault_yes() { - expect(getMock(IWebUtilsService.class).getAllowedLanguages()).andReturn(Arrays.asList("en", - "de")).atLeastOnce(); - expect(xwiki.getXWikiPreference(eq("celSuppressInvalidLang"), eq( - "celements.language.suppressInvalid"), eq("0"), same(context))).andReturn( - "1").atLeastOnce(); + expect(getMock(IWebUtilsService.class).getAllowedLanguages()) + .andReturn(Arrays.asList("en", "de")).atLeastOnce(); + expect(xwiki.getXWikiPreference(eq("celSuppressInvalidLang"), + eq("celements.language.suppressInvalid"), eq("0"), same(context))).andReturn("1") + .atLeastOnce(); replayDefault(); assertFalse(prepVeloContextService.isInvalidLanguageOrDefault("en")); verifyDefault(); @@ -362,11 +363,11 @@ public void testIsInvalidLanguageOrDefault_yes() { @Test public void testIsInvalidLanguageOrDefault_no() { - expect(getMock(IWebUtilsService.class).getAllowedLanguages()).andReturn(Arrays.asList("en", - "de")).atLeastOnce(); - expect(xwiki.getXWikiPreference(eq("celSuppressInvalidLang"), eq( - "celements.language.suppressInvalid"), eq("0"), same(context))).andReturn( - "1").atLeastOnce(); + expect(getMock(IWebUtilsService.class).getAllowedLanguages()) + .andReturn(Arrays.asList("en", "de")).atLeastOnce(); + expect(xwiki.getXWikiPreference(eq("celSuppressInvalidLang"), + eq("celements.language.suppressInvalid"), eq("0"), same(context))).andReturn("1") + .atLeastOnce(); replayDefault(); assertTrue(prepVeloContextService.isInvalidLanguageOrDefault("fr")); verifyDefault(); @@ -374,9 +375,9 @@ public void testIsInvalidLanguageOrDefault_no() { @Test public void testIsInvalidLanguageOrDefault_no_noSuppress() { - expect(xwiki.getXWikiPreference(eq("celSuppressInvalidLang"), eq( - "celements.language.suppressInvalid"), eq("0"), same(context))).andReturn( - "0").atLeastOnce(); + expect(xwiki.getXWikiPreference(eq("celSuppressInvalidLang"), + eq("celements.language.suppressInvalid"), eq("0"), same(context))).andReturn("0") + .atLeastOnce(); replayDefault(); assertFalse(prepVeloContextService.isInvalidLanguageOrDefault("fr")); verifyDefault(); @@ -386,41 +387,41 @@ public void testIsInvalidLanguageOrDefault_no_noSuppress() { public void testInitCelementsVelocity_checkNPEs_forEmptyVContext() throws XWikiException { VelocityContext vContext = new VelocityContext(); context.put("vcontext", vContext); - expect(xwiki.getPluginApi(eq(prepVeloContextService.getVelocityName()), same( - context))).andReturn(null).anyTimes(); - expect(xwiki.getSpacePreference(eq("language"), eq("mySpace"), eq(""), same( - context))).andReturn("").anyTimes(); + expect(xwiki.getPluginApi(eq(prepVeloContextService.getVelocityName()), same(context))) + .andReturn(null).anyTimes(); + expect(xwiki.getSpacePreference(eq("language"), eq("mySpace"), eq(""), same(context))) + .andReturn("").anyTimes(); expect(getMock(IWebUtilsService.class).getDefaultLanguage()).andReturn("en").atLeastOnce(); - expect(getMock(IWebUtilsService.class).getAllowedLanguages()).andReturn( - Collections.emptyList()).anyTimes(); + expect(getMock(IWebUtilsService.class).getAllowedLanguages()) + .andReturn(Collections.emptyList()).anyTimes(); expect(getMock(IWebUtilsService.class).isAdminUser()).andReturn(false).atLeastOnce(); expect(getMock(IWebUtilsService.class).isSuperAdminUser()).andReturn(false).atLeastOnce(); expect(getMock(IWebUtilsService.class).getAdminLanguage()).andReturn("en").atLeastOnce(); expect(getMock(IWebUtilsService.class).getAdminMessageTool()).andReturn(null).atLeastOnce(); expect(xwiki.getSpacePreference(eq("skin"), same(context))).andReturn("").anyTimes(); - expect(xwiki.getSpacePreference(eq("admin_language"), eq("de"), same(context))).andReturn( - "").anyTimes(); + expect(xwiki.getSpacePreference(eq("admin_language"), eq("de"), same(context))).andReturn("") + .anyTimes(); expect(skinDoc.getURL(eq("view"), same(context))).andReturn("").anyTimes(); expect(xwiki.exists(eq("PageTypes.RichText"), same(context))).andReturn(true).atLeastOnce(); - expect(xwiki.getDocument(eq("PageTypes.RichText"), same(context))).andReturn( - new XWikiDocument()).atLeastOnce(); - expect(xwiki.getSpacePreference(eq("editbox_width"), same(context))).andReturn( - "123").anyTimes(); + expect(xwiki.getDocument(eq("PageTypes.RichText"), same(context))) + .andReturn(new XWikiDocument()).atLeastOnce(); + expect(xwiki.getSpacePreference(eq("editbox_width"), same(context))).andReturn("123") + .anyTimes(); expect(ptResolverMock.getPageTypeObject(getContext().getDoc())).andReturn(null).atLeastOnce(); expect(configSourceMock.getProperty(eq("editbox_height"))).andReturn("432").anyTimes(); expect(xwiki.getSkin(same(context))).andReturn("celements2web:Skins.CellSkin").anyTimes(); DocumentReference cellSkinDoc = new DocumentReference("celements2web", "Skins", "CellSkin"); - expect(xwiki.getDocument(eq(cellSkinDoc), same(context))).andReturn(new XWikiDocument( - cellSkinDoc)).atLeastOnce(); - expect(xwiki.getUser(eq("XWiki.myTestUser"), same(context))).andReturn(new User( - context.getXWikiUser(), context)).atLeastOnce(); + expect(xwiki.getDocument(eq(cellSkinDoc), same(context))) + .andReturn(new XWikiDocument(cellSkinDoc)).atLeastOnce(); + expect(xwiki.getUser(eq("XWiki.myTestUser"), same(context))) + .andReturn(new User(context.getXWikiUser(), context)).atLeastOnce(); context.setWiki(xwiki); expect(rightServiceMock.hasAccessLevel(eq("edit"), eq("XWiki.myTestUser"), eq("mySpace.myDoc"), same(context))).andReturn(false).anyTimes(); expect(rightServiceMock.hasAdminRights(same(context))).andReturn(false).anyTimes(); expect(xwiki.Param("celements.admin_language")).andReturn("").anyTimes(); - PageTypeReference ptRef = new PageTypeReference("RichText", "testProvider", Arrays.asList( - "cat1")); + PageTypeReference ptRef = new PageTypeReference("RichText", "testProvider", + Arrays.asList("cat1")); expect(ptResolverMock.getPageTypeRefForCurrentDoc()).andReturn(ptRef).atLeastOnce(); replayDefault(); // context.setUser calls xwiki.isVirtualMode in xwiki version 4.5 thus why it must be @@ -437,38 +438,38 @@ public void testInitCelementsVelocity_checkNPEs_forMissingURLfactory() throws XW assertNull(context.getURLFactory()); VelocityContext vContext = new VelocityContext(); context.put("vcontext", vContext); - expect(xwiki.getPluginApi(eq(prepVeloContextService.getVelocityName()), same( - context))).andReturn(null).anyTimes(); - expect(xwiki.getSpacePreference(eq("language"), eq("mySpace"), eq(""), same( - context))).andReturn("").anyTimes(); + expect(xwiki.getPluginApi(eq(prepVeloContextService.getVelocityName()), same(context))) + .andReturn(null).anyTimes(); + expect(xwiki.getSpacePreference(eq("language"), eq("mySpace"), eq(""), same(context))) + .andReturn("").anyTimes(); expect(getMock(IWebUtilsService.class).getDefaultLanguage()).andReturn("en").atLeastOnce(); - expect(getMock(IWebUtilsService.class).getAllowedLanguages()).andReturn( - Collections.emptyList()).anyTimes(); + expect(getMock(IWebUtilsService.class).getAllowedLanguages()) + .andReturn(Collections.emptyList()).anyTimes(); expect(getMock(IWebUtilsService.class).isAdminUser()).andReturn(false).atLeastOnce(); expect(getMock(IWebUtilsService.class).isSuperAdminUser()).andReturn(false).atLeastOnce(); expect(getMock(IWebUtilsService.class).getAdminLanguage()).andReturn("en").atLeastOnce(); expect(getMock(IWebUtilsService.class).getAdminMessageTool()).andReturn(null).atLeastOnce(); expect(xwiki.getSpacePreference(eq("skin"), same(context))).andReturn("").anyTimes(); - expect(xwiki.getSpacePreference(eq("editbox_width"), same(context))).andReturn( - "123").anyTimes(); + expect(xwiki.getSpacePreference(eq("editbox_width"), same(context))).andReturn("123") + .anyTimes(); expect(xwiki.exists(eq("PageTypes.RichText"), same(context))).andReturn(true).atLeastOnce(); - expect(xwiki.getDocument(eq("PageTypes.RichText"), same(context))).andReturn( - new XWikiDocument()).atLeastOnce(); + expect(xwiki.getDocument(eq("PageTypes.RichText"), same(context))) + .andReturn(new XWikiDocument()).atLeastOnce(); expect(ptResolverMock.getPageTypeObject(getContext().getDoc())).andReturn(null).atLeastOnce(); expect(configSourceMock.getProperty(eq("editbox_height"))).andReturn("432").anyTimes(); expect(xwiki.getSkin(same(context))).andReturn("celements2web:Skins.CellSkin").anyTimes(); DocumentReference cellSkinDoc = new DocumentReference("celements2web", "Skins", "CellSkin"); - expect(xwiki.getDocument(eq(cellSkinDoc), same(context))).andReturn(new XWikiDocument( - cellSkinDoc)).atLeastOnce(); - expect(xwiki.getUser(eq("XWiki.myTestUser"), same(context))).andReturn(new User( - context.getXWikiUser(), context)).atLeastOnce(); + expect(xwiki.getDocument(eq(cellSkinDoc), same(context))) + .andReturn(new XWikiDocument(cellSkinDoc)).atLeastOnce(); + expect(xwiki.getUser(eq("XWiki.myTestUser"), same(context))) + .andReturn(new User(context.getXWikiUser(), context)).atLeastOnce(); context.setWiki(xwiki); expect(rightServiceMock.hasAccessLevel(eq("edit"), eq("XWiki.myTestUser"), eq("mySpace.myDoc"), same(context))).andReturn(false).anyTimes(); expect(rightServiceMock.hasAdminRights(same(context))).andReturn(false).anyTimes(); expect(xwiki.Param("celements.admin_language")).andReturn("").anyTimes(); - PageTypeReference ptRef = new PageTypeReference("RichText", "testProvider", Arrays.asList( - "cat1")); + PageTypeReference ptRef = new PageTypeReference("RichText", "testProvider", + Arrays.asList("cat1")); expect(ptResolverMock.getPageTypeRefForCurrentDoc()).andReturn(ptRef).atLeastOnce(); replayDefault(); // context.setUser calls xwiki.isVirtualMode in xwiki version 4.5 thus why it must be @@ -483,10 +484,10 @@ public void testInitCelementsVelocity_checkNPEs_forMissingURLfactory() throws XW public void testInitPanelsVelocity_checkNPEs_forEmptyVContext() { context.setDoc(null); context.put("vcontext", new VelocityContext()); - expect(xwiki.getSpacePreference(eq("showRightPanels"), same(context))).andReturn( - null).atLeastOnce(); - expect(xwiki.getSpacePreference(eq("showLeftPanels"), same(context))).andReturn( - null).atLeastOnce(); + expect(xwiki.getSpacePreference(eq("showRightPanels"), same(context))).andReturn(null) + .atLeastOnce(); + expect(xwiki.getSpacePreference(eq("showLeftPanels"), same(context))).andReturn(null) + .atLeastOnce(); replayDefault(); prepVeloContextService.initPanelsVelocity((VelocityContext) context.get("vcontext")); verifyDefault(); @@ -496,8 +497,8 @@ public void testInitPanelsVelocity_checkNPEs_forEmptyVContext() { public void testGetRTEwidth_default() throws Exception { expect(xwiki.getSpacePreference(eq("editbox_width"), same(context))).andReturn(""); expect(xwiki.exists(eq("PageTypes.RichText"), same(context))).andReturn(true).atLeastOnce(); - expect(xwiki.getDocument(eq("PageTypes.RichText"), same(context))).andReturn( - new XWikiDocument()).atLeastOnce(); + expect(xwiki.getDocument(eq("PageTypes.RichText"), same(context))) + .andReturn(new XWikiDocument()).atLeastOnce(); replayDefault(); assertEquals("453", prepVeloContextService.getRTEwidth(context)); verifyDefault(); @@ -507,8 +508,8 @@ public void testGetRTEwidth_default() throws Exception { public void testGetRTEwidth_preferences() throws Exception { expect(xwiki.getSpacePreference(eq("editbox_width"), same(context))).andReturn("500"); expect(xwiki.exists(eq("PageTypes.RichText"), same(context))).andReturn(true).atLeastOnce(); - expect(xwiki.getDocument(eq("PageTypes.RichText"), same(context))).andReturn( - new XWikiDocument()).atLeastOnce(); + expect(xwiki.getDocument(eq("PageTypes.RichText"), same(context))) + .andReturn(new XWikiDocument()).atLeastOnce(); replayDefault(); assertEquals("500", prepVeloContextService.getRTEwidth(context)); verifyDefault(); @@ -518,10 +519,10 @@ public void testGetRTEwidth_preferences() throws Exception { public void testGetRTEwidth_pageType() throws Exception { XWikiRequest request = createDefaultMock(XWikiRequest.class); context.setRequest(request); - expect(xwiki.getSpacePreference(eq("editbox_width"), same(context))).andReturn( - "500").anyTimes(); - XWikiDocument theDoc = new XWikiDocument(new DocumentReference(context.getDatabase(), "MySpace", - "myPage")); + expect(xwiki.getSpacePreference(eq("editbox_width"), same(context))).andReturn("500") + .anyTimes(); + XWikiDocument theDoc = new XWikiDocument( + new DocumentReference(context.getDatabase(), "MySpace", "myPage")); BaseObject pageTypeObj = new BaseObject(); pageTypeObj.setStringValue("page_type", "SpecialRichText"); DocumentReference pagTypeClassRef = new DocumentReference(context.getDatabase(), "Celements2", @@ -532,11 +533,11 @@ public void testGetRTEwidth_pageType() throws Exception { expect(request.get(eq("template"))).andReturn(null).anyTimes(); DocumentReference specialPTRef = new DocumentReference(context.getDatabase(), "PageTypes", "SpecialRichText"); - expect(xwiki.exists(eq("PageTypes.SpecialRichText"), same(context))).andReturn( - true).atLeastOnce(); + expect(xwiki.exists(eq("PageTypes.SpecialRichText"), same(context))).andReturn(true) + .atLeastOnce(); XWikiDocument pageTypeDoc = new XWikiDocument(specialPTRef); - expect(xwiki.getDocument(eq("PageTypes.SpecialRichText"), same(context))).andReturn( - pageTypeDoc).once(); + expect(xwiki.getDocument(eq("PageTypes.SpecialRichText"), same(context))).andReturn(pageTypeDoc) + .once(); BaseObject pageTypePropObj = new BaseObject(); pageTypePropObj.setIntValue("rte_width", 700); DocumentReference pageTypePropClassRef = new DocumentReference(context.getDatabase(), @@ -571,8 +572,8 @@ public void testGetRTEheight_pageType() throws Exception { XWikiRequest request = createDefaultMock(XWikiRequest.class); context.setRequest(request); expect(configSourceMock.getProperty(eq("editbox_height"))).andReturn("543").anyTimes(); - XWikiDocument theDoc = new XWikiDocument(new DocumentReference(context.getDatabase(), "MySpace", - "myPage")); + XWikiDocument theDoc = new XWikiDocument( + new DocumentReference(context.getDatabase(), "MySpace", "myPage")); BaseObject pageTypeObj = new BaseObject(); pageTypeObj.setStringValue("page_type", "SpecialRichText"); DocumentReference pagTypeClassRef = new DocumentReference(context.getDatabase(), "Celements2", @@ -588,8 +589,8 @@ public void testGetRTEheight_pageType() throws Exception { DocumentReference pageTypePropClassRef = new DocumentReference(context.getDatabase(), "Celements2", "PageTypeProperties"); pageTypePropObj.setXClassReference(pageTypePropClassRef); - expect(ptResolverMock.getPageTypeObject(getContext().getDoc())).andReturn( - pageTypePropObj).atLeastOnce(); + expect(ptResolverMock.getPageTypeObject(getContext().getDoc())).andReturn(pageTypePropObj) + .atLeastOnce(); replayDefault(); assertEquals("700", prepVeloContextService.getRTEheight()); verifyDefault(); @@ -613,11 +614,11 @@ public void testGetRightPanels() throws Exception { rightPanelsConfigObj.setXClassReference(panelsConfigClassRef); rightPanelsConfigObj.setStringValue("config_name", "rightPanels"); rightPanelsConfigObj.setIntValue("show_panels", 1); - rightPanelsConfigObj.setStringValue("panels", "Panels.VideoPlayerPanel," - + "Panels.GalleryPanel,Panels.BgPosEditPanel"); + rightPanelsConfigObj.setStringValue("panels", + "Panels.VideoPlayerPanel," + "Panels.GalleryPanel,Panels.BgPosEditPanel"); ptConfigDoc.addXObject(rightPanelsConfigObj); - expect(xwiki.getDocument(eq("PageTypes.Movie"), same(context))).andReturn( - ptConfigDoc).atLeastOnce(); + expect(xwiki.getDocument(eq("PageTypes.Movie"), same(context))).andReturn(ptConfigDoc) + .atLeastOnce(); replayDefault(); assertEquals(expectedPanels, prepVeloContextService.getRightPanels()); verifyDefault(); @@ -641,11 +642,11 @@ public void testGetLeftPanels() throws Exception { leftPanelsConfigObj.setXClassReference(panelsConfigClassRef); leftPanelsConfigObj.setStringValue("config_name", "leftPanels"); leftPanelsConfigObj.setIntValue("show_panels", 1); - leftPanelsConfigObj.setStringValue("panels", "Panels.VideoPlayerPanel," - + "Panels.GalleryPanel,Panels.BgPosEditPanel"); + leftPanelsConfigObj.setStringValue("panels", + "Panels.VideoPlayerPanel," + "Panels.GalleryPanel,Panels.BgPosEditPanel"); ptConfigDoc.addXObject(leftPanelsConfigObj); - expect(xwiki.getDocument(eq("PageTypes.Movie"), same(context))).andReturn( - ptConfigDoc).atLeastOnce(); + expect(xwiki.getDocument(eq("PageTypes.Movie"), same(context))).andReturn(ptConfigDoc) + .atLeastOnce(); replayDefault(); assertEquals(expectedPanels, prepVeloContextService.getLeftPanels()); verifyDefault(); diff --git a/src/test/java/com/celements/web/service/WebUtilsServiceTest.java b/src/test/java/com/celements/web/service/WebUtilsServiceTest.java index 6cc8c0b53..aac8bfdc9 100644 --- a/src/test/java/com/celements/web/service/WebUtilsServiceTest.java +++ b/src/test/java/com/celements/web/service/WebUtilsServiceTest.java @@ -67,8 +67,8 @@ public void prepareTest() throws Exception { public void testGetParentForLevel_1() throws Exception { DocumentReference docRef = new DocumentReference(context.getDatabase(), "mySpace", "myDoc"); XWikiDocument doc = new XWikiDocument(docRef); - expect(getMock(IDocumentParentsListerRole.class).getDocumentParentsList(eq(docRef), eq( - true))).andReturn(Collections.emptyList()).once(); + expect(getMock(IDocumentParentsListerRole.class).getDocumentParentsList(eq(docRef), eq(true))) + .andReturn(Collections.emptyList()).once(); replayDefault(); context.setDoc(doc); @@ -82,8 +82,8 @@ public void testGetParentForLevel_2() throws Exception { DocumentReference parentRef = new DocumentReference(context.getDatabase(), "mySpace", "parent1"); XWikiDocument doc = new XWikiDocument(docRef); - expect(getMock(IDocumentParentsListerRole.class).getDocumentParentsList(eq(docRef), eq( - true))).andReturn(Arrays.asList(docRef, parentRef)).once(); + expect(getMock(IDocumentParentsListerRole.class).getDocumentParentsList(eq(docRef), eq(true))) + .andReturn(Arrays.asList(docRef, parentRef)).once(); replayDefault(); context.setDoc(doc); assertEquals(parentRef, webUtilsService.getParentForLevel(2)); @@ -96,8 +96,8 @@ public void testGetParentForLevel_3() throws Exception { DocumentReference parentRef = new DocumentReference(context.getDatabase(), "mySpace", "parent1"); XWikiDocument doc = new XWikiDocument(docRef); - expect(getMock(IDocumentParentsListerRole.class).getDocumentParentsList(eq(docRef), eq( - true))).andReturn(Arrays.asList(docRef, parentRef)).once(); + expect(getMock(IDocumentParentsListerRole.class).getDocumentParentsList(eq(docRef), eq(true))) + .andReturn(Arrays.asList(docRef, parentRef)).once(); replayDefault(); context.setDoc(doc); assertEquals(docRef, webUtilsService.getParentForLevel(3)); @@ -110,8 +110,8 @@ public void testGetParentForLevel_IndexOutOfBounds() throws Exception { DocumentReference parentRef = new DocumentReference(context.getDatabase(), "mySpace", "parent1"); XWikiDocument doc = new XWikiDocument(docRef); - expect(getMock(IDocumentParentsListerRole.class).getDocumentParentsList(eq(docRef), eq( - true))).andReturn(Arrays.asList(docRef, parentRef)).times(3); + expect(getMock(IDocumentParentsListerRole.class).getDocumentParentsList(eq(docRef), eq(true))) + .andReturn(Arrays.asList(docRef, parentRef)).times(3); replayDefault(); context.setDoc(doc); assertNull(webUtilsService.getParentForLevel(4)); @@ -128,8 +128,8 @@ public void testGetDocumentParentsList() throws Exception { DocumentReference parentRef = new DocumentReference(context.getDatabase(), "mySpace", "parent1"); List docParentsList = Arrays.asList(parentRef); - expect(getMock(IDocumentParentsListerRole.class).getDocumentParentsList(eq(docRef), eq( - includeDoc))).andReturn(docParentsList).once(); + expect(getMock(IDocumentParentsListerRole.class).getDocumentParentsList(eq(docRef), + eq(includeDoc))).andReturn(docParentsList).once(); replayDefault(); assertSame(docParentsList, webUtilsService.getDocumentParentsList(docRef, includeDoc)); verifyDefault(); @@ -143,8 +143,8 @@ public void testGetDocumentParentsList_includeDoc() throws Exception { DocumentReference parentRef = new DocumentReference(context.getDatabase(), "mySpace", "parent1"); List docParentsList = Arrays.asList(parentRef); - expect(getMock(IDocumentParentsListerRole.class).getDocumentParentsList(eq(docRef), eq( - includeDoc))).andReturn(docParentsList).once(); + expect(getMock(IDocumentParentsListerRole.class).getDocumentParentsList(eq(docRef), + eq(includeDoc))).andReturn(docParentsList).once(); replayDefault(); assertSame(docParentsList, webUtilsService.getDocumentParentsList(docRef, includeDoc)); verifyDefault(); @@ -179,8 +179,8 @@ public void testGetDocSection_empty() throws Exception { XWikiDocument doc = createMock(XWikiDocument.class); expect(xwiki.getDocument(eq(docRef), same(context))).andReturn(doc).once(); - expect(doc.getTranslatedDocument(same(context))).andReturn(new XWikiDocument( - transDocRef)).once(); + expect(doc.getTranslatedDocument(same(context))).andReturn(new XWikiDocument(transDocRef)) + .once(); replayDefault(doc); assertNull(webUtilsService.getDocSection("(?=abc{/pre}"), eq(context.getDoc()), same( - context))).andReturn("abc
    ").atLeastOnce(); + expect(mockRenderer.renderText(eq("{pre}abc
    {/pre}"), eq(context.getDoc()), + same(context))).andReturn("abc
    ").atLeastOnce(); replayDefault(doc, mockRenderer); assertEquals("abc
    ", webUtilsService.getDocSection("(?= resultList = Arrays.asList("de", "en"); assertEquals("Expect languages from space preferences", resultList, @@ -850,8 +850,8 @@ public void testGetAllowedLanguages_spaceName_WebPreferences() { XWikiDocument currentDoc = new XWikiDocument(curDocRef); context.setDoc(currentDoc); expect(xwiki.getXWikiPreference(eq("languages"), same(context))).andReturn("fr,it").anyTimes(); - expect(xwiki.getSpacePreference(eq("languages"), eq("testSpace"), eq(""), same( - context))).andReturn("de,en").once(); + expect(xwiki.getSpacePreference(eq("languages"), eq("testSpace"), eq(""), same(context))) + .andReturn("de,en").once(); replayDefault(); List resultList = Arrays.asList("de", "en"); assertEquals("Expect languages from space preferences", resultList, @@ -864,11 +864,11 @@ public void testGetAllowedLanguages_deprecatedUsageOfFieldLanguage() { DocumentReference curDocRef = new DocumentReference(context.getDatabase(), "mySpace", "myDoc"); XWikiDocument currentDoc = new XWikiDocument(curDocRef); context.setDoc(currentDoc); - expect(xwiki.getSpacePreference(eq("languages"), eq("mySpace"), eq(""), same( - context))).andReturn("").once(); + expect(xwiki.getSpacePreference(eq("languages"), eq("mySpace"), eq(""), same(context))) + .andReturn("").once(); expect(xwiki.getXWikiPreference(eq("language"), same(context))).andReturn("fr it").anyTimes(); - expect(xwiki.getSpacePreference(eq("language"), eq("mySpace"), eq(""), same( - context))).andReturn("de en").once(); + expect(xwiki.getSpacePreference(eq("language"), eq("mySpace"), eq(""), same(context))) + .andReturn("de en").once(); replayDefault(); List resultList = Arrays.asList("de", "en"); assertEquals("Expect languages from space preferences", resultList, @@ -881,11 +881,11 @@ public void testGetAllowedLanguages_spaceName_deprecatedUsageOfFieldLanguage() { DocumentReference curDocRef = new DocumentReference(context.getDatabase(), "mySpace", "myDoc"); XWikiDocument currentDoc = new XWikiDocument(curDocRef); context.setDoc(currentDoc); - expect(xwiki.getSpacePreference(eq("languages"), eq("testSpace"), eq(""), same( - context))).andReturn("").once(); + expect(xwiki.getSpacePreference(eq("languages"), eq("testSpace"), eq(""), same(context))) + .andReturn("").once(); expect(xwiki.getXWikiPreference(eq("language"), same(context))).andReturn("fr it").anyTimes(); - expect(xwiki.getSpacePreference(eq("language"), eq("testSpace"), eq(""), same( - context))).andReturn("de en").once(); + expect(xwiki.getSpacePreference(eq("language"), eq("testSpace"), eq(""), same(context))) + .andReturn("de en").once(); replayDefault(); List resultList = Arrays.asList("de", "en"); assertEquals("Expect languages from space preferences", resultList, @@ -895,8 +895,8 @@ public void testGetAllowedLanguages_spaceName_deprecatedUsageOfFieldLanguage() { @Test public void testGetParentSpace() { - expect(xwiki.getSpacePreference(eq("parent"), same(context))).andReturn( - "parentSpaceName").atLeastOnce(); + expect(xwiki.getSpacePreference(eq("parent"), same(context))).andReturn("parentSpaceName") + .atLeastOnce(); replayDefault(); assertEquals("parentSpaceName", webUtilsService.getParentSpace()); verifyDefault(); @@ -904,8 +904,8 @@ public void testGetParentSpace() { @Test public void testGetParentSpace_spaceName() { - expect(xwiki.getSpacePreference(eq("parent"), eq("mySpace"), eq(""), same(context))).andReturn( - "parentSpaceName").atLeastOnce(); + expect(xwiki.getSpacePreference(eq("parent"), eq("mySpace"), eq(""), same(context))) + .andReturn("parentSpaceName").atLeastOnce(); replayDefault(); assertEquals("parentSpaceName", webUtilsService.getParentSpace("mySpace")); verifyDefault(); @@ -974,8 +974,8 @@ public void testGetInheritedTemplatedPath_central_exists() { "myView"); expect(modelAccessMock.exists(centralTemplateRef)).andReturn(true); replayDefault(); - assertEquals("celements2web:Templates.myView", webUtilsService.getInheritedTemplatedPath( - localTemplateRef)); + assertEquals("celements2web:Templates.myView", + webUtilsService.getInheritedTemplatedPath(localTemplateRef)); verifyDefault(); } @@ -985,8 +985,8 @@ public void testGetInheritedTemplatedPath_inital_central_exists() { "myView"); expect(modelAccessMock.exists(centralTemplateRef)).andReturn(true); replayDefault(); - assertEquals("celements2web:Templates.myView", webUtilsService.getInheritedTemplatedPath( - centralTemplateRef)); + assertEquals("celements2web:Templates.myView", + webUtilsService.getInheritedTemplatedPath(centralTemplateRef)); verifyDefault(); } @@ -996,8 +996,8 @@ public void testGetInheritedTemplatedPath_inital_central_notExists() { "myView"); expect(modelAccessMock.exists(centralTemplateRef)).andReturn(false); replayDefault(); - assertEquals(":Templates.myView", webUtilsService.getInheritedTemplatedPath( - centralTemplateRef)); + assertEquals(":Templates.myView", + webUtilsService.getInheritedTemplatedPath(centralTemplateRef)); verifyDefault(); } @@ -1020,21 +1020,21 @@ public void testGetInheritedTemplatedPath_disk_inital_central() { "myView"); expect(modelAccessMock.exists(centralTemplateRef)).andReturn(false); replayDefault(); - assertEquals(":Templates.myView", webUtilsService.getInheritedTemplatedPath( - centralTemplateRef)); + assertEquals(":Templates.myView", + webUtilsService.getInheritedTemplatedPath(centralTemplateRef)); verifyDefault(); } @Test public void testGetTemplatePathOnDisk_Template() { - assertEquals("/templates/celTemplates/myScript.vm", webUtilsService.getTemplatePathOnDisk( - ":Templates.myScript")); + assertEquals("/templates/celTemplates/myScript.vm", + webUtilsService.getTemplatePathOnDisk(":Templates.myScript")); } @Test public void testGetTemplatePathOnDisk_Ajax() { - assertEquals("/templates/celAjax/myScript.vm", webUtilsService.getTemplatePathOnDisk( - ":Ajax.myScript")); + assertEquals("/templates/celAjax/myScript.vm", + webUtilsService.getTemplatePathOnDisk(":Ajax.myScript")); } @Test @@ -1048,17 +1048,16 @@ public void testRenderInheritableDocument_local_exists() throws Exception { .andReturn(Optional.of(localTemplateDoc)); String localScriptText = "my expected local script"; localTemplateDoc.setContent(localScriptText); - XWikiRenderingEngine mockRenderingEngine = createDefaultMock( - XWikiRenderingEngine.class); - expect(mockRenderingEngine.getRendererNames()).andReturn(Arrays.asList("velocity", - "groovy")).anyTimes(); + XWikiRenderingEngine mockRenderingEngine = createDefaultMock(XWikiRenderingEngine.class); + expect(mockRenderingEngine.getRendererNames()).andReturn(Arrays.asList("velocity", "groovy")) + .anyTimes(); String expectedRenderedText = "my expected rendered local script"; expect(mockRenderingEngine.renderText(eq(localScriptText), same(localTemplateDoc), (XWikiDocument) isNull(), same(context))).andReturn(expectedRenderedText).once(); replayDefault(); webUtilsService.injectedRenderingEngine = mockRenderingEngine; - assertEquals(expectedRenderedText, webUtilsService.renderInheritableDocument(localTemplateRef, - "de")); + assertEquals(expectedRenderedText, + webUtilsService.renderInheritableDocument(localTemplateRef, "de")); verifyDefault(); } @@ -1076,25 +1075,23 @@ public void testRenderInheritableDocument_central_exists() throws Exception { .andReturn(Optional.of(centralTemplateDoc)); String centralScriptText = "my expected central script"; centralTemplateDoc.setContent(centralScriptText); - XWikiRenderingEngine mockRenderingEngine = createDefaultMock( - XWikiRenderingEngine.class); - expect(mockRenderingEngine.getRendererNames()).andReturn(Arrays.asList("velocity", - "groovy")).anyTimes(); + XWikiRenderingEngine mockRenderingEngine = createDefaultMock(XWikiRenderingEngine.class); + expect(mockRenderingEngine.getRendererNames()).andReturn(Arrays.asList("velocity", "groovy")) + .anyTimes(); String expectedRenderedText = "my expected rendered central script"; expect(mockRenderingEngine.renderText(eq(centralScriptText), same(centralTemplateDoc), (XWikiDocument) isNull(), same(context))).andReturn(expectedRenderedText).once(); replayDefault(); webUtilsService.injectedRenderingEngine = mockRenderingEngine; - assertEquals(expectedRenderedText, webUtilsService.renderInheritableDocument(localTemplateRef, - "en")); + assertEquals(expectedRenderedText, + webUtilsService.renderInheritableDocument(localTemplateRef, "en")); verifyDefault(); } @Test public void testRenderInheritableDocument_disk_langSpecific_no_local_no_central() throws Exception { - XWikiRenderingEngine mockRenderingEngine = createDefaultMock( - XWikiRenderingEngine.class); + XWikiRenderingEngine mockRenderingEngine = createDefaultMock(XWikiRenderingEngine.class); DocumentReference localTemplateRef = new DocumentReference(context.getDatabase(), "Templates", "myView"); expect(modelAccessMock.exists(localTemplateRef)).andReturn(false); @@ -1102,66 +1099,64 @@ public void testRenderInheritableDocument_disk_langSpecific_no_local_no_central( "myView"); expect(modelAccessMock.exists(centralTemplateRef)).andReturn(false); String diskScriptText = "my expected disk script fr"; - expect(xwiki.getResourceContent(eq("/templates/celTemplates/myView_fr.vm"))).andReturn( - diskScriptText).once(); + expect(xwiki.getResourceContent(eq("/templates/celTemplates/myView_fr.vm"))) + .andReturn(diskScriptText).once(); String expectedRenderedText = "my expected rendered disk script"; expect(mockRenderingEngine.renderText(eq(diskScriptText), (XWikiDocument) isNull(), (XWikiDocument) isNull(), same(context))).andReturn(expectedRenderedText).once(); replayDefault(); webUtilsService.injectedRenderingEngine = mockRenderingEngine; // TODO check for language doc on disc - assertEquals(expectedRenderedText, webUtilsService.renderInheritableDocument(localTemplateRef, - "fr")); + assertEquals(expectedRenderedText, + webUtilsService.renderInheritableDocument(localTemplateRef, "fr")); verifyDefault(); } @Test public void testRenderInheritableDocument_disk_noLang_no_local_no_central() throws Exception { - XWikiRenderingEngine mockRenderingEngine = createDefaultMock( - XWikiRenderingEngine.class); + XWikiRenderingEngine mockRenderingEngine = createDefaultMock(XWikiRenderingEngine.class); DocumentReference localTemplateRef = new DocumentReference(context.getDatabase(), "Templates", "myView"); expect(modelAccessMock.exists(localTemplateRef)).andReturn(false); DocumentReference centralTemplateRef = new DocumentReference("celements2web", "Templates", "myView"); expect(modelAccessMock.exists(centralTemplateRef)).andReturn(false); - expect(xwiki.getResourceContent(eq("/templates/celTemplates/myView_fr.vm"))).andThrow( - new IOException()).once(); + expect(xwiki.getResourceContent(eq("/templates/celTemplates/myView_fr.vm"))) + .andThrow(new IOException()).once(); String diskScriptText = "my expected disk script"; - expect(xwiki.getResourceContent(eq("/templates/celTemplates/myView.vm"))).andReturn( - diskScriptText).once(); + expect(xwiki.getResourceContent(eq("/templates/celTemplates/myView.vm"))) + .andReturn(diskScriptText).once(); String expectedRenderedText = "my expected rendered disk script"; expect(mockRenderingEngine.renderText(eq(diskScriptText), (XWikiDocument) isNull(), (XWikiDocument) isNull(), same(context))).andReturn(expectedRenderedText).once(); replayDefault(); webUtilsService.injectedRenderingEngine = mockRenderingEngine; - assertEquals(expectedRenderedText, webUtilsService.renderInheritableDocument(localTemplateRef, - "fr")); + assertEquals(expectedRenderedText, + webUtilsService.renderInheritableDocument(localTemplateRef, "fr")); verifyDefault(); } @Test public void testRenderInheritableDocument_disk_defLang_no_local_no_central() throws Exception { - XWikiRenderingEngine mockRenderingEngine = createDefaultMock( - XWikiRenderingEngine.class); + XWikiRenderingEngine mockRenderingEngine = createDefaultMock(XWikiRenderingEngine.class); DocumentReference localTemplateRef = new DocumentReference(context.getDatabase(), "Templates", "myView"); expect(modelAccessMock.exists(localTemplateRef)).andReturn(false); DocumentReference centralTemplateRef = new DocumentReference("celements2web", "Templates", "myView"); expect(modelAccessMock.exists(centralTemplateRef)).andReturn(false); - expect(xwiki.getResourceContent(eq("/templates/celTemplates/myView_fr.vm"))).andThrow( - new IOException()).once(); + expect(xwiki.getResourceContent(eq("/templates/celTemplates/myView_fr.vm"))) + .andThrow(new IOException()).once(); String diskScriptText = "my expected disk script"; - expect(xwiki.getResourceContent(eq("/templates/celTemplates/myView_en.vm"))).andReturn( - diskScriptText).once(); + expect(xwiki.getResourceContent(eq("/templates/celTemplates/myView_en.vm"))) + .andReturn(diskScriptText).once(); String expectedRenderedText = "my expected rendered disk script"; expect(mockRenderingEngine.renderText(eq(diskScriptText), (XWikiDocument) isNull(), (XWikiDocument) isNull(), same(context))).andReturn(expectedRenderedText).once(); replayDefault(); webUtilsService.injectedRenderingEngine = mockRenderingEngine; - assertEquals(expectedRenderedText, webUtilsService.renderInheritableDocument(localTemplateRef, - "fr", "en")); + assertEquals(expectedRenderedText, + webUtilsService.renderInheritableDocument(localTemplateRef, "fr", "en")); verifyDefault(); } @@ -1193,8 +1188,8 @@ public void testFilterAttachmentsByTag_tagDoesNotExist() { List attachments = new ArrayList<>(); attachments.add(new Attachment(null, null, getContext())); attachments.add(new Attachment(null, null, getContext())); - expect(xwiki.exists(eq(webUtilsService.resolveDocumentReference("Tag.T")), same( - getContext()))).andReturn(false).once(); + expect(xwiki.exists(eq(webUtilsService.resolveDocumentReference("Tag.T")), same(getContext()))) + .andReturn(false).once(); replayDefault(); List atts = webUtilsService.filterAttachmentsByTag(attachments, "Tag.T"); verifyDefault(); @@ -1235,19 +1230,22 @@ public void testFilterAttachmentsByTag() throws Exception { expect(tagDoc.clone()).andReturn(tagDoc).anyTimes(); expect(xwiki.getDocument(eq(tagRef), same(getContext()))).andReturn(tagDoc).once(); expect(tagDoc.getXObjectSize(eq(tagClassRef))).andReturn(3); - expect(tagDoc.getXObject(eq(tagClassRef), eq("attachment"), eq(docName + "/abc.jpg"), eq( - false))).andReturn(new BaseObject()).once(); - expect(tagDoc.getXObject(eq(tagClassRef), eq("attachment"), eq(docName + "/bcd.jpg"), eq( - false))).andReturn(null).once(); - expect(tagDoc.getXObject(eq(tagClassRef), eq("attachment"), eq(docName + "/cde.jpg"), eq( - false))).andReturn(new BaseObject()).once(); + expect( + tagDoc.getXObject(eq(tagClassRef), eq("attachment"), eq(docName + "/abc.jpg"), eq(false))) + .andReturn(new BaseObject()).once(); + expect( + tagDoc.getXObject(eq(tagClassRef), eq("attachment"), eq(docName + "/bcd.jpg"), eq(false))) + .andReturn(null).once(); + expect( + tagDoc.getXObject(eq(tagClassRef), eq("attachment"), eq(docName + "/cde.jpg"), eq(false))) + .andReturn(new BaseObject()).once(); List attachments = new ArrayList<>(); - attachments.add(new Attachment(theDoc.newDocument(getContext()), new XWikiAttachment(theDoc, - "abc.jpg"), getContext())); - attachments.add(new Attachment(theDoc.newDocument(getContext()), new XWikiAttachment(theDoc, - "bcd.jpg"), getContext())); - attachments.add(new Attachment(theDoc.newDocument(getContext()), new XWikiAttachment(theDoc, - "cde.jpg"), getContext())); + attachments.add(new Attachment(theDoc.newDocument(getContext()), + new XWikiAttachment(theDoc, "abc.jpg"), getContext())); + attachments.add(new Attachment(theDoc.newDocument(getContext()), + new XWikiAttachment(theDoc, "bcd.jpg"), getContext())); + attachments.add(new Attachment(theDoc.newDocument(getContext()), + new XWikiAttachment(theDoc, "cde.jpg"), getContext())); replayDefault(tagDoc); List atts = webUtilsService.filterAttachmentsByTag(attachments, tagName); verifyDefault(tagDoc); @@ -1363,8 +1361,8 @@ public void testGetAttachmentApi_XWE() throws Exception { public void testResolveEntityTypeForFullName_wiki() { String fullName = "myWiki"; assertSame(EntityType.WIKI, webUtilsService.resolveEntityTypeForFullName(fullName)); - assertSame(EntityType.WIKI, webUtilsService.resolveEntityTypeForFullName(fullName, - EntityType.WIKI)); + assertSame(EntityType.WIKI, + webUtilsService.resolveEntityTypeForFullName(fullName, EntityType.WIKI)); } @Test @@ -1376,8 +1374,8 @@ public void testResolveEntityTypeForFullName_space() { @Test public void testResolveEntityTypeForFullName_space_local() { String fullName = "mySpace"; - assertSame(EntityType.SPACE, webUtilsService.resolveEntityTypeForFullName(fullName, - EntityType.SPACE)); + assertSame(EntityType.SPACE, + webUtilsService.resolveEntityTypeForFullName(fullName, EntityType.SPACE)); } @Test @@ -1611,8 +1609,8 @@ public void testGetDefaultLanguage_withSpaceRef() throws Exception { DocumentReference webPrefDocRef = new DocumentReference("WebPreferences", spaceRef); expect(modelAccessMock.exists(webPrefDocRef)).andReturn(true); - expect(modelAccessMock.getOrCreateDocument(webPrefDocRef)).andReturn(new XWikiDocument( - webPrefDocRef)); + expect(modelAccessMock.getOrCreateDocument(webPrefDocRef)) + .andReturn(new XWikiDocument(webPrefDocRef)); assertEquals("xwikidb", getContext().getDatabase()); assertNull(getContext().getDoc()); diff --git a/src/test/java/com/celements/web/service/XWikiUrlServiceTest.java b/src/test/java/com/celements/web/service/XWikiUrlServiceTest.java index da0de60eb..888e73036 100644 --- a/src/test/java/com/celements/web/service/XWikiUrlServiceTest.java +++ b/src/test/java/com/celements/web/service/XWikiUrlServiceTest.java @@ -39,8 +39,9 @@ public void test_getURL() throws Exception { String queryString = "key=value1&key=value2"; String file = "/" + action + "/space/page?" + queryString; URL url = new URL("http", "wiki.celements.com", 8080, file); - expect(urlFactoryMock.createURL("space", "page", action, queryString, null, "wiki", - getContext())).andReturn(url); + expect( + urlFactoryMock.createURL("space", "page", action, queryString, null, "wiki", getContext())) + .andReturn(url); replayDefault(); assertEquals(file, service.getURL(docRef, action, queryString)); @@ -51,8 +52,8 @@ public void test_getURL() throws Exception { public void test_getURL_defaults() throws Exception { String file = "/space/page"; URL url = new URL("http", "wiki.celements.com", 8080, file); - expect(urlFactoryMock.createURL("space", "page", "view", null, null, "wiki", - getContext())).andReturn(url); + expect(urlFactoryMock.createURL("space", "page", "view", null, null, "wiki", getContext())) + .andReturn(url); replayDefault(); assertEquals(file, service.getURL(docRef)); @@ -64,8 +65,8 @@ public void test_getURL_space() throws Exception { SpaceReference spaceRef = docRef.getLastSpaceReference(); String file = "/space/"; URL url = new URL("http", "wiki.celements.com", 8080, file); - expect(urlFactoryMock.createURL("space", "", "view", null, null, "wiki", - getContext())).andReturn(url); + expect(urlFactoryMock.createURL("space", "", "view", null, null, "wiki", getContext())) + .andReturn(url); replayDefault(); assertEquals(file, service.getURL(spaceRef)); @@ -117,8 +118,9 @@ public void test_getExternalURL() throws Exception { String queryString = "key=value1&key=value2"; String file = "/" + action + "/space/page?" + queryString; URL url = new URL("http", "wiki.celements.com", 8080, file); - expect(urlFactoryMock.createURL("space", "page", action, queryString, null, "wiki", - getContext())).andReturn(url); + expect( + urlFactoryMock.createURL("space", "page", action, queryString, null, "wiki", getContext())) + .andReturn(url); replayDefault(); assertEquals(url.toString(), service.getExternalURL(docRef, action, queryString)); @@ -171,8 +173,8 @@ public void test_createURLObject_notEmptyForContentWebHome() throws Exception { EntityReference docRefContentWebHome = new DocumentReference(getContext().getDatabase(), "Content", "WebHome"); expect(urlFactoryMock.createURL(eq("Content"), eq("WebHome"), eq("view"), eq(""), - (String) isNull(), eq(getContext().getDatabase()), same(getContext()))).andReturn(new URL( - "http", "myTest.domain", "")); + (String) isNull(), eq(getContext().getDatabase()), same(getContext()))) + .andReturn(new URL("http", "myTest.domain", "")); replayDefault(); String urlStr = ((XWikiUrlService) service).getURL(docRefContentWebHome, "view", ""); assertEquals("/", urlStr);