From bdbcf302fab657ec5eb7f6ed207032b0c99fe870 Mon Sep 17 00:00:00 2001 From: vedfordev Date: Fri, 12 Apr 2024 13:40:34 +0530 Subject: [PATCH] #94 | added is_voided in file and added test case for that --- src/main/resources/sql/etl/user.sql.st | 5 +++-- .../etl/DataSyncIntegrationTest.java | 17 +++++++++++++++++ 2 files changed, 20 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..d3ed9b1 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 fcac247..3468fa4 100644 --- a/src/test/java/org/avniproject/etl/DataSyncIntegrationTest.java +++ b/src/test/java/org/avniproject/etl/DataSyncIntegrationTest.java @@ -351,4 +351,21 @@ public void userTableShouldUpdateWithOldUserData() throws InterruptedException { Long numberOfRowsAfterSecondRun = countOfRowsIn("orgc.users"); 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 userTableShouldHaveIsVoided() throws InterruptedException { + String numberOfUserRows = "select count(*) from orgc.users where id = 3453;"; + + runDataSync(); + Long numberOfRowsAfterFirstRun = countOfRowsIn("orgc.users"); + + 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))); + } }