This is an automated email from the ASF dual-hosted git repository.

zhonghongsheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new ffe0a0466c2 Add unit test for GovernanceRepositoryAPIImpl (#28842)
ffe0a0466c2 is described below

commit ffe0a0466c2e62a6f3a2c4ffedadf79ebf5f2f57
Author: ManaMatrix <[email protected]>
AuthorDate: Tue Oct 24 01:03:37 2023 +1100

    Add unit test for GovernanceRepositoryAPIImpl (#28842)
    
    * Add unit test for GovernanceRepositoryAPIImpl persistLatestCheckJobId, 
getLatestCheckJobId, deleteLatestCheckJobId
    
    * Remove combined importing and combine three test method in one unit test 
method
    
    * Refactor test and rename vars for clarity.
    
    * Rename vars by following Code of Conduct
    
    * Rename the test method
    
    * Reformat code
---
 .../core/job/service/GovernanceRepositoryAPIImplTest.java   | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git 
a/test/it/pipeline/src/test/java/org/apache/shardingsphere/test/it/data/pipeline/core/job/service/GovernanceRepositoryAPIImplTest.java
 
b/test/it/pipeline/src/test/java/org/apache/shardingsphere/test/it/data/pipeline/core/job/service/GovernanceRepositoryAPIImplTest.java
index d151d0221cc..5227ff06efb 100644
--- 
a/test/it/pipeline/src/test/java/org/apache/shardingsphere/test/it/data/pipeline/core/job/service/GovernanceRepositoryAPIImplTest.java
+++ 
b/test/it/pipeline/src/test/java/org/apache/shardingsphere/test/it/data/pipeline/core/job/service/GovernanceRepositoryAPIImplTest.java
@@ -51,6 +51,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.mockito.Mockito.mock;
 
 class GovernanceRepositoryAPIImplTest {
@@ -156,6 +157,18 @@ class GovernanceRepositoryAPIImplTest {
         assertThat(actual.get(), is("testValue"));
     }
     
+    @Test
+    void assertLatestCheckJobIdPersistenceDeletion() {
+        String parentJobId = "testParentJob";
+        String expectedCheckJobId = "testCheckJob";
+        governanceRepositoryAPI.persistLatestCheckJobId(parentJobId, 
expectedCheckJobId);
+        Optional<String> actualCheckJobIdOpt = 
governanceRepositoryAPI.getLatestCheckJobId(parentJobId);
+        assertTrue(actualCheckJobIdOpt.isPresent(), "Expected a checkJobId to 
be present");
+        assertEquals(expectedCheckJobId, actualCheckJobIdOpt.get(), "The 
retrieved checkJobId does not match the expected one");
+        governanceRepositoryAPI.deleteLatestCheckJobId(parentJobId);
+        
assertFalse(governanceRepositoryAPI.getLatestCheckJobId(parentJobId).isPresent(),
 "Expected no checkJobId to be present after deletion");
+    }
+    
     private MigrationJobItemContext mockJobItemContext() {
         MigrationJobItemContext result = 
PipelineContextUtils.mockMigrationJobItemContext(JobConfigurationBuilder.createJobConfiguration());
         MigrationTaskConfiguration taskConfig = result.getTaskConfig();

Reply via email to