Search in sources :

Example 41 with NewLiferayModuleProjectOp

use of com.liferay.ide.project.core.modules.NewLiferayModuleProjectOp in project liferay-ide by liferay.

the class NewLiferayModuleProjectOpTests method testNewLiferayModuleProjectDefaultValueServiceIsListeningToProjectName.

@Test
@Ignore
public void testNewLiferayModuleProjectDefaultValueServiceIsListeningToProjectName() throws Exception {
    NewLiferayModuleProjectOp op = NewLiferayModuleProjectOp.TYPE.instantiate();
    op.setProjectName("my.test.project");
    op.setProjectTemplateName("portlet");
    assertEquals("MyTestProject", op.getComponentName().content(true));
    op.setProjectName("my_abc-test");
    assertEquals("MyAbcTest", op.getComponentName().content(true));
}
Also used : NewLiferayModuleProjectOp(com.liferay.ide.project.core.modules.NewLiferayModuleProjectOp) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 42 with NewLiferayModuleProjectOp

use of com.liferay.ide.project.core.modules.NewLiferayModuleProjectOp in project liferay-ide by liferay.

the class NewLiferayModuleProjectOpTests method testNewLiferayModuleProjectNewProperties.

@Test
public void testNewLiferayModuleProjectNewProperties() throws Exception {
    NewLiferayModuleProjectOp op = NewLiferayModuleProjectOp.TYPE.instantiate();
    op.setProjectName("test-properties-in-portlet");
    op.setProjectTemplateName("portlet");
    op.setComponentName("Test");
    PropertyKey pk = op.getPropertyKeys().insert();
    pk.setName("property-test-key");
    pk.setValue("property-test-value");
    Status exStatus = NewLiferayModuleProjectOpMethods.execute(op, ProgressMonitorBridge.create(new NullProgressMonitor()));
    assertEquals("OK", exStatus.message());
    IProject modPorject = CoreUtil.getProject(op.getProjectName().content());
    modPorject.open(new NullProgressMonitor());
    SearchFilesVisitor sv = new SearchFilesVisitor();
    List<IFile> searchFiles = sv.searchFiles(modPorject, "TestPortlet.java");
    IFile componentClassFile = searchFiles.get(0);
    assertEquals(componentClassFile.exists(), true);
    String actual = CoreUtil.readStreamToString(componentClassFile.getContents());
    assertTrue(actual, actual.contains("\"property-test-key=property-test-value\""));
}
Also used : Status(org.eclipse.sapphire.modeling.Status) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFile(org.eclipse.core.resources.IFile) NewLiferayModuleProjectOp(com.liferay.ide.project.core.modules.NewLiferayModuleProjectOp) SearchFilesVisitor(com.liferay.ide.project.core.util.SearchFilesVisitor) PropertyKey(com.liferay.ide.project.core.modules.PropertyKey) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test)

Example 43 with NewLiferayModuleProjectOp

use of com.liferay.ide.project.core.modules.NewLiferayModuleProjectOp in project liferay-ide by liferay.

the class NewLiferayModuleProjectOpTests method testNewLiferayPortletProviderNewProperties.

@Test
public void testNewLiferayPortletProviderNewProperties() throws Exception {
    NewLiferayModuleProjectOp op = NewLiferayModuleProjectOp.TYPE.instantiate();
    op.setProjectName("test-properties-in-portlet-provider");
    op.setComponentName("Test");
    op.setProjectTemplateName("portlet-provider");
    PropertyKey pk = op.getPropertyKeys().insert();
    pk.setName("property-test-key");
    pk.setValue("property-test-value");
    Status exStatus = NewLiferayModuleProjectOpMethods.execute(op, ProgressMonitorBridge.create(new NullProgressMonitor()));
    assertTrue(exStatus.message(), exStatus.ok());
    IProject modPorject = CoreUtil.getProject(op.getProjectName().content());
    modPorject.open(new NullProgressMonitor());
    IFile testAddPortletProvider = modPorject.getFile("src/main/java/test/properties/in/portlet/provider/portlet/TestAddPortletProvider.java");
    assertTrue(testAddPortletProvider.exists());
    SearchFilesVisitor sv = new SearchFilesVisitor();
    List<IFile> searchFiles = sv.searchFiles(modPorject, "TestAddPortletProvider.java");
    IFile componentClassFile = searchFiles.get(0);
    assertEquals(componentClassFile.exists(), true);
    String actual = CoreUtil.readStreamToString(componentClassFile.getContents());
    assertTrue(actual.contains("property-test-key=property-test-value"));
}
Also used : Status(org.eclipse.sapphire.modeling.Status) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFile(org.eclipse.core.resources.IFile) NewLiferayModuleProjectOp(com.liferay.ide.project.core.modules.NewLiferayModuleProjectOp) SearchFilesVisitor(com.liferay.ide.project.core.util.SearchFilesVisitor) PropertyKey(com.liferay.ide.project.core.modules.PropertyKey) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test)

Example 44 with NewLiferayModuleProjectOp

use of com.liferay.ide.project.core.modules.NewLiferayModuleProjectOp in project liferay-ide by liferay.

the class NewLiferayModuleProjectOpTests method testNewLiferayModuleProjectPackageDefaultValueService.

@Test
@Ignore
public void testNewLiferayModuleProjectPackageDefaultValueService() throws Exception {
    NewLiferayModuleProjectOp op = NewLiferayModuleProjectOp.TYPE.instantiate();
    op.setProjectName("my-test-project");
    op.setProjectTemplateName("Portlet");
    assertEquals("my.test.project", op.getPackageName().content(true));
    op.setProjectName("my.test.foo");
    assertEquals("my.test.foo", op.getPackageName().content(true));
    op.setProjectName("my_test_foo1");
    op.setProjectTemplateName("ServiceWrapper");
    assertEquals("my.test.foo1", op.getPackageName().content(true));
}
Also used : NewLiferayModuleProjectOp(com.liferay.ide.project.core.modules.NewLiferayModuleProjectOp) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 45 with NewLiferayModuleProjectOp

use of com.liferay.ide.project.core.modules.NewLiferayModuleProjectOp in project liferay-ide by liferay.

the class NewLiferayWorkspaceOpTests method testNewLiferayWorkspaceOp.

@Test
public void testNewLiferayWorkspaceOp() throws Exception {
    ILiferayProjectImporter importer = LiferayCore.getImporter("gradle");
    File eclipseWorkspaceLocation = CoreUtil.getWorkspaceRoot().getLocation().toFile();
    URL projectZipUrl = Platform.getBundle("com.liferay.ide.project.core.tests").getEntry("projects/existingProject.zip");
    final File projectZipFile = new File(FileLocator.toFileURL(projectZipUrl).getFile());
    ZipUtil.unzip(projectZipFile, eclipseWorkspaceLocation);
    File projectFolder = new File(eclipseWorkspaceLocation, "existingProject");
    waitForBuildAndValidation();
    importer.importProjects(projectFolder.getAbsolutePath(), new NullProgressMonitor());
    NewLiferayWorkspaceOp op = NewLiferayWorkspaceOp.TYPE.instantiate();
    op.setWorkspaceName("existingProject");
    String message = op.validation().message();
    assertNotNull(message);
    assertEquals("A project with that name(ignore case) already exists.", message);
    op.setWorkspaceName("ExistingProject");
    message = op.validation().message();
    assertTrue(message.equals("A project with that name(ignore case) already exists."));
    String projectName = "test-liferay-workspace";
    IPath workspaceLocation = CoreUtil.getWorkspaceRoot().getLocation();
    op.setWorkspaceName(projectName);
    op.setUseDefaultLocation(false);
    op.setLocation(workspaceLocation.toPortableString());
    op.execute(new ProgressMonitor());
    String wsLocation = workspaceLocation.append(projectName).toPortableString();
    File wsFile = new File(wsLocation);
    assertTrue(wsFile.exists());
    assertTrue(LiferayWorkspaceUtil.isValidWorkspaceLocation(wsLocation));
    File propertiesFile = new File(wsFile, "gradle.properties");
    Properties prop = PropertiesUtil.loadProperties(propertiesFile);
    prop.setProperty(LiferayWorkspaceUtil.LIFERAY_WORKSPACE_WARS_DIR, "wars,wars2");
    PropertiesUtil.saveProperties(prop, propertiesFile);
    NewLiferayModuleProjectOp moduleProjectOp = NewLiferayModuleProjectOp.TYPE.instantiate();
    moduleProjectOp.setProjectName("testThemeWarDefault");
    moduleProjectOp.setProjectTemplateName("theme");
    moduleProjectOp.execute(new ProgressMonitor());
    waitForBuildAndValidation();
    assertTrue(CoreUtil.getProject("testThemeWarDefault").exists());
    moduleProjectOp = NewLiferayModuleProjectOp.TYPE.instantiate();
    moduleProjectOp.setProjectName("testThemeWarNotDefault");
    moduleProjectOp.setProjectTemplateName("theme");
    moduleProjectOp.setUseDefaultLocation(false);
    moduleProjectOp.setLocation(wsLocation + "/wars");
    moduleProjectOp.execute(new ProgressMonitor());
    waitForBuildAndValidation();
    assertTrue(CoreUtil.getProject("testThemeWarNotDefault").exists());
    moduleProjectOp = NewLiferayModuleProjectOp.TYPE.instantiate();
    moduleProjectOp.setProjectName("testThemeWar2");
    moduleProjectOp.setProjectTemplateName("theme");
    moduleProjectOp.setUseDefaultLocation(false);
    moduleProjectOp.setLocation(wsLocation + "/wars2");
    moduleProjectOp.execute(new ProgressMonitor());
    waitForBuildAndValidation();
    assertTrue(CoreUtil.getProject("testThemeWar2").exists());
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ProgressMonitor(org.eclipse.sapphire.modeling.ProgressMonitor) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) NewLiferayWorkspaceOp(com.liferay.ide.project.core.workspace.NewLiferayWorkspaceOp) ILiferayProjectImporter(com.liferay.ide.core.ILiferayProjectImporter) IPath(org.eclipse.core.runtime.IPath) NewLiferayModuleProjectOp(com.liferay.ide.project.core.modules.NewLiferayModuleProjectOp) Properties(java.util.Properties) File(java.io.File) URL(java.net.URL) Test(org.junit.Test)

Aggregations

NewLiferayModuleProjectOp (com.liferay.ide.project.core.modules.NewLiferayModuleProjectOp)95 Test (org.junit.Test)94 IProject (org.eclipse.core.resources.IProject)30 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)18 IFile (org.eclipse.core.resources.IFile)12 Status (org.eclipse.sapphire.modeling.Status)9 Ignore (org.junit.Ignore)6 IBundleProject (com.liferay.ide.core.IBundleProject)5 NewLiferayComponentOp (com.liferay.ide.project.core.modules.NewLiferayComponentOp)5 PropertyKey (com.liferay.ide.project.core.modules.PropertyKey)3 SearchFilesVisitor (com.liferay.ide.project.core.util.SearchFilesVisitor)3 IPath (org.eclipse.core.runtime.IPath)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 File (java.io.File)2 URL (java.net.URL)2 ILiferayProjectImporter (com.liferay.ide.core.ILiferayProjectImporter)1 IProjectBuilder (com.liferay.ide.project.core.IProjectBuilder)1 ProjectName (com.liferay.ide.project.core.model.ProjectName)1 NewLiferayWorkspaceOp (com.liferay.ide.project.core.workspace.NewLiferayWorkspaceOp)1 ArrayList (java.util.ArrayList)1