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.resourceadapter;
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.testsuite.Console;
22  import org.jboss.hal.testsuite.Random;
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.model.ResourceVerifier;
27  import org.jboss.hal.testsuite.page.Places;
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.OnlineManagementClient;
35  import org.wildfly.extras.creaper.core.online.operations.Operations;
36  import org.wildfly.extras.creaper.core.online.operations.Values;
37  
38  import com.gwtplatform.mvp.shared.proxy.PlaceRequest;
39  
40  import static org.jboss.hal.dmr.ModelDescriptionConstants.ARCHIVE;
41  import static org.jboss.hal.dmr.ModelDescriptionConstants.NAME;
42  import static org.jboss.hal.dmr.ModelDescriptionConstants.RESOURCE_ADAPTERS;
43  import static org.jboss.hal.testsuite.container.WildFlyConfiguration.DEFAULT;
44  import static org.jboss.hal.testsuite.fixtures.ResourceAdapterFixtures.RESOURCE_ADAPTER_CREATE;
45  import static org.jboss.hal.testsuite.fixtures.ResourceAdapterFixtures.RESOURCE_ADAPTER_DELETE;
46  import static org.jboss.hal.testsuite.fixtures.ResourceAdapterFixtures.RESOURCE_ADAPTER_READ;
47  import static org.jboss.hal.testsuite.fixtures.ResourceAdapterFixtures.resourceAdapterAddress;
48  import static org.jboss.hal.testsuite.fragment.finder.FinderFragment.configurationSubsystemPath;
49  import static org.junit.jupiter.api.Assertions.assertFalse;
50  
51  @Manatoko
52  @Testcontainers
53  class ResourceAdapterFinderTest {
54  
55      @Container static WildFlyContainer wildFly = WildFlyContainer.standalone(DEFAULT);
56      private static OnlineManagementClient client;
57  
58      @BeforeAll
59      static void setupModel() throws Exception {
60          client = wildFly.managementClient();
61          Operations operations = new Operations(client);
62          operations.add(resourceAdapterAddress(RESOURCE_ADAPTER_READ), Values.of(ARCHIVE, Random.name()));
63          operations.add(resourceAdapterAddress(RESOURCE_ADAPTER_DELETE), Values.of(ARCHIVE, Random.name()));
64      }
65  
66      @Inject Console console;
67      ColumnFragment column;
68  
69      @BeforeEach
70      void setUp() {
71          column = console.finder(NameTokens.CONFIGURATION, configurationSubsystemPath(RESOURCE_ADAPTERS))
72                  .column(Ids.RESOURCE_ADAPTER);
73      }
74  
75      @Test
76      void create() throws Exception {
77          AddResourceDialogFragment dialog = column.add();
78          dialog.getForm().text(NAME, RESOURCE_ADAPTER_CREATE);
79          dialog.getForm().text(ARCHIVE, Random.name());
80          dialog.add();
81  
82          console.verifySuccess();
83          new ResourceVerifier(resourceAdapterAddress(RESOURCE_ADAPTER_CREATE), client)
84                  .verifyExists();
85      }
86  
87      @Test
88      void select() {
89          column.selectItem(Ids.resourceAdapter(RESOURCE_ADAPTER_READ));
90          PlaceRequest place = Places.finderPlace(NameTokens.CONFIGURATION, configurationSubsystemPath(RESOURCE_ADAPTERS)
91                  .append(Ids.RESOURCE_ADAPTER, Ids.resourceAdapter(RESOURCE_ADAPTER_READ)));
92          console.verify(place);
93      }
94  
95      @Test
96      void view() {
97          column.selectItem(Ids.resourceAdapter(RESOURCE_ADAPTER_READ)).view();
98          PlaceRequest placeRequest = new PlaceRequest.Builder().nameToken(NameTokens.RESOURCE_ADAPTER)
99                  .with(NAME, RESOURCE_ADAPTER_READ)
100                 .build();
101         console.verify(placeRequest);
102     }
103 
104     @Test
105     void delete() throws Exception {
106         column.selectItem(Ids.resourceAdapter(RESOURCE_ADAPTER_DELETE))
107                 .dropdown()
108                 .click("Remove");
109         console.confirmationDialog().confirm();
110 
111         console.verifySuccess();
112         assertFalse(column.containsItem(Ids.resourceAdapter(RESOURCE_ADAPTER_DELETE)));
113         new ResourceVerifier(resourceAdapterAddress(RESOURCE_ADAPTER_DELETE), client)
114                 .verifyDoesNotExist();
115     }
116 }