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.jgroups;
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.Random;
23  import org.jboss.hal.testsuite.container.WildFlyContainer;
24  import org.jboss.hal.testsuite.fragment.FormFragment;
25  import org.jboss.hal.testsuite.fragment.TableFragment;
26  import org.jboss.hal.testsuite.page.configuration.JGroupsPage;
27  import org.jboss.hal.testsuite.test.Manatoko;
28  import org.junit.jupiter.api.BeforeAll;
29  import org.junit.jupiter.api.BeforeEach;
30  import org.junit.jupiter.api.Test;
31  import org.testcontainers.junit.jupiter.Container;
32  import org.testcontainers.junit.jupiter.Testcontainers;
33  import org.wildfly.extras.creaper.core.online.OnlineManagementClient;
34  import org.wildfly.extras.creaper.core.online.operations.Operations;
35  import org.wildfly.extras.creaper.core.online.operations.Values;
36  
37  import static org.jboss.hal.dmr.ModelDescriptionConstants.NAME;
38  import static org.jboss.hal.dmr.ModelDescriptionConstants.STACK;
39  import static org.jboss.hal.testsuite.container.WildFlyConfiguration.HA;
40  import static org.jboss.hal.testsuite.fixtures.JGroupsFixtures.CHANNEL_CREATE;
41  import static org.jboss.hal.testsuite.fixtures.JGroupsFixtures.CHANNEL_DELETE;
42  import static org.jboss.hal.testsuite.fixtures.JGroupsFixtures.CHANNEL_UPDATE;
43  import static org.jboss.hal.testsuite.fixtures.JGroupsFixtures.CLUSTER;
44  import static org.jboss.hal.testsuite.fixtures.JGroupsFixtures.TCP;
45  import static org.jboss.hal.testsuite.fixtures.JGroupsFixtures.channelAddress;
46  
47  @Manatoko
48  @Testcontainers
49  class ChannelTest {
50  
51      @Container static WildFlyContainer wildFly = WildFlyContainer.standalone(HA);
52  
53      @BeforeAll
54      static void setupModel() throws Exception {
55          OnlineManagementClient client = wildFly.managementClient();
56          Operations operations = new Operations(client);
57          operations.add(channelAddress(CHANNEL_UPDATE), Values.of(STACK, TCP));
58          operations.add(channelAddress(CHANNEL_DELETE), Values.of(STACK, TCP));
59      }
60  
61      @Page JGroupsPage page;
62      @Inject CrudOperations crud;
63      @Inject Console console;
64      FormFragment form;
65      TableFragment table;
66  
67      @BeforeEach
68      void setUp() {
69          page.navigate();
70          console.verticalNavigation().selectPrimary("jgroups-channel-item");
71  
72          table = page.getChannelTable();
73          form = page.getChannelForm();
74          table.bind(form);
75      }
76  
77      @Test
78      void create() throws Exception {
79          crud.create(channelAddress(CHANNEL_CREATE), table, form -> {
80              form.text(NAME, CHANNEL_CREATE);
81              form.text(STACK, TCP);
82          });
83      }
84  
85      @Test
86      void update() throws Exception {
87          table.select(CHANNEL_UPDATE);
88          crud.update(channelAddress(CHANNEL_UPDATE), form, CLUSTER, Random.name());
89      }
90  
91      @Test
92      void updateEmptyStack() {
93          table.select(CHANNEL_UPDATE);
94          crud.updateWithError(form, f -> f.clear(STACK), STACK);
95      }
96  
97      @Test
98      void reset() throws Exception {
99          table.select(CHANNEL_UPDATE);
100         crud.reset(channelAddress(CHANNEL_UPDATE), form);
101     }
102 
103     @Test
104     void delete() throws Exception {
105         crud.delete(channelAddress(CHANNEL_DELETE), table, CHANNEL_DELETE);
106     }
107 }