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 4c23f97 commit bdbcf30
Show file tree
Hide file tree
Showing 2 changed files with 20 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>';
17 changes: 17 additions & 0 deletions src/test/java/org/avniproject/etl/DataSyncIntegrationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Map<String, Object>> list = jdbcTemplate.queryForList("select * from orgc.users where is_voided = true and id = 3453;");
assertThat(list.size(), is(equalTo(1)));
}
}

0 comments on commit bdbcf30

Please sign in to comment.