[ 
https://issues.apache.org/jira/browse/GOBBLIN-2110?focusedWorklogId=926303&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-926303
 ]

ASF GitHub Bot logged work on GOBBLIN-2110:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 17/Jul/24 07:22
            Start Date: 17/Jul/24 07:22
    Worklog Time Spent: 10m 
      Work Description: pratapaditya04 commented on code in PR #4001:
URL: https://github.com/apache/gobblin/pull/4001#discussion_r1680553784


##########
gobblin-utility/src/test/java/org/apache/gobblin/util/retry/RetryerFactoryTest.java:
##########
@@ -0,0 +1,80 @@
+/*
+ * 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.gobblin.util.retry;
+
+import java.util.Arrays;
+
+import org.mockito.Mockito;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Predicate;
+import com.typesafe.config.Config;
+
+/**
+ * Unit tests for the {@link org.apache.gobblin.util.retry.RetryerFactory} 
class.
+ */
+public class RetryerFactoryTest {
+  private static final String EXCEPTION_LIST_FOR_RETRY_CONFIG_KEY = 
"EXCEPTION_LIST_FOR_RETRY";
+
+  @Test
+  public void testGetRetryPredicateFromConfigOrDefault_withEmptyConfig() {
+    Config config = Mockito.mock(Config.class);
+    
Mockito.when(config.hasPath(EXCEPTION_LIST_FOR_RETRY_CONFIG_KEY)).thenReturn(false);
+    Predicate<Throwable> result = 
RetryerFactory.getRetryPredicateFromConfigOrDefault(config);
+
+    Assert.assertEquals(RetryerFactory.RETRY_EXCEPTION_PREDICATE_DEFAULT, 
result);
+  }
+
+  @Test
+  public void testGetRetryPredicateFromConfigOrDefault_withValidException() {
+    Config config = Mockito.mock(Config.class);
+    
Mockito.when(config.hasPath(EXCEPTION_LIST_FOR_RETRY_CONFIG_KEY)).thenReturn(true);
+    Mockito.when(config.getStringList(EXCEPTION_LIST_FOR_RETRY_CONFIG_KEY))
+        .thenReturn(Arrays.asList("java.lang.RuntimeException"));
+
+    Predicate<Throwable> result = 
RetryerFactory.getRetryPredicateFromConfigOrDefault(config);
+
+    Assert.assertTrue(result.test(new RuntimeException()));
+    Assert.assertFalse(result.test(new Exception()));
+  }
+
+  @Test
+  public void testGetRetryPredicateFromConfigOrDefault_withInvalidException() {
+    Config config = Mockito.mock(Config.class);
+    
Mockito.when(config.hasPath(EXCEPTION_LIST_FOR_RETRY_CONFIG_KEY)).thenReturn(true);
+    Mockito.when(config.getStringList(EXCEPTION_LIST_FOR_RETRY_CONFIG_KEY))
+        .thenReturn(Arrays.asList("non.existent.Exception"));
+
+    Predicate<Throwable> result = 
RetryerFactory.getRetryPredicateFromConfigOrDefault(config);
+
+    Assert.assertEquals(RetryerFactory.RETRY_EXCEPTION_PREDICATE_DEFAULT, 
result);
+  }
+
+  @Test
+  public void testGetRetryPredicateFromConfigOrDefault_withMixedExceptions() {
+    Config config = Mockito.mock(Config.class);
+    
Mockito.when(config.hasPath(EXCEPTION_LIST_FOR_RETRY_CONFIG_KEY)).thenReturn(true);

Review Comment:
   addressed





Issue Time Tracking
-------------------

    Worklog Id:     (was: 926303)
    Time Spent: 2h 20m  (was: 2h 10m)

> Make retry_exception_predicate configurable in RetryerFactory
> -------------------------------------------------------------
>
>                 Key: GOBBLIN-2110
>                 URL: https://issues.apache.org/jira/browse/GOBBLIN-2110
>             Project: Apache Gobblin
>          Issue Type: Bug
>            Reporter: Aditya Pratap Singh
>            Priority: Minor
>          Time Spent: 2h 20m
>  Remaining Estimate: 0h
>
> Make retry_exception_predicate configurable in RetryerFactory



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to