Skip to content

Commit

Permalink
avniproject#94 | added is_voided in file and added test case for that
Browse files Browse the repository at this point in the history
  • Loading branch information
vedfordev committed Apr 12, 2024
1 parent 9059191 commit 64a6cf7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/main/resources/sql/etl/user.sql.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
INSERT INTO <schemaName>.<tableName> (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,
Expand All @@ -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 > '<startTime>'
and entity.last_modified_date_time \<= '<endTime>';
14 changes: 14 additions & 0 deletions src/test/java/org/avniproject/etl/DataSyncIntegrationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Map<String, Object>> 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)
Expand Down

0 comments on commit 64a6cf7

Please sign in to comment.