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