### Question:
GuidedSearchUtility { public boolean includesPublicCall(T individual, Set<GenericAccessibleObject<?>> publicCalls) { Iterator<GenericAccessibleObject<?>> publicCallsIterator = publicCalls.iterator(); TestChromosome candidateChrom = (TestChromosome) individual; TestCase candidate = candidateChrom.getTestCase(); if (candidate.size() == 0){ return false; } while (publicCallsIterator.hasNext()){ GenericAccessibleObject<?> call = publicCallsIterator.next(); for (int index= 0 ; index < candidate.size() ;index++) { Statement currentStatement = candidate.getStatement(index); if(currentStatement.getAccessibleObject() != null && currentStatement.getAccessibleObject().equals(call)){ return true; } } } return false; }  BytecodeInstruction collectPublicCalls(StackTrace trace); boolean includesPublicCall(T individual, Set<GenericAccessibleObject<?>> publicCalls); public Set<BytecodeInstruction> publicCallsBC; }### Answer:
@Test public void testIncludesPublicCall_falseCase() { BytecodeInstruction stmt = Mockito.mock(BytecodeInstruction.class); Mockito.doReturn("java.lang.Integer").when(stmt).getClassName(); Mockito.doReturn("reverse()").when(stmt).getMethodName(); Mockito.doReturn(1).when(stmt).getLineNumber(); List<BytecodeInstruction> instructions = new ArrayList<>(); instructions.add(stmt); ActualControlFlowGraph actualCFG = mockActualControlFlowGraph(stmt, true); Mockito.doReturn(actualCFG).when(stmt).getActualCFG(); GuidedSearchUtility utility = new GuidedSearchUtility(); TestCase tc = new DefaultTestCase(); tc.addStatement(new BooleanPrimitiveStatement(tc, false)); TestChromosome ch = new TestChromosome(); ch.setTestCase(tc); GenericAccessibleObject geObj = Mockito.mock(GenericAccessibleObject.class); Set<GenericAccessibleObject> publicCalls = new HashSet<>(); publicCalls.add(geObj); boolean flag = utility.includesPublicCall(ch,publicCalls); assertFalse(flag); }
@Test public void testIncludesPublicCall() { BytecodeInstruction stmt = Mockito.mock(BytecodeInstruction.class); Mockito.doReturn("java.lang.Integer").when(stmt).getClassName(); Mockito.doReturn("reverse()").when(stmt).getMethodName(); Mockito.doReturn(1).when(stmt).getLineNumber(); Mockito.doReturn(1).when(stmt).getLineNumber(); List<BytecodeInstruction> instructions = new ArrayList<>(); instructions.add(stmt); ActualControlFlowGraph actualCFG = mockActualControlFlowGraph(stmt, true); Mockito.doReturn(actualCFG).when(stmt).getActualCFG(); GuidedSearchUtility utility = new GuidedSearchUtility(); Set<GenericAccessibleObject> publicCalls = new HashSet<>(); publicCalls.add(chromosome.getTestCase().getStatement(1).getAccessibleObject()); boolean flag = utility.includesPublicCall(chromosome,publicCalls); assertTrue(flag); }