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 tests for validation errors in the addEakApplication mutation #1932

Open
seluianova opened this issue Feb 19, 2025 · 0 comments
Open

Add tests for validation errors in the addEakApplication mutation #1932

seluianova opened this issue Feb 19, 2025 · 0 comments
Assignees
Labels

Comments

@seluianova
Copy link
Contributor

seluianova commented Feb 19, 2025

Describe the Problem

We have data validity checks in the init blocks of the application class and its fields.
Such as:

    init {
        if (!onlySelectedIsPresent(entitlementByCardType, cardType)) {
            throw InvalidJsonException("The specified entitlement(s) do not match card type.")
        }
        if ((applicationType != null) != (cardType == BavariaCardType.BLUE)) {
            throw InvalidJsonException("Application type must not be null if and only if card type is blue.")
        }
        if (!wantsPhysicalCard && !wantsDigitalCard) {
            throw InvalidJsonException("Does not apply for a physical nor for a digital card.")
        }
        if (!hasAcceptedPrivacyPolicy) {
            throw InvalidJsonException("Has not accepted privacy policy.")
        }
        if (!givenInformationIsCorrectAndComplete) {
            throw InvalidJsonException("Has not confirmed that information is correct and complete.")
        }
    }

Integration tests should be added to check the response when an invalid application is sent.

In the current approach (see Verein360ApplicationTest class) we create an Application object, serialize it, and send in the request.
But it's not possible to create an application object with invalid values, such as givenInformationIsCorrectAndComplete = false because this will throw an exception.

Describe Your Preferred Solution

We need another approach to generate test requests.
For example, build application as a string, instead of an object?
Or create a fake test application class without init blocks?
Or think of better options.

Describe Possible Alternatives

Probably mock or spy objects can be used

Related Issues

Additional Information

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: No status
Development

When branches are created from issues, their pull requests are automatically linked.

1 participant