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.web;
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.FilterPage;
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.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.PATH;
39  import static org.jboss.hal.testsuite.container.WildFlyConfiguration.DEFAULT;
40  import static org.jboss.hal.testsuite.fixtures.WebFixtures.CODE;
41  import static org.jboss.hal.testsuite.fixtures.WebFixtures.FILTER_CREATE;
42  import static org.jboss.hal.testsuite.fixtures.WebFixtures.FILTER_DELETE;
43  import static org.jboss.hal.testsuite.fixtures.WebFixtures.FILTER_UPDATE;
44  import static org.jboss.hal.testsuite.fixtures.WebFixtures.errorPageAddress;
45  
46  @Manatoko
47  @Testcontainers
48  public class ErrorPageTest {
49  
50      @Container static WildFlyContainer wildFly = WildFlyContainer.standalone(DEFAULT);
51  
52      @BeforeAll
53      static void setupModel() throws Exception {
54          Operations operations = new Operations(wildFly.managementClient());
55          operations.add(errorPageAddress(FILTER_UPDATE), Values.of(CODE, Random.number()));
56          operations.add(errorPageAddress(FILTER_DELETE), Values.of(CODE, Random.number()));
57      }
58  
59      @Inject Console console;
60      @Page FilterPage page;
61      @Inject CrudOperations crud;
62      TableFragment table;
63      FormFragment form;
64  
65      @BeforeEach
66      void prepare() {
67          page.navigate();
68          console.verticalNavigation().selectPrimary(Ids.build("undertow-error-page", "item"));
69          table = page.getErrorPageTable();
70          form = page.getErrorPageForm();
71          table.bind(form);
72      }
73  
74      @Test
75      void create() throws Exception {
76          crud.create(errorPageAddress(FILTER_CREATE), table, form -> {
77              form.text(NAME, FILTER_CREATE);
78              form.number(CODE, Random.number());
79          });
80      }
81  
82      @Test
83      void update() throws Exception {
84          int code = Random.number();
85          String path = Random.name();
86  
87          table.select(FILTER_UPDATE);
88          crud.update(errorPageAddress(FILTER_UPDATE), form, f -> {
89              f.number(CODE, code);
90              f.text(PATH, path);
91          }, resourceVerifier -> {
92              resourceVerifier.verifyAttribute(CODE, code);
93              resourceVerifier.verifyAttribute(PATH, path);
94          });
95      }
96  
97      @Test
98      void delete() throws Exception {
99          crud.delete(errorPageAddress(FILTER_DELETE), table, FILTER_DELETE);
100     }
101 }