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.interfce;
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.INET_ADDRESS;
42  import static org.jboss.hal.dmr.ModelDescriptionConstants.NAME;
43  import static org.jboss.hal.testsuite.container.WildFlyConfiguration.DEFAULT;
44  import static org.jboss.hal.testsuite.fixtures.InterfaceFixtures.CREATE;
45  import static org.jboss.hal.testsuite.fixtures.InterfaceFixtures.DELETE;
46  import static org.jboss.hal.testsuite.fixtures.InterfaceFixtures.LOCALHOST;
47  import static org.jboss.hal.testsuite.fixtures.InterfaceFixtures.READ;
48  import static org.jboss.hal.testsuite.fixtures.InterfaceFixtures.interfaceAddress;
49  import static org.junit.jupiter.api.Assertions.assertFalse;
50  import static org.junit.jupiter.api.Assertions.assertTrue;
51  
52  @Manatoko
53  @Testcontainers
54  class InterfaceFinderTest {
55  
56      @Container static WildFlyContainer wildFly = WildFlyContainer.standalone(DEFAULT);
57      static OnlineManagementClient client;
58  
59      @BeforeAll
60      static void setupModel() throws Exception {
61          client = wildFly.managementClient();
62          Operations operations = new Operations(client);
63          operations.add(interfaceAddress(READ), Values.empty().and(INET_ADDRESS, LOCALHOST));
64          operations.add(interfaceAddress(DELETE), Values.empty().and(INET_ADDRESS, LOCALHOST));
65      }
66  
67      @Inject Console console;
68      ColumnFragment column;
69  
70      @BeforeEach
71      void prepare() {
72          column = console.finder(NameTokens.CONFIGURATION,
73                  new FinderPath().append(Ids.CONFIGURATION, Ids.asId(Names.INTERFACES)))
74                  .column(Ids.INTERFACE);
75      }
76  
77      @Test
78      void create() throws Exception {
79          AddResourceDialogFragment dialog = column.add();
80          dialog.getForm().text(NAME, CREATE);
81          dialog.getForm().text(INET_ADDRESS, LOCALHOST);
82          dialog.add();
83  
84          console.verifySuccess();
85          assertTrue(column.containsItem(CREATE));
86          new ResourceVerifier(interfaceAddress(CREATE), client).verifyExists();
87      }
88  
89      @Test
90      void read() {
91          assertTrue(column.containsItem(READ));
92      }
93  
94      @Test
95      void select() {
96          column.selectItem(READ);
97          PlaceRequest placeRequest = Places.finderPlace(NameTokens.CONFIGURATION, new FinderPath()
98                  .append(Ids.CONFIGURATION, Ids.build(Names.INTERFACES))
99                  .append(Ids.INTERFACE, READ));
100         console.verify(placeRequest);
101     }
102 
103     @Test
104     void view() {
105         column.selectItem(READ).view();
106 
107         PlaceRequest placeRequest = new PlaceRequest.Builder().nameToken(NameTokens.INTERFACE)
108                 .with(NAME, READ)
109                 .build();
110         console.verify(placeRequest);
111     }
112 
113     @Test
114     void delete() throws Exception {
115         column.selectItem(DELETE).dropdown().click("Remove");
116         console.confirmationDialog().confirm();
117 
118         console.verifySuccess();
119         assertFalse(column.containsItem(DELETE));
120         new ResourceVerifier(interfaceAddress(DELETE), client).verifyDoesNotExist();
121     }
122 }