Skip to content
This repository has been archived by the owner on Apr 8, 2019. It is now read-only.

Commit

Permalink
Run navigation importer tests with mongo and fix a few bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
vietj committed Aug 31, 2013
1 parent c458cfc commit 690cbe3
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 2 deletions.
Expand Up @@ -118,7 +118,7 @@ private DBObject make(DescriptionState state) {
@Override
public void saveDescriptions(String id, Map<Locale, DescriptionState> descriptions) {
BasicDBObject doc = new BasicDBObject("_id", new ObjectId(id));
if (descriptions != null) {
if (descriptions != null && descriptions.size() > 0) {
for (Map.Entry<Locale, DescriptionState> entry : descriptions.entrySet()) {
doc.put(I18N.toJavaIdentifier(entry.getKey()), make(entry.getValue()));
}
Expand Down
Expand Up @@ -167,7 +167,7 @@ public NodeData<NodeState>[] createNode(String parentId, String previousId, Stri
String id = doc.get("_id").toString();
DBObject parentDoc = navigations.findOne(new BasicDBObject("_id", new ObjectId(parentId)));
List<String> children = (List<String>) parentDoc.get("children");
int index = previousId != null ? children.indexOf(previousId) + 1 : children.size();
int index = previousId != null ? children.indexOf(previousId) + 1 : 0;
children.add(index, id);
navigations.update(new BasicDBObject("_id", new ObjectId(parentId)), new BasicDBObject("$set", new BasicDBObject("children", children)));
return new NodeData[]{
Expand Down
@@ -0,0 +1,30 @@
/*
* Copyright (C) 2012 eXo Platform SAS.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/

package org.exoplatform.portal.mop.importer;

import org.exoplatform.portal.mop.PersistenceContext;

/** @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a> */
public class TestMongoNavigationImporter extends TestNavigationImporter {
@Override
protected PersistenceContext createPersistenceContext() {
return new PersistenceContext.Mongo();
}
}
@@ -0,0 +1,30 @@
/*
* Copyright (C) 2012 eXo Platform SAS.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/

package org.exoplatform.portal.mop.importer;

import org.exoplatform.portal.mop.PersistenceContext;

/** @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a> */
public class TestMongoNavigationNodeImporter extends TestNavigationNodeImporter {
@Override
protected PersistenceContext createPersistenceContext() {
return new PersistenceContext.Mongo();
}
}

0 comments on commit 690cbe3

Please sign in to comment.