@Test public void testValidateForCreate_WhenVcNameExistsRequest_ThrowsValidationException() throws Exception { this.exception.expect(VmidcBrokerValidationException.class); VirtualizationConnectorDto dto = VirtualizationConnectorDtoValidatorTestData.OPENSTACK_NAME_ALREADY_EXISTS_NOCONTROLLER_VC; this.exception.expectMessage("Virtualization Connector Name: " + dto.getName() + " already exists."); this.dtoValidator.validateForCreate(dto); }
@Override public void validateForCreate(VirtualizationConnectorDto dto) throws Exception { OSCEntityManager<VirtualizationConnector> emgr = new OSCEntityManager<>( VirtualizationConnector.class, this.em, this.txBroadcastUtil); if (dto.getType().isKubernetes() && !dto.isControllerDefined()) { throw new VmidcBrokerValidationException( "Virtualization connectors for Kubernetes must have a SDN controller."); } boolean usesProviderCreds = dto.isControllerDefined() && this.apiFactoryService.usesProviderCreds(dto.getControllerType()); VirtualizationConnectorDtoValidator.checkForNullFields(dto, usesProviderCreds); VirtualizationConnectorDtoValidator.checkFieldLength(dto); if (dto.getType().isOpenstack()) { dto.setSoftwareVersion(OpenstackSoftwareVersion.OS_ICEHOUSE.toString()); } if (emgr.isExisting("name", dto.getName())) { throw new VmidcBrokerValidationException( "Virtualization Connector Name: " + dto.getName() + " already exists."); } if (dto.isControllerDefined() && !this.apiFactoryService.usesProviderCreds(dto.getControllerType())) { ValidateUtil.checkForValidIpAddressFormat(dto.getControllerIP()); if (emgr.isExisting("controllerIpAddress", dto.getControllerIP())) { throw new VmidcBrokerValidationException( "Controller IP Address: " + dto.getControllerIP() + " already exists."); } } VirtualizationConnectorDtoValidator.checkFieldFormat(dto); if (emgr.isExisting("providerIpAddress", dto.getProviderIP())) { throw new VmidcBrokerValidationException( "Provider IP Address: " + dto.getProviderIP() + " already exists."); } }
VirtualizationConnectorDtoValidator implements DtoValidator<VirtualizationConnectorDto, VirtualizationConnector> { @Override public void validateForCreate(VirtualizationConnectorDto dto) throws Exception { OSCEntityManager<VirtualizationConnector> emgr = new OSCEntityManager<>( VirtualizationConnector.class, this.em, this.txBroadcastUtil); if (dto.getType().isKubernetes() && !dto.isControllerDefined()) { throw new VmidcBrokerValidationException( "Virtualization connectors for Kubernetes must have a SDN controller."); } boolean usesProviderCreds = dto.isControllerDefined() && this.apiFactoryService.usesProviderCreds(dto.getControllerType()); VirtualizationConnectorDtoValidator.checkForNullFields(dto, usesProviderCreds); VirtualizationConnectorDtoValidator.checkFieldLength(dto); if (dto.getType().isOpenstack()) { dto.setSoftwareVersion(OpenstackSoftwareVersion.OS_ICEHOUSE.toString()); } if (emgr.isExisting("name", dto.getName())) { throw new VmidcBrokerValidationException( "Virtualization Connector Name: " + dto.getName() + " already exists."); } if (dto.isControllerDefined() && !this.apiFactoryService.usesProviderCreds(dto.getControllerType())) { ValidateUtil.checkForValidIpAddressFormat(dto.getControllerIP()); if (emgr.isExisting("controllerIpAddress", dto.getControllerIP())) { throw new VmidcBrokerValidationException( "Controller IP Address: " + dto.getControllerIP() + " already exists."); } } VirtualizationConnectorDtoValidator.checkFieldFormat(dto); if (emgr.isExisting("providerIpAddress", dto.getProviderIP())) { throw new VmidcBrokerValidationException( "Provider IP Address: " + dto.getProviderIP() + " already exists."); } } }
VirtualizationConnectorDtoValidator implements DtoValidator<VirtualizationConnectorDto, VirtualizationConnector> { @Override public void validateForCreate(VirtualizationConnectorDto dto) throws Exception { OSCEntityManager<VirtualizationConnector> emgr = new OSCEntityManager<>( VirtualizationConnector.class, this.em, this.txBroadcastUtil); if (dto.getType().isKubernetes() && !dto.isControllerDefined()) { throw new VmidcBrokerValidationException( "Virtualization connectors for Kubernetes must have a SDN controller."); } boolean usesProviderCreds = dto.isControllerDefined() && this.apiFactoryService.usesProviderCreds(dto.getControllerType()); VirtualizationConnectorDtoValidator.checkForNullFields(dto, usesProviderCreds); VirtualizationConnectorDtoValidator.checkFieldLength(dto); if (dto.getType().isOpenstack()) { dto.setSoftwareVersion(OpenstackSoftwareVersion.OS_ICEHOUSE.toString()); } if (emgr.isExisting("name", dto.getName())) { throw new VmidcBrokerValidationException( "Virtualization Connector Name: " + dto.getName() + " already exists."); } if (dto.isControllerDefined() && !this.apiFactoryService.usesProviderCreds(dto.getControllerType())) { ValidateUtil.checkForValidIpAddressFormat(dto.getControllerIP()); if (emgr.isExisting("controllerIpAddress", dto.getControllerIP())) { throw new VmidcBrokerValidationException( "Controller IP Address: " + dto.getControllerIP() + " already exists."); } } VirtualizationConnectorDtoValidator.checkFieldFormat(dto); if (emgr.isExisting("providerIpAddress", dto.getProviderIP())) { throw new VmidcBrokerValidationException( "Provider IP Address: " + dto.getProviderIP() + " already exists."); } } VirtualizationConnectorDtoValidator(EntityManager em, TransactionalBroadcastUtil txBroadcastUtil, ApiFactoryService apiFactoryService); }
VirtualizationConnectorDtoValidator implements DtoValidator<VirtualizationConnectorDto, VirtualizationConnector> { @Override public void validateForCreate(VirtualizationConnectorDto dto) throws Exception { OSCEntityManager<VirtualizationConnector> emgr = new OSCEntityManager<>( VirtualizationConnector.class, this.em, this.txBroadcastUtil); if (dto.getType().isKubernetes() && !dto.isControllerDefined()) { throw new VmidcBrokerValidationException( "Virtualization connectors for Kubernetes must have a SDN controller."); } boolean usesProviderCreds = dto.isControllerDefined() && this.apiFactoryService.usesProviderCreds(dto.getControllerType()); VirtualizationConnectorDtoValidator.checkForNullFields(dto, usesProviderCreds); VirtualizationConnectorDtoValidator.checkFieldLength(dto); if (dto.getType().isOpenstack()) { dto.setSoftwareVersion(OpenstackSoftwareVersion.OS_ICEHOUSE.toString()); } if (emgr.isExisting("name", dto.getName())) { throw new VmidcBrokerValidationException( "Virtualization Connector Name: " + dto.getName() + " already exists."); } if (dto.isControllerDefined() && !this.apiFactoryService.usesProviderCreds(dto.getControllerType())) { ValidateUtil.checkForValidIpAddressFormat(dto.getControllerIP()); if (emgr.isExisting("controllerIpAddress", dto.getControllerIP())) { throw new VmidcBrokerValidationException( "Controller IP Address: " + dto.getControllerIP() + " already exists."); } } VirtualizationConnectorDtoValidator.checkFieldFormat(dto); if (emgr.isExisting("providerIpAddress", dto.getProviderIP())) { throw new VmidcBrokerValidationException( "Provider IP Address: " + dto.getProviderIP() + " already exists."); } } VirtualizationConnectorDtoValidator(EntityManager em, TransactionalBroadcastUtil txBroadcastUtil, ApiFactoryService apiFactoryService); @Override void validateForCreate(VirtualizationConnectorDto dto); @Override VirtualizationConnector validateForUpdate(VirtualizationConnectorDto dto); static void checkForNullFields(VirtualizationConnectorDto dto, boolean skipPasswordNullCheck, boolean usesProviderCreds); static void checkForNullFields(VirtualizationConnectorDto dto, boolean usesProviderCreds); static void checkFieldLength(VirtualizationConnectorDto dto); static void checkFieldFormat(VirtualizationConnectorDto dto); }
VirtualizationConnectorDtoValidator implements DtoValidator<VirtualizationConnectorDto, VirtualizationConnector> { @Override public void validateForCreate(VirtualizationConnectorDto dto) throws Exception { OSCEntityManager<VirtualizationConnector> emgr = new OSCEntityManager<>( VirtualizationConnector.class, this.em, this.txBroadcastUtil); if (dto.getType().isKubernetes() && !dto.isControllerDefined()) { throw new VmidcBrokerValidationException( "Virtualization connectors for Kubernetes must have a SDN controller."); } boolean usesProviderCreds = dto.isControllerDefined() && this.apiFactoryService.usesProviderCreds(dto.getControllerType()); VirtualizationConnectorDtoValidator.checkForNullFields(dto, usesProviderCreds); VirtualizationConnectorDtoValidator.checkFieldLength(dto); if (dto.getType().isOpenstack()) { dto.setSoftwareVersion(OpenstackSoftwareVersion.OS_ICEHOUSE.toString()); } if (emgr.isExisting("name", dto.getName())) { throw new VmidcBrokerValidationException( "Virtualization Connector Name: " + dto.getName() + " already exists."); } if (dto.isControllerDefined() && !this.apiFactoryService.usesProviderCreds(dto.getControllerType())) { ValidateUtil.checkForValidIpAddressFormat(dto.getControllerIP()); if (emgr.isExisting("controllerIpAddress", dto.getControllerIP())) { throw new VmidcBrokerValidationException( "Controller IP Address: " + dto.getControllerIP() + " already exists."); } } VirtualizationConnectorDtoValidator.checkFieldFormat(dto); if (emgr.isExisting("providerIpAddress", dto.getProviderIP())) { throw new VmidcBrokerValidationException( "Provider IP Address: " + dto.getProviderIP() + " already exists."); } } VirtualizationConnectorDtoValidator(EntityManager em, TransactionalBroadcastUtil txBroadcastUtil, ApiFactoryService apiFactoryService); @Override void validateForCreate(VirtualizationConnectorDto dto); @Override VirtualizationConnector validateForUpdate(VirtualizationConnectorDto dto); static void checkForNullFields(VirtualizationConnectorDto dto, boolean skipPasswordNullCheck, boolean usesProviderCreds); static void checkForNullFields(VirtualizationConnectorDto dto, boolean usesProviderCreds); static void checkFieldLength(VirtualizationConnectorDto dto); static void checkFieldFormat(VirtualizationConnectorDto dto);  }