Program: 105213
Project: 105213
Buggy source:
@Test public void testMigrateCommand(){
  final Connect conn=Mockito.mock(Connect.class);
  final Connect dconn=Mockito.mock(Connect.class);
  final LibvirtUtilitiesHelper libvirtUtilitiesHelper=Mockito.mock(LibvirtUtilitiesHelper.class);
  final String vmName="String_Node_Str";
  final String destIp="String_Node_Str";
  final boolean isWindows=false;
  final VirtualMachineTO vmTO=Mockito.mock(VirtualMachineTO.class);
  final boolean executeInSequence=false;
  final MigrateCommand command=new MigrateCommand(vmName,destIp,isWindows,vmTO,executeInSequence);
  when(libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper);
  try {
    when(libvirtUtilitiesHelper.getConnectionByVmName(vmName)).thenReturn(conn);
    when(libvirtUtilitiesHelper.retrieveQemuConnection("String_Node_Str" + command.getDestinationIp() + "String_Node_Str")).thenReturn(dconn);
  }
 catch (  final LibvirtException e) {
    fail(e.getMessage());
  }
  final InterfaceDef interfaceDef=Mockito.mock(InterfaceDef.class);
  final List<InterfaceDef> ifaces=new ArrayList<InterfaceDef>();
  ifaces.add(interfaceDef);
  when(libvirtComputingResource.getInterfaces(conn,vmName)).thenReturn(ifaces);
  final DiskDef diskDef=Mockito.mock(DiskDef.class);
  final List<DiskDef> disks=new ArrayList<DiskDef>();
  disks.add(diskDef);
  when(libvirtComputingResource.getDisks(conn,vmName)).thenReturn(disks);
  final Domain dm=Mockito.mock(Domain.class);
  try {
    when(conn.domainLookupByName(vmName)).thenReturn(dm);
    when(libvirtComputingResource.getPrivateIp()).thenReturn("String_Node_Str");
    when(dm.getXMLDesc(0)).thenReturn("String_Node_Str");
    when(dm.isPersistent()).thenReturn(1);
    doNothing().when(dm).undefine();
  }
 catch (  final LibvirtException e) {
    fail(e.getMessage());
  }
catch (  final Exception e) {
    fail(e.getMessage());
  }
  final LibvirtRequestWrapper wrapper=LibvirtRequestWrapper.getInstance();
  assertNotNull(wrapper);
  final Answer answer=wrapper.execute(command,libvirtComputingResource);
  assertTrue(answer.getResult());
  verify(libvirtComputingResource,times(1)).getLibvirtUtilitiesHelper();
  try {
    verify(libvirtUtilitiesHelper,times(1)).getConnectionByVmName(vmName);
    verify(libvirtUtilitiesHelper,times(1)).retrieveQemuConnection("String_Node_Str" + command.getDestinationIp() + "String_Node_Str");
  }
 catch (  final LibvirtException e) {
    fail(e.getMessage());
  }
  verify(libvirtComputingResource,times(1)).getInterfaces(conn,vmName);
  verify(libvirtComputingResource,times(1)).getDisks(conn,vmName);
  try {
    verify(conn,times(1)).domainLookupByName(vmName);
    verify(dm,times(1)).getXMLDesc(0);
  }
 catch (  final LibvirtException e) {
    fail(e.getMessage());
  }
}

Fixed version (ground truth):
@Test public void testMigrateCommand(){
  final Connect conn=Mockito.mock(Connect.class);
  final Connect dconn=Mockito.mock(Connect.class);
  final LibvirtUtilitiesHelper libvirtUtilitiesHelper=Mockito.mock(LibvirtUtilitiesHelper.class);
  final String vmName="String_Node_Str";
  final String destIp="String_Node_Str";
  final boolean isWindows=false;
  final VirtualMachineTO vmTO=Mockito.mock(VirtualMachineTO.class);
  final boolean executeInSequence=false;
  final MigrateCommand command=new MigrateCommand(vmName,destIp,isWindows,vmTO,executeInSequence);
  when(libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper);
  try {
    when(libvirtUtilitiesHelper.getConnectionByVmName(vmName)).thenReturn(conn);
    when(libvirtUtilitiesHelper.retrieveQemuConnection("String_Node_Str" + command.getDestinationIp() + "String_Node_Str")).thenReturn(dconn);
  }
 catch (  final LibvirtException e) {
    fail(e.getMessage());
  }
  final InterfaceDef interfaceDef=Mockito.mock(InterfaceDef.class);
  final List<InterfaceDef> ifaces=new ArrayList<InterfaceDef>();
  ifaces.add(interfaceDef);
  when(libvirtComputingResource.getInterfaces(conn,vmName)).thenReturn(ifaces);
  final DiskDef diskDef=Mockito.mock(DiskDef.class);
  final List<DiskDef> disks=new ArrayList<DiskDef>();
  disks.add(diskDef);
  when(libvirtComputingResource.getDisks(conn,vmName)).thenReturn(disks);
  final Domain dm=Mockito.mock(Domain.class);
  try {
    when(conn.domainLookupByName(vmName)).thenReturn(dm);
    when(libvirtComputingResource.getPrivateIp()).thenReturn("String_Node_Str");
    when(dm.getXMLDesc(8)).thenReturn("String_Node_Str");
    when(dm.isPersistent()).thenReturn(1);
    doNothing().when(dm).undefine();
  }
 catch (  final LibvirtException e) {
    fail(e.getMessage());
  }
catch (  final Exception e) {
    fail(e.getMessage());
  }
  final LibvirtRequestWrapper wrapper=LibvirtRequestWrapper.getInstance();
  assertNotNull(wrapper);
  final Answer answer=wrapper.execute(command,libvirtComputingResource);
  assertTrue(answer.getResult());
  verify(libvirtComputingResource,times(1)).getLibvirtUtilitiesHelper();
  try {
    verify(libvirtUtilitiesHelper,times(1)).getConnectionByVmName(vmName);
    verify(libvirtUtilitiesHelper,times(1)).retrieveQemuConnection("String_Node_Str" + command.getDestinationIp() + "String_Node_Str");
  }
 catch (  final LibvirtException e) {
    fail(e.getMessage());
  }
  verify(libvirtComputingResource,times(1)).getInterfaces(conn,vmName);
  verify(libvirtComputingResource,times(1)).getDisks(conn,vmName);
  try {
    verify(conn,times(1)).domainLookupByName(vmName);
    verify(dm,times(1)).getXMLDesc(8);
  }
 catch (  final LibvirtException e) {
    fail(e.getMessage());
  }
}