@Test(expected = DuplicateChannelException.class) public void saveOrUpdateShouldThrowDuplicateChannelExceptionExceptionWhenChannelEntityExistsAndItsDeletedFieldIsFalse() { given(this.channelRepository.findByName(CHANNEL_NAME_FACEBOOK)).willReturn(facebookEntity); this.channelService.saveOrUpdate(facebookDto); }
@Transactional @Override public Long saveOrUpdate(ChannelDTO channel) { Assert.notNull(channel); Assert.notNull(channel.getName()); ChannelEntity channelEntity = this.channelRepository.findByName(channel.getName()); if (channelEntity == null) { channelEntity = this.converterService.convert(channel, ChannelEntity.class); } else if (channelEntity.isDeleted() != null && channelEntity.isDeleted()) { channelEntity.setDeleted(false); } else { throw new DuplicateChannelException(channel.getName()); } this.channelRepository.saveAndFlush(channelEntity); return channelEntity.getId(); }
ChannelServiceImpl extends AbstractLogicallyDeletableService<ChannelDTO, ChannelEntity> implements ChannelService { @Transactional @Override public Long saveOrUpdate(ChannelDTO channel) { Assert.notNull(channel); Assert.notNull(channel.getName()); ChannelEntity channelEntity = this.channelRepository.findByName(channel.getName()); if (channelEntity == null) { channelEntity = this.converterService.convert(channel, ChannelEntity.class); } else if (channelEntity.isDeleted() != null && channelEntity.isDeleted()) { channelEntity.setDeleted(false); } else { throw new DuplicateChannelException(channel.getName()); } this.channelRepository.saveAndFlush(channelEntity); return channelEntity.getId(); } }
ChannelServiceImpl extends AbstractLogicallyDeletableService<ChannelDTO, ChannelEntity> implements ChannelService { @Transactional @Override public Long saveOrUpdate(ChannelDTO channel) { Assert.notNull(channel); Assert.notNull(channel.getName()); ChannelEntity channelEntity = this.channelRepository.findByName(channel.getName()); if (channelEntity == null) { channelEntity = this.converterService.convert(channel, ChannelEntity.class); } else if (channelEntity.isDeleted() != null && channelEntity.isDeleted()) { channelEntity.setDeleted(false); } else { throw new DuplicateChannelException(channel.getName()); } this.channelRepository.saveAndFlush(channelEntity); return channelEntity.getId(); } @Autowired  ChannelServiceImpl(ChannelRepository channelRepository,
                            ConverterService converterService); }
ChannelServiceImpl extends AbstractLogicallyDeletableService<ChannelDTO, ChannelEntity> implements ChannelService { @Transactional @Override public Long saveOrUpdate(ChannelDTO channel) { Assert.notNull(channel); Assert.notNull(channel.getName()); ChannelEntity channelEntity = this.channelRepository.findByName(channel.getName()); if (channelEntity == null) { channelEntity = this.converterService.convert(channel, ChannelEntity.class); } else if (channelEntity.isDeleted() != null && channelEntity.isDeleted()) { channelEntity.setDeleted(false); } else { throw new DuplicateChannelException(channel.getName()); } this.channelRepository.saveAndFlush(channelEntity); return channelEntity.getId(); } @Autowired  ChannelServiceImpl(ChannelRepository channelRepository,
                            ConverterService converterService); @Transactional(readOnly = true) @Override ChannelDTO getChannelDtoById(Long channelId); @Transactional(readOnly = true) @Override ChannelDTO getChannelDtoByName(String channelName); @Transactional @Override Long saveOrUpdate(ChannelDTO channel); }
ChannelServiceImpl extends AbstractLogicallyDeletableService<ChannelDTO, ChannelEntity> implements ChannelService { @Transactional @Override public Long saveOrUpdate(ChannelDTO channel) { Assert.notNull(channel); Assert.notNull(channel.getName()); ChannelEntity channelEntity = this.channelRepository.findByName(channel.getName()); if (channelEntity == null) { channelEntity = this.converterService.convert(channel, ChannelEntity.class); } else if (channelEntity.isDeleted() != null && channelEntity.isDeleted()) { channelEntity.setDeleted(false); } else { throw new DuplicateChannelException(channel.getName()); } this.channelRepository.saveAndFlush(channelEntity); return channelEntity.getId(); } @Autowired  ChannelServiceImpl(ChannelRepository channelRepository,
                            ConverterService converterService); @Transactional(readOnly = true) @Override ChannelDTO getChannelDtoById(Long channelId); @Transactional(readOnly = true) @Override ChannelDTO getChannelDtoByName(String channelName); @Transactional @Override Long saveOrUpdate(ChannelDTO channel);  }