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.configuration.systemproperty;
17  
18  import org.jboss.arquillian.core.api.annotation.Inject;
19  import org.jboss.arquillian.graphene.page.Page;
20  import org.jboss.hal.testsuite.CrudOperations;
21  import org.jboss.hal.testsuite.Random;
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.SystemPropertyPage;
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.operations.Operations;
33  import org.wildfly.extras.creaper.core.online.operations.Values;
34  
35  import static org.jboss.hal.dmr.ModelDescriptionConstants.NAME;
36  import static org.jboss.hal.dmr.ModelDescriptionConstants.VALUE;
37  import static org.jboss.hal.testsuite.container.WildFlyConfiguration.DEFAULT;
38  import static org.jboss.hal.testsuite.fixtures.SystemPropertyFixtures.CREATE_NAME;
39  import static org.jboss.hal.testsuite.fixtures.SystemPropertyFixtures.CREATE_VALUE;
40  import static org.jboss.hal.testsuite.fixtures.SystemPropertyFixtures.DELETE_NAME;
41  import static org.jboss.hal.testsuite.fixtures.SystemPropertyFixtures.DELETE_VALUE;
42  import static org.jboss.hal.testsuite.fixtures.SystemPropertyFixtures.READ_NAME;
43  import static org.jboss.hal.testsuite.fixtures.SystemPropertyFixtures.READ_VALUE;
44  import static org.jboss.hal.testsuite.fixtures.SystemPropertyFixtures.UPDATE_NAME;
45  import static org.jboss.hal.testsuite.fixtures.SystemPropertyFixtures.UPDATE_VALUE;
46  import static org.jboss.hal.testsuite.fixtures.SystemPropertyFixtures.systemPropertyAddress;
47  import static org.junit.jupiter.api.Assertions.assertEquals;
48  
49  @Manatoko
50  @Testcontainers
51  class SystemPropertyTest {
52  
53      @Container static WildFlyContainer wildFly = WildFlyContainer.standalone(DEFAULT);
54  
55      @BeforeAll
56      static void setupModel() throws Exception {
57          Operations operations = new Operations(wildFly.managementClient());
58          operations.add(systemPropertyAddress(READ_NAME), Values.empty().and(VALUE, READ_VALUE));
59          operations.add(systemPropertyAddress(UPDATE_NAME), Values.empty().and(VALUE, UPDATE_VALUE));
60          operations.add(systemPropertyAddress(DELETE_NAME), Values.empty().and(VALUE, DELETE_VALUE));
61      }
62  
63      @Page SystemPropertyPage page;
64      @Inject CrudOperations crud;
65      TableFragment table;
66      FormFragment form;
67  
68      @BeforeEach
69      void prepare() {
70          page.navigate();
71          form = page.getForm();
72          table = page.getTable();
73          table.bind(form);
74      }
75  
76      @Test
77      void create() throws Exception {
78          crud.create(systemPropertyAddress(CREATE_NAME), table, form -> {
79              form.text(NAME, CREATE_NAME);
80              form.text(VALUE, CREATE_VALUE);
81          });
82      }
83  
84      @Test
85      void read() {
86          table.select(READ_NAME);
87          assertEquals(READ_VALUE, form.value(VALUE));
88      }
89  
90      @Test
91      void update() throws Exception {
92          table.select(UPDATE_NAME);
93          crud.update(systemPropertyAddress(UPDATE_NAME), form, VALUE, Random.name());
94      }
95  
96      @Test
97      void delete() throws Exception {
98          crud.delete(systemPropertyAddress(DELETE_NAME), table, DELETE_NAME);
99      }
100 }