#647 - Switch to AssertJ and upgrade to Mockito 2.
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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}.
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user