@Test public void testValidateForUpdate_WhenDistributedApplianceNotFound_ThrowsValidationException() throws Exception { Long notFoundDaId = 2000L; DistributedApplianceDto daDto = createDistributedApplianceDto(); daDto.setId(notFoundDaId); this.exception.expect(VmidcBrokerValidationException.class); this.exception.expectMessage(MessageFormat.format("Distributed Appliance entry with name: {0}) is not found.", daDto.getName())); this.validator.validateForUpdate(daDto); }
@Override public DistributedAppliance validateForUpdate(DistributedApplianceDto dto) throws Exception { BaseDtoValidator.checkForNullId(dto); DistributedAppliance da = this.em.find(DistributedAppliance.class, dto.getId()); if (da == null) { throw new VmidcBrokerValidationException("Distributed Appliance entry with name: " + dto.getName() + ") is not found."); } ValidateUtil.checkMarkedForDeletion(da, da.getName()); if (!dto.getMcId().equals(da.getApplianceManagerConnector().getId())) { throw new VmidcBrokerValidationException("Appliance Manager Connector change is not allowed."); } validate(dto, false, da); return da; }
DistributedApplianceDtoValidator implements DtoValidator<DistributedApplianceDto, DistributedAppliance> { @Override public DistributedAppliance validateForUpdate(DistributedApplianceDto dto) throws Exception { BaseDtoValidator.checkForNullId(dto); DistributedAppliance da = this.em.find(DistributedAppliance.class, dto.getId()); if (da == null) { throw new VmidcBrokerValidationException("Distributed Appliance entry with name: " + dto.getName() + ") is not found."); } ValidateUtil.checkMarkedForDeletion(da, da.getName()); if (!dto.getMcId().equals(da.getApplianceManagerConnector().getId())) { throw new VmidcBrokerValidationException("Appliance Manager Connector change is not allowed."); } validate(dto, false, da); return da; } }
DistributedApplianceDtoValidator implements DtoValidator<DistributedApplianceDto, DistributedAppliance> { @Override public DistributedAppliance validateForUpdate(DistributedApplianceDto dto) throws Exception { BaseDtoValidator.checkForNullId(dto); DistributedAppliance da = this.em.find(DistributedAppliance.class, dto.getId()); if (da == null) { throw new VmidcBrokerValidationException("Distributed Appliance entry with name: " + dto.getName() + ") is not found."); } ValidateUtil.checkMarkedForDeletion(da, da.getName()); if (!dto.getMcId().equals(da.getApplianceManagerConnector().getId())) { throw new VmidcBrokerValidationException("Appliance Manager Connector change is not allowed."); } validate(dto, false, da); return da; }  }
DistributedApplianceDtoValidator implements DtoValidator<DistributedApplianceDto, DistributedAppliance> { @Override public DistributedAppliance validateForUpdate(DistributedApplianceDto dto) throws Exception { BaseDtoValidator.checkForNullId(dto); DistributedAppliance da = this.em.find(DistributedAppliance.class, dto.getId()); if (da == null) { throw new VmidcBrokerValidationException("Distributed Appliance entry with name: " + dto.getName() + ") is not found."); } ValidateUtil.checkMarkedForDeletion(da, da.getName()); if (!dto.getMcId().equals(da.getApplianceManagerConnector().getId())) { throw new VmidcBrokerValidationException("Appliance Manager Connector change is not allowed."); } validate(dto, false, da); return da; }  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 DistributedAppliance validateForUpdate(DistributedApplianceDto dto) throws Exception { BaseDtoValidator.checkForNullId(dto); DistributedAppliance da = this.em.find(DistributedAppliance.class, dto.getId()); if (da == null) { throw new VmidcBrokerValidationException("Distributed Appliance entry with name: " + dto.getName() + ") is not found."); } ValidateUtil.checkMarkedForDeletion(da, da.getName()); if (!dto.getMcId().equals(da.getApplianceManagerConnector().getId())) { throw new VmidcBrokerValidationException("Appliance Manager Connector change is not allowed."); } validate(dto, false, da); return da; }  DistributedApplianceDtoValidator create(EntityManager em); @Override void validateForCreate(DistributedApplianceDto dto); @Override DistributedAppliance validateForUpdate(DistributedApplianceDto dto); static void checkForNullFields(DistributedApplianceDto dto); static void checkFieldLength(DistributedApplianceDto dto);  }