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

TestZFrame validation methods should be moved to common methods #887

Open
sonalgoyal opened this issue Aug 28, 2024 · 0 comments
Open

TestZFrame validation methods should be moved to common methods #887

sonalgoyal opened this issue Aug 28, 2024 · 0 comments
Assignees

Comments

@sonalgoyal
Copy link
Member

Duplicate code like

for (int idx = 0; idx < sampleData.size(); idx++) {
            R row = rows.get(idx);
            for (Field column : fields) {
                String columnName  = column.getName();
                if (column.getType() == String.class) {
                    assertEquals(column.get(sampleData.get(idx)), zFrameSortedDesc.getAsString(row, columnName),
                            "value in ZFrame and sample input is not same");
                } else if (column.getType() == Integer.class) {
                    assertEquals(column.get(sampleData.get(idx)), zFrameSortedDesc.getAsInt(row, columnName),
                            "value in ZFrame and sample input is not same");
                } else if (column.getType() == Double.class) {
                    assertEquals(column.get(sampleData.get(idx)), zFrameSortedDesc.getAsDouble(row, columnName),
                            "value in ZFrame and sample input is not same");
                } else if (column.getType() == Long.class) {
                    assertEquals(column.get(sampleData.get(idx)), zFrameSortedDesc.getAsLong(row, columnName),
                            "value in ZFrame and sample input is not same");
                } else {
                    throw new Exception("Not a valid data type");
                }
            }
        }

AND

for (Person schema : sampleDataWithDistinctSurnameAndPostCode) {
            for (R row : rows) {
                boolean rowMatched = true;
                for (Field column : fields) {
                    String columnName = column.getName();
                    if (!column.get(schema).toString().
                            equals(zFrame.getAsString(row, columnName))) {
                        rowMatched = false;
                        break;
                    }
                }
                if (rowMatched) {
                    matchedCount++;
                    break;
                }
            }
        }


        assertEquals(rows.size(), matchedCount,
                "rows count is not as expected");
        assertEquals(sampleDataWithDistinctSurnameAndPostCode.size(), matchedCount,
                "rows count is not as expected");
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

No branches or pull requests

2 participants