use of org.ovirt.engine.core.common.businessentities.network.Network in project ovirt-engine by oVirt.
the class IscsiBondValidatorTest method addedLogicalNetworkBelongToAnotherDatacenter2.
@Test
public void addedLogicalNetworkBelongToAnotherDatacenter2() {
Guid dataCenterId = Guid.newGuid();
IscsiBond before = createIscsiBond("Before", dataCenterId);
IscsiBond after = createIscsiBond("After", dataCenterId);
List<Network> networks = new ArrayList<>();
networks.add(createNetwork(dataCenterId));
doReturn(networks).when(networkDao).getAllForDataCenter(dataCenterId);
before.getNetworkIds().add(networks.get(0).getId());
after.getNetworkIds().add(networks.get(0).getId());
after.getNetworkIds().add(Guid.newGuid());
ValidationResult res = validator.validateAddedLogicalNetworks(after, before);
assertThat(res, failsWith(EngineMessage.NETWORKS_DONT_EXIST_IN_DATA_CENTER));
assertEquals(2, res.getVariableReplacements().size());
assertEquals("$networkIds " + after.getNetworkIds().get(1).toString(), res.getVariableReplacements().get(0));
assertEquals("$dataCenterId " + after.getStoragePoolId().toString(), res.getVariableReplacements().get(1));
}
use of org.ovirt.engine.core.common.businessentities.network.Network in project ovirt-engine by oVirt.
the class NetworkAttachmentValidatorTest method testNetworkNotAttachedToHostWhenAttached.
@Test
public void testNetworkNotAttachedToHostWhenAttached() {
Network network = createNetwork();
when(networkDaoMock.get(network.getId())).thenReturn(network);
when(vdsDaoMock.getAllForNetwork(eq(network.getId()))).thenReturn(Collections.singletonList(host));
String networkName = NETWORK_NAME;
NetworkAttachment attachment = new NetworkAttachment();
attachment.setNetworkId(network.getId());
attachment.setNetworkName(networkName);
assertThat(createNetworkAttachmentValidator(attachment).networkNotAttachedToHost(), failsWith(EngineMessage.NETWORK_ALREADY_ATTACHED_TO_HOST, ReplacementUtils.createSetVariableString(NETWORK_NAME, networkName), ReplacementUtils.createSetVariableString(HOST_NAME, host.getName())));
}
use of org.ovirt.engine.core.common.businessentities.network.Network in project ovirt-engine by oVirt.
the class NetworkAttachmentValidatorTest method testNetworkNotAttachedToHost.
@Test
public void testNetworkNotAttachedToHost() {
Network network = createNetwork();
when(networkDaoMock.get(network.getId())).thenReturn(network);
NetworkAttachment attachment = new NetworkAttachment();
attachment.setNetworkId(network.getId());
assertThat(createNetworkAttachmentValidator(attachment).networkNotAttachedToHost(), isValid());
}
use of org.ovirt.engine.core.common.businessentities.network.Network in project ovirt-engine by oVirt.
the class NetworkAttachmentValidatorTest method testNotExternalNetwork.
@Test
public void testNotExternalNetwork() {
Network notExternalNetwork = new Network();
notExternalNetwork.setId(Guid.newGuid());
notExternalNetwork.setProvidedBy(null);
when(networkDaoMock.get(eq(notExternalNetwork.getId()))).thenReturn(notExternalNetwork);
NetworkAttachment attachment = new NetworkAttachment();
attachment.setNetworkId(notExternalNetwork.getId());
NetworkAttachmentValidator validator = createNetworkAttachmentValidator(attachment);
assertThat(validator.notExternalNetwork(), isValid());
}
use of org.ovirt.engine.core.common.businessentities.network.Network 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())));
}
Aggregations