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.ee;
17  
18  import org.jboss.arquillian.core.api.annotation.Inject;
19  import org.jboss.arquillian.graphene.page.Page;
20  import org.jboss.hal.resources.Ids;
21  import org.jboss.hal.testsuite.Console;
22  import org.jboss.hal.testsuite.CrudOperations;
23  import org.jboss.hal.testsuite.container.WildFlyContainer;
24  import org.jboss.hal.testsuite.fragment.TableFragment;
25  import org.jboss.hal.testsuite.page.configuration.EEPage;
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  
35  import static org.jboss.hal.dmr.ModelDescriptionConstants.GLOBAL_MODULES;
36  import static org.jboss.hal.dmr.ModelDescriptionConstants.NAME;
37  import static org.jboss.hal.testsuite.container.WildFlyConfiguration.DEFAULT;
38  import static org.jboss.hal.testsuite.fixtures.EEFixtures.GLOBAL_MODULES_CREATE;
39  import static org.jboss.hal.testsuite.fixtures.EEFixtures.GLOBAL_MODULES_DELETE;
40  import static org.jboss.hal.testsuite.fixtures.EEFixtures.SUBSYSTEM_ADDRESS;
41  import static org.jboss.hal.testsuite.fixtures.EEFixtures.globalModule;
42  
43  @Manatoko
44  @Testcontainers
45  class GlobalModulesTest {
46  
47      @Container static WildFlyContainer wildFly = WildFlyContainer.standalone(DEFAULT);
48  
49      @BeforeAll
50      static void setupModel() throws Exception {
51          OnlineManagementClient client = wildFly.managementClient();
52          Operations operations = new Operations(client);
53          operations.writeListAttribute(SUBSYSTEM_ADDRESS, GLOBAL_MODULES,
54                  globalModule(GLOBAL_MODULES_DELETE));
55      }
56  
57      @Inject Console console;
58      @Inject CrudOperations crud;
59      @Page EEPage page;
60      TableFragment table;
61  
62      @BeforeEach
63      void prepare() {
64          page.navigate();
65          console.verticalNavigation().selectPrimary(Ids.EE_GLOBAL_MODULES_ITEM);
66          table = page.getGlobalModulesTable();
67      }
68  
69      @Test
70      void create() throws Exception {
71          crud.create(SUBSYSTEM_ADDRESS, table,
72                  form -> form.text(NAME, GLOBAL_MODULES_CREATE),
73                  resourceVerifier -> resourceVerifier.verifyListAttributeContainsValue(GLOBAL_MODULES,
74                          globalModule(GLOBAL_MODULES_CREATE)));
75      }
76  
77      @Test
78      void delete() throws Exception {
79          crud.delete(SUBSYSTEM_ADDRESS, table, GLOBAL_MODULES_DELETE,
80                  resourceVerifier -> resourceVerifier.verifyListAttributeDoesNotContainValue(GLOBAL_MODULES,
81                          globalModule(GLOBAL_MODULES_DELETE)));
82      }
83  }