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.paths;
17  
18  import java.io.IOException;
19  
20  import org.jboss.arquillian.core.api.annotation.Inject;
21  import org.jboss.arquillian.graphene.page.Page;
22  import org.jboss.hal.testsuite.CrudOperations;
23  import org.jboss.hal.testsuite.Random;
24  import org.jboss.hal.testsuite.container.WildFlyContainer;
25  import org.jboss.hal.testsuite.fixtures.PathsFixtures;
26  import org.jboss.hal.testsuite.page.configuration.PathsPage;
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.operations.Operations;
34  import org.wildfly.extras.creaper.core.online.operations.Values;
35  
36  import static org.jboss.hal.testsuite.container.WildFlyConfiguration.DEFAULT;
37  
38  @Manatoko
39  @Testcontainers
40  class PathsTest {
41  
42      @Container static WildFlyContainer wildFly = WildFlyContainer.standalone(DEFAULT);
43  
44      @BeforeAll
45      static void setupModel() throws Exception {
46          Operations operations = new Operations(wildFly.managementClient());
47          createPathWithRandomPathValue(operations, PathsFixtures.PATH_EDIT);
48          createPathWithRandomPathValue(operations, PathsFixtures.PATH_DELETE);
49          createPathWithRandomPathValue(operations, PathsFixtures.RELATIVE_TO_PATH);
50      }
51  
52      private static void createPathWithRandomPathValue(Operations operations, String pathName) throws IOException {
53          operations.add(PathsFixtures.pathAddress(pathName), Values.of(PathsFixtures.PATH, Random.name()));
54      }
55  
56      @Inject CrudOperations crud;
57      @Page PathsPage page;
58  
59      @BeforeEach
60      void setUp() {
61          page.navigate();
62      }
63  
64      @Test
65      void create() throws Exception {
66          String path = Random.name();
67          crud.create(PathsFixtures.pathAddress(PathsFixtures.PATH_CREATE), page.getPathsTable(), form -> {
68              form.text("name", PathsFixtures.PATH_CREATE);
69              form.text(PathsFixtures.PATH, path);
70          }, resourceVerifier -> {
71              resourceVerifier.verifyExists();
72              resourceVerifier.verifyAttribute(PathsFixtures.PATH, path);
73          });
74      }
75  
76      @Test
77      void editPath() throws Exception {
78          String path = Random.name();
79          page.getPathsTable().select(PathsFixtures.PATH_EDIT);
80          crud.update(PathsFixtures.pathAddress(PathsFixtures.PATH_EDIT), page.getPathsForm(), PathsFixtures.PATH, path);
81      }
82  
83      @Test
84      void editRelativeTo() throws Exception {
85          page.getPathsTable().select(PathsFixtures.PATH_EDIT);
86          crud.update(PathsFixtures.pathAddress(PathsFixtures.PATH_EDIT), page.getPathsForm(), "relative-to",
87                  PathsFixtures.RELATIVE_TO_PATH);
88      }
89  
90      @Test
91      void delete() throws Exception {
92          crud.delete(PathsFixtures.pathAddress(PathsFixtures.PATH_DELETE), page.getPathsTable(),
93                  PathsFixtures.PATH_DELETE);
94      }
95  
96  }