@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); }
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; }
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; } }
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; }  }
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); }
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; }