From c0125c99a8d9ca9a2b776f23edc366b3f40e5adb Mon Sep 17 00:00:00 2001 From: Oliver Drotbohm Date: Wed, 6 Oct 2021 12:35:09 +0200 Subject: [PATCH] Qualify references to ResourceType.COLLECTION to avoid ambiguities to AssertJ in tests. Fixes #2071. --- .../CrudMethodsSupportedHttpMethodsUnitTests.java | 11 ++++++----- .../RootResourceInformationIntegrationTests.java | 6 +++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/spring-data-rest-core/src/test/java/org/springframework/data/rest/core/mapping/CrudMethodsSupportedHttpMethodsUnitTests.java b/spring-data-rest-core/src/test/java/org/springframework/data/rest/core/mapping/CrudMethodsSupportedHttpMethodsUnitTests.java index 69275712b..1eb4445df 100755 --- a/spring-data-rest-core/src/test/java/org/springframework/data/rest/core/mapping/CrudMethodsSupportedHttpMethodsUnitTests.java +++ b/spring-data-rest-core/src/test/java/org/springframework/data/rest/core/mapping/CrudMethodsSupportedHttpMethodsUnitTests.java @@ -61,8 +61,8 @@ public class CrudMethodsSupportedHttpMethodsUnitTests { SupportedHttpMethods supportedMethods = getSupportedHttpMethodsFor(RawRepository.class); - assertMethodsSupported(supportedMethods, COLLECTION, true, OPTIONS); - assertMethodsSupported(supportedMethods, COLLECTION, false, GET, PUT, POST, PATCH, DELETE, HEAD); + assertMethodsSupported(supportedMethods, ResourceType.COLLECTION, true, OPTIONS); + assertMethodsSupported(supportedMethods, ResourceType.COLLECTION, false, GET, PUT, POST, PATCH, DELETE, HEAD); assertMethodsSupported(supportedMethods, ITEM, true, OPTIONS); assertMethodsSupported(supportedMethods, ITEM, false, GET, PUT, POST, PATCH, DELETE, HEAD); @@ -82,8 +82,8 @@ public class CrudMethodsSupportedHttpMethodsUnitTests { SupportedHttpMethods supportedHttpMethods = getSupportedHttpMethodsFor(SampleRepository.class); - assertMethodsSupported(supportedHttpMethods, COLLECTION, true, GET, POST, OPTIONS, HEAD); - assertMethodsSupported(supportedHttpMethods, COLLECTION, false, PUT, PATCH, DELETE); + assertMethodsSupported(supportedHttpMethods, ResourceType.COLLECTION, true, GET, POST, OPTIONS, HEAD); + assertMethodsSupported(supportedHttpMethods, ResourceType.COLLECTION, false, PUT, PATCH, DELETE); } @Test // DATACMNS-589, DATAREST-409 @@ -133,7 +133,8 @@ public class CrudMethodsSupportedHttpMethodsUnitTests { reset(mappings); when(mappings.exposeMethodsByDefault()).thenReturn(false); - assertMethodsSupported(getSupportedHttpMethodsFor(MethodsExplicitlyExportedRepository.class), COLLECTION, true, + assertMethodsSupported(getSupportedHttpMethodsFor(MethodsExplicitlyExportedRepository.class), + ResourceType.COLLECTION, true, POST, OPTIONS); assertMethodsSupported(getSupportedHttpMethodsFor(MethodsExplicitlyExportedRepository.class), ITEM, true, OPTIONS, PUT, PATCH); diff --git a/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/RootResourceInformationIntegrationTests.java b/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/RootResourceInformationIntegrationTests.java index 51791d91e..33f8e0482 100755 --- a/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/RootResourceInformationIntegrationTests.java +++ b/spring-data-rest-tests/spring-data-rest-tests-jpa/src/test/java/org/springframework/data/rest/webmvc/RootResourceInformationIntegrationTests.java @@ -16,11 +16,11 @@ package org.springframework.data.rest.webmvc; import static org.assertj.core.api.Assertions.*; -import static org.springframework.data.rest.core.mapping.ResourceType.*; import static org.springframework.http.HttpMethod.*; import org.junit.Test; import org.junit.runner.RunWith; +import org.springframework.data.rest.core.mapping.ResourceType; import org.springframework.data.rest.core.mapping.SupportedHttpMethods; import org.springframework.data.rest.tests.AbstractControllerIntegrationTests; import org.springframework.data.rest.webmvc.jpa.Address; @@ -43,13 +43,13 @@ public class RootResourceInformationIntegrationTests extends AbstractControllerI public void getIsNotSupportedIfFindAllIsNotExported() { SupportedHttpMethods supportedMethods = getResourceInformation(Address.class).getSupportedMethods(); - assertThat(supportedMethods.getMethodsFor(COLLECTION)).doesNotContain(GET); + assertThat(supportedMethods.getMethodsFor(ResourceType.COLLECTION)).doesNotContain(GET); } @Test // DATAREST-217 public void postIsNotSupportedIfSaveIsNotExported() { SupportedHttpMethods supportedMethods = getResourceInformation(Address.class).getSupportedMethods(); - assertThat(supportedMethods.getMethodsFor(COLLECTION)).doesNotContain(POST); + assertThat(supportedMethods.getMethodsFor(ResourceType.COLLECTION)).doesNotContain(POST); } }