View Javadoc
1   /*
2    *  Copyright 2022 Red Hat
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of the License at
7    *
8    *      https://www.apache.org/licenses/LICENSE-2.0
9    *
10   *  Unless required by applicable law or agreed to in writing, software
11   *  distributed under the License is distributed on an "AS IS" BASIS,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
15   */
16  package org.jboss.hal.testsuite.test.configuration.distributableweb;
17  
18  import org.jboss.arquillian.core.api.annotation.Inject;
19  import org.jboss.arquillian.graphene.page.Page;
20  import org.jboss.hal.testsuite.Console;
21  import org.jboss.hal.testsuite.CrudOperations;
22  import org.jboss.hal.testsuite.container.WildFlyContainer;
23  import org.jboss.hal.testsuite.fragment.FormFragment;
24  import org.jboss.hal.testsuite.fragment.TableFragment;
25  import org.jboss.hal.testsuite.page.configuration.DistributableWebPage;
26  import org.jboss.hal.testsuite.test.Manatoko;
27  import org.junit.jupiter.api.BeforeAll;
28  import org.junit.jupiter.api.BeforeEach;
29  import org.junit.jupiter.api.Test;
30  import org.testcontainers.junit.jupiter.Container;
31  import org.testcontainers.junit.jupiter.Testcontainers;
32  import org.wildfly.extras.creaper.core.online.OnlineManagementClient;
33  import org.wildfly.extras.creaper.core.online.operations.Operations;
34  import org.wildfly.extras.creaper.core.online.operations.Values;
35  
36  import static org.jboss.hal.dmr.ModelDescriptionConstants.CACHE_CONTAINER;
37  import static org.jboss.hal.dmr.ModelDescriptionConstants.NAME;
38  import static org.jboss.hal.testsuite.container.WildFlyConfiguration.FULL;
39  import static org.jboss.hal.testsuite.fixtures.DistributableWebFixtures.INFINISPAN_SSO_CREATE;
40  import static org.jboss.hal.testsuite.fixtures.DistributableWebFixtures.INFINISPAN_SSO_DELETE;
41  import static org.jboss.hal.testsuite.fixtures.DistributableWebFixtures.INFINISPAN_SSO_UPDATE;
42  import static org.jboss.hal.testsuite.fixtures.DistributableWebFixtures.infinispanSSOAddress;
43  import static org.jboss.hal.testsuite.fixtures.InfinispanFixtures.CC_CREATE;
44  import static org.jboss.hal.testsuite.test.configuration.distributableweb.DistributableWebOperations.addCacheContainer;
45  
46  @Manatoko
47  @Testcontainers
48  class InfinispanSSOTest {
49  
50      @Container static WildFlyContainer wildFly = WildFlyContainer.standalone(FULL);
51  
52      @BeforeAll
53      static void setupModel() throws Exception {
54          OnlineManagementClient client = wildFly.managementClient();
55          Operations operations = new Operations(client);
56          addCacheContainer(client, operations, CC_CREATE);
57          Values values = Values.of(CACHE_CONTAINER, CC_CREATE);
58          operations.add(infinispanSSOAddress(INFINISPAN_SSO_UPDATE), values);
59          operations.add(infinispanSSOAddress(INFINISPAN_SSO_DELETE), values);
60      }
61  
62      @Page DistributableWebPage page;
63      @Inject CrudOperations crud;
64      @Inject Console console;
65      TableFragment table;
66      FormFragment form;
67  
68      @BeforeEach
69      void setUp() {
70          page.navigate();
71          console.verticalNavigation().selectPrimary("dw-infinispan-sso-management-item");
72          table = page.getInfinispanSSOManagementTable();
73          form = page.getInfinispanSSOManagementForm();
74          table.bind(form);
75      }
76  
77      @Test
78      void create() throws Exception {
79          crud.create(infinispanSSOAddress(INFINISPAN_SSO_CREATE), table, f -> {
80              f.text(NAME, INFINISPAN_SSO_CREATE);
81              f.text(CACHE_CONTAINER, CC_CREATE);
82          });
83      }
84  
85      @Test
86      void reset() throws Exception {
87          table.select(INFINISPAN_SSO_UPDATE);
88          crud.reset(infinispanSSOAddress(INFINISPAN_SSO_UPDATE), form);
89      }
90  
91      @Test
92      void delete() throws Exception {
93          table.select(INFINISPAN_SSO_DELETE);
94          crud.delete(infinispanSSOAddress(INFINISPAN_SSO_DELETE), table, INFINISPAN_SSO_DELETE);
95      }
96  }