View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
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 de.agilecoders.wicket.core.markup.html.bootstrap.dialog.Modal;
25  import org.apache.syncope.client.console.pages.Realms;
26  import org.apache.syncope.client.console.pages.Types;
27  import org.apache.syncope.client.console.panels.AjaxDataTablePanel;
28  import org.apache.syncope.client.console.wicket.markup.html.bootstrap.dialog.BaseModal;
29  import org.apache.syncope.client.ui.commons.Constants;
30  import org.apache.wicket.Component;
31  import org.apache.wicket.markup.html.basic.Label;
32  import org.apache.wicket.util.tester.FormTester;
33  import org.junit.jupiter.api.Test;
34  
35  public class AnyTypesITCase extends AbstractTypesITCase {
36  
37      @Test
38      public void read() {
39          browsingToAnyTypes();
40          TESTER.assertComponent(
41                  DATATABLE_PATH
42                  + ":tablePanel:groupForm:"
43                  + "checkgroup:dataTable:body:rows:1:cells:1:cell", Label.class);
44  
45          Component component = findComponentByProp(KEY, DATATABLE_PATH, "GROUP");
46  
47          TESTER.executeAjaxEvent(component.getPageRelativePath(), Constants.ON_CLICK);
48  
49          // click edit
50          TESTER.clickLink(
51                  "body:content:tabbedPanel:panel:outerObjectsRepeater:1:outer:container:content:"
52                  + "togglePanelContainer:container:actions:actions:actionRepeater:0:action:action");
53  
54          TESTER.assertComponent("body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer",
55                  BaseModal.class);
56      }
57  
58      @Test
59      public void create() {
60          browsingToAnyTypes();
61          final String anyTypeTest = "anyTypeTest2";
62  
63          TESTER.clickLink("body:content:tabbedPanel:panel:container:content:add");
64  
65          TESTER.assertComponent("body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer",
66                  Modal.class);
67  
68          final FormTester formTester = TESTER.newFormTester(
69                  "body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer:form");
70          formTester.setValue("content:anyTypeDetailsPanel:container:form:key:textField", anyTypeTest);
71          formTester.setValue("content:anyTypeDetailsPanel:container:form:classes:paletteField:recorder", "csv");
72  
73          TESTER.clearFeedbackMessages();
74          TESTER.clickLink(
75                  "body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer:dialog:footer:inputs:0:submit");
76          assertSuccessMessage();
77  
78          TESTER.clearFeedbackMessages();
79          TESTER.assertRenderedPage(Types.class);
80  
81          TESTER.clickLink("body:content:tabbedPanel:tabs-container:tabs:1:link");
82          TESTER.assertComponent(DATATABLE_PATH, AjaxDataTablePanel.class);
83  
84          Component component = findComponentByProp(KEY, DATATABLE_PATH, anyTypeTest);
85  
86          TESTER.assertLabel(component.getPageRelativePath() + ":cells:1:cell", anyTypeTest);
87          TESTER.assertLabel(component.getPageRelativePath() + ":cells:3:cell", "[csv]");
88  
89          // issue SYNCOPE-1111
90          TESTER.clickLink("body:realmsLI:realms", false);
91          TESTER.assertRenderedPage(Realms.class);
92          TESTER.assertLabel(
93                  "body:content:body:container:content:tabbedPanel:tabs-container:tabs:4:link:title",
94                  anyTypeTest);
95      }
96  
97      @Test
98      public void update() {
99          final String name = "anyTypeClassUpdate";
100         createAnyTypeClassWithoutSchema(name);
101         browsingToAnyTypes();
102 
103         Component component = findComponentByProp(KEY, DATATABLE_PATH, "GROUP");
104         assertNotNull(component);
105 
106         TESTER.executeAjaxEvent(component.getPageRelativePath(), Constants.ON_CLICK);
107 
108         // click edit
109         TESTER.clickLink(
110                 "body:content:tabbedPanel:panel:outerObjectsRepeater:1:outer:container:content:"
111                 + "togglePanelContainer:container:actions:actions:actionRepeater:0:action:action");
112 
113         final FormTester formTester = TESTER.newFormTester(
114                 "body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer:form");
115         formTester.setValue(
116                 "content:anyTypeDetailsPanel:container:form:classes:paletteField:recorder", name + ",minimal group");
117 
118         TESTER.clearFeedbackMessages();
119         TESTER.clickLink(
120                 "body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer:dialog:footer:inputs:0:submit");
121         assertSuccessMessage();
122     }
123 
124     @Test
125     public void delete() {
126         String name = "anyTypeDelete";
127         createAnyType(name);
128         browsingToAnyTypes();
129 
130         TESTER.assertComponent(DATATABLE_PATH, AjaxDataTablePanel.class);
131         Component component = findComponentByProp(KEY, DATATABLE_PATH, name);
132         assertNotNull(component);
133 
134         TESTER.executeAjaxEvent(component.getPageRelativePath(), Constants.ON_CLICK);
135 
136         TESTER.getRequest().addParameter("confirm", "true");
137 
138         // click delete
139         TESTER.clickLink(TESTER.getComponentFromLastRenderedPage(
140                 "body:content:tabbedPanel:panel:outerObjectsRepeater:1:outer:container:content:"
141                 + "togglePanelContainer:container:actions:actions:actionRepeater:1:action:action"));
142 
143         TESTER.executeAjaxEvent(TESTER.getComponentFromLastRenderedPage(
144                 "body:content:tabbedPanel:panel:outerObjectsRepeater:1:outer:container:content:"
145                 + "togglePanelContainer:container:actions:actions:actionRepeater:1:action:action"),
146                 Constants.ON_CLICK);
147 
148         assertSuccessMessage();
149         TESTER.cleanupFeedbackMessages();
150 
151         component = findComponentByProp(KEY, DATATABLE_PATH, name);
152         assertNull(component);
153     }
154 }