@Test public void updateDomainExceptionTest() throws PacManException { when(domainRepository.existsById(anyString())).thenReturn(false); assertThatThrownBy(() -> domainService.updateDomain(getDomainDetailsRequest(), "user123")) .isInstanceOf(PacManException.class); }
@Override public String updateDomain(final CreateUpdateDomain createUpdateDomain, final String userId) throws PacManException { boolean isDomainExits = domainRepository.existsById(createUpdateDomain.getName()); if (isDomainExits) { Domain existingDomain = domainRepository.findById(createUpdateDomain.getName()).get(); existingDomain.setDomainDesc(createUpdateDomain.getDesc()); existingDomain.setConfig(createUpdateDomain.getConfig()); existingDomain.setModifiedDate(new Date()); existingDomain.setUserId(userId); domainRepository.save(existingDomain); return AdminConstants.DOMAIN_UPDATION_SUCCESS; } else { throw new PacManException(AdminConstants.DOMAIN_NAME_EXITS); } }
DomainServiceImpl implements DomainService, Constants { @Override public String updateDomain(final CreateUpdateDomain createUpdateDomain, final String userId) throws PacManException { boolean isDomainExits = domainRepository.existsById(createUpdateDomain.getName()); if (isDomainExits) { Domain existingDomain = domainRepository.findById(createUpdateDomain.getName()).get(); existingDomain.setDomainDesc(createUpdateDomain.getDesc()); existingDomain.setConfig(createUpdateDomain.getConfig()); existingDomain.setModifiedDate(new Date()); existingDomain.setUserId(userId); domainRepository.save(existingDomain); return AdminConstants.DOMAIN_UPDATION_SUCCESS; } else { throw new PacManException(AdminConstants.DOMAIN_NAME_EXITS); } } }
DomainServiceImpl implements DomainService, Constants { @Override public String updateDomain(final CreateUpdateDomain createUpdateDomain, final String userId) throws PacManException { boolean isDomainExits = domainRepository.existsById(createUpdateDomain.getName()); if (isDomainExits) { Domain existingDomain = domainRepository.findById(createUpdateDomain.getName()).get(); existingDomain.setDomainDesc(createUpdateDomain.getDesc()); existingDomain.setConfig(createUpdateDomain.getConfig()); existingDomain.setModifiedDate(new Date()); existingDomain.setUserId(userId); domainRepository.save(existingDomain); return AdminConstants.DOMAIN_UPDATION_SUCCESS; } else { throw new PacManException(AdminConstants.DOMAIN_NAME_EXITS); } }  }
DomainServiceImpl implements DomainService, Constants { @Override public String updateDomain(final CreateUpdateDomain createUpdateDomain, final String userId) throws PacManException { boolean isDomainExits = domainRepository.existsById(createUpdateDomain.getName()); if (isDomainExits) { Domain existingDomain = domainRepository.findById(createUpdateDomain.getName()).get(); existingDomain.setDomainDesc(createUpdateDomain.getDesc()); existingDomain.setConfig(createUpdateDomain.getConfig()); existingDomain.setModifiedDate(new Date()); existingDomain.setUserId(userId); domainRepository.save(existingDomain); return AdminConstants.DOMAIN_UPDATION_SUCCESS; } else { throw new PacManException(AdminConstants.DOMAIN_NAME_EXITS); } }  @Override Collection<String> getAllDomainNames(); @Override List<Domain> getAllDomains(); @Override Domain getDomainByName(final String domainName); @Override Page<Object[]> getAllDomainDetails(final String searchTerm, final int page, final int size); @Override String createDomain(final CreateUpdateDomain createUpdateDomain, final String userId); @Override String updateDomain(final CreateUpdateDomain createUpdateDomain, final String userId); }
DomainServiceImpl implements DomainService, Constants { @Override public String updateDomain(final CreateUpdateDomain createUpdateDomain, final String userId) throws PacManException { boolean isDomainExits = domainRepository.existsById(createUpdateDomain.getName()); if (isDomainExits) { Domain existingDomain = domainRepository.findById(createUpdateDomain.getName()).get(); existingDomain.setDomainDesc(createUpdateDomain.getDesc()); existingDomain.setConfig(createUpdateDomain.getConfig()); existingDomain.setModifiedDate(new Date()); existingDomain.setUserId(userId); domainRepository.save(existingDomain); return AdminConstants.DOMAIN_UPDATION_SUCCESS; } else { throw new PacManException(AdminConstants.DOMAIN_NAME_EXITS); } }  @Override Collection<String> getAllDomainNames(); @Override List<Domain> getAllDomains(); @Override Domain getDomainByName(final String domainName); @Override Page<Object[]> getAllDomainDetails(final String searchTerm, final int page, final int size); @Override String createDomain(final CreateUpdateDomain createUpdateDomain, final String userId); @Override String updateDomain(final CreateUpdateDomain createUpdateDomain, final String userId);  }