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.Random;
24  import org.jboss.hal.testsuite.container.WildFlyContainer;
25  import org.jboss.hal.testsuite.fragment.FormFragment;
26  import org.jboss.hal.testsuite.fragment.TableFragment;
27  import org.jboss.hal.testsuite.page.configuration.EEPage;
28  import org.jboss.hal.testsuite.test.Manatoko;
29  import org.junit.jupiter.api.BeforeAll;
30  import org.junit.jupiter.api.BeforeEach;
31  import org.junit.jupiter.api.Test;
32  import org.testcontainers.junit.jupiter.Container;
33  import org.testcontainers.junit.jupiter.Testcontainers;
34  import org.wildfly.extras.creaper.core.online.OnlineManagementClient;
35  import org.wildfly.extras.creaper.core.online.operations.Operations;
36  import org.wildfly.extras.creaper.core.online.operations.Values;
37  
38  import static org.jboss.hal.dmr.ModelDescriptionConstants.JNDI_NAME;
39  import static org.jboss.hal.dmr.ModelDescriptionConstants.NAME;
40  import static org.jboss.hal.testsuite.container.WildFlyConfiguration.DEFAULT;
41  import static org.jboss.hal.testsuite.fixtures.EEFixtures.EXECUTOR_CREATE;
42  import static org.jboss.hal.testsuite.fixtures.EEFixtures.EXECUTOR_DELETE;
43  import static org.jboss.hal.testsuite.fixtures.EEFixtures.EXECUTOR_READ;
44  import static org.jboss.hal.testsuite.fixtures.EEFixtures.EXECUTOR_UPDATE;
45  import static org.jboss.hal.testsuite.fixtures.EEFixtures.executorAddress;
46  
47  @Manatoko
48  @Testcontainers
49  class ExecutorTest {
50  
51      @Container static WildFlyContainer wildFly = WildFlyContainer.standalone(DEFAULT);
52  
53      @BeforeAll
54      static void setupModel() throws Exception {
55          OnlineManagementClient client = wildFly.managementClient();
56          Operations operations = new Operations(client);
57          operations.add(executorAddress(EXECUTOR_READ), Values.of(JNDI_NAME, Random.jndiName()));
58          operations.add(executorAddress(EXECUTOR_UPDATE), Values.of(JNDI_NAME, Random.jndiName()));
59          operations.add(executorAddress(EXECUTOR_DELETE), Values.of(JNDI_NAME, Random.jndiName()));
60      }
61  
62      @Inject Console console;
63      @Inject CrudOperations crud;
64      @Page EEPage page;
65      TableFragment table;
66      FormFragment form;
67  
68      @BeforeEach
69      void prepare() {
70          page.navigate();
71          console.verticalNavigation().selectSecondary(Ids.EE_SERVICES_ITEM, Ids.EE_MANAGED_EXECUTOR);
72  
73          table = page.getExecutorTable();
74          form = page.getExecutorForm();
75          table.bind(form);
76      }
77  
78      @Test
79      void create() throws Exception {
80          crud.create(executorAddress(EXECUTOR_CREATE), table, form -> {
81              form.text(NAME, EXECUTOR_CREATE);
82              form.text(JNDI_NAME, Random.jndiName());
83          });
84      }
85  
86      @Test
87      void update() throws Exception {
88          table.select(EXECUTOR_UPDATE);
89          crud.update(executorAddress(EXECUTOR_UPDATE), form, JNDI_NAME, Random.jndiName());
90      }
91  
92      @Test
93      void reset() throws Exception {
94          table.select(EXECUTOR_UPDATE);
95          crud.reset(executorAddress(EXECUTOR_UPDATE), form);
96      }
97  
98      @Test
99      void delete() throws Exception {
100         crud.delete(executorAddress(EXECUTOR_DELETE), table, EXECUTOR_DELETE);
101     }
102 }