Author: chris.laprun(a)jboss.com
Date: 2011-07-29 12:46:44 -0400 (Fri, 29 Jul 2011)
New Revision: 6951
Added:
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/portal/
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/portal/SiteTestCase.java
Modified:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/PortalImpl.java
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/SiteImpl.java
Log:
- Added SiteTestCase to check that Type is properly retrieved.
Modified:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/PortalImpl.java
===================================================================
---
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/PortalImpl.java 2011-07-29
16:44:27 UTC (rev 6950)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/PortalImpl.java 2011-07-29
16:46:44 UTC (rev 6951)
@@ -37,7 +37,7 @@
public PortalImpl(PortalData portal, GateInImpl gateIn)
{
- super(gateIn.siteId(Type.forName(portal.getKey().getType(), Site.class),
portal.getKey().getId()), portal.getName(), gateIn);
+ super(gateIn.siteId(getAPITypeFrom(portal.getKey()), portal.getKey().getId()),
portal.getName(), gateIn);
}
public ContentRegistry getContentRegistry()
Modified:
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/SiteImpl.java
===================================================================
---
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/SiteImpl.java 2011-07-29
16:44:27 UTC (rev 6950)
+++
portal/branches/api/component/api-impl/src/main/java/org/gatein/portal/api/impl/portal/SiteImpl.java 2011-07-29
16:46:44 UTC (rev 6951)
@@ -28,11 +28,13 @@
import org.exoplatform.portal.mop.navigation.NavigationState;
import org.exoplatform.portal.mop.navigation.NodeModel;
import org.exoplatform.portal.mop.navigation.Scope;
+import org.exoplatform.portal.pom.data.OwnerKey;
import org.gatein.api.id.Id;
import org.gatein.api.portal.Navigation;
import org.gatein.api.portal.Page;
import org.gatein.api.portal.Site;
import org.gatein.api.util.HierarchicalContainer;
+import org.gatein.api.util.Type;
import org.gatein.portal.api.impl.GateInImpl;
import org.gatein.portal.api.impl.IdentifiableImpl;
@@ -50,6 +52,11 @@
return getType().getName() + "\n" + getNavigation().toString();
}
+ static Type getAPITypeFrom(OwnerKey key)
+ {
+ return Type.forName(key.getType(), Site.class);
+ }
+
public HierarchicalContainer<String, Page> getPageRegistry()
{
return null; //To change body of implemented methods use File | Settings | File
Templates.
Added:
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/portal/SiteTestCase.java
===================================================================
---
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/portal/SiteTestCase.java
(rev 0)
+++
portal/branches/api/component/api-impl/src/test/java/org/gatein/portal/api/impl/portal/SiteTestCase.java 2011-07-29
16:46:44 UTC (rev 6951)
@@ -0,0 +1,42 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* 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.gatein.portal.api.impl.portal;
+
+import org.exoplatform.portal.mop.SiteType;
+import org.exoplatform.portal.pom.data.PageKey;
+import org.exoplatform.portal.pom.data.PortalKey;
+import org.gatein.api.portal.Site;
+import org.testng.annotations.Test;
+
+/** @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a> */
+public class SiteTestCase
+{
+ @Test
+ public void getAPITypeShouldProperlyResolve()
+ {
+ assert Site.DASHBOARD.equals(SiteImpl.getAPITypeFrom(new
PageKey(SiteType.USER.getName(), "foo", "foo")));
+ assert Site.GROUP.equals(SiteImpl.getAPITypeFrom(new
PageKey(SiteType.GROUP.getName(), "foo", "foo")));
+ assert Site.PORTAL.equals(SiteImpl.getAPITypeFrom(new
PortalKey(SiteType.PORTAL.getName(), "foo")));
+ assert Site.PORTAL.equals(SiteImpl.getAPITypeFrom(new PortalKey("portal",
"foo")));
+ }
+}