|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2024 the original author or authors. |
| 2 | + * Copyright 2002-2025 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
52 | 52 | import org.springframework.stereotype.Controller;
|
53 | 53 |
|
54 | 54 | import static org.assertj.core.api.Assertions.assertThat;
|
| 55 | +import static org.assertj.core.api.Assertions.assertThatIllegalStateException; |
55 | 56 |
|
56 | 57 | /**
|
57 | 58 | * Tests for requests handled through {@code @EntityMapping} methods.
|
@@ -175,6 +176,18 @@ void batchingWithoutResult(Class<?> controllerClass) {
|
175 | 176 | assertError(helper, 2, "INTERNAL_ERROR", "Entity fetcher returned null or completed empty");
|
176 | 177 | }
|
177 | 178 |
|
| 179 | + @Test |
| 180 | + void unmappedEntity() { |
| 181 | + Map<String, Object> variables = |
| 182 | + Map.of("representations", List.of( |
| 183 | + Map.of("__typename", "Book", "id", "-99"), |
| 184 | + Map.of("__typename", "Book", "id", "4"), |
| 185 | + Map.of("__typename", "Book", "id", "5"))); |
| 186 | + |
| 187 | + assertThatIllegalStateException().isThrownBy(() -> executeWith(EmptyController.class, variables)) |
| 188 | + .withMessage("No EntityMapping method for federated type: 'Book'"); |
| 189 | + } |
| 190 | + |
178 | 191 | private static ResponseHelper executeWith(Class<?> controllerClass, Map<String, Object> variables) {
|
179 | 192 | ExecutionGraphQlRequest request = TestExecutionRequest.forDocumentAndVars(document, variables);
|
180 | 193 | Mono<ExecutionGraphQlResponse> responseMono = graphQlService(controllerClass).execute(request);
|
@@ -299,6 +312,13 @@ public GraphQLError handle(IllegalArgumentException ex, DataFetchingEnvironment
|
299 | 312 | }
|
300 | 313 |
|
301 | 314 |
|
| 315 | + @SuppressWarnings("unused") |
| 316 | + @Controller |
| 317 | + private static class EmptyController { |
| 318 | + |
| 319 | + } |
| 320 | + |
| 321 | + |
302 | 322 | private static class BookBatchService {
|
303 | 323 |
|
304 | 324 | public List<Book> book(List<Integer> idList, List<Map<String, Object>> representations) {
|
|
0 commit comments