DATAREST-1176 - Add explicitly method annotated detection strategy
This commit is contained in:
committed by
Oliver Gierke
parent
d4a3ba1195
commit
5172f89281
@@ -25,6 +25,7 @@ import java.util.Set;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.springframework.data.annotation.ReadOnlyProperty;
|
||||
import org.springframework.data.annotation.Reference;
|
||||
@@ -47,6 +48,9 @@ import org.springframework.http.HttpMethod;
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class CrudMethodsSupportedHttpMethodsUnitTests {
|
||||
|
||||
@Mock
|
||||
private RepositoryResourceMappings mappings;
|
||||
|
||||
@Test // DATACMNS-589, DATAREST-409
|
||||
public void doesNotSupportAnyHttpMethodForEmptyRepository() {
|
||||
|
||||
@@ -118,12 +122,12 @@ public class CrudMethodsSupportedHttpMethodsUnitTests {
|
||||
assertMethodsSupported(getSupportedHttpMethodsFor(NoFindOne.class), ITEM, false, DELETE);
|
||||
}
|
||||
|
||||
private static SupportedHttpMethods getSupportedHttpMethodsFor(Class<?> repositoryInterface) {
|
||||
private SupportedHttpMethods getSupportedHttpMethodsFor(Class<?> repositoryInterface) {
|
||||
|
||||
RepositoryMetadata metadata = new DefaultRepositoryMetadata(repositoryInterface);
|
||||
CrudMethods crudMethods = new DefaultCrudMethods(metadata);
|
||||
|
||||
return new CrudMethodsSupportedHttpMethods(crudMethods);
|
||||
return new CrudMethodsSupportedHttpMethods(crudMethods, mappings);
|
||||
}
|
||||
|
||||
private static void assertMethodsSupported(SupportedHttpMethods methods, ResourceType type, boolean supported,
|
||||
|
||||
@@ -89,6 +89,19 @@ public class RepositoryDetectionStrategiesUnitTests {
|
||||
});
|
||||
}
|
||||
|
||||
@Test // DATAREST-1176
|
||||
public void onlyExplicitAnnotatedMethodsAreExposed() {
|
||||
|
||||
assertExposures(EXPLICIT_METHOD_ANNOTATED, new HashMap<Class<?>, Boolean>() {
|
||||
{
|
||||
put(AnnotatedRepository.class, true);
|
||||
put(HiddenRepository.class, false);
|
||||
put(PublicRepository.class, false);
|
||||
put(PackageProtectedRepository.class, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void assertExposures(RepositoryDetectionStrategy strategy, Map<Class<?>, Boolean> expected) {
|
||||
|
||||
for (Entry<Class<?>, Boolean> entry : expected.entrySet()) {
|
||||
|
||||
@@ -131,7 +131,8 @@ public class RepositoryMethodResourceMappingUnitTests {
|
||||
}
|
||||
|
||||
private RepositoryMethodResourceMapping getMappingFor(Method method) {
|
||||
return new RepositoryMethodResourceMapping(method, resourceMapping, metadata);
|
||||
RepositoryDetectionStrategy strategy = RepositoryDetectionStrategies.DEFAULT;
|
||||
return new RepositoryMethodResourceMapping(method, resourceMapping, metadata, strategy);
|
||||
}
|
||||
|
||||
static class Person {}
|
||||
|
||||
Reference in New Issue
Block a user