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.configuration.batch;
17  
18  import org.jboss.arquillian.core.api.annotation.Inject;
19  import org.jboss.arquillian.graphene.page.Page;
20  import org.jboss.hal.testsuite.Console;
21  import org.jboss.hal.testsuite.CrudOperations;
22  import org.jboss.hal.testsuite.container.WildFlyContainer;
23  import org.jboss.hal.testsuite.fragment.FormFragment;
24  import org.jboss.hal.testsuite.page.configuration.BatchPage;
25  import org.jboss.hal.testsuite.test.Manatoko;
26  import org.junit.jupiter.api.BeforeAll;
27  import org.junit.jupiter.api.BeforeEach;
28  import org.junit.jupiter.api.Test;
29  import org.testcontainers.junit.jupiter.Container;
30  import org.testcontainers.junit.jupiter.Testcontainers;
31  import org.wildfly.extras.creaper.core.online.operations.Operations;
32  
33  import static org.jboss.hal.dmr.ModelDescriptionConstants.RESTART_JOBS_ON_RESUME;
34  import static org.jboss.hal.testsuite.container.WildFlyConfiguration.DEFAULT;
35  import static org.jboss.hal.testsuite.fixtures.BatchFixtures.SUBSYSTEM_ADDRESS;
36  
37  @Manatoko
38  @Testcontainers
39  class BatchConfigurationTest {
40  
41      @Container static WildFlyContainer wildFly = WildFlyContainer.standalone(DEFAULT);
42      static boolean restart;
43  
44      @BeforeAll
45      static void setupModel() throws Exception {
46          Operations operations = new Operations(wildFly.managementClient());
47          restart = operations.readAttribute(SUBSYSTEM_ADDRESS, RESTART_JOBS_ON_RESUME).booleanValue();
48      }
49  
50      @Page BatchPage page;
51      @Inject Console console;
52      @Inject CrudOperations crud;
53      FormFragment form;
54  
55      @BeforeEach
56      void prepare() {
57          page.navigate();
58          console.verticalNavigation().selectPrimary("batch-configuration-item");
59          form = page.getConfigurationForm();
60      }
61  
62      @Test
63      void update() throws Exception {
64          crud.update(SUBSYSTEM_ADDRESS, form, RESTART_JOBS_ON_RESUME, !restart);
65      }
66  
67      @Test
68      void reset() throws Exception {
69          crud.reset(SUBSYSTEM_ADDRESS, form);
70      }
71  }