Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#2995]Fix header validation for all-repeatable forms. #3074

Merged
merged 8 commits into from
May 9, 2019

Conversation

stellanl
Copy link
Contributor

Before the PR (what is the issue or what needed to be done)

Forms with the first or all groups repeatable were not imported correctly

The solution

Handle that, chiefly by changing the verify() method.

Screenshots (if appropriate)

Checklist

  • Test plan
  • Copyright header
  • Code formatting
  • Documentation

@stellanl stellanl requested review from valllllll2000 and muloem and removed request for valllllll2000 April 24, 2019 10:00
@muloem muloem changed the base branch from develop to release/1.9.46 April 30, 2019 13:38
Copy link
Member

@muloem muloem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The root cause of issues was that the check for a question column was failing in the special case where there were only repeat question groups and no questions for the base sheet. However, maybe we can revise the implementation to address the fact that our assumption that there would always be a question on the base sheet has now changed.

Perhaps we can check to make sure that all sheets are validated and if no questions are found on any of them, we throw this particular "Question not found" error.

@muloem muloem changed the base branch from release/1.9.46 to develop May 6, 2019 09:25
Copy link
Member

@muloem muloem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest adding a @AfterClass method to cleanup the files that have been created.

sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, i - 1));

for (int j = 0; j < questionColumns; j++) {
row1.createCell(i + j).setCellValue(j + "|Question" + j);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a good idea to simulate what the real question IDs look like.. e.g. 1230001

File file1 = createValidTestSpreadsheet("/tmp/valid1.xlsx");
Map<Integer,String> errors = dimp.validate(file1);
for (Integer i: errors.keySet()) {
System.out.printf("Unexpected error, row %d: %s", i, errors.get(i));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case rather than print out the errors, since it’s supposed to be a valid test sheet, you should assert that errors is empty and that should be enough. If it isn’t empty I believe it prints out the error map

Map<Integer,String> errors = dimp.validate(file);
assertEquals(1, errors.size());
String err1 = errors.get(-11);
assertNotEquals(err1, null);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be more accurate to assertEquals() and actually copy the error text here?

@muloem muloem merged commit 503b5fe into develop May 9, 2019
@muloem muloem deleted the issue/2995-all-repeated-group-imports branch May 9, 2019 11:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants