linweihs commented on code in PR #4070:
URL: https://github.com/apache/gobblin/pull/4070#discussion_r1851090968


##########
gobblin-data-management/src/test/java/org/apache/gobblin/data/management/trash/TimeBasedSnapshotCleanupPolicyTest.java:
##########
@@ -0,0 +1,90 @@
+/*
+ * 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.data.management.trash;
+
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.Path;
+import org.joda.time.DateTime;
+import org.joda.time.DateTimeZone;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+import org.testng.annotations.BeforeMethod;
+
+import java.io.IOException;
+import java.util.Properties;
+
+public class TimeBasedSnapshotCleanupPolicyTest {
+
+    private MockTimeBasedSnapshotCleanupPolicy cleanupPolicy;
+
+    @BeforeMethod
+    public void setUp()  {
+        // Initialize the cleanup policy with a retention period (e.g., 1 day)
+        Properties properties = new Properties();
+        
properties.setProperty(MockTimeBasedSnapshotCleanupPolicy.SNAPSHOT_RETENTION_POLICY_MINUTES_KEY,
 "1440"); // 1440 minutes = 1 day
+        
properties.setProperty(MockTimeBasedSnapshotCleanupPolicy.RETENTION_SNAPSHOT_TIMEZONE,
 "UTC");
+        // Mock the cutoff time to be 2024-10-30 01:01:00 UTC
+        cleanupPolicy = new MockTimeBasedSnapshotCleanupPolicy(properties, new 
DateTime(2024, 10, 30, 1, 1));
+    }
+
+    @Test
+    public void testShouldDeleteSnapshot() throws IOException {
+
+        // Create a Trash
+        TrashTestBase trashTestBase = new TrashTestBase(new Properties());
+        Trash trash = trashTestBase.trash;
+
+        // Create dummy paths
+        FileStatus fs1 = new FileStatus(0, true, 0, 0, 0, 
+                                        new Path(trash.getTrashLocation(), new 
DateTime(2024, 10, 29, 1, 0, 
DateTimeZone.UTC).toString(Trash.TRASH_SNAPSHOT_NAME_FORMATTER)));

Review Comment:
   updated. Mock the FileStatus object to return the path



-- 
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.

To unsubscribe, e-mail: dev-unsubscr...@gobblin.apache.org

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

Reply via email to