Skip to content

Commit

Permalink
MGR-89
Browse files Browse the repository at this point in the history
  • Loading branch information
madness-inc committed Feb 11, 2020
1 parent 33b58b2 commit 0a58e5c
Show file tree
Hide file tree
Showing 6 changed files with 178 additions and 7 deletions.
Expand Up @@ -29,6 +29,7 @@
import org.appng.api.support.CallableDataSource;
import org.appng.application.manager.form.PropertyForm;
import org.appng.core.domain.PropertyImpl;
import org.appng.testsupport.validation.WritingXmlValidator;
import org.appng.xml.platform.FieldDef;
import org.junit.Assert;
import org.junit.FixMethodOrder;
Expand All @@ -40,6 +41,10 @@ public class PlatformPropertiesTest extends AbstractTest {

private static final String PROPERTY_EVENT = "propertyEvent";

static {
WritingXmlValidator.writeXml = false;
}

@Test
public void testCreate() throws ProcessingException, IOException {
PropertyForm form = new PropertyForm(new PropertyImpl("testproperty", "5"));
Expand All @@ -61,6 +66,36 @@ public void testCreateStringOrClob() throws ProcessingException, IOException {
assertError(fp.getField("property.clob"), "Please set the value or the multiline value.");
}

@Test
public void testCreateBoolean() throws ProcessingException, IOException {
PropertyImpl booleanProp = new PropertyImpl("booleanProp", null);
booleanProp.setDescription("this is bool, man!");
PropertyForm form = new PropertyForm(booleanProp);
form.getProperty().setDefaultString("true");
CallableAction action = getCreateAction().getCallableAction(form);
action.perform();

CallableDataSource dataSource = getDataSource("property").withParam("id", "platform.booleanProp")
.getCallableDataSource();
dataSource.perform("test");
validate(dataSource.getDatasource());
}

@Test
public void testCreateMultiline() throws ProcessingException, IOException {
PropertyImpl multilineProp = new PropertyImpl("multilineProp", null);
multilineProp.setDescription("Toto - Hold the line");
PropertyForm form = new PropertyForm(multilineProp);
form.getProperty().setClob("Hold the line,\nlove isn't always on time,\noh oh oh");
CallableAction action = getCreateAction().getCallableAction(form);
action.perform();

CallableDataSource dataSource = getDataSource("property").withParam("id", "platform.multilineProp")
.getCallableDataSource();
dataSource.perform("test");
validate(dataSource.getDatasource());
}

private void assertError(FieldDef field, String message) {
String actual = field.getMessages().getMessageList().get(0).getContent();
Assert.assertEquals(message, actual);
Expand Down
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<datasource xmlns="http://www.appng.org/schema/platform" id="property">
<config>
<title id="property">property</title>
<params>
<param name="id">platform.booleanProp</param>
</params>
<meta-data binding="property" bindClass="org.appng.application.manager.form.PropertyForm">
<field name="type" type="text" hidden="true" binding="property.type" />
<field name="value" type="checkbox" binding="property.value">
<label id="value">booleanProp</label>
</field>
<field name="defaultString" type="text" readonly="true" binding="property.defaultString">
<label id="defaultvalue">Default-Value</label>
</field>
<field name="description" type="longtext" readonly="true" binding="property.description">
<label id="description">Description</label>
</field>
</meta-data>
</config>
<data>
<result>
<field name="type" type="text">
<value>BOOLEAN</value>
</field>
<field name="value" type="checkbox">
<value>true</value>
</field>
<field name="defaultString" type="text">
<value>true</value>
</field>
<field name="description" type="longtext">
<value>this is bool, man!</value>
</field>
</result>
</data>
</datasource>
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<datasource xmlns="http://www.appng.org/schema/platform" id="property">
<config>
<title id="property">property</title>
<params>
<param name="id">platform.multilineProp</param>
</params>
<meta-data binding="property" bindClass="org.appng.application.manager.form.PropertyForm">
<field name="type" type="text" hidden="true" binding="property.type" />
<field name="value" type="longtext" binding="property.value">
<label id="value">multilineProp</label>
</field>
<field name="defaultString" type="text" readonly="true" binding="property.defaultString">
<label id="defaultvalue">Default-Value</label>
</field>
<field name="description" type="longtext" readonly="true" binding="property.description">
<label id="description">Description</label>
</field>
</meta-data>
</config>
<data>
<result>
<field name="type" type="text">
<value>MULTILINE</value>
</field>
<field name="value" type="longtext">
<value>Hold the line,
love isn't always on time,
oh oh oh</value>
</field>
<field name="defaultString" type="text">
<value></value>
</field>
<field name="description" type="longtext">
<value>Toto - Hold the line</value>
</field>
</result>
</data>
</datasource>
62 changes: 61 additions & 1 deletion src/test/resources/xml/PlatformPropertiesTest-testShowAll.xml
Expand Up @@ -68,7 +68,7 @@
</config>
<data>
<resultset chunk="0" chunkname="platformProperties" chunksize="10" nextchunk="0" previouschunk="0"
firstchunk="0" lastchunk="0" hits="2">
firstchunk="0" lastchunk="0" hits="4">
<result>
<field name="shortName" type="text">
<value>anotherproperty</value>
Expand Down Expand Up @@ -98,6 +98,66 @@
</link>
</linkpanel>
</result>
<result>
<field name="shortName" type="text">
<value>booleanProp</value>
</field>
<field name="displayValue" type="longtext">
<value>true</value>
</field>
<field name="description" type="text">
<value>this is bool, man!</value>
</field>
<field name="changedValue" type="image">
<value>false</value>
<icon type="class">led_orange</icon>
</field>
<linkpanel id="actions" location="inline">
<link id="actions[1]" mode="intern"
target="/platform/property/update/platform.booleanProp#tab_platformProperties" default="true">
<label id="edit">Edit</label>
<icon>edit</icon>
</link>
<link id="actions[2]" mode="intern"
target="/platform?form_action=delete-platform-property&amp;propertyid=platform.booleanProp#tab_platformProperties">
<label id="delete">Delete</label>
<icon>delete</icon>
<confirmation id="property.delete.confirm" params="#{shortName}">Do you really want to delete the property
"booleanProp"?</confirmation>
</link>
</linkpanel>
</result>
<result>
<field name="shortName" type="text">
<value>multilineProp</value>
</field>
<field name="displayValue" type="longtext">
<value>Hold the line,
love isn't always on time,
oh oh oh</value>
</field>
<field name="description" type="text">
<value>Toto - Hold the line</value>
</field>
<field name="changedValue" type="image">
<value>true</value>
<icon type="class">led_green</icon>
</field>
<linkpanel id="actions" location="inline">
<link id="actions[1]" mode="intern"
target="/platform/property/update/platform.multilineProp#tab_platformProperties" default="true">
<label id="edit">Edit</label>
<icon>edit</icon>
</link>
<link id="actions[2]" mode="intern"
target="/platform?form_action=delete-platform-property&amp;propertyid=platform.multilineProp#tab_platformProperties">
<label id="delete">Delete</label>
<icon>delete</icon>
<confirmation id="property.delete.confirm" params="#{shortName}">Do you really want to delete the property
"multilineProp"?</confirmation>
</link>
</linkpanel>
</result>
<result>
<field name="shortName" type="text">
<value>testproperty</value>
Expand Down
6 changes: 3 additions & 3 deletions src/test/resources/xml/PlatformPropertiesTest-testShowOne.xml
Expand Up @@ -7,7 +7,7 @@
</params>
<meta-data binding="property" bindClass="org.appng.application.manager.form.PropertyForm">
<field name="type" type="text" hidden="true" binding="property.type" />
<field name="value" type="text" binding="property.value">
<field name="value" type="int" format="#" binding="property.value">
<label id="value">testproperty</label>
</field>
<field name="defaultString" type="text" readonly="true" binding="property.defaultString">
Expand All @@ -21,9 +21,9 @@
<data>
<result>
<field name="type" type="text">
<value>TEXT</value>
<value>INT</value>
</field>
<field name="value" type="text">
<field name="value" type="int">
<value>5</value>
</field>
<field name="defaultString" type="text">
Expand Down
Expand Up @@ -7,7 +7,7 @@
</params>
<meta-data binding="property" bindClass="org.appng.application.manager.form.PropertyForm">
<field name="type" type="text" hidden="true" binding="property.type" />
<field name="value" type="text" binding="property.value">
<field name="value" type="int" format="#" binding="property.value">
<label id="value">testproperty</label>
</field>
<field name="defaultString" type="text" readonly="true" binding="property.defaultString">
Expand All @@ -21,9 +21,9 @@
<data>
<result>
<field name="type" type="text">
<value>TEXT</value>
<value>INT</value>
</field>
<field name="value" type="text">
<field name="value" type="int">
<value>7</value>
</field>
<field name="defaultString" type="text">
Expand Down

0 comments on commit 0a58e5c

Please sign in to comment.