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.testsuite.CrudOperations;
21  import org.jboss.hal.testsuite.container.WildFlyContainer;
22  import org.jboss.hal.testsuite.fragment.FormFragment;
23  import org.jboss.hal.testsuite.fragment.TableFragment;
24  import org.jboss.hal.testsuite.page.configuration.BufferCachePage;
25  import org.jboss.hal.testsuite.test.Manatoko;
26  import org.junit.jupiter.api.BeforeAll;
27  import org.junit.jupiter.api.BeforeEach;
28  import org.junit.jupiter.api.Test;
29  import org.testcontainers.junit.jupiter.Container;
30  import org.testcontainers.junit.jupiter.Testcontainers;
31  import org.wildfly.extras.creaper.core.online.operations.Operations;
32  
33  import static org.jboss.hal.dmr.ModelDescriptionConstants.NAME;
34  import static org.jboss.hal.testsuite.container.WildFlyConfiguration.DEFAULT;
35  import static org.jboss.hal.testsuite.fixtures.WebFixtures.BUFFERS_PER_REGION;
36  import static org.jboss.hal.testsuite.fixtures.WebFixtures.BUFFER_CACHE_CREATE;
37  import static org.jboss.hal.testsuite.fixtures.WebFixtures.BUFFER_CACHE_DELETE;
38  import static org.jboss.hal.testsuite.fixtures.WebFixtures.BUFFER_CACHE_UPDATE;
39  import static org.jboss.hal.testsuite.fixtures.WebFixtures.BUFFER_SIZE;
40  import static org.jboss.hal.testsuite.fixtures.WebFixtures.MAX_REGIONS;
41  import static org.jboss.hal.testsuite.fixtures.WebFixtures.bufferCacheAddress;
42  
43  @Manatoko
44  @Testcontainers
45  class BufferCacheTest {
46  
47      @Container static WildFlyContainer wildFly = WildFlyContainer.standalone(DEFAULT);
48  
49      @BeforeAll
50      static void setupModel() throws Exception {
51          Operations operations = new Operations(wildFly.managementClient());
52          operations.add(bufferCacheAddress(BUFFER_CACHE_UPDATE));
53          operations.add(bufferCacheAddress(BUFFER_CACHE_DELETE));
54      }
55  
56      @Page BufferCachePage page;
57      @Inject CrudOperations crud;
58      TableFragment table;
59      FormFragment form;
60  
61      @BeforeEach
62      void prepare() {
63          page.navigate();
64          table = page.getTable();
65          form = page.getForm();
66          table.bind(form);
67      }
68  
69      @Test
70      void create() throws Exception {
71          crud.create(bufferCacheAddress(BUFFER_CACHE_CREATE), table, form -> form.text(NAME, BUFFER_CACHE_CREATE));
72      }
73  
74      @Test
75      void update() throws Exception {
76          table.select(BUFFER_CACHE_UPDATE);
77          crud.update(bufferCacheAddress(BUFFER_CACHE_UPDATE), form, f -> {
78              f.number(BUFFER_SIZE, 10);
79              f.number(BUFFERS_PER_REGION, 11);
80              f.number(MAX_REGIONS, 12);
81          }, resourceVerifier -> {
82              resourceVerifier.verifyAttribute(BUFFER_SIZE, 10);
83              resourceVerifier.verifyAttribute(BUFFERS_PER_REGION, 11);
84              resourceVerifier.verifyAttribute(MAX_REGIONS, 12);
85          });
86      }
87  
88      @Test
89      void delete() throws Exception {
90          crud.delete(bufferCacheAddress(BUFFER_CACHE_DELETE), table, BUFFER_CACHE_DELETE);
91      }
92  }