@Test public void testValidateForCreate_WhenDistributedApplianceExists_ThrowsValidationException() throws Exception { DistributedApplianceDto existingDaDto= createDistributedApplianceDto(); existingDaDto.setName(DA_NAME_EXISTING_DA); existingDaDto.setApplianceId(this.app.getId()); existingDaDto.setMcId(this.amc.getId()); for (VirtualSystemDto vsDto : existingDaDto.getVirtualizationSystems()) { vsDto.setVcId(this.vc.getId()); vsDto.setDomainId(this.domain.getId()); } this.exception.expect(VmidcBrokerValidationException.class); this.exception.expectMessage(MessageFormat.format("Distributed Appliance Name: {0} already exists.", DA_NAME_EXISTING_DA)); this.validator.validateForCreate(existingDaDto); }
@Override public void validateForCreate(DistributedApplianceDto dto) throws Exception { validate(dto); OSCEntityManager<DistributedAppliance> emgr = new OSCEntityManager<DistributedAppliance>(DistributedAppliance.class, this.em, this.txBroadcastUtil); if (emgr.isExisting("name", dto.getName())) { throw new VmidcBrokerValidationException("Distributed Appliance Name: " + dto.getName() + " already exists."); } }
DistributedApplianceDtoValidator implements DtoValidator<DistributedApplianceDto, DistributedAppliance> { @Override public void validateForCreate(DistributedApplianceDto dto) throws Exception { validate(dto); OSCEntityManager<DistributedAppliance> emgr = new OSCEntityManager<DistributedAppliance>(DistributedAppliance.class, this.em, this.txBroadcastUtil); if (emgr.isExisting("name", dto.getName())) { throw new VmidcBrokerValidationException("Distributed Appliance Name: " + dto.getName() + " already exists."); } } }
DistributedApplianceDtoValidator implements DtoValidator<DistributedApplianceDto, DistributedAppliance> { @Override public void validateForCreate(DistributedApplianceDto dto) throws Exception { validate(dto); OSCEntityManager<DistributedAppliance> emgr = new OSCEntityManager<DistributedAppliance>(DistributedAppliance.class, this.em, this.txBroadcastUtil); if (emgr.isExisting("name", dto.getName())) { throw new VmidcBrokerValidationException("Distributed Appliance Name: " + dto.getName() + " already exists."); } }  }
DistributedApplianceDtoValidator implements DtoValidator<DistributedApplianceDto, DistributedAppliance> { @Override public void validateForCreate(DistributedApplianceDto dto) throws Exception { validate(dto); OSCEntityManager<DistributedAppliance> emgr = new OSCEntityManager<DistributedAppliance>(DistributedAppliance.class, this.em, this.txBroadcastUtil); if (emgr.isExisting("name", dto.getName())) { throw new VmidcBrokerValidationException("Distributed Appliance Name: " + dto.getName() + " already exists."); } }  DistributedApplianceDtoValidator create(EntityManager em); @Override void validateForCreate(DistributedApplianceDto dto); @Override DistributedAppliance validateForUpdate(DistributedApplianceDto dto); static void checkForNullFields(DistributedApplianceDto dto); static void checkFieldLength(DistributedApplianceDto dto); }
DistributedApplianceDtoValidator implements DtoValidator<DistributedApplianceDto, DistributedAppliance> { @Override public void validateForCreate(DistributedApplianceDto dto) throws Exception { validate(dto); OSCEntityManager<DistributedAppliance> emgr = new OSCEntityManager<DistributedAppliance>(DistributedAppliance.class, this.em, this.txBroadcastUtil); if (emgr.isExisting("name", dto.getName())) { throw new VmidcBrokerValidationException("Distributed Appliance Name: " + dto.getName() + " already exists."); } }  DistributedApplianceDtoValidator create(EntityManager em); @Override void validateForCreate(DistributedApplianceDto dto); @Override DistributedAppliance validateForUpdate(DistributedApplianceDto dto); static void checkForNullFields(DistributedApplianceDto dto); static void checkFieldLength(DistributedApplianceDto dto);  }