@Test public void testListByDataCenterIdVMTypeAndStates() { final VMInstanceVO vmInstanceVO = mock(VMInstanceVO.class); final SearchBuilder<VMInstanceVO> vmInstanceSearch = mock(SearchBuilder.class); when(mockVmDao.createSearchBuilder()).thenReturn(vmInstanceSearch); when(vmInstanceSearch.entity()).thenReturn(vmInstanceVO); when(vmInstanceVO.getType()).thenReturn(VirtualMachineType.Instance); when(vmInstanceVO.getState()).thenReturn(VirtualMachine.State.Stopped); when(vmInstanceVO.getPodIdToDeployIn()).thenReturn(POD_ID1); final SearchBuilder<HostPodVO> podIdSearch = mock(SearchBuilder.class); when(mockPodDao.createSearchBuilder()).thenReturn(podIdSearch); final SearchCriteria<HostPodVO> sc = mock(SearchCriteria.class); final HostPodVO hostPodVO = mock(HostPodVO.class); when(podIdSearch.entity()).thenReturn(hostPodVO); when(hostPodVO.getId()).thenReturn(POD_ID1); when(hostPodVO.getDataCenterId()).thenReturn(ZONE_ID); when(podIdSearch.create()).thenReturn(sc); final List<HostPodVO> expectedPods = mock(List.class); when(mockPodDao.search(sc, null)).thenReturn(expectedPods); final List<HostPodVO> pods = deployment.listByDataCenterIdVMTypeAndStates(ZONE_ID, VirtualMachineType.User, VirtualMachine.State.Starting, VirtualMachine.State.Running); assertNotNull(pods); assertEquals(expectedPods, pods); verify(sc, times(1)).setParameters("dc", ZONE_ID); verify(sc, times(1)).setJoinParameters("vmInstanceSearch", "type", VirtualMachineType.User); verify(sc, times(1)).setJoinParameters("vmInstanceSearch", "states", VirtualMachine.State.Starting, VirtualMachine.State.Running); verify(mockPodDao, times(1)).search(sc, null); }
protected List<HostPodVO> listByDataCenterIdVMTypeAndStates(final long id, final VirtualMachineType type, final VirtualMachine.State... states) { final SearchBuilder<VMInstanceVO> vmInstanceSearch = vmDao.createSearchBuilder(); vmInstanceSearch.and("type", vmInstanceSearch.entity().getType(), SearchCriteria.Op.EQ); vmInstanceSearch.and("states", vmInstanceSearch.entity().getState(), SearchCriteria.Op.IN); final SearchBuilder<HostPodVO> podIdSearch = podDao.createSearchBuilder(); podIdSearch.and("dc", podIdSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ); podIdSearch.select(null, SearchCriteria.Func.DISTINCT, podIdSearch.entity().getId()); podIdSearch.join("vmInstanceSearch", vmInstanceSearch, podIdSearch.entity().getId(), vmInstanceSearch.entity().getPodIdToDeployIn(), JoinBuilder.JoinType.INNER); podIdSearch.done(); final SearchCriteria<HostPodVO> sc = podIdSearch.create(); sc.setParameters("dc", id); sc.setJoinParameters("vmInstanceSearch", "type", type); sc.setJoinParameters("vmInstanceSearch", "states", (Object[]) states); return podDao.search(sc, null); }
RouterDeploymentDefinition { protected List<HostPodVO> listByDataCenterIdVMTypeAndStates(final long id, final VirtualMachineType type, final VirtualMachine.State... states) { final SearchBuilder<VMInstanceVO> vmInstanceSearch = vmDao.createSearchBuilder(); vmInstanceSearch.and("type", vmInstanceSearch.entity().getType(), SearchCriteria.Op.EQ); vmInstanceSearch.and("states", vmInstanceSearch.entity().getState(), SearchCriteria.Op.IN); final SearchBuilder<HostPodVO> podIdSearch = podDao.createSearchBuilder(); podIdSearch.and("dc", podIdSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ); podIdSearch.select(null, SearchCriteria.Func.DISTINCT, podIdSearch.entity().getId()); podIdSearch.join("vmInstanceSearch", vmInstanceSearch, podIdSearch.entity().getId(), vmInstanceSearch.entity().getPodIdToDeployIn(), JoinBuilder.JoinType.INNER); podIdSearch.done(); final SearchCriteria<HostPodVO> sc = podIdSearch.create(); sc.setParameters("dc", id); sc.setJoinParameters("vmInstanceSearch", "type", type); sc.setJoinParameters("vmInstanceSearch", "states", (Object[]) states); return podDao.search(sc, null); } }
RouterDeploymentDefinition { protected List<HostPodVO> listByDataCenterIdVMTypeAndStates(final long id, final VirtualMachineType type, final VirtualMachine.State... states) { final SearchBuilder<VMInstanceVO> vmInstanceSearch = vmDao.createSearchBuilder(); vmInstanceSearch.and("type", vmInstanceSearch.entity().getType(), SearchCriteria.Op.EQ); vmInstanceSearch.and("states", vmInstanceSearch.entity().getState(), SearchCriteria.Op.IN); final SearchBuilder<HostPodVO> podIdSearch = podDao.createSearchBuilder(); podIdSearch.and("dc", podIdSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ); podIdSearch.select(null, SearchCriteria.Func.DISTINCT, podIdSearch.entity().getId()); podIdSearch.join("vmInstanceSearch", vmInstanceSearch, podIdSearch.entity().getId(), vmInstanceSearch.entity().getPodIdToDeployIn(), JoinBuilder.JoinType.INNER); podIdSearch.done(); final SearchCriteria<HostPodVO> sc = podIdSearch.create(); sc.setParameters("dc", id); sc.setJoinParameters("vmInstanceSearch", "type", type); sc.setJoinParameters("vmInstanceSearch", "states", (Object[]) states); return podDao.search(sc, null); } protected  RouterDeploymentDefinition(final Network guestNetwork, final DeployDestination dest, final Account owner, final Map<Param, Object> params); }
RouterDeploymentDefinition { protected List<HostPodVO> listByDataCenterIdVMTypeAndStates(final long id, final VirtualMachineType type, final VirtualMachine.State... states) { final SearchBuilder<VMInstanceVO> vmInstanceSearch = vmDao.createSearchBuilder(); vmInstanceSearch.and("type", vmInstanceSearch.entity().getType(), SearchCriteria.Op.EQ); vmInstanceSearch.and("states", vmInstanceSearch.entity().getState(), SearchCriteria.Op.IN); final SearchBuilder<HostPodVO> podIdSearch = podDao.createSearchBuilder(); podIdSearch.and("dc", podIdSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ); podIdSearch.select(null, SearchCriteria.Func.DISTINCT, podIdSearch.entity().getId()); podIdSearch.join("vmInstanceSearch", vmInstanceSearch, podIdSearch.entity().getId(), vmInstanceSearch.entity().getPodIdToDeployIn(), JoinBuilder.JoinType.INNER); podIdSearch.done(); final SearchCriteria<HostPodVO> sc = podIdSearch.create(); sc.setParameters("dc", id); sc.setJoinParameters("vmInstanceSearch", "type", type); sc.setJoinParameters("vmInstanceSearch", "states", (Object[]) states); return podDao.search(sc, null); } protected  RouterDeploymentDefinition(final Network guestNetwork, final DeployDestination dest, final Account owner, final Map<Param, Object> params); Long getServiceOfferingId(); Long getSecondaryServiceOfferingId(); Vpc getVpc(); Network getGuestNetwork(); DeployDestination getDest(); Account getOwner(); Map<Param, Object> getParams(); boolean isRedundant(); DeploymentPlan getPlan(); boolean isVpcRouter(); Pod getPod(); Long getPodId(); List<DomainRouterVO> getRouters(); VirtualRouterProvider getVirtualProvider(); boolean isBasic(); boolean isPublicNetwork(); PublicIp getSourceNatIP(); boolean needsPublicNic(); boolean hasSourceNatService(); boolean hasGatewayService(); List<DomainRouterVO> deployVirtualRouter(); }
RouterDeploymentDefinition { protected List<HostPodVO> listByDataCenterIdVMTypeAndStates(final long id, final VirtualMachineType type, final VirtualMachine.State... states) { final SearchBuilder<VMInstanceVO> vmInstanceSearch = vmDao.createSearchBuilder(); vmInstanceSearch.and("type", vmInstanceSearch.entity().getType(), SearchCriteria.Op.EQ); vmInstanceSearch.and("states", vmInstanceSearch.entity().getState(), SearchCriteria.Op.IN); final SearchBuilder<HostPodVO> podIdSearch = podDao.createSearchBuilder(); podIdSearch.and("dc", podIdSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ); podIdSearch.select(null, SearchCriteria.Func.DISTINCT, podIdSearch.entity().getId()); podIdSearch.join("vmInstanceSearch", vmInstanceSearch, podIdSearch.entity().getId(), vmInstanceSearch.entity().getPodIdToDeployIn(), JoinBuilder.JoinType.INNER); podIdSearch.done(); final SearchCriteria<HostPodVO> sc = podIdSearch.create(); sc.setParameters("dc", id); sc.setJoinParameters("vmInstanceSearch", "type", type); sc.setJoinParameters("vmInstanceSearch", "states", (Object[]) states); return podDao.search(sc, null); } protected  RouterDeploymentDefinition(final Network guestNetwork, final DeployDestination dest, final Account owner, final Map<Param, Object> params); Long getServiceOfferingId(); Long getSecondaryServiceOfferingId(); Vpc getVpc(); Network getGuestNetwork(); DeployDestination getDest(); Account getOwner(); Map<Param, Object> getParams(); boolean isRedundant(); DeploymentPlan getPlan(); boolean isVpcRouter(); Pod getPod(); Long getPodId(); List<DomainRouterVO> getRouters(); VirtualRouterProvider getVirtualProvider(); boolean isBasic(); boolean isPublicNetwork(); PublicIp getSourceNatIP(); boolean needsPublicNic(); boolean hasSourceNatService(); boolean hasGatewayService(); List<DomainRouterVO> deployVirtualRouter();  }