Custom Operation"
(Created page with "{{ZATSEssentialsPageHeader}} Since 1.1.0 Currently, ZATS Mimic supports many operations of ZK components, however, there are still cases where operations are not yet covered. F...") |
m (correct highlight (via JWB)) |
||
(One intermediate revision by the same user not shown) | |||
Line 2: | Line 2: | ||
Since 1.1.0 | Since 1.1.0 | ||
− | Currently, ZATS Mimic supports many operations of ZK components, however, there are still cases where operations are not yet covered. For example, you create a custom component which receives custom [[ZK_Client-side_Reference/Communication/AU_Requests/Client-side_Firing| AU requests]], or a new ZK component in which Mimic doesn't support yet. In such cases, existing operation agents are not able to help you to test it. Therefore, in ZATS Mimic1.1.0 we introduce a new agent called < | + | Currently, ZATS Mimic supports many operations of ZK components, however, there are still cases where operations are not yet covered. For example, you create a custom component <ref>About creating your components, please refer to [[ZK Component Development Essentials]] </ref> which receives custom [[ZK_Client-side_Reference/Communication/AU_Requests/Client-side_Firing| AU requests]], or a new ZK component in which Mimic doesn't support yet. In such cases, existing operation agents are not able to help you to test it. Therefore, in ZATS Mimic1.1.0 we introduce a new agent called <code>AuAgent</code> and it can help you perform custom operations with a condition that the custom component must implement a particular interface: <javadoc>org.zkoss.zk.ui.Component</javadoc>. You can then simulate your component's custom operations by constructing your custom event data with <code>AuData</code> and send it with <code>AuAgent.post()</code>. |
Line 14: | Line 14: | ||
'''Test Case''' | '''Test Case''' | ||
− | <source lang='java' start='10' | + | <source lang='java' start='10' highlight='14,15,16'> |
@Test | @Test | ||
public void test() throws Exception{ | public void test() throws Exception{ | ||
Line 26: | Line 26: | ||
</source> | </source> | ||
* Line 14,15: Construct the data carried by an AU request first, which would depend on how you design the component. | * Line 14,15: Construct the data carried by an AU request first, which would depend on how you design the component. | ||
− | * Line 16: Like using other operation agents, get < | + | * Line 16: Like using other operation agents, get <code>AuAgent</code> from the component and invoke <code>post()</code> to perform an operation. |
+ | <references/> | ||
Latest revision as of 02:55, 18 January 2022
Since 1.1.0
Currently, ZATS Mimic supports many operations of ZK components, however, there are still cases where operations are not yet covered. For example, you create a custom component [1] which receives custom AU requests, or a new ZK component in which Mimic doesn't support yet. In such cases, existing operation agents are not able to help you to test it. Therefore, in ZATS Mimic1.1.0 we introduce a new agent called AuAgent
and it can help you perform custom operations with a condition that the custom component must implement a particular interface: Component. You can then simulate your component's custom operations by constructing your custom event data with AuData
and send it with AuAgent.post()
.
Application with custom component
<mycomponent id="my" />
This test case simulates custom operation supported by your custom component and verifies the result.
Test Case
@Test
public void test() throws Exception{
DesktopAgent desktop = Zats.newClient().connect("/essentials/custom.zul");
ComponentAgent mycomponent = desktop.query("mycomponent");
AuData myEventData = new AuData("onMyEventName");
myEventData.setData("mykey", "myvalue").setData("data", 10);
mycomponent.as(AuAgent.class).post(myEventData);
//verify result
}
- Line 14,15: Construct the data carried by an AU request first, which would depend on how you design the component.
- Line 16: Like using other operation agents, get
AuAgent
from the component and invokepost()
to perform an operation.
- ↑ About creating your components, please refer to ZK Component Development Essentials