Commit dd726282 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

unit test is properly checking against thrown exception

parent 8af689e3
......@@ -28,8 +28,8 @@ import lcsb.mapviewer.model.security.PrivilegeType;
import lcsb.mapviewer.model.user.*;
import lcsb.mapviewer.model.user.annotator.*;
import lcsb.mapviewer.services.InvalidTokenException;
import lcsb.mapviewer.services.utils.EmailSender;
import lcsb.mapviewer.services.interfaces.ILayoutService;
import lcsb.mapviewer.services.utils.EmailSender;
@Transactional(rollbackFor = UpdateConflictException.class)
@Service
......@@ -616,8 +616,12 @@ public class UserRestImpl extends BaseRestImpl {
throw new QueryException("Invalid input", e);
} catch (Exception e) {
if (e.getCause() instanceof ConstraintViolationException) {
// postgres
if (e.getCause().getCause().getMessage().contains("duplicate key value violates unique constraint")) {
throw new UpdateConflictException("Conflict when updating preferences.", e);
// hsqldb
} else if (e.getCause().getCause().getMessage().contains("unique constraint or index violation")) {
throw new UpdateConflictException("Conflict when updating preferences.", e);
}
}
throw e;
......
......@@ -105,7 +105,7 @@ public class UserControllerIntegrationTestWithoutTransaction extends ControllerI
int status = mockMvc.perform(request).andReturn().getResponse().getStatus();
assertNotEquals(500, status);
} catch (Exception e) {
} catch (Throwable e) {
e.printStackTrace();
exceptionHappened.setTrue();
} finally {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment