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.Types;
26  import org.apache.syncope.client.console.panels.AjaxDataTablePanel;
27  import org.apache.syncope.client.console.wicket.extensions.markup.html.repeater.data.table.AjaxFallbackDataTable;
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.util.tester.FormTester;
32  import org.junit.jupiter.api.Test;
33  
34  public class AnyTypeClassesITCase extends AbstractTypesITCase {
35  
36      @Test
37      public void read() {
38          browsingToAnyTypeClasses();
39  
40          Component component = findComponentByProp(KEY, DATATABLE_PATH, "csv");
41          TESTER.executeAjaxEvent(component.getPageRelativePath(), Constants.ON_CLICK);
42  
43          // click edit
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("body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer",
49                  BaseModal.class);
50      }
51  
52      @Test
53      public void create() {
54          browsingToAnyTypeClasses();
55          final String anyTypeClassTest = "anyTypeClassTest";
56  
57          TESTER.clickLink("body:content:tabbedPanel:panel:container:content:add");
58  
59          TESTER.assertComponent("body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer",
60                  Modal.class);
61  
62          FormTester formTester = TESTER.newFormTester(
63                  "body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer:form");
64          formTester.setValue("content:anyTypeClassDetailsPanel:form:key:textField", anyTypeClassTest);
65          formTester.setValue(
66                  "content:anyTypeClassDetailsPanel:form:container:derSchemas:paletteField:recorder", "mderiveddata");
67  
68          TESTER.clearFeedbackMessages();
69          TESTER.clickLink(
70                  "body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer:dialog:footer:inputs:0:submit");
71          assertSuccessMessage();
72  
73          TESTER.clearFeedbackMessages();
74          TESTER.assertRenderedPage(Types.class);
75  
76          TESTER.clickLink("body:content:tabbedPanel:tabs-container:tabs:2:link");
77          TESTER.assertComponent(DATATABLE_PATH + ":tablePanel:groupForm:checkgroup:dataTable",
78                  AjaxFallbackDataTable.class);
79  
80          TESTER.assertComponent(DATATABLE_PATH, AjaxDataTablePanel.class);
81  
82          Component result = findComponentByProp(KEY, DATATABLE_PATH, anyTypeClassTest);
83  
84          TESTER.assertLabel(result.getPageRelativePath() + ":cells:3:cell", "[mderiveddata]");
85      }
86  
87      @Test
88      public void update() {
89          String plainSchema = "anyPlainSchema";
90          String name = "anyTypeClassToUpdate";
91          createAnyTypeClassWithoutSchema(name);
92          createPlainSchema(plainSchema);
93          browsingToAnyTypeClasses();
94  
95          Component component = findComponentByProp(KEY, DATATABLE_PATH, name);
96          TESTER.executeAjaxEvent(component.getPageRelativePath(), Constants.ON_CLICK);
97  
98          // click edit
99          TESTER.clickLink(
100                 "body:content:tabbedPanel:panel:outerObjectsRepeater:1:outer:container:content:"
101                 + "togglePanelContainer:container:actions:actions:actionRepeater:0:action:action");
102 
103         FormTester formTester = TESTER.newFormTester(
104                 "body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer:form");
105         formTester.setValue(
106                 "content:anyTypeClassDetailsPanel:form:container:plainSchemas:paletteField:recorder", plainSchema);
107 
108         TESTER.clickLink(
109                 "body:content:tabbedPanel:panel:outerObjectsRepeater:0:outer:dialog:footer:inputs:0:submit");
110         assertSuccessMessage();
111         TESTER.cleanupFeedbackMessages();
112 
113         component = findComponentByProp(KEY, DATATABLE_PATH, name);
114         assertNotNull(component);
115 
116         TESTER.executeAjaxEvent(component.getPageRelativePath(), Constants.ON_CLICK);
117         TESTER.getRequest().addParameter("confirm", "true");
118 
119         // click delete
120         TESTER.clickLink(TESTER.getComponentFromLastRenderedPage(
121                 "body:content:tabbedPanel:panel:outerObjectsRepeater:1:outer:container:content:"
122                 + "togglePanelContainer:container:actions:actions:actionRepeater:1:action:action"));
123 
124         TESTER.executeAjaxEvent(TESTER.getComponentFromLastRenderedPage(
125                 "body:content:tabbedPanel:panel:outerObjectsRepeater:1:outer:container:content:"
126                 + "togglePanelContainer:container:actions:actions:actionRepeater:1:action:action"),
127                 Constants.ON_CLICK);
128 
129         assertSuccessMessage();
130         TESTER.cleanupFeedbackMessages();
131 
132         component = findComponentByProp(KEY, DATATABLE_PATH, name);
133         assertNull(component);
134     }
135 
136     @Test
137     public void delete() {
138         final String anyTypeClassName = "zStringDelete";
139         createAnyTypeClassWithoutSchema(anyTypeClassName);
140         browsingToAnyTypeClasses();
141         TESTER.assertComponent(DATATABLE_PATH, AjaxDataTablePanel.class);
142 
143         Component component = findComponentByProp(KEY, DATATABLE_PATH, anyTypeClassName);
144         assertNotNull(component);
145 
146         TESTER.executeAjaxEvent(component.getPageRelativePath(), Constants.ON_CLICK);
147         TESTER.getRequest().addParameter("confirm", "true");
148 
149         // click delete
150         TESTER.clickLink(TESTER.getComponentFromLastRenderedPage(
151                 "body:content:tabbedPanel:panel:outerObjectsRepeater:1:outer:container:content:"
152                 + "togglePanelContainer:container:actions:actions:actionRepeater:1:action:action"));
153 
154         TESTER.executeAjaxEvent(TESTER.getComponentFromLastRenderedPage(
155                 "body:content:tabbedPanel:panel:outerObjectsRepeater:1:outer:container:content:"
156                 + "togglePanelContainer:container:actions:actions:actionRepeater:1:action:action"),
157                 Constants.ON_CLICK);
158 
159         assertSuccessMessage();
160         TESTER.cleanupFeedbackMessages();
161 
162         component = findComponentByProp(KEY, DATATABLE_PATH, anyTypeClassName);
163         assertNull(component);
164     }
165 }