@Test
public void finalizeDeploymentTest() throws ResourceUnavailableException {

    ReservationContext context = Mockito.mock(ReservationContext.class);
    Commands cmds = Mockito.mock(Commands.class);
    DataCenter dc = Mockito.mock(DataCenter.class);
    VirtualMachineProfileImpl profile = Mockito.mock(VirtualMachineProfileImpl.class);
    Mockito.when(profile.getNics()).thenReturn(new ArrayList<NicProfile>());
    Mockito.when(profile.getId()).thenReturn(0l);
    AutonomiccsSystemVm autonomiccsSystemVm = Mockito.mock(AutonomiccsSystemVm.class);
    Mockito.doReturn(autonomiccsSystemVm).when(autonomiccsSystemVmDao).findById(Mockito.anyLong());
    DeployDestination dest = Mockito.mock(DeployDestination.class);
    Mockito.when(dest.getDataCenter()).thenReturn(dc);
    Mockito.doNothing().when(spy).setIpAddressOfEachNic(Mockito.any(AutonomiccsSystemVm.class), Mockito.any(DataCenter.class), Matchers.anyListOf(NicProfile.class));
    Mockito.doReturn(true).when(autonomiccsSystemVmDao).update(Mockito.anyLong(), Mockito.any(AutonomiccsSystemVm.class));
    boolean result = spy.finalizeDeployment(cmds, profile, dest, context);
    Assert.assertEquals(true, result);
    InOrder inOrder = Mockito.inOrder(autonomiccsSystemVmDao, spy);
    inOrder.verify(autonomiccsSystemVmDao).findById(Mockito.anyLong());
    inOrder.verify(spy).setIpAddressOfEachNic(Mockito.any(AutonomiccsSystemVm.class), Mockito.any(DataCenter.class), Matchers.anyListOf(NicProfile.class));
    inOrder.verify(autonomiccsSystemVmDao).update(Mockito.anyLong(), Mockito.any(AutonomiccsSystemVm.class));
}