Search in sources :

Example 31 with NewLiferayPluginProjectOp

use of com.liferay.ide.project.core.model.NewLiferayPluginProjectOp in project liferay-ide by liferay.

the class NewLiferayPluginProjectMavenTests method testProjectProviderListener.

@Test
public void testProjectProviderListener() throws Exception {
    if (shouldSkipBundleTests())
        return;
    final NewLiferayPluginProjectOp op = newProjectOp("test-project-provider-listener");
    final String projectName = op.getProjectName().content();
    op.setPluginType("portlet");
    op.setUseDefaultLocation(true);
    final SDK sdk = SDKUtil.createSDKFromLocation(getLiferayPluginsSdkDir());
    IPath exceptedLocation = null;
    op.setProjectProvider("ant");
    exceptedLocation = sdk.getLocation().append("portlets").append(projectName + "-portlet");
    assertEquals(exceptedLocation, PathBridge.create(op.getLocation().content()));
    op.setProjectProvider("maven");
    exceptedLocation = CoreUtil.getWorkspaceRoot().getLocation().append(projectName);
    assertEquals(exceptedLocation, PathBridge.create(op.getLocation().content()));
}
Also used : IPath(org.eclipse.core.runtime.IPath) NewLiferayPluginProjectOp(com.liferay.ide.project.core.model.NewLiferayPluginProjectOp) SDK(com.liferay.ide.sdk.core.SDK) Test(org.junit.Test)

Example 32 with NewLiferayPluginProjectOp

use of com.liferay.ide.project.core.model.NewLiferayPluginProjectOp in project liferay-ide by liferay.

the class NewLiferayPluginProjectMavenTests method testUseDefaultLocationListener.

protected void testUseDefaultLocationListener(boolean versionRestriction) throws Exception {
    final NewLiferayPluginProjectOp op = newProjectOp("test-use-default-location-listener");
    final String projectName = op.getProjectName().content();
    op.setProjectProvider("maven");
    IPath exceptedLocation = null;
    op.setUseDefaultLocation(true);
    exceptedLocation = CoreUtil.getWorkspaceRoot().getLocation().append(projectName);
    assertEquals(exceptedLocation, PathBridge.create(op.getLocation().content()));
    op.setUseDefaultLocation(false);
    assertEquals(null, op.getLocation().content());
    if (versionRestriction) {
        op.setProjectProvider("ant");
        op.setPluginType("portlet");
        op.setUseDefaultLocation(true);
        final SDK sdk = SDKUtil.createSDKFromLocation(getLiferayPluginsSdkDir());
        exceptedLocation = sdk.getLocation().append("portlets").append(projectName + "-portlet");
        assertEquals(exceptedLocation, PathBridge.create(op.getLocation().content()));
        op.setUseDefaultLocation(false);
        assertEquals(null, op.getLocation().content());
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) NewLiferayPluginProjectOp(com.liferay.ide.project.core.model.NewLiferayPluginProjectOp) SDK(com.liferay.ide.sdk.core.SDK)

Example 33 with NewLiferayPluginProjectOp

use of com.liferay.ide.project.core.model.NewLiferayPluginProjectOp in project liferay-ide by liferay.

the class NewLiferayPluginProjectMavenTests method testPortletProjectName.

@Test
public void testPortletProjectName() throws Exception {
    final NewLiferayPluginProjectOp op = newProjectOp("test-name");
    op.setProjectProvider("maven");
    op.setPluginType(PluginType.portlet);
    op.setUseDefaultLocation(true);
    op.setPortletFramework("mvc");
    op.setPortletName("testPortlet");
    IProject expectedProject = createMavenProject(op);
    String expectedProjectName = expectedProject.getName();
    String actualProjectName = op.getProjectNames().get(0).getName().content();
    assertEquals(expectedProjectName, actualProjectName);
}
Also used : NewLiferayPluginProjectOp(com.liferay.ide.project.core.model.NewLiferayPluginProjectOp) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test)

Example 34 with NewLiferayPluginProjectOp

use of com.liferay.ide.project.core.model.NewLiferayPluginProjectOp in project liferay-ide by liferay.

the class NewLiferayPluginProjectMavenTests method testProjectProviderPossibleValues.

@Test
public void testProjectProviderPossibleValues() throws Exception {
    if (shouldSkipBundleTests())
        return;
    final NewLiferayPluginProjectOp op = newProjectOp("test-project-provider-possbile-values");
    final Set<String> acturalValues = op.getProjectProvider().service(PossibleValuesService.class).values();
    assertNotNull(acturalValues);
    Set<String> exceptedValues = new HashSet<>();
    exceptedValues.add("ant");
    exceptedValues.add("maven");
    assertEquals(true, exceptedValues.containsAll(acturalValues));
    assertEquals(true, acturalValues.containsAll(exceptedValues));
}
Also used : PossibleValuesService(org.eclipse.sapphire.PossibleValuesService) NewLiferayPluginProjectOp(com.liferay.ide.project.core.model.NewLiferayPluginProjectOp) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 35 with NewLiferayPluginProjectOp

use of com.liferay.ide.project.core.model.NewLiferayPluginProjectOp in project liferay-ide by liferay.

the class NewLiferayPluginProjectMavenTests method testLocationValidation.

@Test
@Ignore
public void testLocationValidation() throws Exception {
    final NewLiferayPluginProjectOp op = newProjectOp("test-location-validation-service");
    op.setProjectProvider("maven");
    op.setPluginType("portlet");
    op.setUseDefaultLocation(false);
    final ValidationService vs = op.getLocation().service(ValidationService.class);
    String invalidLocation = null;
    invalidLocation = "not-absolute-location";
    op.setLocation(invalidLocation);
    final String expected = "\"" + invalidLocation + "\"" + " is not an absolute path.";
    assertEquals(normalize(expected), normalize(vs.validation().message()));
    assertEquals(normalize(expected), normalize(op.getLocation().validation().message()));
    if (CoreUtil.isWindows()) {
        invalidLocation = "Z:\\test-location-validation-service";
    } else {
        invalidLocation = "/test-location-validation-service";
    }
    op.setLocation(invalidLocation);
    final String expected2 = "Cannot create project content at " + "\"" + invalidLocation + "\"";
    assertEquals(expected2, vs.validation().message());
    assertEquals(expected2, op.getLocation().validation().message());
    if (CoreUtil.isWindows()) {
        invalidLocation = CoreUtil.getWorkspaceRoot().getLocation().getDevice() + "\\";
    } else {
        invalidLocation = "/";
    }
    op.setLocation(invalidLocation);
    final String expected3 = "Project location is not empty or a parent pom.";
    assertEquals(expected3, vs.validation().message());
    // assertEquals( expected3, op.getLocation().validation().message() );
    // IDE-2069
    invalidLocation = getLiferayRuntimeDir().removeLastSegments(2).toOSString();
    op.setLocation(invalidLocation);
    final String expected5 = "Project location is not empty or a parent pom.";
    assertEquals(expected5, vs.validation().message());
    op.setLocation("");
    final String expected4 = "Location must be specified.";
    assertEquals(expected4, vs.validation().message());
    assertEquals(expected4, op.getLocation().validation().message());
}
Also used : ValidationService(org.eclipse.sapphire.services.ValidationService) NewLiferayPluginProjectOp(com.liferay.ide.project.core.model.NewLiferayPluginProjectOp) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

NewLiferayPluginProjectOp (com.liferay.ide.project.core.model.NewLiferayPluginProjectOp)122 Test (org.junit.Test)61 IProject (org.eclipse.core.resources.IProject)48 IWebProject (com.liferay.ide.core.IWebProject)18 IFile (org.eclipse.core.resources.IFile)18 IPath (org.eclipse.core.runtime.IPath)14 IFolder (org.eclipse.core.resources.IFolder)13 SDK (com.liferay.ide.sdk.core.SDK)12 Status (org.eclipse.sapphire.modeling.Status)10 PropertyContentEvent (org.eclipse.sapphire.PropertyContentEvent)9 Path (org.eclipse.sapphire.modeling.Path)8 CoreException (org.eclipse.core.runtime.CoreException)7 IPortletFramework (com.liferay.ide.project.core.IPortletFramework)6 HashSet (java.util.HashSet)5 PossibleValuesService (org.eclipse.sapphire.PossibleValuesService)5 ValidationService (org.eclipse.sapphire.services.ValidationService)5 IVirtualComponent (org.eclipse.wst.common.componentcore.resources.IVirtualComponent)5 NewLiferayProfile (com.liferay.ide.project.core.model.NewLiferayProfile)4 IStatus (org.eclipse.core.runtime.IStatus)4 LayoutTplDescriptorHelper (com.liferay.ide.layouttpl.core.operation.LayoutTplDescriptorHelper)3