DATAREST-93 - Removed compiler warnings.

Removed dependency on jMock.
This commit is contained in:
Oliver Gierke
2013-06-05 23:50:28 +02:00
parent cb4056e351
commit 90c4b62428
45 changed files with 155 additions and 204 deletions

View File

@@ -27,6 +27,7 @@ import org.springframework.web.method.support.ModelAndViewContainer;
*
* @author Jon Brisbin
*/
@SuppressWarnings("deprecation")
public class PagingAndSortingMethodArgumentResolver implements HandlerMethodArgumentResolver {
private static final int DEFAULT_PAGE = 1; // We're 1-based, not 0-based

View File

@@ -30,8 +30,8 @@ public class PersistentEntityResourceHandlerMethodArgumentResolver implements Ha
return PersistentEntityResource.class.isAssignableFrom(parameter.getParameterType());
}
@SuppressWarnings({"unchecked"})
@Override
@SuppressWarnings({"unchecked", "rawtypes"})
public Object resolveArgument(MethodParameter parameter,
ModelAndViewContainer mavContainer,
NativeWebRequest webRequest,
@@ -49,7 +49,7 @@ public class PersistentEntityResourceHandlerMethodArgumentResolver implements Ha
}
Object obj = converter.read(domainType, request);
return new PersistentEntityResource(repoRequest.getPersistentEntity(),
return new PersistentEntityResource<Object>(repoRequest.getPersistentEntity(),
obj);
}

View File

@@ -41,7 +41,6 @@ public class RepositoryRestHandlerMapping extends RequestMappingHandlerMapping {
setOrder(Ordered.LOWEST_PRECEDENCE);
}
@SuppressWarnings({"unchecked"})
@Override
protected HandlerMethod lookupHandlerMethod(String lookupPath,
HttpServletRequest origRequest) throws Exception {

View File

@@ -33,7 +33,7 @@ class RepositoryRestRequest {
private final Link repoLink;
private final Object repository;
private final RepositoryMethodInvoker repoMethodInvoker;
private final PersistentEntity persistentEntity;
private final PersistentEntity<?, ?> persistentEntity;
private final ResourceMapping entityMapping;
public RepositoryRestRequest(RepositoryRestConfiguration config,
@@ -95,7 +95,7 @@ class RepositoryRestRequest {
return repoMethodInvoker;
}
PersistentEntity getPersistentEntity() {
PersistentEntity<?, ?> getPersistentEntity() {
return persistentEntity;
}
@@ -103,7 +103,7 @@ class RepositoryRestRequest {
return entityMapping;
}
void addNextLink(Page page, List<Link> links) {
void addNextLink(Page<?> page, List<Link> links) {
UriComponentsBuilder builder = UriComponentsBuilder.fromUri(baseUri);
// Add existing query parameters
addQueryParameters(request, builder);
@@ -114,7 +114,7 @@ class RepositoryRestRequest {
links.add(new Link(builder.build().toString(), "page.next"));
}
void addPrevLink(Page page, List<Link> links) {
void addPrevLink(Page<?> page, List<Link> links) {
UriComponentsBuilder builder = UriComponentsBuilder.fromUri(baseUri);
// Add existing query parameters
addQueryParameters(request, builder);

View File

@@ -6,7 +6,10 @@ package org.springframework.data.rest.webmvc;
* @author Jon Brisbin
*/
public class ResourceNotFoundException extends RuntimeException {
public ResourceNotFoundException() {
private static final long serialVersionUID = 7992904489502842099L;
public ResourceNotFoundException() {
super("Resource not found");
}

View File

@@ -8,7 +8,7 @@ import org.springframework.web.util.UriComponentsBuilder;
/**
* @author Jon Brisbin
*/
public class BaseUriLinkBuilder extends LinkBuilderSupport {
public class BaseUriLinkBuilder extends LinkBuilderSupport<BaseUriLinkBuilder> {
public BaseUriLinkBuilder(UriComponentsBuilder builder) {
super(builder);

View File

@@ -21,7 +21,7 @@ public class ConstraintViolationExceptionMessage {
MessageSource msgSrc,
Locale locale) {
this.cve = cve;
for(ConstraintViolation cv : cve.getConstraintViolations()) {
for(ConstraintViolation<?> cv : cve.getConstraintViolations()) {
messages.add(new ConstraintViolationMessage(cv, msgSrc, locale));
}
}

View File

@@ -10,15 +10,15 @@ import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.BeanFactoryUtils;
import org.springframework.beans.factory.ListableBeanFactory;
import org.springframework.orm.jpa.support.OpenEntityManagerInViewInterceptor;
import org.springframework.web.context.request.WebRequestInterceptor;
/**
* @author Jon Brisbin
*/
public class JpaHelper implements BeanFactoryAware {
private List interceptor = new ArrayList<Object>();
private List<WebRequestInterceptor> interceptor = new ArrayList<WebRequestInterceptor>();
@SuppressWarnings({"unchecked"})
@Override public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
String[] beanNames = BeanFactoryUtils.beanNamesForTypeIncludingAncestors(
(ListableBeanFactory)beanFactory,
@@ -32,7 +32,7 @@ public class JpaHelper implements BeanFactoryAware {
}
}
public List getInterceptors() {
public List<WebRequestInterceptor> getInterceptors() {
return interceptor;
}

View File

@@ -14,13 +14,11 @@ import org.springframework.validation.FieldError;
*/
public class RepositoryConstraintViolationExceptionMessage {
private final RepositoryConstraintViolationException violationException;
private final List<ValidationError> errors = new ArrayList<ValidationError>();
public RepositoryConstraintViolationExceptionMessage(RepositoryConstraintViolationException violationException,
MessageSource msgSrc,
Locale locale) {
this.violationException = violationException;
for(FieldError fe : violationException.getErrors().getFieldErrors()) {
List<Object> args = new ArrayList<Object>();

View File

@@ -36,7 +36,7 @@ public class RepositoryEntityLinks extends AbstractEntityLinks {
}
@Override public boolean supports(Class<?> delimiter) {
PersistentEntity persistentEntity = repositories.getPersistentEntity(delimiter);
PersistentEntity<?, ?> persistentEntity = repositories.getPersistentEntity(delimiter);
return (null != persistentEntity);
}
@@ -45,7 +45,7 @@ public class RepositoryEntityLinks extends AbstractEntityLinks {
if(null == repoInfo) {
throw new IllegalArgumentException(type + " is not managed by any repository.");
}
PersistentEntity persistentEntity = repositories.getPersistentEntity(type);
PersistentEntity<?, ?> persistentEntity = repositories.getPersistentEntity(type);
if(null == persistentEntity) {
throw new IllegalArgumentException(type + " is not managed by any repository.");
}
@@ -71,19 +71,20 @@ public class RepositoryEntityLinks extends AbstractEntityLinks {
throw new IllegalArgumentException(type + " is not managed by any repository.");
}
ResourceMapping repoMapping = getResourceMapping(config, repoInfo);
PersistentEntity persistentEntity = repositories.getPersistentEntity(type);
PersistentEntity<?, ?> persistentEntity = repositories.getPersistentEntity(type);
ResourceMapping entityMapping = getResourceMapping(config, persistentEntity);
return linkFor(type).slash(id).withRel(repoMapping.getRel() + "." + entityMapping.getRel());
}
private class PersistentEntityLinkBuilder implements LinkBuilder {
private final UriComponentsBuilder builder;
private final ResourceMapping repoMapping;
private final ResourceMapping entityMapping;
private PersistentEntityLinkBuilder(URI baseUri,
RepositoryInformation repoInfo,
PersistentEntity persistentEntity) {
PersistentEntity<?, ?> persistentEntity) {
this.repoMapping = getResourceMapping(config, repoInfo);
this.entityMapping = getResourceMapping(config, persistentEntity);
if(null == baseUri) {
@@ -101,7 +102,7 @@ public class RepositoryEntityLinks extends AbstractEntityLinks {
@Override public LinkBuilder slash(Object object) {
String path = String.format("%s", object);
if(object instanceof PersistentProperty) {
String propName = ((PersistentProperty)object).getName();
String propName = ((PersistentProperty<?>) object).getName();
if(entityMapping.hasResourceMappingFor(propName)) {
path = entityMapping.getResourceMappingFor(propName).getPath();
}

View File

@@ -1,17 +0,0 @@
package org.springframework.data.rest.webmvc;
import org.jmock.integration.junit4.JUnitRuleMockery;
import org.jmock.lib.legacy.ClassImposteriser;
/**
* Abstract base classes for JUnit tests that use JMock.
*
* @author Jon Brisbin
*/
public abstract class AbstractJMockTests {
protected JUnitRuleMockery context = new JUnitRuleMockery() {{
setImposteriser(ClassImposteriser.INSTANCE);
}};
}

View File

@@ -1,23 +0,0 @@
package org.springframework.data.rest.webmvc;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.junit.Before;
import org.junit.BeforeClass;
/**
* @author Jon Brisbin
*/
public abstract class AbstractServerEnabledTest {
private Server server;
@Before
public void setup() {
if(null == server) {
server = new Server(0);
}
}
}