DATAREST-978 - Migrate ticket references in test code to Spring Framework style.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2016 the original author or authors.
|
||||
* Copyright 2014-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -68,10 +68,7 @@ public class AssociationLinksUnitTests {
|
||||
this.links = new Associations(mappings, config);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-262
|
||||
*/
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class) // DATAREST-262
|
||||
public void rejectsNullMappings() {
|
||||
new Associations(null, mock(RepositoryRestConfiguration.class));
|
||||
}
|
||||
@@ -81,36 +78,24 @@ public class AssociationLinksUnitTests {
|
||||
new Associations(mappings, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-262
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-262
|
||||
public void considersNullPropertyUnlinkable() {
|
||||
assertThat(links.isLinkableAssociation((PersistentProperty<?>) null), is(false));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-262
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-262
|
||||
public void consideredHiddenPropertyUnlinkable() {
|
||||
assertThat(links.isLinkableAssociation(entity.getPersistentProperty("hiddenProperty")), is(false));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-262
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-262
|
||||
public void considersUnexportedPropertyUnlinkable() {
|
||||
|
||||
KeyValuePersistentProperty property = entity.getPersistentProperty("unexportedProperty");
|
||||
assertThat(links.isLinkableAssociation(property), is(false));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-262
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-262
|
||||
public void createsLinkToAssociationProperty() {
|
||||
|
||||
PersistentProperty<?> property = entity.getPersistentProperty("property");
|
||||
@@ -120,10 +105,7 @@ public class AssociationLinksUnitTests {
|
||||
assertThat(associationLinks, hasItem(new Link("/base/property", "property")));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-262
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-262
|
||||
public void doesNotCreateLinksForHiddenProperty() {
|
||||
|
||||
PersistentProperty<?> property = entity.getPersistentProperty("hiddenProperty");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2015 the original author or authors.
|
||||
* Copyright 2014-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -29,20 +29,14 @@ import org.junit.Test;
|
||||
*/
|
||||
public class BaseUriUnitTests {
|
||||
|
||||
/**
|
||||
* @see DATAREST-276
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-276
|
||||
public void doesNotMatchNonOverlap() {
|
||||
|
||||
assertThat(new BaseUri(URI.create("foo")).getRepositoryLookupPath("/bar"), is(nullValue()));
|
||||
assertThat(new BaseUri(URI.create("http://localhost:8080/foo/")).getRepositoryLookupPath("/bar"), is(nullValue()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-276
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-276
|
||||
public void matchesSimpleBaseUri() {
|
||||
|
||||
BaseUri uri = new BaseUri(URI.create("foo"));
|
||||
@@ -50,10 +44,7 @@ public class BaseUriUnitTests {
|
||||
assertThat(uri.getRepositoryLookupPath("/foo"), isEmptyString());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-276
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-276
|
||||
public void ignoresTrailingSlash() {
|
||||
|
||||
BaseUri uri = new BaseUri(URI.create("foo/"));
|
||||
@@ -62,10 +53,7 @@ public class BaseUriUnitTests {
|
||||
assertThat(uri.getRepositoryLookupPath("/foo/"), isEmptyString());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-276
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-276
|
||||
public void ignoresLeadingSlash() {
|
||||
|
||||
BaseUri uri = new BaseUri(URI.create("/foo"));
|
||||
@@ -74,10 +62,7 @@ public class BaseUriUnitTests {
|
||||
assertThat(uri.getRepositoryLookupPath("/foo/"), isEmptyString());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-276
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-276
|
||||
public void matchesAbsoluteBaseUriOnOverlap() {
|
||||
|
||||
BaseUri uri = new BaseUri(URI.create("http://localhost:8080/foo/"));
|
||||
@@ -88,11 +73,7 @@ public class BaseUriUnitTests {
|
||||
assertThat(uri.getRepositoryLookupPath("/foo/people/"), is("/people"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-674
|
||||
* @see SPR-13455
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-674, SPR-13455
|
||||
public void repositoryLookupPathHandlesDoubleSlashes() {
|
||||
assertThat(BaseUri.NONE.getRepositoryLookupPath("/books//1"), is("/books/1"));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 the original author or authors.
|
||||
* Copyright 2016-2017 original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -41,10 +41,7 @@ public class CustomAcceptHeaderHttpServletRequestUnitTests {
|
||||
|
||||
HttpServletRequest request = new MockHttpServletRequest();
|
||||
|
||||
/**
|
||||
* @see DATAREST-863
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-863
|
||||
public void returnsRegisterdHeadersOnAccessForMultipleOnes() {
|
||||
|
||||
List<MediaType> mediaTypes = Arrays.asList(MediaType.APPLICATION_OCTET_STREAM, MediaType.APPLICATION_ATOM_XML);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 the original author or authors.
|
||||
* Copyright 2015-2017 original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -37,10 +37,7 @@ public class IncomingRequestUnitTests {
|
||||
this.request = new MockHttpServletRequest("PATCH", "/");
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-498
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-498
|
||||
public void identifiesJsonPatchRequestForRequestWithContentTypeParameters() {
|
||||
|
||||
request.addHeader("Content-Type", "application/json-patch+json;charset=UTF-8");
|
||||
@@ -51,10 +48,7 @@ public class IncomingRequestUnitTests {
|
||||
assertThat(incomingRequest.isJsonMergePatchRequest(), is(false));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-498
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-498
|
||||
public void identifiesJsonMergePatchRequestForRequestWithContentTypeParameters() {
|
||||
|
||||
request.addHeader("Content-Type", "application/merge-patch+json;charset=UTF-8");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
* Copyright 2014-2017 original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -53,26 +53,17 @@ public class PersistentEntityResourceUnitTests {
|
||||
this.resources = new Resources<EmbeddedWrapper>(Collections.singleton(wrapper));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-317
|
||||
*/
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class) // DATAREST-317
|
||||
public void rejectsNullPayload() {
|
||||
PersistentEntityResource.build(null, entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-317
|
||||
*/
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class) // DATAREST-317
|
||||
public void rejectsNullPersistentEntity() {
|
||||
PersistentEntityResource.build(payload, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-317
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-317
|
||||
public void defaultsEmbeddedsToEmptyResources() {
|
||||
|
||||
PersistentEntityResource resource = PersistentEntityResource.build(payload, entity).build();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 the original author or authors.
|
||||
* Copyright 2016-2017 original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -52,10 +52,7 @@ public class RepositoryCorsConfigurationAccessorUnitTests {
|
||||
accessor = new RepositoryCorsConfigurationAccessor(mappings, repositories, NoOpStringValueResolver.INSTANCE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-573
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-573
|
||||
public void createConfigurationShouldConstructCorsConfiguration() {
|
||||
|
||||
CorsConfiguration configuration = accessor.createConfiguration(AnnotatedRepository.class);
|
||||
@@ -69,10 +66,7 @@ public class RepositoryCorsConfigurationAccessorUnitTests {
|
||||
assertThat(configuration.getMaxAge(), is(1800L));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-573
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-573
|
||||
public void createConfigurationShouldConstructFullCorsConfiguration() {
|
||||
|
||||
CorsConfiguration configuration = accessor.createConfiguration(FullyConfiguredCorsRepository.class);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 the original author or authors.
|
||||
* Copyright 2016-2017 original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -64,10 +64,7 @@ public class RepositoryPropertyReferenceControllerUnitTests {
|
||||
|
||||
KeyValueMappingContext mappingContext = new KeyValueMappingContext();
|
||||
|
||||
/**
|
||||
* @see DATAREST-791
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-791
|
||||
public void usesRepositoryInvokerToLookupRelatedInstance() throws Exception {
|
||||
|
||||
KeyValuePersistentEntity<?> entity = mappingContext.getPersistentEntity(Sample.class);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 the original author or authors.
|
||||
* Copyright 2015-2017 original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -57,10 +57,7 @@ public class RepositoryRestExceptionHandlerUnitTests {
|
||||
logger.setLevel(logLevel);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-427
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-427
|
||||
public void handlesHttpMessageNotReadableException() {
|
||||
|
||||
ResponseEntity<ExceptionMessage> result = HANDLER
|
||||
@@ -69,10 +66,7 @@ public class RepositoryRestExceptionHandlerUnitTests {
|
||||
assertThat(result.getStatusCode(), is(HttpStatus.BAD_REQUEST));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-507
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-507
|
||||
public void handlesConflictCorrectly() {
|
||||
|
||||
ResponseEntity<ExceptionMessage> result = HANDLER.handleConflict(new DataIntegrityViolationException("Message!"));
|
||||
@@ -80,10 +74,7 @@ public class RepositoryRestExceptionHandlerUnitTests {
|
||||
assertThat(result.getStatusCode(), is(HttpStatus.CONFLICT));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-706
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-706
|
||||
public void forwardsExceptionForMiscellaneousFailure() {
|
||||
|
||||
String message = "My Message!";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2015 the original author or authors.
|
||||
* Copyright 2013-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -91,20 +91,14 @@ public class RepositoryRestHandlerMappingUnitTests {
|
||||
new RepositoryRestHandlerMapping(mappings, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-111
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-111
|
||||
public void returnsNullForUriNotMapped() throws Exception {
|
||||
|
||||
handlerMapping.afterPropertiesSet();
|
||||
assertThat(handlerMapping.lookupHandlerMethod("/foo", mockRequest), is(nullValue()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-111
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-111
|
||||
public void looksUpRepositoryEntityControllerMethodCorrectly() throws Exception {
|
||||
|
||||
when(mappings.exportsTopLevelResourceFor("/people")).thenReturn(true);
|
||||
@@ -117,10 +111,7 @@ public class RepositoryRestHandlerMappingUnitTests {
|
||||
assertThat(method.getMethod(), is(listEntitiesMethod));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-292
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-292
|
||||
public void returnsRepositoryHandlerMethodWithBaseUriConfigured() throws Exception {
|
||||
|
||||
when(mappings.exportsTopLevelResourceFor("/people")).thenReturn(true);
|
||||
@@ -135,10 +126,7 @@ public class RepositoryRestHandlerMappingUnitTests {
|
||||
assertThat(method.getMethod(), is(listEntitiesMethod));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-292
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-292
|
||||
public void returnsRootHandlerMethodWithBaseUriConfigured() throws Exception {
|
||||
|
||||
when(mappings.exportsTopLevelResourceFor("/people")).thenReturn(true);
|
||||
@@ -153,10 +141,7 @@ public class RepositoryRestHandlerMappingUnitTests {
|
||||
assertThat(method.getMethod(), is(rootHandlerMethod));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-276
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-276
|
||||
public void returnsRepositoryHandlerMethodForAbsoluteBaseUri() throws Exception {
|
||||
|
||||
when(mappings.exportsTopLevelResourceFor("/people")).thenReturn(true);
|
||||
@@ -171,10 +156,7 @@ public class RepositoryRestHandlerMappingUnitTests {
|
||||
assertThat(method.getMethod(), is(listEntitiesMethod));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-276
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-276
|
||||
public void returnsRepositoryHandlerMethodForAbsoluteBaseUriWithServletMapping() throws Exception {
|
||||
|
||||
when(mappings.exportsTopLevelResourceFor("/people")).thenReturn(true);
|
||||
@@ -190,10 +172,7 @@ public class RepositoryRestHandlerMappingUnitTests {
|
||||
assertThat(method.getMethod(), is(listEntitiesMethod));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-276
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-276
|
||||
public void refrainsFromMappingIfTheRequestDoesNotPointIntoAbsolutelyDefinedUriSpace() throws Exception {
|
||||
|
||||
when(mappings.exportsTopLevelResourceFor("/people")).thenReturn(true);
|
||||
@@ -207,10 +186,7 @@ public class RepositoryRestHandlerMappingUnitTests {
|
||||
assertThat(method, is(nullValue()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-276
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-276
|
||||
public void refrainsFromMappingWhenUrisDontMatch() throws Exception {
|
||||
|
||||
String baseUri = "foo";
|
||||
@@ -227,10 +203,7 @@ public class RepositoryRestHandlerMappingUnitTests {
|
||||
assertThat(method, is(nullValue()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-609
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-609
|
||||
public void rejectsUnexpandedUriTemplateWithNotFound() throws Exception {
|
||||
|
||||
when(mappings.exportsTopLevelResourceFor("/people")).thenReturn(true);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 the original author or authors.
|
||||
* Copyright 2015-2017 original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -28,18 +28,12 @@ import org.junit.Test;
|
||||
*/
|
||||
public class RepositorySearchesResourceUnitTests {
|
||||
|
||||
/**
|
||||
* @see DATAREST-515
|
||||
*/
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class) // DATAREST-515
|
||||
public void rejectsNullDomainType() {
|
||||
new RepositorySearchesResource(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-515
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-515
|
||||
public void returnsConfiguredDomainType() {
|
||||
assertThat(new RepositorySearchesResource(String.class).getDomainType(), is(typeCompatibleWith(String.class)));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 the original author or authors.
|
||||
* Copyright 2016-2017 original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -61,26 +61,17 @@ public class ResourceStatusUnitTests {
|
||||
doReturn(new HttpHeaders()).when(preparer).prepareHeaders(eq(entity), Matchers.any());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-835
|
||||
*/
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class) // DATAREST-835
|
||||
public void rejectsNullPreparer() {
|
||||
ResourceStatus.of(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-835
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-835
|
||||
public void returnsModifiedIfNoHeadersGiven() {
|
||||
assertModified(status.getStatusAndHeaders(new HttpHeaders(), new Sample(0), entity));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-835
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-835
|
||||
public void returnsNotModifiedForEntityWithRequestedETag() {
|
||||
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
@@ -89,10 +80,7 @@ public class ResourceStatusUnitTests {
|
||||
assertNotModified(status.getStatusAndHeaders(headers, new Sample(1), entity));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-835
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-835
|
||||
public void returnsNotModifiedIfEntityIsStillConsideredValid() {
|
||||
|
||||
doReturn(true).when(preparer).isObjectStillValid(Matchers.any(), Matchers.any(HttpHeaders.class));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
* Copyright 2014-2017 original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -54,10 +54,7 @@ public class RootResourceInformationUnitTests {
|
||||
this.information = new RootResourceInformation(metadata, entity, invoker);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-330
|
||||
*/
|
||||
@Test(expected = ResourceNotFoundException.class)
|
||||
@Test(expected = ResourceNotFoundException.class) // DATAREST-330
|
||||
public void throwsExceptionOnVerificationIfResourceIsNotExported() throws HttpRequestMethodNotSupportedException {
|
||||
|
||||
when(metadata.isExported()).thenReturn(false);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 the original author or authors.
|
||||
* Copyright 2015-2017 original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -47,26 +47,17 @@ public class ArgumentResolverPagingAndSortingTemplateVariablesUnitTests {
|
||||
@Mock HateoasSortHandlerMethodArgumentResolver sortResolver;
|
||||
@Mock UriComponentsBuilder builder;
|
||||
|
||||
/**
|
||||
* @see DATAREST-467
|
||||
*/
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class) // DATAREST-467
|
||||
public void rejectsNullArgumentResolverForPageable() {
|
||||
new ArgumentResolverPagingAndSortingTemplateVariables(null, sortResolver);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-467
|
||||
*/
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class) // DATAREST-467
|
||||
public void rejectsNullArgumentResolverForSort() {
|
||||
new ArgumentResolverPagingAndSortingTemplateVariables(pageableResolver, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-467
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-467
|
||||
public void supportsPageableAndSortMethodParameters() {
|
||||
|
||||
PagingAndSortingTemplateVariables variables = new ArgumentResolverPagingAndSortingTemplateVariables(
|
||||
@@ -77,18 +68,12 @@ public class ArgumentResolverPagingAndSortingTemplateVariablesUnitTests {
|
||||
assertThat(variables.supportsParameter(getParameterMock(Object.class)), is(false));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-467
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-467
|
||||
public void forwardsEnhanceRequestForPageable() {
|
||||
assertForwardsEnhanceFor(new PageRequest(0, 10), pageableResolver, sortResolver);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-467
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-467
|
||||
public void forwardsEnhanceRequestForSort() {
|
||||
assertForwardsEnhanceFor(new Sort("property"), sortResolver, pageableResolver);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2015 the original author or authors.
|
||||
* Copyright 2013-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -82,10 +82,7 @@ public class RepositoryRestMvConfigurationIntegrationTests {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-210
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-210
|
||||
public void assertEnableHypermediaSupportWorkingCorrectly() {
|
||||
|
||||
assertThat(context.getBean("entityLinksPluginRegistry"), is(notNullValue()));
|
||||
@@ -103,10 +100,7 @@ public class RepositoryRestMvConfigurationIntegrationTests {
|
||||
mapper.writeValueAsString(new RepositoryLinksResource());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-271
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-271
|
||||
public void assetConsidersPaginationCustomization() {
|
||||
|
||||
HateoasPageableHandlerMethodArgumentResolver resolver = context
|
||||
@@ -124,10 +118,7 @@ public class RepositoryRestMvConfigurationIntegrationTests {
|
||||
assertThat(params.get("mySize").get(0), is("7000"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-336
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-336
|
||||
public void objectMapperRendersDatesInIsoByDefault() throws Exception {
|
||||
|
||||
Sample sample = new Sample();
|
||||
@@ -143,18 +134,12 @@ public class RepositoryRestMvConfigurationIntegrationTests {
|
||||
assertThat(result, is((Object) formatter.print(sample.date, Locale.US)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-362
|
||||
*/
|
||||
@Test(expected = NoSuchBeanDefinitionException.class)
|
||||
@Test(expected = NoSuchBeanDefinitionException.class) // DATAREST-362
|
||||
public void doesNotExposePersistentEntityJackson2ModuleAsBean() {
|
||||
context.getBean(PersistentEntityJackson2Module.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-362
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-362
|
||||
public void registeredHttpMessageConvertersAreTypeConstrained() {
|
||||
|
||||
Collection<MappingJackson2HttpMessageConverter> converters = context
|
||||
@@ -166,10 +151,7 @@ public class RepositoryRestMvConfigurationIntegrationTests {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-424
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-424
|
||||
public void halHttpMethodConverterIsRegisteredBeforeTheGeneralOne() {
|
||||
|
||||
CollectingComponent component = context.getBean(CollectingComponent.class);
|
||||
@@ -179,10 +161,7 @@ public class RepositoryRestMvConfigurationIntegrationTests {
|
||||
assertThat(converters.get(1).getSupportedMediaTypes(), hasItem(RestMediaTypes.SCHEMA_JSON));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-424
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-424
|
||||
public void halHttpMethodConverterIsRegisteredAfterTheGeneralOneIfHalIsDisabledAsDefaultMediaType() {
|
||||
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(NonHalConfiguration.class);
|
||||
@@ -195,10 +174,7 @@ public class RepositoryRestMvConfigurationIntegrationTests {
|
||||
assertThat(converters.get(1).getSupportedMediaTypes(), hasItem(MediaTypes.HAL_JSON));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-431, DATACMNS-626
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-431, DATACMNS-626
|
||||
public void hasConvertersForPointAndDistance() {
|
||||
|
||||
ConversionService service = context.getBean("defaultConversionService", ConversionService.class);
|
||||
@@ -209,10 +185,7 @@ public class RepositoryRestMvConfigurationIntegrationTests {
|
||||
assertThat(service.canConvert(Distance.class, String.class), is(true));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-686
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-686
|
||||
public void defaultsEncodingForMessageSourceToUtfEight() {
|
||||
|
||||
MessageSourceAccessor accessor = context.getBean("resourceDescriptionMessageSourceAccessor",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2016 the original author or authors.
|
||||
* Copyright 2015-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -95,10 +95,7 @@ public class DomainObjectReaderUnitTests {
|
||||
this.reader = new DomainObjectReader(entities, new Associations(mappings, mock(RepositoryRestConfiguration.class)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-461
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-461
|
||||
public void doesNotConsiderIgnoredProperties() throws Exception {
|
||||
|
||||
SampleUser user = new SampleUser("firstname", "password");
|
||||
@@ -110,10 +107,7 @@ public class DomainObjectReaderUnitTests {
|
||||
assertThat(result.password, is("password"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-556
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-556
|
||||
public void considersMappedFieldNamesWhenApplyingNodeToDomainObject() throws Exception {
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
@@ -127,10 +121,7 @@ public class DomainObjectReaderUnitTests {
|
||||
assertThat(result.lastName, is("Beauford"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-605
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-605
|
||||
public void mergesMapCorrectly() throws Exception {
|
||||
|
||||
SampleUser user = new SampleUser("firstname", "password");
|
||||
@@ -146,10 +137,7 @@ public class DomainObjectReaderUnitTests {
|
||||
assertThat(result.relatedUsers.get("parent").name, is("Oliver"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-701
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-701
|
||||
@SuppressWarnings("unchecked")
|
||||
public void mergesNestedMapWithoutTypeInformation() throws Exception {
|
||||
|
||||
@@ -169,10 +157,7 @@ public class DomainObjectReaderUnitTests {
|
||||
assertThat(((Map<Object, Object>) object).get("c"), is((Object) "2"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-701
|
||||
*/
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class) // DATAREST-701
|
||||
public void rejectsMergingUnknownDomainObject() throws Exception {
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
@@ -181,10 +166,7 @@ public class DomainObjectReaderUnitTests {
|
||||
reader.readPut(node, "", mapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-705
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-705
|
||||
public void doesNotWipeIdAndVersionPropertyForPut() throws Exception {
|
||||
|
||||
VersionedType type = new VersionedType();
|
||||
@@ -203,10 +185,7 @@ public class DomainObjectReaderUnitTests {
|
||||
assertThat(result.version, is(1L));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-873
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-873
|
||||
public void doesNotApplyInputToReadOnlyFields() throws Exception {
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
@@ -220,10 +199,7 @@ public class DomainObjectReaderUnitTests {
|
||||
assertThat(reader.readPut(node, sample, mapper).createdDate, is(reference));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-931
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-931
|
||||
public void readsPatchForEntityNestedInCollection() throws Exception {
|
||||
|
||||
Phone phone = new Phone();
|
||||
@@ -240,10 +216,7 @@ public class DomainObjectReaderUnitTests {
|
||||
assertThat(result.phones.get(0).creationDate, is(notNullValue()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-919
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-919
|
||||
@SuppressWarnings("unchecked")
|
||||
public void readsComplexNestedMapsAndArrays() throws Exception {
|
||||
|
||||
@@ -281,10 +254,7 @@ public class DomainObjectReaderUnitTests {
|
||||
assertThat(sub4.get("c2"), is("new"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-938
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-938
|
||||
public void nestedEntitiesAreUpdated() throws Exception {
|
||||
|
||||
Inner inner = new Inner();
|
||||
@@ -307,10 +277,7 @@ public class DomainObjectReaderUnitTests {
|
||||
assertThat(result.inner, is(sameInstance(inner)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-937
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-937
|
||||
public void considersTransientProperties() throws Exception {
|
||||
|
||||
SampleWithTransient sample = new SampleWithTransient();
|
||||
@@ -325,10 +292,7 @@ public class DomainObjectReaderUnitTests {
|
||||
assertThat(result.temporary, is("new temp"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-953
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-953
|
||||
public void writesArrayForPut() throws Exception {
|
||||
|
||||
Child inner = new Child();
|
||||
@@ -345,10 +309,7 @@ public class DomainObjectReaderUnitTests {
|
||||
assertThat(result.inner.items.get(0).some, is("value"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-956
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-956
|
||||
public void writesArrayWithAddedItemForPut() throws Exception {
|
||||
|
||||
Child inner = new Child();
|
||||
@@ -369,10 +330,7 @@ public class DomainObjectReaderUnitTests {
|
||||
assertThat(result.inner.items.get(2).some, is("value3"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-956
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-956
|
||||
public void writesArrayWithRemovedItemForPut() throws Exception {
|
||||
|
||||
Child inner = new Child();
|
||||
@@ -392,10 +350,7 @@ public class DomainObjectReaderUnitTests {
|
||||
assertThat(result.inner.items.get(0).some, is("value"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-959
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-959
|
||||
public void addsElementToPreviouslyEmptyCollection() throws Exception {
|
||||
|
||||
Parent source = new Parent();
|
||||
@@ -410,10 +365,7 @@ public class DomainObjectReaderUnitTests {
|
||||
assertThat(result.inner.items.get(0).some, is("value"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-959
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-959
|
||||
@SuppressWarnings("unchecked")
|
||||
public void turnsObjectIntoCollection() throws Exception {
|
||||
|
||||
@@ -464,9 +416,7 @@ public class DomainObjectReaderUnitTests {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-556
|
||||
*/
|
||||
// DATAREST-556
|
||||
@JsonAutoDetect(fieldVisibility = Visibility.ANY)
|
||||
static class Person {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 the original author or authors.
|
||||
* Copyright 2015-2017 original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -47,42 +47,27 @@ public class EnumTranslatorUnitTests {
|
||||
this.configuration = new EnumTranslator(new MessageSourceAccessor(messageSource));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-654
|
||||
*/
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class) // DATAREST-654
|
||||
public void rejectsNullMessageSourceAccessor() {
|
||||
new EnumTranslator(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-654
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-654
|
||||
public void parsesNullForNullSource() {
|
||||
assertThat(configuration.fromText(MyEnum.class, null), is(nullValue()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-654
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-654
|
||||
public void parsesNullForEmptySource() {
|
||||
assertThat(configuration.fromText(MyEnum.class, null), is(nullValue()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-654
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-654
|
||||
public void parsesNullForUnknownValue() {
|
||||
assertThat(configuration.fromText(MyEnum.class, "Foobar"), is(nullValue()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-654
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-654
|
||||
public void returnsEnumNameIfDefaultTranslationIsDisabled() {
|
||||
|
||||
configuration.setEnableDefaultTranslation(false);
|
||||
@@ -90,19 +75,13 @@ public class EnumTranslatorUnitTests {
|
||||
assertThat(configuration.asText(MyEnum.SECOND_VALUE), is(MyEnum.SECOND_VALUE.name()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-654
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-654
|
||||
public void returnsDefaultTranslationByDefault() {
|
||||
|
||||
assertThat(configuration.asText(MyEnum.SECOND_VALUE), is("Second value"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-654
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-654
|
||||
public void parsesEnumNameIfDefaultTranslationIsDisabled() {
|
||||
|
||||
configuration.setEnableDefaultTranslation(false);
|
||||
@@ -110,20 +89,14 @@ public class EnumTranslatorUnitTests {
|
||||
assertThat(configuration.fromText(MyEnum.class, "FIRST_VALUE"), is(MyEnum.FIRST_VALUE));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-654
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-654
|
||||
public void parsesStandardTranslationAndEnumNameByDefault() {
|
||||
|
||||
assertThat(configuration.fromText(MyEnum.class, "FIRST_VALUE"), is(MyEnum.FIRST_VALUE));
|
||||
assertThat(configuration.fromText(MyEnum.class, "Second value"), is(MyEnum.SECOND_VALUE));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-654
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-654
|
||||
public void translatesEnumName() {
|
||||
|
||||
LocaleContextHolder.setLocale(Locale.US);
|
||||
@@ -134,10 +107,7 @@ public class EnumTranslatorUnitTests {
|
||||
assertThat(configuration.asText(MyEnum.FIRST_VALUE), is("Translated"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-654
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-654
|
||||
public void parsesEnumNameByDefaultEvenIfMessageDefined() {
|
||||
|
||||
// Parses resolved message and enum name
|
||||
@@ -152,10 +122,7 @@ public class EnumTranslatorUnitTests {
|
||||
assertThat(configuration.fromText(MyEnum.class, "SECOND_VALUE"), is(MyEnum.SECOND_VALUE));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-654
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-654
|
||||
public void parsesEnumWithDefaultTranslationDisabled() {
|
||||
|
||||
configuration.setEnableDefaultTranslation(false);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2016 the original author or authors.
|
||||
* Copyright 2015-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -57,10 +57,7 @@ public class JacksonMetadataUnitTests {
|
||||
this.mapper.disable(MapperFeature.INFER_PROPERTY_MUTATORS);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-644
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-644
|
||||
public void detectsReadOnlyProperty() {
|
||||
|
||||
JacksonMetadata metadata = new JacksonMetadata(mapper, User.class);
|
||||
@@ -72,10 +69,7 @@ public class JacksonMetadataUnitTests {
|
||||
assertThat(metadata.isReadOnly(property), is(true));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-644
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-644
|
||||
public void reportsConstructorArgumentAsJacksonWritable() {
|
||||
|
||||
JacksonMetadata metadata = new JacksonMetadata(mapper, Value.class);
|
||||
@@ -86,10 +80,7 @@ public class JacksonMetadataUnitTests {
|
||||
assertThat(metadata.isReadOnly(property), is(false));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-644
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-644
|
||||
public void detectsCustomSerializerFortType() {
|
||||
|
||||
JsonSerializer<?> serializer = new JacksonMetadata(new ObjectMapper(), SomeBean.class)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 the original author or authors.
|
||||
* Copyright 2016-2017 original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -48,10 +48,7 @@ public class JacksonSerializersUnitTests {
|
||||
this.mapper.registerModule(new JacksonSerializers(translator));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-929
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-929
|
||||
public void translatesPlainEnumCorrectly() throws Exception {
|
||||
|
||||
Sample result = mapper.readValue("{ \"property\" : \"value\"}", Sample.class);
|
||||
@@ -59,10 +56,7 @@ public class JacksonSerializersUnitTests {
|
||||
assertThat(result.property, is(SampleEnum.VALUE));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-929
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-929
|
||||
public void translatesCollectionOfEnumsCorrectly() throws Exception {
|
||||
|
||||
Sample result = mapper.readValue("{ \"collection\" : [ \"value\" ] }", Sample.class);
|
||||
@@ -70,10 +64,7 @@ public class JacksonSerializersUnitTests {
|
||||
assertThat(result.collection, hasItem(SampleEnum.VALUE));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-929
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-929
|
||||
public void translatesEnumArraysCorrectly() throws Exception {
|
||||
|
||||
Sample result = mapper.readValue("{ \"array\" : [ \"value\" ] }", Sample.class);
|
||||
@@ -81,10 +72,7 @@ public class JacksonSerializersUnitTests {
|
||||
assertThat(result.array, hasItemInArray(SampleEnum.VALUE));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-929
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-929
|
||||
public void translatesMapEnumValueCorrectly() throws Exception {
|
||||
|
||||
Sample result = mapper.readValue("{ \"mapToEnum\" : { \"foo\" : \"value\" } }", Sample.class);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 the original author or authors.
|
||||
* Copyright 2015-2017 original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -32,10 +32,7 @@ public class JsonSchemaUnitTests {
|
||||
|
||||
static final TypeInformation<?> type = ClassTypeInformation.from(Sample.class);
|
||||
|
||||
/**
|
||||
* @see DATAREST-492
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-492
|
||||
public void considersNumberPrimitivesJsonSchemaNumbers() {
|
||||
|
||||
JsonSchemaProperty property = new JsonSchemaProperty("foo", null, "bar", false);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 the original author or authors.
|
||||
* Copyright 2016-2017 original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -39,40 +39,28 @@ public class MappedPropertiesUnitTests {
|
||||
KeyValuePersistentEntity<?> entity = context.getPersistentEntity(Sample.class);
|
||||
MappedProperties properties = MappedProperties.fromJacksonProperties(entity, mapper);
|
||||
|
||||
/**
|
||||
* @see DATAREST-575
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-575
|
||||
public void doesNotExposeMappedPropertyForNonSpringDataPersistentProperty() {
|
||||
|
||||
assertThat(properties.hasPersistentPropertyForField("notExposedBySpringData"), is(false));
|
||||
assertThat(properties.getPersistentProperty("notExposedBySpringData"), is(nullValue()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-575
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-575
|
||||
public void doesNotExposeMappedPropertyForNonJacksonProperty() {
|
||||
|
||||
assertThat(properties.hasPersistentPropertyForField("notExposedByJackson"), is(false));
|
||||
assertThat(properties.getPersistentProperty("notExposedByJackson"), is(nullValue()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-575
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-575
|
||||
public void exposesProperty() {
|
||||
|
||||
assertThat(properties.hasPersistentPropertyForField("exposedProperty"), is(true));
|
||||
assertThat(properties.getPersistentProperty("exposedProperty"), is(notNullValue()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-575
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-575
|
||||
public void exposesRenamedPropertyByExternalName() {
|
||||
|
||||
assertThat(properties.hasPersistentPropertyForField("email"), is(true));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 the original author or authors.
|
||||
* Copyright 2016-2017 original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -56,10 +56,7 @@ public class MappingAwarePageableArgumentResolverUnitTests {
|
||||
resolver = new MappingAwarePageableArgumentResolver(translator, delegate);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-906
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-906
|
||||
public void resolveArgumentShouldReturnTranslatedPageable() throws Exception {
|
||||
|
||||
Sort translated = new Sort("world");
|
||||
@@ -75,10 +72,7 @@ public class MappingAwarePageableArgumentResolverUnitTests {
|
||||
assertThat(result.getSort(), is(equalTo(translated)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-906
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-906
|
||||
public void resolveArgumentShouldReturnPageableWithoutSort() throws Exception {
|
||||
|
||||
Pageable pageable = new PageRequest(0, 1);
|
||||
@@ -92,10 +86,7 @@ public class MappingAwarePageableArgumentResolverUnitTests {
|
||||
assertThat(result.getSort(), is(nullValue()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-906
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-906
|
||||
public void resolveArgumentShouldReturnNoPageable() throws Exception {
|
||||
|
||||
Pageable result = resolver.resolveArgument(parameter, modelAndViewContainer, webRequest, binderFactory);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2016 the original author or authors.
|
||||
* Copyright 2014-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -102,10 +102,7 @@ public class PersistentEntityJackson2ModuleUnitTests {
|
||||
this.mapper.registerModule(module);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-328, DATAREST-320
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-328, DATAREST-320
|
||||
public void doesNotDropPropertiesWithCustomizedNames() throws Exception {
|
||||
|
||||
Sample sample = new Sample();
|
||||
@@ -116,10 +113,7 @@ public class PersistentEntityJackson2ModuleUnitTests {
|
||||
assertThat(JsonPath.read(result, "$.foo"), is((Object) "bar"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-340
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-340
|
||||
public void rendersAdditionalJsonPropertiesNotBackedByAPersistentField() throws Exception {
|
||||
|
||||
SampleWithAdditionalGetters sample = new SampleWithAdditionalGetters();
|
||||
@@ -128,10 +122,7 @@ public class PersistentEntityJackson2ModuleUnitTests {
|
||||
assertThat(JsonPath.read(result, "$.number"), is((Object) 5));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-662
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-662
|
||||
public void resolvesReferenceToSubtypeCorrectly() throws IOException {
|
||||
|
||||
PersistentProperty<?> property = persistentEntities.getPersistentEntity(PetOwner.class)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2015 the original author or authors.
|
||||
* Copyright 2014-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -51,10 +51,7 @@ public class ProjectionJacksonIntegrationTests {
|
||||
this.mapper.setHandlerInstantiator(new HalHandlerInstantiator(new EvoInflectorRelProvider(), null, null));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-221
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-221
|
||||
public void considersJacksonAnnotationsOnProjectionInterfaces() throws Exception {
|
||||
|
||||
Customer customer = new Customer();
|
||||
@@ -68,10 +65,7 @@ public class ProjectionJacksonIntegrationTests {
|
||||
assertThat(JsonPath.read(result, "$.firstname"), is((Object) "Dave"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-221
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-221
|
||||
public void rendersHalContentCorrectly() throws Exception {
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 the original author or authors.
|
||||
* Copyright 2016-2017 original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -60,10 +60,7 @@ public class SortTranslatorUnitTests {
|
||||
sortTranslator = new SortTranslator(persistentEntities, objectMapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-883
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-883
|
||||
public void shouldMapKnownProperties() {
|
||||
|
||||
Sort translatedSort = sortTranslator.translateSort(new Sort("hello", "name"),
|
||||
@@ -73,10 +70,7 @@ public class SortTranslatorUnitTests {
|
||||
assertThat(translatedSort.getOrderFor("name"), is(notNullValue()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-883
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-883
|
||||
public void returnsNullSortIfNoPropertiesMatch() {
|
||||
|
||||
Sort translatedSort = sortTranslator.translateSort(new Sort("hello", "world"),
|
||||
@@ -85,10 +79,7 @@ public class SortTranslatorUnitTests {
|
||||
assertThat(translatedSort, is(nullValue()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-883
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-883
|
||||
public void shouldMapKnownPropertiesWithJsonProperty() {
|
||||
|
||||
Sort translatedSort = sortTranslator.translateSort(new Sort("hello", "foo"),
|
||||
@@ -98,10 +89,7 @@ public class SortTranslatorUnitTests {
|
||||
assertThat(translatedSort.getOrderFor("name"), is(notNullValue()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-883
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-883
|
||||
public void shouldJacksonFieldNameForMapping() {
|
||||
|
||||
Sort translatedSort = sortTranslator.translateSort(new Sort("name"),
|
||||
@@ -110,10 +98,7 @@ public class SortTranslatorUnitTests {
|
||||
assertThat(translatedSort, is(nullValue()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-910
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-910
|
||||
public void shouldMapKnownNestedProperties() {
|
||||
|
||||
Sort translatedSort = sortTranslator.translateSort(
|
||||
@@ -125,10 +110,7 @@ public class SortTranslatorUnitTests {
|
||||
assertThat(translatedSort.getOrderFor("embedded.someInterface"), is(notNullValue()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-910
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-910
|
||||
public void shouldSkipWrongNestedProperties() {
|
||||
|
||||
Sort translatedSort = sortTranslator.translateSort(new Sort("embedded.unknown"),
|
||||
@@ -137,10 +119,7 @@ public class SortTranslatorUnitTests {
|
||||
assertThat(translatedSort, is(nullValue()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-910
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-910
|
||||
public void shouldSkipKnownAssociationProperties() {
|
||||
|
||||
Sort translatedSort = sortTranslator.translateSort(new Sort("refEmbedded.name"),
|
||||
@@ -149,10 +128,7 @@ public class SortTranslatorUnitTests {
|
||||
assertThat(translatedSort, is(nullValue()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-910
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-910
|
||||
public void shouldJacksonFieldNameForNestedFieldMapping() {
|
||||
|
||||
Sort translatedSort = sortTranslator.translateSort(new Sort("em.foo"),
|
||||
@@ -161,10 +137,7 @@ public class SortTranslatorUnitTests {
|
||||
assertThat(translatedSort.getOrderFor("embeddedWithJsonProperty.bar"), is(notNullValue()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-910
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-910
|
||||
public void shouldTranslatePathForSingleLevelJsonUnwrappedObject() {
|
||||
|
||||
Sort translatedSort = sortTranslator.translateSort(new Sort("un-name"),
|
||||
@@ -173,10 +146,7 @@ public class SortTranslatorUnitTests {
|
||||
assertThat(translatedSort.getOrderFor("embedded.name"), is(notNullValue()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-910
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-910
|
||||
public void shouldTranslatePathForMultiLevelLevelJsonUnwrappedObject() {
|
||||
|
||||
Sort translatedSort = sortTranslator.translateSort(new Sort("un-name", "burrito.un-name"),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2015 the original author or authors.
|
||||
* Copyright 2014-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -69,36 +69,24 @@ public class UriStringDeserializerUnitTests {
|
||||
ReflectionTestUtils.setField(context, "_parser", parser);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-316
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-316
|
||||
public void extractsUriToForwardToConverter() throws Exception {
|
||||
assertConverterInvokedWithUri("/foo/32", URI.create("/foo/32"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-316
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-316
|
||||
public void extractsUriFromTemplateToForwardToConverter() throws Exception {
|
||||
assertConverterInvokedWithUri("/foo/32{?projection}", URI.create("/foo/32"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-377
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-377
|
||||
public void returnsNullUriIfSourceIsEmptyOrNull() throws Exception {
|
||||
|
||||
assertThat(invokeConverterWith(""), is(nullValue()));
|
||||
assertThat(invokeConverterWith(null), is(nullValue()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-377
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-377
|
||||
public void rejectsNonUriValue() throws Exception {
|
||||
|
||||
exception.expect(JsonMappingException.class);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 the original author or authors.
|
||||
* Copyright 2016-2017 original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -59,10 +59,7 @@ public class WrappedPropertiesUnitTests {
|
||||
persistentEntities = new PersistentEntities(Collections.singleton(mappingContext));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-910
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-910
|
||||
public void wrappedPropertiesShouldConsiderSingleLevelUnwrapping() {
|
||||
|
||||
PersistentEntity<?, ?> persistentEntity = persistentEntities.getPersistentEntity(OneLevelNesting.class);
|
||||
@@ -81,10 +78,7 @@ public class WrappedPropertiesUnitTests {
|
||||
assertThat(street, contains(addressProperty, streetProperty));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-910
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-910
|
||||
public void wrappedPropertiesShouldConsiderMultiLevelUnwrapping() {
|
||||
|
||||
PersistentEntity<?, ?> persistentEntity = persistentEntities.getPersistentEntity(MultiLevelNesting.class);
|
||||
@@ -106,10 +100,7 @@ public class WrappedPropertiesUnitTests {
|
||||
assertThat(street, contains(oneLevelNestingProperty, addressProperty, streetProperty));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-910
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-910
|
||||
public void wrappedPropertiesShouldConsiderJacksonFieldNames() {
|
||||
|
||||
PersistentEntity<?, ?> persistentEntity = persistentEntities.getPersistentEntity(MultiLevelNesting.class);
|
||||
@@ -119,10 +110,7 @@ public class WrappedPropertiesUnitTests {
|
||||
assertThat(wrappedProperties.hasPersistentPropertiesForField("pre-zip-post"), is(true));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-910
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-910
|
||||
public void wrappedPropertiesShouldIgnoreIgnoredJacksonFields() {
|
||||
|
||||
PersistentEntity<?, ?> persistentEntity = persistentEntities.getPersistentEntity(MultiLevelNesting.class);
|
||||
@@ -132,10 +120,7 @@ public class WrappedPropertiesUnitTests {
|
||||
assertThat(wrappedProperties.hasPersistentPropertiesForField("pre-street-ignored"), is(false));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-910
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-910
|
||||
public void wrappedPropertiesShouldIgnoreSyntheticProperties() {
|
||||
|
||||
PersistentEntity<?, ?> persistentEntity = persistentEntities.getPersistentEntity(SyntheticProperties.class);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2016 the original author or authors.
|
||||
* Copyright 2014-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -121,10 +121,7 @@ public class JsonPatchTests {
|
||||
assertEquals("F", todos.get(5).getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-889
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-889
|
||||
public void patchArray() throws Exception {
|
||||
|
||||
Todo todo = new Todo(1L, "F", false);
|
||||
@@ -136,10 +133,7 @@ public class JsonPatchTests {
|
||||
assertEquals(Arrays.asList("one", "two", "three"), patchedTodo.getItems());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-889
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-889
|
||||
public void patchUnknownType() throws Exception {
|
||||
|
||||
Todo todo = new Todo();
|
||||
@@ -152,10 +146,7 @@ public class JsonPatchTests {
|
||||
readJsonPatch("patch-biginteger.json");
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-889
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-889
|
||||
public void failureWithInvalidPatchContent() throws Exception {
|
||||
|
||||
Todo todo = new Todo();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2016 the original author or authors.
|
||||
* Copyright 2014-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -68,10 +68,7 @@ public class ReplaceOperationTests {
|
||||
assertEquals("22", todos.get(1).getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-885
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-885
|
||||
public void replaceObjectPropertyValue() throws Exception {
|
||||
|
||||
Todo todo = new Todo(1L, "A", false);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 the original author or authors.
|
||||
* Copyright 2015-2017 original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -44,10 +44,7 @@ public class DelegatingHandlerMappingUnitTests {
|
||||
@Mock HandlerMapping first, second;
|
||||
@Mock HttpServletRequest request;
|
||||
|
||||
/**
|
||||
* @see DATAREST-490, DATAREST-522
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-490, DATAREST-522
|
||||
public void consultsAllHandlerMappingsAndThrowsExceptionEventually() throws Exception {
|
||||
|
||||
DelegatingHandlerMapping mapping = new DelegatingHandlerMapping(Arrays.asList(first, second));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
* Copyright 2014-2017 original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -24,18 +24,12 @@ import org.junit.Test;
|
||||
*/
|
||||
public class ETagDoesntMatchExceptionUnitTests {
|
||||
|
||||
/**
|
||||
* @see DATAREST-160
|
||||
*/
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class) // DATAREST-160
|
||||
public void rejectsNullTargetBean() {
|
||||
new ETagDoesntMatchException(null, ETag.from("1"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-160
|
||||
*/
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test(expected = IllegalArgumentException.class) // DATAREST-160
|
||||
public void rejectsNullExpectedETag() {
|
||||
new ETagDoesntMatchException(new Object(), null);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2016 the original author or authors.
|
||||
* Copyright 2014-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -38,28 +38,19 @@ public class ETagUnitTests {
|
||||
|
||||
KeyValueMappingContext context = new KeyValueMappingContext();
|
||||
|
||||
/**
|
||||
* @see DATAREST-160
|
||||
*/
|
||||
@Test(expected = ETagDoesntMatchException.class)
|
||||
@Test(expected = ETagDoesntMatchException.class) // DATAREST-160
|
||||
public void expectWrongEtag() throws Exception {
|
||||
|
||||
ETag eTag = ETag.from("1");
|
||||
eTag.verify(context.getPersistentEntity(Sample.class), new Sample(0L));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-160
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-160
|
||||
public void expectCorrectEtag() throws Exception {
|
||||
ETag.from("0").verify(context.getPersistentEntity(Sample.class), new Sample(0L));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-160
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-160
|
||||
public void createsETagFromVersionValue() throws Exception {
|
||||
|
||||
PersistentEntity<?, ?> entity = context.getPersistentEntity(Sample.class);
|
||||
@@ -68,34 +59,22 @@ public class ETagUnitTests {
|
||||
assertThat(from.toString(), is((Object) "\"0\""));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-160
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-160
|
||||
public void surroundsValueWithQuotationMarksOnToString() {
|
||||
assertThat(ETag.from("1").toString(), is("\"1\""));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-160
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-160
|
||||
public void returnsNoEtagForNullStringSource() {
|
||||
assertThat(ETag.from((String) null), is(ETag.NO_ETAG));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-160
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-160
|
||||
public void returnsNoEtagForNullPersistentEntityResourceSource() {
|
||||
assertThat(ETag.from((PersistentEntityResource) null), is(ETag.NO_ETAG));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-160
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-160
|
||||
public void hasValueObjectEqualsSemantics() {
|
||||
|
||||
ETag one = ETag.from("1");
|
||||
@@ -110,64 +89,43 @@ public class ETagUnitTests {
|
||||
assertThat(one.equals(""), is(false));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-160
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-160
|
||||
public void returnsNoEtagForEntityWithoutVersionProperty() {
|
||||
|
||||
PersistentEntity<?, ?> entity = context.getPersistentEntity(SampleWithoutVersion.class);
|
||||
assertThat(ETag.from(PersistentEntityResource.build(new SampleWithoutVersion(), entity).build()), is(ETag.NO_ETAG));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-160
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-160
|
||||
public void noETagReturnsNullForToString() {
|
||||
assertThat(ETag.NO_ETAG.toString(), is(nullValue()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-160
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-160
|
||||
public void noETagDoesNotRejectVerification() {
|
||||
ETag.NO_ETAG.verify(context.getPersistentEntity(Sample.class), new Sample(5L));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-160
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-160
|
||||
public void verificationDoesNotRejectNullEntity() {
|
||||
ETag.from("5").verify(context.getPersistentEntity(Sample.class), null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-160
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-160
|
||||
public void stripsTrailingAndLeadingQuotesOnCreation() {
|
||||
|
||||
assertThat(ETag.from("\"1\""), is(ETag.from("1")));
|
||||
assertThat(ETag.from("\"\"1\"\""), is(ETag.from("1")));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-160
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-160
|
||||
public void addsETagToHeadersIfNotNoETag() {
|
||||
|
||||
HttpHeaders headers = ETag.from("1").addTo(new HttpHeaders());
|
||||
assertThat(headers.getETag(), is(notNullValue()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-160
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-160
|
||||
public void doesNotAddHeaderForNoETag() {
|
||||
|
||||
HttpHeaders headers = ETag.NO_ETAG.addTo(new HttpHeaders());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2016 the original author or authors.
|
||||
* Copyright 2014-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -56,10 +56,7 @@ public class PersistentEntityProjectorUnitTests {
|
||||
doReturn(Excerpt.class).when(metadata).getExcerptProjection();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-221
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-221
|
||||
public void returnsObjectAsIsIfNoProjectionTypeFound() {
|
||||
|
||||
Object object = new Object();
|
||||
@@ -67,10 +64,7 @@ public class PersistentEntityProjectorUnitTests {
|
||||
assertThat(projector.project(object), is(object));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-221
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-221
|
||||
public void invokesProjectionFactoryIfProjectionFound() {
|
||||
|
||||
configuration.addProjection(Sample.class, Object.class);
|
||||
@@ -78,10 +72,7 @@ public class PersistentEntityProjectorUnitTests {
|
||||
assertThat(projector.project(new Object()), is(instanceOf(Sample.class)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-806
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-806
|
||||
public void favorsExplicitProjectionOverExcerpt() {
|
||||
|
||||
configuration.addProjection(Sample.class, Object.class);
|
||||
@@ -89,18 +80,12 @@ public class PersistentEntityProjectorUnitTests {
|
||||
assertThat(projector.projectExcerpt(new Object()), is(instanceOf(Sample.class)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-806
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-806
|
||||
public void excerptProjectionIsUsedForExcerpt() {
|
||||
assertThat(projector.projectExcerpt(new Object()), is(instanceOf(Excerpt.class)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-806
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-806
|
||||
public void usesExcerptProjectionIfNoExplicitProjectionWasRequested() {
|
||||
|
||||
configuration.addProjection(Sample.class, Object.class);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 the original author or authors.
|
||||
* Copyright 2016-2017 original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -32,10 +32,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
*/
|
||||
public class UriUtilsUnitTests {
|
||||
|
||||
/**
|
||||
* @see DATAREST-910
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-910
|
||||
public void pathSegmentsShouldDiscoverPathUsingMethodMapping() throws Exception {
|
||||
|
||||
Method method = ClassUtils.getMethod(MappedMethod.class, "method");
|
||||
@@ -44,10 +41,7 @@ public class UriUtilsUnitTests {
|
||||
assertThat(pathSegments, hasItems("hello", "world"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREST-910
|
||||
*/
|
||||
@Test
|
||||
@Test // DATAREST-910
|
||||
public void pathSegmentsShouldDiscoverPathUsingTypeAndMethodMapping() throws Exception {
|
||||
|
||||
Method method = ClassUtils.getMethod(MappedClassAndMethod.class, "method");
|
||||
|
||||
Reference in New Issue
Block a user