use of org.eclipse.sapphire.modeling.Status 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 org.eclipse.sapphire.modeling.Status 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 org.eclipse.sapphire.modeling.Status in project liferay-ide by liferay.
the class NewLiferayPluginProjectOp625Tests method testProjectNameValidationServiceAfterProjectCreated.
@Test
public void testProjectNameValidationServiceAfterProjectCreated() throws Exception {
if (shouldSkipBundleTests())
return;
// test service-builder project
NewLiferayPluginProjectOp opCreateProjectA = newProjectOp("test-project-name");
opCreateProjectA.setIncludeSampleCode(false);
opCreateProjectA.setPluginType(PluginType.portlet);
createAntProject(opCreateProjectA);
Status projectNameAValidationResult = opCreateProjectA.getProjectName().validation();
assertEquals(true, projectNameAValidationResult.ok());
NewLiferayPluginProjectOp opCreateProjectB = newProjectOp("test-project-name");
Status projectNameBValidationResult = opCreateProjectB.getProjectName().validation();
assertEquals(false, projectNameBValidationResult.ok());
}
use of org.eclipse.sapphire.modeling.Status in project liferay-ide by liferay.
the class BundleUrlValidationService method compute.
@Override
protected Status compute() {
Status retval = Status.createOkStatus();
Value<String> bundleUrlValue = _op().getBundleUrl();
String bundleUrl = bundleUrlValue.content();
try {
new URI(bundleUrl);
} catch (Exception e) {
retval = Status.createErrorStatus("The bundle URL should be a vaild URL.");
}
return retval;
}
use of org.eclipse.sapphire.modeling.Status in project liferay-ide by liferay.
the class ProjectLocationValidationService method compute.
@Override
protected Status compute() {
Status retval = Status.createOkStatus();
int countPossibleWorkspaceSDKProjects = SDKUtil.countPossibleWorkspaceSDKProjects();
if (countPossibleWorkspaceSDKProjects > 1) {
return StatusBridge.create(ProjectCore.createErrorStatus("This workspace has more than one SDK."));
}
Value<Path> sdkLocation = _op().getSdkLocation();
final Path location = sdkLocation.content(true);
if ((location == null) || location.isEmpty()) {
return StatusBridge.create(ProjectCore.createErrorStatus("Liferay Plugins SDK or Maven location is empty."));
}
IStatus buildType = ImportLiferayModuleProjectOpMethods.getBuildType(location.removeFileExtension().toPortableString());
SDK sdk = SDKUtil.createSDKFromLocation(PathBridge.create(location));
if (sdk != null) {
String version = sdk.getVersion();
if (version != null) {
Version sdkVersion = new Version(version);
int result = sdkVersion.compareTo(new Version("6.1.0"));
if (result < 0) {
return StatusBridge.create(ProjectCore.createErrorStatus("This tool doesn't support 6.0.x."));
}
}
} else if (!buildType.getMessage().equals("maven")) {
return StatusBridge.create(ProjectCore.createErrorStatus("Plugins SDK or Maven location is not valid."));
}
return retval;
}
Aggregations