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

GraphQlTester - ToEntity also converting data for sub-entities #1064

Open
Hugofbf21 opened this issue Oct 4, 2024 · 2 comments
Open

GraphQlTester - ToEntity also converting data for sub-entities #1064

Hugofbf21 opened this issue Oct 4, 2024 · 2 comments
Labels
status: feedback-reminder We've sent a reminder that we need additional information before we can continue status: waiting-for-feedback We need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged

Comments

@Hugofbf21
Copy link

Hugofbf21 commented Oct 4, 2024

Hello!
I have been writing some integration tests for my example class:

class ThingResponse(
        val Id: String,,
        val name: String,
        val isCool: Boolean,
        val associatedEntity: AssociatedEntity?
    )

class AssociatedEntity(
        Id: UUID,
        val name: String,
        val wow: String
    )

In the test:

val responseFlux = documentName("onSubscription")
                .variable("something", "123")
                .variable("Something else", "3b23e223-2edb-4f5e-8e96-2e2607abd22b")
                .executeSubscription()
                .toFlux()

            val verifier = StepVerifier.create(responseFlux)
                .assertNext { response ->
                    run {
                        // should bring 5 thingResponses
                        var entities = response.path("onSubscription").entityList(ThingResponse::class.java)
                            .hasSize(5).get()
                        // 2 thingResponses should come with associatedEntity
                        //TODO how could i get the associatedEntity? without acessing [i] 
                        // where i would know the index
                    }
                }
                .thenCancel()
                .verifyLater()

The variable entities the fields come all mapped correctly besides the associatedEntity that comes always at null, is there any way the conversion of data could "cascade" down to the sub entities?
If this is already implemented in another way it would be awesome to know as well.

Further clarification:

  • The subscription in itself returns a list of ThingResponse.
  • The AssociatedEntity comes by schema mapping and it's a nullable field. I don't want to be restricted by order of which values are returned from the subscription.
  • I would like to have a way to verify if that field comes null or not and if not to access its atributes.
  • If I try to access the possible nullable field by:
    response.path("onSubscription[3]. associatedEntity").entity(AssociatedEntity::class.java).get(). I can get a No results for path: $['data']['onSubscription'][3]['associatedEntity'])

How could I verify if it has a value and then get it.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Oct 4, 2024
@Hugofbf21 Hugofbf21 changed the title GraphQlTester - Also converting data for sub-entities GraphQlTester - ToEntity also converting data for sub-entities Oct 4, 2024
@rstoyanchev
Copy link
Contributor

Can you provide a small sample please?

@rstoyanchev rstoyanchev added the status: waiting-for-feedback We need additional information before we can continue label Oct 17, 2024
@spring-projects-issues
Copy link
Collaborator

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

@spring-projects-issues spring-projects-issues added the status: feedback-reminder We've sent a reminder that we need additional information before we can continue label Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: feedback-reminder We've sent a reminder that we need additional information before we can continue status: waiting-for-feedback We need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged
Projects
None yet
Development

No branches or pull requests

3 participants