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));
}
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\""));
}
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"));
}
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));
}
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());
}
Aggregations