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.mail;
17  
18  import org.jboss.arquillian.core.api.annotation.Inject;
19  import org.jboss.arquillian.graphene.page.Page;
20  import org.jboss.hal.resources.Ids;
21  import org.jboss.hal.testsuite.Console;
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.fragment.TableFragment;
26  import org.jboss.hal.testsuite.page.configuration.MailPage;
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.MethodOrderer;
31  import org.junit.jupiter.api.Test;
32  import org.junit.jupiter.api.TestMethodOrder;
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 static org.jboss.hal.dmr.ModelDescriptionConstants.IMAP;
40  import static org.jboss.hal.dmr.ModelDescriptionConstants.JNDI_NAME;
41  import static org.jboss.hal.dmr.ModelDescriptionConstants.NAME;
42  import static org.jboss.hal.dmr.ModelDescriptionConstants.OUTBOUND_SOCKET_BINDING_REF;
43  import static org.jboss.hal.dmr.ModelDescriptionConstants.POP3;
44  import static org.jboss.hal.dmr.ModelDescriptionConstants.SMTP;
45  import static org.jboss.hal.testsuite.container.WildFlyConfiguration.DEFAULT;
46  import static org.jboss.hal.testsuite.fixtures.MailFixtures.MAIL_SMTP;
47  import static org.jboss.hal.testsuite.fixtures.MailFixtures.SESSION_CREATE;
48  import static org.jboss.hal.testsuite.fixtures.MailFixtures.serverAddress;
49  import static org.jboss.hal.testsuite.fixtures.MailFixtures.sessionAddress;
50  
51  @Manatoko
52  @Testcontainers
53  @TestMethodOrder(MethodOrderer.MethodName.class)
54  class MailServerCreateTest {
55  
56      @Container static WildFlyContainer wildFly = WildFlyContainer.standalone(DEFAULT);
57  
58      @BeforeAll
59      static void setupModel() throws Exception {
60          OnlineManagementClient client = wildFly.managementClient();
61          Operations operations = new Operations(client);
62          operations.add(sessionAddress(SESSION_CREATE), Values.of(JNDI_NAME, Random.jndiName(SESSION_CREATE)));
63      }
64  
65      @Inject Console console;
66      @Inject CrudOperations crud;
67      @Page MailPage page;
68      TableFragment table;
69  
70      @BeforeEach
71      void prepare() {
72          page.navigate(NAME, SESSION_CREATE);
73          console.verticalNavigation().selectPrimary(Ids.MAIL_SERVER_ITEM);
74          table = page.getMailServerTable();
75      }
76  
77      @Test
78      void createIMAP() throws Exception {
79          createServer(IMAP);
80      }
81  
82      @Test
83      void createPOP3() throws Exception {
84          createServer(POP3);
85      }
86  
87      @Test
88      void createSMTP() throws Exception {
89          createServer(SMTP);
90      }
91  
92      private void createServer(String type) throws Exception {
93          crud.create(serverAddress(SESSION_CREATE, type), table,
94                  form -> form.text(OUTBOUND_SOCKET_BINDING_REF, MAIL_SMTP));
95      }
96  }