mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 23:45:44 +01:00
Fix injection for unit tests
This commit is contained in:
@@ -1,13 +1,16 @@
|
||||
package sonia.scm.api.rest;
|
||||
|
||||
import sonia.scm.AlreadyExistsException;
|
||||
import sonia.scm.api.v2.resources.ExceptionWithContextToErrorDtoMapper;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.ws.rs.core.Response.Status;
|
||||
import javax.ws.rs.ext.Provider;
|
||||
|
||||
@Provider
|
||||
public class AlreadyExistsExceptionMapper extends ContextualExceptionMapper<AlreadyExistsException> {
|
||||
public AlreadyExistsExceptionMapper() {
|
||||
super(AlreadyExistsException.class, Status.CONFLICT);
|
||||
@Inject
|
||||
public AlreadyExistsExceptionMapper(ExceptionWithContextToErrorDtoMapper mapper) {
|
||||
super(AlreadyExistsException.class, Status.CONFLICT, mapper);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
package sonia.scm.api.rest;
|
||||
|
||||
import sonia.scm.ConcurrentModificationException;
|
||||
import sonia.scm.api.v2.resources.ExceptionWithContextToErrorDtoMapper;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.ext.Provider;
|
||||
|
||||
@Provider
|
||||
public class ConcurrentModificationExceptionMapper extends ContextualExceptionMapper<ConcurrentModificationException> {
|
||||
public ConcurrentModificationExceptionMapper() {
|
||||
super(ConcurrentModificationException.class, Response.Status.CONFLICT);
|
||||
@Inject
|
||||
public ConcurrentModificationExceptionMapper(ExceptionWithContextToErrorDtoMapper mapper) {
|
||||
super(ConcurrentModificationException.class, Response.Status.CONFLICT, mapper);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,15 +12,15 @@ import javax.ws.rs.ext.ExceptionMapper;
|
||||
|
||||
public class ContextualExceptionMapper<E extends Throwable & ExceptionWithContext> implements ExceptionMapper<E> {
|
||||
|
||||
@Inject
|
||||
private ExceptionWithContextToErrorDtoMapper mapper;
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ContextualExceptionMapper.class);
|
||||
|
||||
private ExceptionWithContextToErrorDtoMapper mapper;
|
||||
|
||||
private final Response.Status status;
|
||||
private final Class<E> type;
|
||||
|
||||
public ContextualExceptionMapper(Class<E> type, Response.Status status) {
|
||||
public ContextualExceptionMapper(Class<E> type, Response.Status status, ExceptionWithContextToErrorDtoMapper mapper) {
|
||||
this.mapper = mapper;
|
||||
this.type = type;
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user