Skip to content

Commit

Permalink
#102 | Fix Build break
Browse files Browse the repository at this point in the history
  • Loading branch information
himeshr committed Jul 17, 2024
1 parent 6a03e37 commit 8084e4b
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 22 deletions.
14 changes: 7 additions & 7 deletions src/test/java/org/avniproject/etl/DataSyncIntegrationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Map<String, Object>> getPersons() {
Expand Down Expand Up @@ -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<Map<String, Object>> groupList = jdbcTemplate.queryForList("select * from og.person;");
Expand All @@ -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<Map<String, Object>> groupList = jdbcTemplate.queryForList("select * from og.person;");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ 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;
return this;
}

public OrganisationIdentity build() {
return OrganisationIdentity.createForOrganisation(dbUser, schemaName);
return OrganisationIdentity.createForOrganisation(dbUser, schemaName, mediaDirectory);
}

public OrganisationIdentityBuilder withDbUser(String dbUser) {
Expand All @@ -25,4 +26,9 @@ public OrganisationIdentityBuilder withSchemaName(String schemaName) {
this.schemaName = schemaName;
return this;
}

public OrganisationIdentityBuilder withMediaDirectory(String mediaDirectory) {
this.mediaDirectory = mediaDirectory;
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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())));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;"));
}
Expand All @@ -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;"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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\";"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
}
Expand All @@ -31,15 +31,15 @@ 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"));
}

@Test
@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"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 8084e4b

Please sign in to comment.