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.assertEquals;
22  
23  import java.util.Collection;
24  import java.util.Iterator;
25  import java.util.List;
26  import org.apache.syncope.client.ui.commons.markup.html.form.AjaxPalettePanel;
27  import org.apache.wicket.model.IModel;
28  import org.apache.wicket.model.util.ListModel;
29  import org.apache.wicket.util.tester.FormTester;
30  import org.junit.jupiter.api.Test;
31  
32  public class AjaxPalettePanelITCase extends AbstractConsoleITCase {
33  
34      private static final IModel<List<String>> SELECTED = new ListModel<>(List.of("A", "D"));
35  
36      private static final ListModel<String> ALL = new ListModel<>(List.of("A", "B", "C", "D"));
37  
38      @Test
39      public void isRendered() {
40          TestPage<String, AjaxPalettePanel<String>> testPage =
41                  new TestPage.Builder<String, AjaxPalettePanel<String>>().build(
42                          new AjaxPalettePanel.Builder<String>().setAllowOrder(true).build(
43                                  TestPage.FIELD, SELECTED, ALL));
44          TESTER.startPage(testPage);
45  
46          FormTester formTester = TESTER.newFormTester(testPage.getForm().getId());
47          formTester.submit();
48  
49          Collection<String> list = testPage.getFieldPanel().getModelCollection();
50          assertEquals(2, list.size());
51          Iterator<String> iterator = list.iterator();
52          assertEquals("A", iterator.next());
53          assertEquals("D", iterator.next());
54      }
55  }