Search in sources :

Example 1 with StrutsActionPathPossibleValuesService

use of com.liferay.ide.hook.core.model.internal.StrutsActionPathPossibleValuesService in project liferay-ide by liferay.

the class LiferayHookModelTests method strutsActionPathPossibleValuesService.

/**
 * @throws Exception
 */
@Test
public void strutsActionPathPossibleValuesService() throws Exception {
    if (shouldSkipBundleTests())
        return;
    final NewLiferayPluginProjectOp op = newProjectOp("testPossibleValues");
    op.setPluginType(PluginType.hook);
    final IProject hookProject = createAntProject(op);
    final IFolder webappRoot = LiferayCore.create(IWebProject.class, hookProject).getDefaultDocrootFolder();
    assertNotNull(webappRoot);
    final IFile hookXml = webappRoot.getFile("WEB-INF/liferay-hook.xml");
    assertEquals(true, hookXml.exists());
    final XmlResourceStore store = new XmlResourceStore(hookXml.getContents()) {

        public <A> A adapt(Class<A> adapterType) {
            if (IProject.class.equals(adapterType)) {
                return adapterType.cast(hookProject);
            }
            return super.adapt(adapterType);
        }
    };
    final Hook hook = Hook6xx.TYPE.instantiate(new RootXmlResource(store));
    assertNotNull(hook);
    final StrutsAction strutsAction = hook.getStrutsActions().insert();
    final Value<String> strutsActionPath = strutsAction.getStrutsActionPath();
    final Set<String> values = strutsActionPath.service(StrutsActionPathPossibleValuesService.class).values();
    assertNotNull(values);
    assertTrue(values.size() > 10);
}
Also used : Hook(com.liferay.ide.hook.core.model.Hook) IFile(org.eclipse.core.resources.IFile) IWebProject(com.liferay.ide.core.IWebProject) XmlResourceStore(org.eclipse.sapphire.modeling.xml.XmlResourceStore) StrutsAction(com.liferay.ide.hook.core.model.StrutsAction) RootXmlResource(org.eclipse.sapphire.modeling.xml.RootXmlResource) IProject(org.eclipse.core.resources.IProject) NewLiferayPluginProjectOp(com.liferay.ide.project.core.model.NewLiferayPluginProjectOp) StrutsActionPathPossibleValuesService(com.liferay.ide.hook.core.model.internal.StrutsActionPathPossibleValuesService) IFolder(org.eclipse.core.resources.IFolder) Test(org.junit.Test)

Aggregations

IWebProject (com.liferay.ide.core.IWebProject)1 Hook (com.liferay.ide.hook.core.model.Hook)1 StrutsAction (com.liferay.ide.hook.core.model.StrutsAction)1 StrutsActionPathPossibleValuesService (com.liferay.ide.hook.core.model.internal.StrutsActionPathPossibleValuesService)1 NewLiferayPluginProjectOp (com.liferay.ide.project.core.model.NewLiferayPluginProjectOp)1 IFile (org.eclipse.core.resources.IFile)1 IFolder (org.eclipse.core.resources.IFolder)1 IProject (org.eclipse.core.resources.IProject)1 RootXmlResource (org.eclipse.sapphire.modeling.xml.RootXmlResource)1 XmlResourceStore (org.eclipse.sapphire.modeling.xml.XmlResourceStore)1 Test (org.junit.Test)1