Fix exception message during factory update with duplicate name (#11630)
parent
81b5a17136
commit
c8071e04bd
|
|
@ -56,7 +56,8 @@ public class JpaFactoryDao implements FactoryDao {
|
|||
try {
|
||||
doCreate(factory);
|
||||
} catch (DuplicateKeyException ex) {
|
||||
throw new ConflictException(ex.getLocalizedMessage());
|
||||
throw new ConflictException(
|
||||
format("Factory with name '%s' already exists for current user", factory.getName()));
|
||||
} catch (IntegrityConstraintViolationException ex) {
|
||||
throw new ConflictException(
|
||||
"Could not create factory with creator that refers on non-existent user");
|
||||
|
|
@ -73,7 +74,8 @@ public class JpaFactoryDao implements FactoryDao {
|
|||
try {
|
||||
return new FactoryImpl(doUpdate(update));
|
||||
} catch (DuplicateKeyException ex) {
|
||||
throw new ConflictException(ex.getLocalizedMessage());
|
||||
throw new ConflictException(
|
||||
format("Factory with name '%s' already exists for current user", update.getName()));
|
||||
} catch (RuntimeException ex) {
|
||||
throw new ServerException(ex.getLocalizedMessage(), ex);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -125,7 +125,10 @@ public class FactoryDaoTest {
|
|||
factoryDao.create(factory);
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = ConflictException.class)
|
||||
@Test(
|
||||
expectedExceptions = ConflictException.class,
|
||||
expectedExceptionsMessageRegExp =
|
||||
"Factory with name 'factoryName0' already exists for current user")
|
||||
public void shouldThrowConflictExceptionWhenCreatingFactoryWithExistingNameAndUserId()
|
||||
throws Exception {
|
||||
final FactoryImpl factory = createFactory(10, users[0].getId());
|
||||
|
|
@ -167,7 +170,10 @@ public class FactoryDaoTest {
|
|||
assertEquals(factoryDao.getById(update.getId()), update);
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = ConflictException.class)
|
||||
@Test(
|
||||
expectedExceptions = ConflictException.class,
|
||||
expectedExceptionsMessageRegExp =
|
||||
"Factory with name 'factoryName1' already exists for current user")
|
||||
public void shouldThrowConflictExceptionWhenUpdateFactoryWithExistingNameAndUserId()
|
||||
throws Exception {
|
||||
final FactoryImpl update = factories[0];
|
||||
|
|
|
|||
Loading…
Reference in New Issue