Program: 56160
Project: 56160
Buggy source:
/** 
 * Checks the behavior of the resourceAllocated() method
 * @throws Exception
 */
@Test public void testResourceAllocated() throws Exception {
  QueueScheduler toTest=spy(new QueueScheduler(this.schedulingListener,this.instanceManager));
  JobID jobid=mock(JobID.class);
  AllocatedResource resource=mock(AllocatedResource.class);
  InstanceType instanceType=new InstanceType();
  InstanceConnectionInfo instanceConnectionInfo=mock(InstanceConnectionInfo.class);
  when(instanceConnectionInfo.toString()).thenReturn("String_Node_Str");
  LocalInstance instance=spy(new LocalInstance(instanceType,instanceConnectionInfo,null,null,null));
  toTest.resourceAllocated(null,null);
  verify(this.loggerMock).error(Matchers.anyString());
  final Method methodToMock=MemberMatcher.method(QueueScheduler.class,JobID.class);
  PowerMockito.when(toTest,methodToMock).withArguments(Matchers.any(JobID.class)).thenReturn(null);
  when(resource.getInstance()).thenReturn(instance);
  toTest.resourceAllocated(jobid,resource);
  try {
    verify(this.instanceManager).releaseAllocatedResource(Matchers.any(JobID.class),Matchers.any(Configuration.class),Matchers.any(AllocatedResource.class));
  }
 catch (  InstanceException e1) {
    e1.printStackTrace();
  }
  PowerMockito.when(toTest,methodToMock).withArguments(Matchers.any(JobID.class)).thenReturn(this.executionGraph);
  when(this.graphIterator.next()).thenReturn(this.vertex1);
  when(this.graphIterator.hasNext()).thenReturn(true,true,true,true,false);
  when(this.graphIterator2.next()).thenReturn(this.vertex1);
  when(this.graphIterator2.hasNext()).thenReturn(true,true,true,true,false);
  when(this.vertex1.getExecutionState()).thenReturn(ExecutionState.ASSIGNING);
  try {
    whenNew(ExecutionGraphIterator.class).withArguments(Matchers.any(ExecutionGraph.class),Matchers.anyBoolean()).thenReturn(this.graphIterator);
    whenNew(ExecutionGraphIterator.class).withArguments(Matchers.any(ExecutionGraph.class),Matchers.anyInt(),Matchers.anyBoolean(),Matchers.anyBoolean()).thenReturn(this.graphIterator2);
  }
 catch (  Exception e) {
    throw new RuntimeException(e);
  }
  when(this.executionGraph.getJobID()).thenReturn(jobid);
  Deque<ExecutionGraph> jobQueue=Whitebox.getInternalState(toTest,"String_Node_Str");
  jobQueue.add(this.executionGraph);
  Whitebox.setInternalState(toTest,"String_Node_Str",jobQueue);
  when(this.vertex1.getAllocatedResource()).thenReturn(null);
  when(resource.getInstance()).thenReturn(instance);
  toTest.resourceAllocated(jobid,resource);
  verify(this.loggerMock).warn(Matchers.anyString());
  when(this.graphIterator2.hasNext()).thenReturn(true,true,true,true,false);
  when(this.graphIterator.hasNext()).thenReturn(true,true,true,true,false);
  when(this.vertex1.getAllocatedResource()).thenReturn(resource);
  toTest.resourceAllocated(jobid,resource);
  verify(this.vertex1,times(4)).setExecutionState(ExecutionState.ASSIGNED);
}

Fixed version (ground truth):
/** 
 * Checks the behavior of the resourceAllocated() method
 * @throws Exception
 */
@Test public void testResourceAllocated() throws Exception {
  QueueScheduler toTest=spy(new QueueScheduler(this.schedulingListener,this.instanceManager));
  JobID jobid=mock(JobID.class);
  AllocatedResource resource=mock(AllocatedResource.class);
  InstanceType instanceType=new InstanceType();
  InstanceConnectionInfo instanceConnectionInfo=mock(InstanceConnectionInfo.class);
  when(instanceConnectionInfo.toString()).thenReturn("String_Node_Str");
  LocalInstance instance=spy(new LocalInstance(instanceType,instanceConnectionInfo,null,null,null));
  toTest.resourceAllocated(null,null);
  verify(this.loggerMock).error(Matchers.anyString());
  final Method methodToMock=MemberMatcher.method(QueueScheduler.class,JobID.class);
  PowerMockito.when(toTest,methodToMock).withArguments(Matchers.any(JobID.class)).thenReturn(null);
  when(resource.getInstance()).thenReturn(instance);
  toTest.resourceAllocated(jobid,resource);
  try {
    verify(this.instanceManager).releaseAllocatedResource(Matchers.any(JobID.class),Matchers.any(Configuration.class),Matchers.any(AllocatedResource.class));
  }
 catch (  InstanceException e1) {
    e1.printStackTrace();
  }
  PowerMockito.when(toTest,methodToMock).withArguments(Matchers.any(JobID.class)).thenReturn(this.executionGraph);
  when(this.graphIterator.next()).thenReturn(this.vertex1);
  when(this.graphIterator.hasNext()).thenReturn(true,true,true,true,false);
  when(this.graphIterator2.next()).thenReturn(this.vertex1);
  when(this.graphIterator2.hasNext()).thenReturn(true,true,true,true,false);
  when(this.vertex1.getExecutionState()).thenReturn(ExecutionState.ASSIGNING);
  try {
    whenNew(ExecutionGraphIterator.class).withArguments(Matchers.any(ExecutionGraph.class),Matchers.anyBoolean()).thenReturn(this.graphIterator);
    whenNew(ExecutionGraphIterator.class).withArguments(Matchers.any(ExecutionGraph.class),Matchers.anyInt(),Matchers.anyBoolean(),Matchers.anyBoolean()).thenReturn(this.graphIterator2);
  }
 catch (  Exception e) {
    throw new RuntimeException(e);
  }
  when(this.executionGraph.getJobID()).thenReturn(jobid);
  Deque<ExecutionGraph> jobQueue=Whitebox.getInternalState(toTest,"String_Node_Str");
  jobQueue.add(this.executionGraph);
  Whitebox.setInternalState(toTest,"String_Node_Str",jobQueue);
  when(this.vertex1.getAllocatedResource()).thenReturn(null);
  when(resource.getInstance()).thenReturn(instance);
  toTest.resourceAllocated(jobid,resource);
  verify(this.loggerMock).warn(Matchers.anyString());
  when(this.graphIterator2.hasNext()).thenReturn(true,true,true,true,false);
  when(this.graphIterator.hasNext()).thenReturn(true,true,true,true,false);
  when(this.vertex1.getAllocatedResource()).thenReturn(resource);
  when(resource.getInstanceType()).thenReturn(instanceType);
  toTest.resourceAllocated(jobid,resource);
  verify(this.vertex1,times(4)).setExecutionState(ExecutionState.ASSIGNED);
}