VpcRouterDeploymentDefinition extends RouterDeploymentDefinition { @Override protected void lock() { final Vpc vpcLock = vpcDao.acquireInLockTable(vpc.getId()); if (vpcLock == null) { throw new ConcurrentOperationException("Unable to lock vpc " + vpc.getId()); } tableLockId = vpcLock.getId(); } 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 testLock() { when(mockVpcDao.acquireInLockTable(VPC_ID)).thenReturn(mockVpc); deployment.lock(); verify(mockVpcDao, times(1)).acquireInLockTable(VPC_ID); assertNotNull(LOCK_NOT_CORRECTLY_GOT, deployment.tableLockId); assertEquals(LOCK_NOT_CORRECTLY_GOT, VPC_ID, deployment.tableLockId.longValue()); }
@Test(expected = ConcurrentOperationException.class) public void testLockFails() { when(mockVpcDao.acquireInLockTable(VPC_ID)).thenReturn(null); try { deployment.lock(); } finally { verify(mockVpcDao, times(1)).acquireInLockTable(VPC_ID); assertNull(deployment.tableLockId); } }