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.modcluster;
17  
18  import org.jboss.arquillian.core.api.annotation.Inject;
19  import org.jboss.arquillian.graphene.page.Page;
20  import org.jboss.hal.testsuite.Console;
21  import org.jboss.hal.testsuite.CrudOperations;
22  import org.jboss.hal.testsuite.Random;
23  import org.jboss.hal.testsuite.container.WildFlyContainer;
24  import org.jboss.hal.testsuite.fragment.EmptyState;
25  import org.jboss.hal.testsuite.fragment.FormFragment;
26  import org.jboss.hal.testsuite.page.configuration.ModclusterPage;
27  import org.jboss.hal.testsuite.test.Manatoko;
28  import org.junit.jupiter.api.BeforeAll;
29  import org.junit.jupiter.api.BeforeEach;
30  import org.junit.jupiter.api.Test;
31  import org.testcontainers.junit.jupiter.Container;
32  import org.testcontainers.junit.jupiter.Testcontainers;
33  import org.wildfly.extras.creaper.core.online.OnlineManagementClient;
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.DEFAULT;
38  import static org.jboss.hal.dmr.ModelDescriptionConstants.LISTENER;
39  import static org.jboss.hal.dmr.ModelDescriptionConstants.NAME;
40  import static org.jboss.hal.testsuite.container.WildFlyConfiguration.HA;
41  import static org.jboss.hal.testsuite.fixtures.ModclusterFixtures.HISTORY;
42  import static org.jboss.hal.testsuite.fixtures.ModclusterFixtures.PROXY_DYNAMIC_LP;
43  import static org.jboss.hal.testsuite.fixtures.ModclusterFixtures.loadProviderDynamicAddress;
44  import static org.jboss.hal.testsuite.fixtures.ModclusterFixtures.proxyAddress;
45  import static org.junit.jupiter.api.Assertions.assertTrue;
46  
47  @Manatoko
48  @Testcontainers
49  class ModclusterLoadProviderDynamicTest {
50  
51      @Container static WildFlyContainer wildFly = WildFlyContainer.standalone(HA);
52  
53      @BeforeAll
54      static void setupModel() throws Exception {
55          OnlineManagementClient client = wildFly.managementClient();
56          Operations operations = new Operations(client);
57          operations.add(proxyAddress(PROXY_DYNAMIC_LP), Values.of(LISTENER, DEFAULT));
58          operations.add(loadProviderDynamicAddress(PROXY_DYNAMIC_LP));
59      }
60  
61      @Inject Console console;
62      @Inject CrudOperations crud;
63      @Page ModclusterPage page;
64      FormFragment form;
65  
66      @BeforeEach
67      void setUp() {
68          page.navigate(NAME, PROXY_DYNAMIC_LP);
69          console.verticalNavigation().selectPrimary("load-provider-dynamic-item");
70          form = page.getLoadProviderDynamicForm();
71      }
72  
73      @Test
74      void noSimpleProvider() {
75          console.verticalNavigation().selectPrimary("load-provider-simple-item");
76          EmptyState empty = page.getLoadProviderSimpleEmpty();
77          assertTrue(empty.getRoot().isDisplayed());
78      }
79  
80      @Test
81      void reset() throws Exception {
82          crud.reset(loadProviderDynamicAddress(PROXY_DYNAMIC_LP), form);
83      }
84  
85      @Test
86      void update() throws Exception {
87          crud.update(loadProviderDynamicAddress(PROXY_DYNAMIC_LP), form, HISTORY, Random.number());
88      }
89  }