use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment in project ovirt-engine by oVirt.
the class NetworkAttachmentValidatorTest method createNetworkAttachmentWithIpv4Configuration.
private NetworkAttachment createNetworkAttachmentWithIpv4Configuration(Ipv4BootProtocol bootProtocol) {
IpConfiguration ipConfiguration = new IpConfiguration();
IPv4Address primaryAddress = new IPv4Address();
primaryAddress.setAddress(null);
primaryAddress.setNetmask(null);
primaryAddress.setBootProtocol(bootProtocol);
ipConfiguration.getIPv4Addresses().add(primaryAddress);
NetworkAttachment attachment = new NetworkAttachment();
attachment.setIpConfiguration(ipConfiguration);
return attachment;
}
use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment in project ovirt-engine by oVirt.
the class NetworkAttachmentValidatorTest method testNetworkExistWhenNeitherIdNorNameIsSpecified.
@Test
public void testNetworkExistWhenNeitherIdNorNameIsSpecified() {
NetworkAttachment networkAttachment = new NetworkAttachment();
NetworkAttachmentValidator validator = createNetworkAttachmentValidator(networkAttachment);
assertThat(validator.networkExists(), failsWith(EngineMessage.NETWORK_ATTACHMENT_NETWORK_ID_OR_NAME_IS_NOT_SET));
}
use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment in project ovirt-engine by oVirt.
the class NetworkAttachmentValidatorTest method testExistingAttachmentExistingHasSameId.
@Test
public void testExistingAttachmentExistingHasSameId() {
Guid networkId = Guid.newGuid();
Guid attachmentId = Guid.newGuid();
NetworkAttachment oldAttachment = new NetworkAttachment();
oldAttachment.setNetworkId(networkId);
oldAttachment.setNetworkName(NETWORK_NAME);
oldAttachment.setId(attachmentId);
Map<Guid, NetworkAttachment> existingAttachmentsByNetworkId = new HashMap<>();
existingAttachmentsByNetworkId.put(networkId, oldAttachment);
NetworkAttachment attachment = new NetworkAttachment();
attachment.setNetworkId(networkId);
attachment.setId(attachmentId);
assertThat(createNetworkAttachmentValidator(attachment).existingAttachmentIsReused(existingAttachmentsByNetworkId), isValid());
}
use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment in project ovirt-engine by oVirt.
the class NetworkAttachmentValidatorTest method testNetworkAttachedToClusterWhenNotAttached.
@Test
public void testNetworkAttachedToClusterWhenNotAttached() {
Network network = new Network();
network.setId(Guid.newGuid());
network.setName(NETWORK_NAME);
NetworkAttachment attachment = new NetworkAttachment();
attachment.setNetworkId(network.getId());
attachment.setNetworkName(network.getName());
EngineMessage engineMessage = EngineMessage.NETWORK_OF_GIVEN_NAME_NOT_EXISTS_IN_CLUSTER;
assertThat(createNetworkAttachmentValidator(attachment).networkAttachedToCluster(), failsWith(engineMessage, ReplacementUtils.getVariableAssignmentString(engineMessage, network.getName())));
}
use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment in project ovirt-engine by oVirt.
the class NetworkAttachmentValidatorTest method testExistingAttachmentIsReusedNotReused.
@Test
public void testExistingAttachmentIsReusedNotReused() {
Guid networkId = Guid.newGuid();
NetworkAttachment oldAttachment = new NetworkAttachment();
oldAttachment.setNetworkId(networkId);
oldAttachment.setNetworkName(NETWORK_NAME);
oldAttachment.setId(Guid.newGuid());
Map<Guid, NetworkAttachment> existingAttachmentsByNetworkId = new HashMap<>();
existingAttachmentsByNetworkId.put(networkId, oldAttachment);
NetworkAttachment attachment = new NetworkAttachment();
attachment.setNetworkId(networkId);
assertThat(createNetworkAttachmentValidator(attachment).existingAttachmentIsReused(existingAttachmentsByNetworkId), failsWith(EngineMessage.ATTACHMENT_IS_NOT_REUSED, ReplacementUtils.createSetVariableString(NetworkAttachmentValidator.VAR_NETWORK_ATTACHMENT_ID, oldAttachment.getId()), ReplacementUtils.createSetVariableString(NetworkAttachmentValidator.VAR_NETWORK_NAME, oldAttachment.getNetworkName())));
}
Aggregations