0

I'm using a lot of classes so I'll rather try to describe my code.

I have entity mapped to database with name field as so:

@Column(nullable=false, length=DataLengthConstants.STRING_SHORT)
private String name;

I'm using service for all CRUD operations. My edit() method:

public UserDto editUser(UserDto userDto) {
    Validate.notNull(userDto);
    Validate.notNull(userDto.getId());

    UserEntity formerEntity = userDao.findById(userDto.getId());

    UserEntity editedEntity = userDao.save(dtoToEntity(formerEntity, userDto));

    return entityToDto(editedEntity);
}

There are no null checkings or anything similar to the problem in DAO/DTO classes or in converter.

When I run my unit tests, I'm expecting to get PersistenceException when trying to save null name. When I run my testCreateUser() everything is fine, exception thrown. However, when trying to edit (same DAO method is used), nothing is thrown and null is stored in database.

Can you help me? I'll attach more info when needed. Thanks!

Jens
  • 67,715
  • 15
  • 98
  • 113
Martin D
  • 667
  • 1
  • 10
  • 25

0 Answers0