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.HEADER_NAME;
38  import static org.jboss.hal.dmr.ModelDescriptionConstants.NAME;
39  import static org.jboss.hal.testsuite.container.WildFlyConfiguration.DEFAULT;
40  import static org.jboss.hal.testsuite.fixtures.WebFixtures.FILTER_CREATE;
41  import static org.jboss.hal.testsuite.fixtures.WebFixtures.FILTER_DELETE;
42  import static org.jboss.hal.testsuite.fixtures.WebFixtures.FILTER_UPDATE;
43  import static org.jboss.hal.testsuite.fixtures.WebFixtures.HEADER_VALUE;
44  import static org.jboss.hal.testsuite.fixtures.WebFixtures.responseHeaderAddress;
45  
46  @Manatoko
47  @Testcontainers
48  public class ResponseHeaderTest {
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(responseHeaderAddress(FILTER_UPDATE),
56                  Values.of(HEADER_NAME, FILTER_UPDATE).and(HEADER_VALUE, Random.name()));
57          operations.add(responseHeaderAddress(FILTER_DELETE),
58                  Values.of(HEADER_NAME, FILTER_DELETE).and(HEADER_VALUE, Random.name()));
59      }
60  
61      @Inject Console console;
62      @Page FilterPage page;
63      @Inject CrudOperations crud;
64      TableFragment table;
65      FormFragment form;
66  
67      @BeforeEach
68      void prepare() {
69          page.navigate();
70          console.verticalNavigation().selectPrimary(Ids.build("undertow-response-header", "item"));
71          table = page.getResponseHeaderTable();
72          form = page.getResponseHeaderForm();
73          table.bind(form);
74      }
75  
76      @Test
77      void create() throws Exception {
78          crud.create(responseHeaderAddress(FILTER_CREATE), table, form -> {
79              form.text(NAME, FILTER_CREATE);
80              form.text(HEADER_NAME, Random.name());
81              form.text(HEADER_VALUE, Random.name());
82          });
83      }
84  
85      @Test
86      void update() throws Exception {
87          String value = Random.name();
88  
89          table.select(FILTER_UPDATE);
90          crud.update(responseHeaderAddress(FILTER_UPDATE), form, f -> f.text(HEADER_VALUE, value),
91                  resourceVerifier -> resourceVerifier.verifyAttribute(HEADER_VALUE, value));
92      }
93  
94      @Test
95      void delete() throws Exception {
96          crud.delete(responseHeaderAddress(FILTER_DELETE), table, FILTER_DELETE);
97      }
98  }