You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2020/10/20 12:19:49 UTC

[GitHub] [shardingsphere-elasticjob] ZHZstruggle opened a new pull request #1620: Add builder to create ErrorHandlerConfiguration to permit default value

ZHZstruggle opened a new pull request #1620:
URL: https://github.com/apache/shardingsphere-elasticjob/pull/1620


   Fixes #1599
   
   Changes proposed in this pull request:
   - Add builder to EmailConfiguration and test cases
   - Add builder to WechatConfiguration and test cases
   - Add builder to DingtalkConfiguration and test cases
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere-elasticjob] terrymanu merged pull request #1620: Add builder to create ErrorHandlerConfiguration to permit default value

Posted by GitBox <gi...@apache.org>.
terrymanu merged pull request #1620:
URL: https://github.com/apache/shardingsphere-elasticjob/pull/1620


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere-elasticjob] TeslaCN commented on a change in pull request #1620: Add builder to create ErrorHandlerConfiguration to permit default value

Posted by GitBox <gi...@apache.org>.
TeslaCN commented on a change in pull request #1620:
URL: https://github.com/apache/shardingsphere-elasticjob/pull/1620#discussion_r508457772



##########
File path: elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-email/src/main/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailConfiguration.java
##########
@@ -50,11 +51,125 @@
     
     private final String bcc;
     
-    // TODO default value is false
     private final boolean debug;
     
     @Override
     public String getType() {
         return EmailType.TYPE;
     }
+    
+    /**
+     * Create Email configuration builder.
+     *
+     * @param host     host
+     * @param port     port
+     * @param username username
+     * @param password password
+     * @param from     from
+     * @param to       to
+     * @return Email configuration builder
+     */
+    public static Builder newBuilder(final String host, final int port, final String username,
+                                     final String password, final String from, final String to) {
+        return new Builder(host, port, username, password, from, to);
+    }
+    
+    @RequiredArgsConstructor(access = AccessLevel.PRIVATE)
+    public static class Builder {
+        
+        private final String host;
+        
+        private final int port;
+        
+        private final String username;
+        
+        private final String password;
+        
+        private boolean useSsl = true;
+        
+        private String subject = "ElasticJob error message";
+        
+        private final String from;
+        
+        private final String to;
+        
+        private String cc;
+        
+        private String bcc;
+        
+        private boolean debug;
+        
+        /**
+         * Set useSsl.
+         *
+         * @param useSsl useSsl
+         * @return Email configuration builder
+         */
+        public Builder useSsl(final boolean useSsl) {
+            this.useSsl = useSsl;
+            return this;
+        }
+        
+        /**
+         * Set subject.
+         *
+         * @param subject subject
+         * @return Email configuration builder
+         */
+        public Builder subject(final String subject) {
+            if (!Strings.isNullOrEmpty(subject)) {
+                this.subject = subject;
+            }
+            return this;
+        }
+        
+        /**
+         * Set cc.
+         *
+         * @param cc cc
+         * @return Email configuration builder
+         */
+        public Builder cc(final String cc) {
+            this.cc = cc;
+            return this;
+        }
+        
+        /**
+         * Set bcc.
+         *
+         * @param bcc bcc
+         * @return Email configuration builder
+         */
+        public Builder bcc(final String bcc) {
+            this.bcc = bcc;
+            return this;
+        }
+        
+        /**
+         * Set debug.
+         *
+         * @param debug debug
+         * @return Email configuration builder
+         */
+        public Builder debug(final boolean debug) {
+            this.debug = debug;
+            return this;
+        }
+        
+        /**
+         * Build Email configuration.
+         *
+         * @return Email configuration
+         */
+        public final EmailConfiguration build() {
+            Preconditions.checkArgument(!Strings.isNullOrEmpty(host), "host can not be empty.");
+            Preconditions.checkArgument(port > 0 && port < 65535, "port should larger than 0 and small than 65535.");

Review comment:
       Constants on the left.

##########
File path: elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-email/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailConfigurationTest.java
##########
@@ -0,0 +1,132 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.elasticjob.error.handler.email;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.junit.MockitoJUnitRunner;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+@RunWith(MockitoJUnitRunner.class)
+public class EmailConfigurationTest {
+    
+    private static final String HOST = "192.168.0.8";

Review comment:
       The IP is not very easy to understand.
   ```suggestion
       private static final String HOST = "smtp.xxx.com";
   ```

##########
File path: elasticjob-error-handler/elasticjob-error-handler-type/elasticjob-error-handler-email/src/test/java/org/apache/shardingsphere/elasticjob/error/handler/email/EmailConfigurationTest.java
##########
@@ -0,0 +1,132 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.elasticjob.error.handler.email;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.junit.MockitoJUnitRunner;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+@RunWith(MockitoJUnitRunner.class)
+public class EmailConfigurationTest {
+    
+    private static final String HOST = "192.168.0.8";
+    
+    private static final int PORT = 8080;

Review comment:
       Using HTTP port in SMTP testcase confuse users.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org