VpcRouterDeploymentDefinition extends RouterDeploymentDefinition { @Override protected void findServiceOfferingId() { serviceOfferingId = vpcOffDao.findById(vpc.getVpcOfferingId()).getServiceOfferingId(); if (serviceOfferingId == null) { findDefaultServiceOfferingId(); } } 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 testFindOfferingIdDefault() { final VpcOfferingVO vpcOffering = mock(VpcOfferingVO.class); when(mockVpcOffDao.findById(VPC_OFFERING_ID)).thenReturn(vpcOffering); when(vpcOffering.getServiceOfferingId()).thenReturn(null); when(mockServiceOfferingDao.findDefaultSystemOffering(Matchers.anyString(), Matchers.anyBoolean())).thenReturn(mockSvcOfferingVO); when(mockSvcOfferingVO.getId()).thenReturn(DEFAULT_OFFERING_ID); deployment.findServiceOfferingId(); assertEquals("Since there is no service offering associated with VPC offering, offering id should have matched default one", DEFAULT_OFFERING_ID, deployment.serviceOfferingId.longValue()); }
@Test public void testFindOfferingIdFromVPC() { final VpcOfferingVO vpcOffering = mock(VpcOfferingVO.class); when(mockVpcOffDao.findById(VPC_OFFERING_ID)).thenReturn(vpcOffering); when(vpcOffering.getServiceOfferingId()).thenReturn(VPC_OFFERING_ID); deployment.findServiceOfferingId(); assertEquals("Service offering id not matching the one associated with VPC offering", VPC_OFFERING_ID, deployment.serviceOfferingId.longValue()); }