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

Add several value check via Cucucumber Data Table and Soft Assertions #117

Open
DmitryPrigodich opened this issue Dec 4, 2017 · 0 comments

Comments

@DmitryPrigodich
Copy link

DmitryPrigodich commented Dec 4, 2017

Currently all the checks are done via separate steps.
It's not that good as test would fail on the first incorrect result.
As an option I would suggest following solution:

@And("^LDAP entity by DN \"([^\"]+)\" attributes values should (|not )match:$")
public void checkEntityAttributesInLDAP(String dn, String condition, List<Map<String, String>> attributes) {
    boolean shouldMatch = condition.isEmpty();
    Attributes entity = entityFacade.getEntityByDn(dn);
    SoftAssertions softly = new SoftAssertions();
    String attrName, expectedValue;
    for (Map<String, String> map : attributes) {
        attrName = map.get("attribute");
        expectedValue = inflater.inflate(map.get("value"));
        Attribute attribute = entity.get(attrName);
        softly.assertThat(
            attribute.contains(expectedValue) && shouldMatch
        ).as(String.format("LDAP entity by DN %s attribute '%s' %scontains expected value '%s'",
                dn, attribute.getID(), shouldMatch ? "" : "not ", expectedValue)
        ).isTrue();
    }
    softly.assertAll();
}

As the result, following step would be possible:

        * LDAP entity by DN "{(DN)}" attributes values should match:
            | attribute   | value    |
            | attr1         | value1  |
            | attr2         | value2  |

or even:

        * LDAP entity by DN "{(DN)}" attributes values should match:
            | attribute   | value    | operation |
            | attr1         | value1  | equals |
            | attr2         | value2  | not equals |
            | attr3         | value3  | empty |
            | attr4         | value4  | not empty |
            | attr5         | value1  | contains|
            | attr6         | value2  | not contains |
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

1 participant