#647 - Switch to AssertJ and upgrade to Mockito 2.

This commit is contained in:
Oliver Gierke
2017-10-13 18:39:55 +02:00
parent b862919868
commit 35033fee0e
59 changed files with 697 additions and 736 deletions

View File

@@ -47,7 +47,7 @@ public class Hop {
/**
* Collection of URI Template parameters.
*/
private final @Wither Map<String, ? extends Object> parameters;
private final @Wither Map<String, Object> parameters;
/**
* Creates a new {@link Hop} for the given relation name.

View File

@@ -56,7 +56,7 @@ public class HeaderLinksResponseEntity<T extends ResourceSupport> extends Respon
* @param entity must not be {@literal null}.
*/
private HeaderLinksResponseEntity(HttpEntity<T> entity) {
this(new ResponseEntity<T>(entity.getBody(), entity.getHeaders(), HttpStatus.OK));
this(ResponseEntity.ok().headers(entity.getHeaders()).body(entity.getBody()));
}
/**
@@ -77,6 +77,20 @@ public class HeaderLinksResponseEntity<T extends ResourceSupport> extends Respon
}
}
/**
* Wraps the given {@link ResourceSupport} into a {@link HeaderLinksResponseEntity}. Will default the status code to
* {@link HttpStatus#OK}.
*
* @param entity must not be {@literal null}.
* @return
*/
public static <S extends ResourceSupport> HeaderLinksResponseEntity<S> wrap(S entity) {
Assert.notNull(entity, "ResourceSupport must not be null!");
return new HeaderLinksResponseEntity<>(ResponseEntity.ok(entity));
}
/**
* Returns the {@link Link}s contained in the {@link ResourceSupport} of the given {@link ResponseEntity} as
* {@link HttpHeaders}.

View File

@@ -126,7 +126,7 @@ public class ResourceProcessorHandlerMethodReturnValueHandler implements Handler
Object rewrapResult(ResourceSupport newBody, Object originalValue) {
if (!(originalValue instanceof HttpEntity)) {
return newBody;
return rootLinksAsHeaders ? HeaderLinksResponseEntity.wrap(newBody) : newBody;
}
HttpEntity<ResourceSupport> entity = null;
@@ -139,10 +139,6 @@ public class ResourceProcessorHandlerMethodReturnValueHandler implements Handler
entity = new HttpEntity<ResourceSupport>(newBody, source.getHeaders());
}
return addLinksToHeaderWrapper(entity);
}
private HttpEntity<?> addLinksToHeaderWrapper(HttpEntity<ResourceSupport> entity) {
return rootLinksAsHeaders ? HeaderLinksResponseEntity.wrap(entity) : entity;
}