Source:
<code>public void testAddNetworkToNicAlongWithAddingItIntoBond() { Network networkA = createNetworkWithName("networkA"); VdsNetworkInterface nicA = createNic("nicA"); VdsNetworkInterface nicB = createNic("nicB"); NetworkAttachment networkAttachment = createNetworkAttachment(networkA, null); networkAttachment.setNicId(nicA.getId()); networkAttachment.setNicName(nicA.getName()); networkAttachment.setNetworkId(networkA.getId()); networkAttachment.setNetworkName(networkA.getName()); Bond bond = new Bond(); bond.setName("bond1"); bond.setSlaves(Arrays.asList(nicA.getName(), nicB.getName())); HostSetupNetworksParameters params = new HostSetupNetworksParameters(host.getId()); params.setNetworkAttachments(Collections.singletonList(networkAttachment)); params.setBonds(Collections.singletonList(bond)); when(networkDaoMock.get(eq(networkA.getId()))).thenReturn(networkA); <START> when(networkClusterDaoMock.get(new NetworkClusterId(host.getVdsGroupId(), networkA.getId()))) <END> .thenReturn(mock(NetworkCluster.class)); HostSetupNetworksValidator validator = new HostSetupNetworksValidatorBuilder() .setExistingAttachments(Collections.<NetworkAttachment> emptyList()) .setParams(params) .setExistingInterfaces(Arrays.asList(nicA, nicB)) .setNetworkBusinessEntityMap(new BusinessEntityMap<>(Collections.singletonList(networkA))) .setHost(host) .build(); ValidationResult validate = validator.validate(); assertThat(validate, CoreMatchers.not(isValid())); assertThat(validate, failsWith(VdcBllMessages.NETWORK_INTERFACE_ADDED_TO_BOND_AND_NETWORK_IS_ATTACHED_TO_IT_AT_THE_SAME_TIME, ReplacementUtils.createSetVariableString(HostSetupNetworksValidator.NETWORK_INTERFACE_ADDED_TO_BOND_AND_NETWORK_IS_ATTACHED_TO_IT_AT_THE_SAME_TIME_ENTITY, nicA.getName()), ReplacementUtils.createSetVariableString(HostSetupNetworksValidator.VAR_NETWORK_NAME, networkA.getName()))); }</code><technical_language>is this needed</technical_language>

Target:
public void testAddNetworkToNicAlongWithAddingItIntoBond() { Network networkA = createNetworkWithName("networkA"); VdsNetworkInterface nicA = createNic("nicA"); VdsNetworkInterface nicB = createNic("nicB"); NetworkAttachment networkAttachment = createNetworkAttachment(networkA, null); networkAttachment.setNicId(nicA.getId()); networkAttachment.setNicName(nicA.getName()); networkAttachment.setNetworkId(networkA.getId()); networkAttachment.setNetworkName(networkA.getName()); Bond bond = new Bond(); bond.setName("bond1"); bond.setSlaves(Arrays.asList(nicA.getName(), nicB.getName())); HostSetupNetworksParameters params = new HostSetupNetworksParameters(host.getId()); params.setNetworkAttachments(Collections.singletonList(networkAttachment)); params.setBonds(Collections.singletonList(bond)); when(networkDaoMock.get(eq(networkA.getId()))).thenReturn(networkA); when(networkClusterDaoMock.get(new NetworkClusterId(host.getVdsGroupId(), networkA.getId()))) .thenReturn(mock(NetworkCluster.class)); HostSetupNetworksValidator validator = new HostSetupNetworksValidatorBuilder() .setExistingAttachments(Collections.<NetworkAttachment> emptyList()) .setParams(params) .setExistingInterfaces(Arrays.asList(nicA, nicB)) .setNetworkBusinessEntityMap(new BusinessEntityMap<>(Collections.singletonList(networkA))) .setHost(host) .build(); ValidationResult validate = validator.validate(); assertThat(validate, CoreMatchers.not(isValid())); assertThat(validate, failsWith(EngineMessage.NETWORK_INTERFACE_ADDED_TO_BOND_AND_NETWORK_IS_ATTACHED_TO_IT_AT_THE_SAME_TIME, ReplacementUtils.createSetVariableString(HostSetupNetworksValidator.NETWORK_INTERFACE_ADDED_TO_BOND_AND_NETWORK_IS_ATTACHED_TO_IT_AT_THE_SAME_TIME_ENTITY, nicA.getName()), ReplacementUtils.createSetVariableString(HostSetupNetworksValidator.VAR_NETWORK_NAME, networkA.getName()))); }