Search in sources :

Example 1 with NicNameAndNicIdAccessors

use of org.ovirt.engine.core.bll.network.host.NicNameNicIdCompleter.NicNameAndNicIdAccessors in project ovirt-engine by oVirt.

the class NicNameNicIdCompleterTest method testProperBondBindingToNicNameAndNicIdAccessors.

@Test
public void testProperBondBindingToNicNameAndNicIdAccessors() {
    CreateOrUpdateBond createOrUpdateBond = new CreateOrUpdateBond();
    createOrUpdateBond.setName("nic name");
    createOrUpdateBond.setId(Guid.newGuid());
    NicNameAndNicIdAccessors accessors = new NicNameAndNicIdAccessors.FromCreateOrUpdateBondData(createOrUpdateBond);
    assertThat(accessors.getId(), is(createOrUpdateBond.getId()));
    assertThat(accessors.getName(), is(createOrUpdateBond.getName()));
    accessors.setId(Guid.newGuid());
    accessors.setName("another name");
    assertThat(createOrUpdateBond.getId(), is(accessors.getId()));
    assertThat(createOrUpdateBond.getName(), is(accessors.getName()));
}
Also used : CreateOrUpdateBond(org.ovirt.engine.core.common.action.CreateOrUpdateBond) NicNameAndNicIdAccessors(org.ovirt.engine.core.bll.network.host.NicNameNicIdCompleter.NicNameAndNicIdAccessors) Test(org.junit.Test)

Example 2 with NicNameAndNicIdAccessors

use of org.ovirt.engine.core.bll.network.host.NicNameNicIdCompleter.NicNameAndNicIdAccessors in project ovirt-engine by oVirt.

the class NicNameNicIdCompleterTest method testCompleteWhenBothIdAndNameDoesNotReferenceExistingNic.

@Test
public void testCompleteWhenBothIdAndNameDoesNotReferenceExistingNic() throws Exception {
    NicNameAndNicIdAccessors accessors = mock(NicNameAndNicIdAccessors.class);
    Guid guidOfNotExistingNic = Guid.newGuid();
    when(accessors.getId()).thenReturn(guidOfNotExistingNic);
    when(accessors.getName()).thenReturn("notAExistingNicName");
    completer.complete(accessors);
    verify(accessors, never()).setName(any());
    verify(accessors, never()).setId(any());
}
Also used : Guid(org.ovirt.engine.core.compat.Guid) NicNameAndNicIdAccessors(org.ovirt.engine.core.bll.network.host.NicNameNicIdCompleter.NicNameAndNicIdAccessors) Test(org.junit.Test)

Example 3 with NicNameAndNicIdAccessors

use of org.ovirt.engine.core.bll.network.host.NicNameNicIdCompleter.NicNameAndNicIdAccessors in project ovirt-engine by oVirt.

the class NicNameNicIdCompleterTest method testProperNetworkAttachmentBindingToNicNameAndNicIdAccessors.

@Test
public void testProperNetworkAttachmentBindingToNicNameAndNicIdAccessors() {
    NetworkAttachment networkAttachment = new NetworkAttachment();
    networkAttachment.setNicId(Guid.newGuid());
    networkAttachment.setNicName("nic name");
    NicNameAndNicIdAccessors accessors = new NicNameAndNicIdAccessors.FromNetworkAttachment(networkAttachment);
    assertThat("id should be bound to nicId", accessors.getId(), is(networkAttachment.getNicId()));
    assertThat("name should be bound to nicName", accessors.getName(), is(networkAttachment.getNicName()));
    accessors.setId(Guid.newGuid());
    accessors.setName("another name");
    assertThat("id should be bound to nicId", networkAttachment.getNicId(), is(accessors.getId()));
    assertThat("name should be bound to nicName", networkAttachment.getNicName(), is(accessors.getName()));
}
Also used : NicNameAndNicIdAccessors(org.ovirt.engine.core.bll.network.host.NicNameNicIdCompleter.NicNameAndNicIdAccessors) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment) Test(org.junit.Test)

Example 4 with NicNameAndNicIdAccessors

use of org.ovirt.engine.core.bll.network.host.NicNameNicIdCompleter.NicNameAndNicIdAccessors in project ovirt-engine by oVirt.

the class NicNameNicIdCompleterTest method testCompleteWhenUnsetIdAndName.

@Test
public void testCompleteWhenUnsetIdAndName() throws Exception {
    NicNameAndNicIdAccessors withoutNameOrIdSet = mock(NicNameAndNicIdAccessors.class);
    completer.complete(withoutNameOrIdSet);
    verify(withoutNameOrIdSet, never()).setName(any());
    verify(withoutNameOrIdSet, never()).setId(any());
}
Also used : NicNameAndNicIdAccessors(org.ovirt.engine.core.bll.network.host.NicNameNicIdCompleter.NicNameAndNicIdAccessors) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)4 NicNameAndNicIdAccessors (org.ovirt.engine.core.bll.network.host.NicNameNicIdCompleter.NicNameAndNicIdAccessors)4 CreateOrUpdateBond (org.ovirt.engine.core.common.action.CreateOrUpdateBond)1 NetworkAttachment (org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)1 Guid (org.ovirt.engine.core.compat.Guid)1