[issue - 46] fix logic of updateStatus()
@@ -164,10 +164,7 @@ public class PlaceServiceImpl implements PlaceService {
log.info(LogMessage.IN_UPDATE_PLACE_STATUS, id, status);
Place updatable = findById(id);
- if (updatable.getStatus() == null) {
- throw new NullPointerException(ErrorMessage.PLACE_STATUS_IS_NULL);
- }
-
+ if (updatable.getStatus() != null) {
if (!updatable.getStatus().equals(status)) {
updatable.setStatus(status);
updatable.setModifiedDate(DateTimeService.getDateTime(AppConstant.UKRAINE_TIMEZONE));
@@ -176,6 +173,9 @@ public class PlaceServiceImpl implements PlaceService {
throw new PlaceStatusException(
ErrorMessage.PLACE_STATUS_NOT_DIFFERENT + updatable.getStatus());
}
+ } else {
+ throw new NullPointerException(ErrorMessage.PLACE_STATUS_IS_NULL);
+ }
return modelMapper.map(placeRepo.save(updatable), PlaceStatusDto.class);
}
