@Test
public void deploySystemVmTest() {

    HostVO host = Mockito.mock(HostVO.class);
    VMTemplateVO systemVmTemplate = Mockito.mock(VMTemplateVO.class);
    Account systemAcct = Mockito.mock(Account.class);
    LinkedHashMap<Network, List<? extends NicProfile>> networks = new LinkedHashMap<>();
    AutonomiccsSystemVm autonomiccsSystemVm = Mockito.mock(AutonomiccsSystemVm.class);
    Mockito.when(host.getDataCenterId()).thenReturn(0l);
    Mockito.when(host.getPodId()).thenReturn(0l);
    Mockito.when(host.getClusterId()).thenReturn(0l);
    Mockito.when(host.getId()).thenReturn(0l);
    Mockito.doReturn(host).when(hostService).findHostById(Mockito.anyLong());
    Mockito.doNothing().when(spy).validateParametersToDeployTheSystemVm(Mockito.anyLong(), Mockito.any(HostVO.class));
    Mockito.doReturn(systemVmTemplate).when(spy).getSystemVmTemplate(Mockito.any(HostVO.class));
    Mockito.doReturn(systemAcct).when(accountManager).getSystemAccount();
    Mockito.doReturn(networks).when(spy).getSystemVmNetworks(Mockito.any(HostVO.class), Mockito.any(DataCenterDeployment.class), Mockito.any(Account.class));
    Mockito.doReturn(0l).when(spy).getNextSystemVmId();
    Mockito.doReturn("vmInstanceSuffix").when(spy).getVirtualMachineInstanceSuffix();
    Mockito.doReturn("name").when(spy).createAutonomiccsSystemVmNameForType(Mockito.anyLong(), Mockito.any(SystemVmType.class), Mockito.anyString());
    Mockito.doReturn(autonomiccsSystemVm).when(spy).createTheAutonomiccsSystemVm(Mockito.any(VMTemplateVO.class), Mockito.any(Account.class), Mockito.anyLong(),
            Mockito.anyString());
    Mockito.doReturn(autonomiccsSystemVm).when(spy).allocateAndStartTheSystemVm(Mockito.any(VMTemplateVO.class), Mockito.any(DataCenterDeployment.class), Mockito.eq(networks),
            Mockito.any(AutonomiccsSystemVm.class));
    Mockito.doNothing().when(spy).waitUntilTheAutonomiccsSystemVmIsUpAndRunning(Mockito.any(AutonomiccsSystemVm.class));
    AutonomiccsSystemVm result = spy.deploySystemVm(0l, SystemVmType.ClusterManagerStartHostService);
    InOrder inOrder = Mockito.inOrder(host, spy);
    Mockito.verify(hostService).findHostById(Mockito.anyLong());
    inOrder.verify(spy).validateParametersToDeployTheSystemVm(Mockito.anyLong(), Mockito.any(HostVO.class));
    inOrder.verify(spy).getSystemVmTemplate(Mockito.any(HostVO.class));
    inOrder.verify(host).getDataCenterId();
    inOrder.verify(host).getPodId();
    inOrder.verify(host).getClusterId();
    inOrder.verify(host).getId();
    Mockito.verify(accountManager).getSystemAccount();
    inOrder.verify(spy).getSystemVmNetworks(Mockito.any(HostVO.class), Mockito.any(DataCenterDeployment.class), Mockito.any(Account.class));
    inOrder.verify(spy).getNextSystemVmId();
    inOrder.verify(spy).getVirtualMachineInstanceSuffix();
    inOrder.verify(spy).createAutonomiccsSystemVmNameForType(Mockito.anyLong(), Mockito.any(SystemVmType.class), Mockito.anyString());
    inOrder.verify(spy).createTheAutonomiccsSystemVm(Mockito.any(VMTemplateVO.class), Mockito.any(Account.class), Mockito.anyLong(), Mockito.anyString());
    inOrder.verify(spy).allocateAndStartTheSystemVm(Mockito.any(VMTemplateVO.class), Mockito.any(DataCenterDeployment.class), Mockito.eq(networks),
            Mockito.any(AutonomiccsSystemVm.class));
    inOrder.verify(spy).waitUntilTheAutonomiccsSystemVmIsUpAndRunning(Mockito.any(AutonomiccsSystemVm.class));
    Assert.assertEquals(autonomiccsSystemVm, result);
}