use of com.liferay.ide.service.core.operation.ServiceBuilderDescriptorHelper in project liferay-ide by liferay.
the class ServiceXmlTests method testAddSampleEntity.
@Test
public void testAddSampleEntity() throws Exception {
if (shouldSkipBundleTests())
return;
final IProject project = importProject("portlets", "com.liferay.ide.service.core.tests", "Add-Sample-Entity-Test-portlet");
final ServiceBuilderDescriptorHelper descriptorHelper = new ServiceBuilderDescriptorHelper(project);
assertEquals(Status.OK_STATUS, descriptorHelper.addDefaultEntity());
final IFile serviceXmlFile = descriptorHelper.getDescriptorFile();
final String serviceXmlContent = CoreUtil.readStreamToString(serviceXmlFile.getContents());
final String expectedServiceXmlContent = CoreUtil.readStreamToString(this.getClass().getResourceAsStream("files/service-sample-6.2.0-add-sample-entity.xml"));
assertEquals(expectedServiceXmlContent.replaceAll("\\s+", StringPool.SPACE), serviceXmlContent.replaceAll("\\s+", StringPool.SPACE));
}
use of com.liferay.ide.service.core.operation.ServiceBuilderDescriptorHelper in project liferay-ide by liferay.
the class ServiceXmlTests method testAddDefaultColumns.
// This test needs to set the "liferay.bundles.dir" in the configuration.
@Test
public void testAddDefaultColumns() throws Exception {
if (shouldSkipBundleTests())
return;
final IProject project = importProject("portlets", "com.liferay.ide.service.core.tests", "Add-Default-Columns-Test-portlet");
final ServiceBuilderDescriptorHelper descriptorHelper = new ServiceBuilderDescriptorHelper(project);
assertEquals(Status.OK_STATUS, descriptorHelper.addEntity("AddDefaultColumns"));
assertEquals(Status.OK_STATUS, descriptorHelper.addDefaultColumns("AddDefaultColumns"));
final IFile serviceXmlFile = descriptorHelper.getDescriptorFile();
final String serviceXmlContent = CoreUtil.readStreamToString(serviceXmlFile.getContents());
final String expectedServiceXmlContent = CoreUtil.readStreamToString(this.getClass().getResourceAsStream("files/service-sample-6.2.0-add-default-columns.xml"));
assertEquals(expectedServiceXmlContent.replaceAll("\\s+", StringPool.SPACE), serviceXmlContent.replaceAll("\\s+", StringPool.SPACE));
}
use of com.liferay.ide.service.core.operation.ServiceBuilderDescriptorHelper in project liferay-ide by liferay.
the class AddDefaultColumnsAction method run.
@Override
protected Object run(Presentation context) {
Element element = context.part().getLocalModelElement();
if (element instanceof Entity) {
String entityName = ((Entity) element).getName().content();
if (CoreUtil.isNullOrEmpty(entityName)) {
String title = "Add Liferay Default Columns";
String message = "The entity name must be specified.";
MessageDialog.openInformation(UIUtil.getActiveShell(), title, message);
} else {
IFile serviceXML = element.adapt(IFile.class);
new ServiceBuilderDescriptorHelper(serviceXML.getProject()).addDefaultColumns(entityName);
}
}
return null;
}
use of com.liferay.ide.service.core.operation.ServiceBuilderDescriptorHelper in project liferay-ide by liferay.
the class AddDefaultEntityAction method run.
@Override
protected Object run(Presentation context) {
Element localModelElement = context.part().getLocalModelElement();
IFile serviceXML = localModelElement.adapt(IFile.class);
new ServiceBuilderDescriptorHelper(serviceXML.getProject()).addDefaultEntity();
return null;
}
Aggregations