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.hal.meta.token.NameTokens;
20  import org.jboss.hal.resources.Ids;
21  import org.jboss.hal.resources.Names;
22  import org.jboss.hal.testsuite.Console;
23  import org.jboss.hal.testsuite.container.WildFlyContainer;
24  import org.jboss.hal.testsuite.fragment.AddResourceDialogFragment;
25  import org.jboss.hal.testsuite.fragment.finder.ColumnFragment;
26  import org.jboss.hal.testsuite.fragment.finder.FinderPath;
27  import org.jboss.hal.testsuite.model.ResourceVerifier;
28  import org.jboss.hal.testsuite.page.Places;
29  import org.jboss.hal.testsuite.test.Manatoko;
30  import org.junit.jupiter.api.BeforeAll;
31  import org.junit.jupiter.api.BeforeEach;
32  import org.junit.jupiter.api.Test;
33  import org.testcontainers.junit.jupiter.Container;
34  import org.testcontainers.junit.jupiter.Testcontainers;
35  import org.wildfly.extras.creaper.core.online.OnlineManagementClient;
36  import org.wildfly.extras.creaper.core.online.operations.Operations;
37  import org.wildfly.extras.creaper.core.online.operations.Values;
38  
39  import com.gwtplatform.mvp.shared.proxy.PlaceRequest;
40  
41  import static org.jboss.hal.dmr.ModelDescriptionConstants.HTTPS;
42  import static org.jboss.hal.dmr.ModelDescriptionConstants.LISTENER;
43  import static org.jboss.hal.dmr.ModelDescriptionConstants.MODCLUSTER;
44  import static org.jboss.hal.dmr.ModelDescriptionConstants.NAME;
45  import static org.jboss.hal.testsuite.container.WildFlyConfiguration.HA;
46  import static org.jboss.hal.testsuite.fixtures.ModclusterFixtures.PROXY_CREATE;
47  import static org.jboss.hal.testsuite.fixtures.ModclusterFixtures.PROXY_CREATE2;
48  import static org.jboss.hal.testsuite.fixtures.ModclusterFixtures.PROXY_DELETE;
49  import static org.jboss.hal.testsuite.fixtures.ModclusterFixtures.PROXY_READ;
50  import static org.jboss.hal.testsuite.fixtures.ModclusterFixtures.PROXY_UPDATE;
51  import static org.jboss.hal.testsuite.fixtures.ModclusterFixtures.proxyAddress;
52  import static org.jboss.hal.testsuite.fragment.finder.FinderFragment.configurationSubsystemPath;
53  import static org.junit.jupiter.api.Assertions.assertFalse;
54  import static org.junit.jupiter.api.Assertions.assertTrue;
55  
56  @Manatoko
57  @Testcontainers
58  class ProxyFinderTest {
59  
60      @Container static WildFlyContainer wildFly = WildFlyContainer.standalone(HA);
61      private static OnlineManagementClient client;
62      private static Operations operations;
63  
64      @BeforeAll
65      static void setupModel() throws Exception {
66          client = wildFly.managementClient();
67          operations = new Operations(client);
68          operations.add(proxyAddress(PROXY_READ), Values.of(LISTENER, HTTPS));
69          operations.add(proxyAddress(PROXY_UPDATE), Values.of(LISTENER, HTTPS));
70          operations.add(proxyAddress(PROXY_DELETE), Values.of(LISTENER, HTTPS));
71      }
72  
73      @Inject Console console;
74      ColumnFragment column;
75  
76      @BeforeEach
77      void setUp() {
78          column = console.finder(NameTokens.CONFIGURATION, configurationSubsystemPath(MODCLUSTER))
79                  .column(Ids.MODCLUSTER_PROXY);
80      }
81  
82      @Test
83      void create() throws Exception {
84          AddResourceDialogFragment dialog = column.add();
85          dialog.getForm().text(NAME, PROXY_CREATE);
86          dialog.getForm().text(LISTENER, HTTPS);
87          dialog.add();
88  
89          console.verifySuccess();
90          assertTrue(column.containsItem(Ids.modclusterProxy(PROXY_CREATE)));
91          new ResourceVerifier(proxyAddress(PROXY_CREATE), client).verifyExists();
92      }
93  
94      @Test
95      void read() {
96          assertTrue(column.containsItem(Ids.modclusterProxy(PROXY_READ)));
97      }
98  
99      @Test
100     void refresh() throws Exception {
101         operations.add(proxyAddress(PROXY_CREATE2), Values.of(LISTENER, HTTPS));
102         console.waitNoNotification();
103         column.refresh();
104         assertTrue(column.containsItem(Ids.modclusterProxy(PROXY_CREATE2)));
105     }
106 
107     @Test
108     void select() {
109         column.selectItem(Ids.modclusterProxy(PROXY_READ));
110         PlaceRequest placeRequest = Places.finderPlace(NameTokens.CONFIGURATION, new FinderPath()
111                 .append(Ids.CONFIGURATION, Ids.asId(Names.SUBSYSTEMS))
112                 .append(Ids.CONFIGURATION_SUBSYSTEM, MODCLUSTER)
113                 .append(Ids.MODCLUSTER_PROXY, Ids.modclusterProxy(PROXY_READ)));
114         console.verify(placeRequest);
115     }
116 
117     @Test
118     void view() {
119         column.selectItem(Ids.modclusterProxy(PROXY_READ)).view();
120 
121         PlaceRequest placeRequest = new PlaceRequest.Builder().nameToken(NameTokens.MODCLUSTER)
122                 .with(NAME, PROXY_READ)
123                 .build();
124         console.verify(placeRequest);
125     }
126 
127     @Test
128     void delete() throws Exception {
129         column.selectItem(Ids.modclusterProxy(PROXY_DELETE)).dropdown().click("Remove");
130         console.confirmationDialog().confirm();
131 
132         console.verifySuccess();
133         assertFalse(column.containsItem(Ids.modclusterProxy(PROXY_DELETE)));
134         new ResourceVerifier(proxyAddress(PROXY_DELETE), client).verifyDoesNotExist();
135     }
136 }