VpcRouterDeploymentDefinition extends RouterDeploymentDefinition { @Override protected void findSourceNatIP() throws InsufficientAddressCapacityException, ConcurrentOperationException { sourceNatIp = null; if (needsPublicNic()) { sourceNatIp = vpcMgr.assignSourceNatIpAddressToVpc(owner, vpc); } } protected  VpcRouterDeploymentDefinition(final Network guestNetwork, final Vpc vpc, final DeployDestination dest, final Account owner,
            final Map<Param, Object> params); @Override Vpc getVpc(); @Override boolean isVpcRouter(); @Override boolean needsPublicNic(); @Override boolean hasSourceNatService(); @Override void generateDeploymentPlan(); @Override boolean isRedundant();  }
@Test public void testFindSourceNatIP() throws InsufficientAddressCapacityException, ConcurrentOperationException { final PublicIp publicIp = mock(PublicIp.class); when(vpcMgr.assignSourceNatIpAddressToVpc(mockOwner, mockVpc)).thenReturn(publicIp); deployment.findSourceNatIP(); final VpcRouterDeploymentDefinition vpcDeployment = (VpcRouterDeploymentDefinition) deployment; if (vpcDeployment.hasSourceNatService()) { assertEquals("SourceNatIp returned by the VpcManager was not correctly set", publicIp, deployment.sourceNatIp); } else { assertEquals("SourceNatIp returned by the VpcManager was not correctly set", null, deployment.sourceNatIp); } }