From 64a6cf7b053ddd77b928a2507c7711ca0dbce8c3 Mon Sep 17 00:00:00 2001 From: vedfordev Date: Fri, 12 Apr 2024 16:39:52 +0530 Subject: [PATCH] #94 | added is_voided in file and added test case for that --- src/main/resources/sql/etl/user.sql.st | 5 +++-- .../avniproject/etl/DataSyncIntegrationTest.java | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/main/resources/sql/etl/user.sql.st b/src/main/resources/sql/etl/user.sql.st index bb335b8..b08e937 100644 --- a/src/main/resources/sql/etl/user.sql.st +++ b/src/main/resources/sql/etl/user.sql.st @@ -1,6 +1,6 @@ INSERT INTO . (id, uuid, username, organisation_id, created_by_id, last_modified_by_id, created_date_time, last_modified_date_time, catchment_id, - email, phone_number, name) + email, phone_number, name, is_voided) SELECT entity.id, entity.uuid, entity.username, @@ -12,7 +12,8 @@ SELECT entity.id, entity.catchment_id, entity.email, entity.phone_number, - entity.name + entity.name, + entity.is_voided FROM public.users entity where entity.last_modified_date_time > '' and entity.last_modified_date_time \<= ''; diff --git a/src/test/java/org/avniproject/etl/DataSyncIntegrationTest.java b/src/test/java/org/avniproject/etl/DataSyncIntegrationTest.java index 908744a..6c23430 100644 --- a/src/test/java/org/avniproject/etl/DataSyncIntegrationTest.java +++ b/src/test/java/org/avniproject/etl/DataSyncIntegrationTest.java @@ -352,6 +352,20 @@ public void userTableShouldUpdateWithOldUserData() throws InterruptedException { assertThat(numberOfRowsAfterSecondRun, is(equalTo(numberOfRowsAfterFirstRun))); } + @Test + @Sql({"/test-data-teardown.sql", "/test-data.sql"}) + @Sql(scripts = "/test-data-teardown.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD) + public void userTableShouldUpdateWithOldUserDataandIsVoided() throws InterruptedException { + runDataSync(); + String updateLastModifiedDateTimeSql = "update public.users set last_modified_date_time = now(),is_voided = true where id = 3453;"; + jdbcTemplate.execute(updateLastModifiedDateTimeSql); + + runDataSync(); + List> list = jdbcTemplate.queryForList("select * from orgc.users where is_voided = true and id = 3453 ; "); + assertThat(list.size(), is(equalTo(1))); + } + + @Test @Sql({"/test-data-teardown.sql", "/test-data.sql"}) @Sql(scripts = "/test-data-teardown.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)