From 8084e4b6987f785ada6f8f3dfd83ffe1c1b3474c Mon Sep 17 00:00:00 2001 From: himeshr Date: Wed, 17 Jul 2024 12:32:27 +0530 Subject: [PATCH] #102 | Fix Build break --- .../avniproject/etl/DataSyncIntegrationTest.java | 14 +++++++------- .../etl/builder/OrganisationIdentityBuilder.java | 8 +++++++- .../avniproject/etl/domain/TableMetadataTest.java | 2 +- .../etl/domain/metadata/ColumnMetadataTest.java | 2 +- .../etl/domain/metadata/diff/AddColumnTest.java | 4 ++-- .../etl/domain/metadata/diff/CreateTableTest.java | 4 ++-- .../etl/domain/metadata/diff/RenameColumnTest.java | 2 +- .../etl/domain/metadata/diff/RenameTableTest.java | 2 +- .../etl/repository/AvniMetadataRepositoryTest.java | 6 +++--- .../repository/SchemaMetadataRepositoryTest.java | 2 +- .../etl/service/EtlServiceIntegrationTest.java | 4 ++-- 11 files changed, 28 insertions(+), 22 deletions(-) diff --git a/src/test/java/org/avniproject/etl/DataSyncIntegrationTest.java b/src/test/java/org/avniproject/etl/DataSyncIntegrationTest.java index 6098a74..7aa8465 100644 --- a/src/test/java/org/avniproject/etl/DataSyncIntegrationTest.java +++ b/src/test/java/org/avniproject/etl/DataSyncIntegrationTest.java @@ -37,7 +37,7 @@ private String getCurrentTime(long subtractSeconds) { } private void runDataSync() { - etlService.runFor(OrganisationIdentity.createForOrganisation("orgc", "orgc")); + etlService.runFor(OrganisationIdentity.createForOrganisation("orgc", "orgc", "orgc")); } private List> getPersons() { @@ -213,10 +213,10 @@ public void allTheDBUserOfOrgGroupAreAbleToQueryTables() { etlService.runForOrganisationGroup("og"); etlService.runForOrganisationGroup("og"); - etlService.runFor(OrganisationIdentity.createForOrganisation("ogi1", "ogi1")); + etlService.runFor(OrganisationIdentity.createForOrganisation("ogi1", "ogi1", "ogi1")); etlService.runForOrganisationGroup("og"); - etlService.runFor(OrganisationIdentity.createForOrganisation("ogi1", "ogi1")); + etlService.runFor(OrganisationIdentity.createForOrganisation("ogi1", "ogi1", "ogi1")); jdbcTemplate.execute("set role og;"); List> groupList = jdbcTemplate.queryForList("select * from og.person;"); @@ -236,13 +236,13 @@ public void allTheDBUserOfOrgGroupAreAbleToQueryTables() { @Sql(scripts = {"/test-data-teardown.sql", "/organisation-group-teardown.sql"}, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD) public void multipleRunsShouldNotCauseDuplicateDataInOrganisationsAndGroups() { - etlService.runFor(OrganisationIdentity.createForOrganisation("ogi2", "ogi2")); + etlService.runFor(OrganisationIdentity.createForOrganisation("ogi2", "ogi2", "ogi2")); etlService.runForOrganisationGroup("og"); - etlService.runFor(OrganisationIdentity.createForOrganisation("ogi1", "ogi1")); + etlService.runFor(OrganisationIdentity.createForOrganisation("ogi1", "ogi1", "ogi2")); - etlService.runFor(OrganisationIdentity.createForOrganisation("ogi2", "ogi2")); + etlService.runFor(OrganisationIdentity.createForOrganisation("ogi2", "ogi2", "ogi2")); etlService.runForOrganisationGroup("og"); - etlService.runFor(OrganisationIdentity.createForOrganisation("ogi1", "ogi1")); + etlService.runFor(OrganisationIdentity.createForOrganisation("ogi1", "ogi1", "ogi2")); jdbcTemplate.execute("set role og;"); List> groupList = jdbcTemplate.queryForList("select * from og.person;"); diff --git a/src/test/java/org/avniproject/etl/builder/OrganisationIdentityBuilder.java b/src/test/java/org/avniproject/etl/builder/OrganisationIdentityBuilder.java index c0dd086..c188a5f 100644 --- a/src/test/java/org/avniproject/etl/builder/OrganisationIdentityBuilder.java +++ b/src/test/java/org/avniproject/etl/builder/OrganisationIdentityBuilder.java @@ -6,6 +6,7 @@ public class OrganisationIdentityBuilder { private Integer id = 1; private String dbUser = "dbUser"; private String schemaName = "schema"; + private String mediaDirectory = "mediaDirectory"; public OrganisationIdentityBuilder withId(Integer id) { this.id = id; @@ -13,7 +14,7 @@ public OrganisationIdentityBuilder withId(Integer id) { } public OrganisationIdentity build() { - return OrganisationIdentity.createForOrganisation(dbUser, schemaName); + return OrganisationIdentity.createForOrganisation(dbUser, schemaName, mediaDirectory); } public OrganisationIdentityBuilder withDbUser(String dbUser) { @@ -25,4 +26,9 @@ public OrganisationIdentityBuilder withSchemaName(String schemaName) { this.schemaName = schemaName; return this; } + + public OrganisationIdentityBuilder withMediaDirectory(String mediaDirectory) { + this.mediaDirectory = mediaDirectory; + return this; + } } diff --git a/src/test/java/org/avniproject/etl/domain/TableMetadataTest.java b/src/test/java/org/avniproject/etl/domain/TableMetadataTest.java index d0114b8..dbe662a 100644 --- a/src/test/java/org/avniproject/etl/domain/TableMetadataTest.java +++ b/src/test/java/org/avniproject/etl/domain/TableMetadataTest.java @@ -74,7 +74,7 @@ public void shouldRenameTableIfNecessary() { @Test public void shouldAddColumnIfMissing() { - OrgIdentityContextHolder.setContext(OrganisationIdentity.createForOrganisation("dbUser", "schema")); + OrgIdentityContextHolder.setContext(OrganisationIdentity.createForOrganisation("dbUser", "schema", "mediaDirectory")); TableMetadata oldTable = new TableMetadataBuilder().forPerson().build(); TableMetadata newTable = new TableMetadataBuilder().forPerson().build(); newTable.addColumnMetadata(List.of(new ColumnMetadata(new Column("newColumn", Column.Type.text), 24, ColumnMetadata.ConceptType.Text, UUID.randomUUID().toString()))); diff --git a/src/test/java/org/avniproject/etl/domain/metadata/ColumnMetadataTest.java b/src/test/java/org/avniproject/etl/domain/metadata/ColumnMetadataTest.java index 40c1407..64779cc 100644 --- a/src/test/java/org/avniproject/etl/domain/metadata/ColumnMetadataTest.java +++ b/src/test/java/org/avniproject/etl/domain/metadata/ColumnMetadataTest.java @@ -17,7 +17,7 @@ class ColumnMetadataTest { @Test public void shouldRenameColumnIfNecessary() { - OrgIdentityContextHolder.setContext(OrganisationIdentity.createForOrganisation("dbUser", "schema")); + OrgIdentityContextHolder.setContext(OrganisationIdentity.createForOrganisation("dbUser", "schema", "mediaDirectory")); String uuid = UUID.randomUUID().toString(); ColumnMetadata oldColumnMetadata = new ColumnMetadata(new Column("oldName", Column.Type.text), 12, ColumnMetadata.ConceptType.Text, uuid); ColumnMetadata newColumnMetadata = new ColumnMetadata(new Column("newName", Column.Type.text), 12, ColumnMetadata.ConceptType.Text, uuid); diff --git a/src/test/java/org/avniproject/etl/domain/metadata/diff/AddColumnTest.java b/src/test/java/org/avniproject/etl/domain/metadata/diff/AddColumnTest.java index bd39f76..dfa6709 100644 --- a/src/test/java/org/avniproject/etl/domain/metadata/diff/AddColumnTest.java +++ b/src/test/java/org/avniproject/etl/domain/metadata/diff/AddColumnTest.java @@ -13,7 +13,7 @@ public class AddColumnTest { @Test public void shouldAddColumn() { - OrgIdentityContextHolder.setContext(OrganisationIdentity.createForOrganisation("dbUser", "schema")); + OrgIdentityContextHolder.setContext(OrganisationIdentity.createForOrganisation("dbUser", "schema", "mediaDirectory")); AddColumn addColumn = new AddColumn("table", new Column("name", Column.Type.text)); assertThat(addColumn.getSql(), is("alter table \"schema\".table add column \"name\" text;")); } @@ -30,7 +30,7 @@ public void checkNameLengthBeforeShortening() { public void shouldAddColumnWithLargeNameAfterShortening() { String columnName = "Total silt requested by the family members – Number of trolleys"; String shortenedColumnName = "Total silt requested by the family members – Nu (1206887472)"; - OrgIdentityContextHolder.setContext(OrganisationIdentity.createForOrganisation("dbUser", "schema")); + OrgIdentityContextHolder.setContext(OrganisationIdentity.createForOrganisation("dbUser", "schema", "mediaDirectory")); AddColumn addColumn = new AddColumn("table", new Column(columnName, Column.Type.text)); assertThat(addColumn.getSql(), is("alter table \"schema\".table add column \""+shortenedColumnName+"\" text;")); } diff --git a/src/test/java/org/avniproject/etl/domain/metadata/diff/CreateTableTest.java b/src/test/java/org/avniproject/etl/domain/metadata/diff/CreateTableTest.java index b2d34dc..e6a4f63 100644 --- a/src/test/java/org/avniproject/etl/domain/metadata/diff/CreateTableTest.java +++ b/src/test/java/org/avniproject/etl/domain/metadata/diff/CreateTableTest.java @@ -14,12 +14,12 @@ public class CreateTableTest { @BeforeEach public void before() { - OrgIdentityContextHolder.setContext(OrganisationIdentity.createForOrganisation("dbUser", "schema")); + OrgIdentityContextHolder.setContext(OrganisationIdentity.createForOrganisation("dbUser", "schema", "mediaDirectory")); } @Test public void shouldCreateSqlWithCommonColumns() { - OrgIdentityContextHolder.setContext(OrganisationIdentity.createForOrganisation("dbUser", "schema")); + OrgIdentityContextHolder.setContext(OrganisationIdentity.createForOrganisation("dbUser", "schema", "mediaDirectory")); TableMetadata tableMetadata = new TableMetadata(); tableMetadata.setName("tableName"); diff --git a/src/test/java/org/avniproject/etl/domain/metadata/diff/RenameColumnTest.java b/src/test/java/org/avniproject/etl/domain/metadata/diff/RenameColumnTest.java index b97f0df..72805e4 100644 --- a/src/test/java/org/avniproject/etl/domain/metadata/diff/RenameColumnTest.java +++ b/src/test/java/org/avniproject/etl/domain/metadata/diff/RenameColumnTest.java @@ -11,7 +11,7 @@ class RenameColumnTest { @Test public void shouldCreateSqlForRenamingColumn() { - OrgIdentityContextHolder.setContext(OrganisationIdentity.createForOrganisation("dbUser", "schema")); + OrgIdentityContextHolder.setContext(OrganisationIdentity.createForOrganisation("dbUser", "schema", "mediaDirectory")); RenameColumn renameColumn = new RenameColumn("table_name", "oldName", "newName"); System.out.println(renameColumn.getSql()); assertThat(renameColumn.getSql(), is("alter table \"schema\".table_name rename column \"oldName\" to \"newName\";")); diff --git a/src/test/java/org/avniproject/etl/domain/metadata/diff/RenameTableTest.java b/src/test/java/org/avniproject/etl/domain/metadata/diff/RenameTableTest.java index 55fb18b..d6dc0f3 100644 --- a/src/test/java/org/avniproject/etl/domain/metadata/diff/RenameTableTest.java +++ b/src/test/java/org/avniproject/etl/domain/metadata/diff/RenameTableTest.java @@ -11,7 +11,7 @@ public class RenameTableTest { @Test public void shouldRenameTable() { - OrgIdentityContextHolder.setContext(OrganisationIdentity.createForOrganisation("dbUser", "schema")); + OrgIdentityContextHolder.setContext(OrganisationIdentity.createForOrganisation("dbUser", "schema", "mediaDirectory")); RenameTable renameTable = new RenameTable("old_name", "new_name"); assertThat(renameTable.getSql(), is("alter table \"schema\".old_name rename to new_name;")); } diff --git a/src/test/java/org/avniproject/etl/repository/AvniMetadataRepositoryTest.java b/src/test/java/org/avniproject/etl/repository/AvniMetadataRepositoryTest.java index d20a94b..6c52b2f 100644 --- a/src/test/java/org/avniproject/etl/repository/AvniMetadataRepositoryTest.java +++ b/src/test/java/org/avniproject/etl/repository/AvniMetadataRepositoryTest.java @@ -22,7 +22,7 @@ public class AvniMetadataRepositoryTest extends BaseIntegrationTest { @Sql({"/test-data-teardown.sql", "/test-data.sql"}) @Sql(scripts = {"/test-data-teardown.sql"}, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD) public void shouldGetConceptName() { - OrgIdentityContextHolder.setContext(OrganisationIdentity.createForOrganisation("orgc", "orgc")); + OrgIdentityContextHolder.setContext(OrganisationIdentity.createForOrganisation("orgc", "orgc", "orgc")); String conceptName = avniMetadataRepository.conceptName("f005ccf7-f714-4615-a2a0-26efa2da6491"); assertThat(conceptName, is("Numeric Question")); } @@ -31,7 +31,7 @@ public void shouldGetConceptName() { @Sql({"/test-data-teardown.sql", "/test-data.sql"}) @Sql(scripts = {"/test-data-teardown.sql"}, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD) public void shouldLookForConceptNameWithinOrganisation() { - OrgIdentityContextHolder.setContext(OrganisationIdentity.createForOrganisation("orgb", "orgb")); + OrgIdentityContextHolder.setContext(OrganisationIdentity.createForOrganisation("orgb", "orgb", "orgb")); assertThrows(Exception.class, () -> avniMetadataRepository.conceptName("f005ccf7-f714-4615-a2a0-26efa2da6491")); } @@ -39,7 +39,7 @@ public void shouldLookForConceptNameWithinOrganisation() { @Sql({"/test-data-teardown.sql", "/test-data.sql"}) @Sql(scripts = {"/test-data-teardown.sql"}, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD) public void shouldRetrieveSyncRegistrationConcepts() { - OrgIdentityContextHolder.setContext(OrganisationIdentity.createForOrganisation("orgc", "orgc")); + OrgIdentityContextHolder.setContext(OrganisationIdentity.createForOrganisation("orgc", "orgc", "orgc")); SyncRegistrationConcept[] syncRegistrationConcepts = avniMetadataRepository.findSyncRegistrationConcepts("a95d8951-17e4-408d-98b0-ef3a6c982b96"); SyncRegistrationConcept concept1 = syncRegistrationConcepts[0]; assertThat(concept1.getUuid(), is("701b68df-dc52-4d69-ab91-f03a70ac1bbc")); diff --git a/src/test/java/org/avniproject/etl/repository/SchemaMetadataRepositoryTest.java b/src/test/java/org/avniproject/etl/repository/SchemaMetadataRepositoryTest.java index 3e32aae..d62dc3c 100644 --- a/src/test/java/org/avniproject/etl/repository/SchemaMetadataRepositoryTest.java +++ b/src/test/java/org/avniproject/etl/repository/SchemaMetadataRepositoryTest.java @@ -24,7 +24,7 @@ public class SchemaMetadataRepositoryTest extends BaseIntegrationTest { @BeforeEach public void before() { - OrganisationIdentity orgb = OrganisationIdentity.createForOrganisation("orgc", "orgc"); + OrganisationIdentity orgb = OrganisationIdentity.createForOrganisation("orgc", "orgc", "orgc"); OrgIdentityContextHolder.setContext(orgb); } diff --git a/src/test/java/org/avniproject/etl/service/EtlServiceIntegrationTest.java b/src/test/java/org/avniproject/etl/service/EtlServiceIntegrationTest.java index 3f163fa..b40aaae 100644 --- a/src/test/java/org/avniproject/etl/service/EtlServiceIntegrationTest.java +++ b/src/test/java/org/avniproject/etl/service/EtlServiceIntegrationTest.java @@ -22,8 +22,8 @@ public class EtlServiceIntegrationTest extends BaseIntegrationTest { @Sql(scripts = {"/test-data-teardown.sql"}, executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD) public void shouldNotFailWhenRunTwice() { - etlService.runFor(OrganisationIdentity.createForOrganisation("orgc", "orgc")); - etlService.runFor(OrganisationIdentity.createForOrganisation("orgc", "orgc")); + etlService.runFor(OrganisationIdentity.createForOrganisation("orgc", "orgc", "orgc")); + etlService.runFor(OrganisationIdentity.createForOrganisation("orgc", "orgc", "orgc")); assertThat(countOfRowsIn("orgc.goat"), equalTo(1L)); assertThat(countOfRowsIn("orgc.household"), equalTo(1L));