1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.syncope.fit.console;
20
21 import static org.junit.jupiter.api.Assertions.assertNotNull;
22 import static org.junit.jupiter.api.Assertions.assertNull;
23
24 import org.apache.syncope.client.console.panels.AjaxDataTablePanel;
25 import org.apache.syncope.client.console.wicket.markup.html.bootstrap.dialog.BaseModal;
26 import org.apache.syncope.client.ui.commons.Constants;
27 import org.apache.wicket.Component;
28 import org.apache.wicket.markup.html.basic.Label;
29 import org.apache.wicket.util.tester.FormTester;
30 import org.junit.jupiter.api.Test;
31
32 public class RelationshipTypesITCase extends AbstractTypesITCase {
33
34 @Test
35 public void read() {
36 browsingToRelationshipType();
37
38 Component result = findComponentByProp(KEY, DATATABLE_PATH, "inclusion");
39
40 TESTER.assertComponent(
41 result.getPageRelativePath() + ":cells:1:cell", Label.class);
42
43 TESTER.executeAjaxEvent(result.getPageRelativePath(), Constants.ON_CLICK);
44 TESTER.clickLink(
45 "body:content:tabbedPanel:panel:outerObjectsRepeater:1:outer:container:content:"
46 + "togglePanelContainer:container:actions:actions:actionRepeater:0:action:action");
47
48 TESTER.assertComponent(
49 "body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer", BaseModal.class);
50 }
51
52 @Test
53 public void create() {
54 final String name = "relationshipTypeTest";
55 createRelationshipType(name);
56 browsingToRelationshipType();
57
58 TESTER.assertComponent(DATATABLE_PATH, AjaxDataTablePanel.class);
59
60 Component result = findComponentByProp(KEY, DATATABLE_PATH, name);
61
62 TESTER.assertLabel(result.getPageRelativePath() + ":cells:1:cell", name);
63 TESTER.assertLabel(result.getPageRelativePath() + ":cells:2:cell", "test relationshipType");
64 }
65
66 @Test
67 public void update() {
68 final String name = "relationshipTypeUpdate";
69 createRelationshipType(name);
70 browsingToRelationshipType();
71
72 Component result = findComponentByProp(KEY, DATATABLE_PATH, name);
73 assertNotNull(result);
74
75 TESTER.executeAjaxEvent(result.getPageRelativePath(), Constants.ON_CLICK);
76 TESTER.clickLink(
77 "body:content:tabbedPanel:panel:outerObjectsRepeater:1:outer:container:content:"
78 + "togglePanelContainer:container:actions:actions:actionRepeater:0:action:action");
79
80 final FormTester formTester = TESTER.newFormTester(
81 "body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer:form");
82 formTester.setValue(
83 "content:relationshipTypeDetails:container:form:description:textField", "new description");
84
85 TESTER.clickLink(
86 "body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer:dialog:footer:inputs:0:submit");
87 assertSuccessMessage();
88 }
89
90 @Test
91 public void delete() {
92 final String name = "relationshipTypeDelete";
93 createRelationshipType(name);
94 browsingToRelationshipType();
95
96 TESTER.assertComponent(DATATABLE_PATH, AjaxDataTablePanel.class);
97
98 Component result = findComponentByProp(KEY, DATATABLE_PATH, name);
99 assertNotNull(result);
100
101 TESTER.executeAjaxEvent(result.getPageRelativePath(), Constants.ON_CLICK);
102 TESTER.getRequest().addParameter("confirm", "true");
103
104 TESTER.clickLink(TESTER.getComponentFromLastRenderedPage(
105 "body:content:tabbedPanel:panel:outerObjectsRepeater:1:outer:container:content:"
106 + "togglePanelContainer:container:actions:actions:actionRepeater:1:action:action"));
107
108 TESTER.executeAjaxEvent(TESTER.getComponentFromLastRenderedPage(
109 "body:content:tabbedPanel:panel:outerObjectsRepeater:1:outer:container:content:"
110 + "togglePanelContainer:container:actions:actions:actionRepeater:1:action:action"), Constants.ON_CLICK);
111
112 assertSuccessMessage();
113
114 TESTER.cleanupFeedbackMessages();
115 result = findComponentByProp(KEY, DATATABLE_PATH, name);
116
117 assertNull(result);
118 }
119 }