@Test public void testGetPublicCalls_trueCase() { GuidedSearchUtility utility = new GuidedSearchUtility(); 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(); utility.getPublicCalls(trace.getTargetClass(),trace.getTargetLine(), instructions); assertEquals(1,utility.publicCallsBC.size()); assertEquals (((BytecodeInstruction)utility.publicCallsBC.toArray()[0]).getClassName(),"java.lang.Integer"); assertEquals (((BytecodeInstruction)utility.publicCallsBC.toArray()[0]).getMethodName(),"reverse()"); assertEquals (((BytecodeInstruction)utility.publicCallsBC.toArray()[0]).getLineNumber(),1); }
protected void getPublicCalls(String targetClass, int targetLine, List<BytecodeInstruction> instructions){ LOG.debug("Detecting the target method call(s) ..."); BytecodeInstruction targetInstruction = getTargetInstruction(instructions, targetLine); if (!isPrivateMethod(targetInstruction.getActualCFG())){ LOG.debug("The target method is public!"); publicCallsBC.add(targetInstruction); } else { LOG.debug("The target call '{}' is private!", targetInstruction.getMethodName()); LOG.debug("Searching for public callers"); searchForNonPrivateMethods(targetInstruction, targetClass); } }
GuidedSearchUtility { protected void getPublicCalls(String targetClass, int targetLine, List<BytecodeInstruction> instructions){ LOG.debug("Detecting the target method call(s) ..."); BytecodeInstruction targetInstruction = getTargetInstruction(instructions, targetLine); if (!isPrivateMethod(targetInstruction.getActualCFG())){ LOG.debug("The target method is public!"); publicCallsBC.add(targetInstruction); } else { LOG.debug("The target call '{}' is private!", targetInstruction.getMethodName()); LOG.debug("Searching for public callers"); searchForNonPrivateMethods(targetInstruction, targetClass); } } }
GuidedSearchUtility { protected void getPublicCalls(String targetClass, int targetLine, List<BytecodeInstruction> instructions){ LOG.debug("Detecting the target method call(s) ..."); BytecodeInstruction targetInstruction = getTargetInstruction(instructions, targetLine); if (!isPrivateMethod(targetInstruction.getActualCFG())){ LOG.debug("The target method is public!"); publicCallsBC.add(targetInstruction); } else { LOG.debug("The target call '{}' is private!", targetInstruction.getMethodName()); LOG.debug("Searching for public callers"); searchForNonPrivateMethods(targetInstruction, targetClass); } }  }
GuidedSearchUtility { protected void getPublicCalls(String targetClass, int targetLine, List<BytecodeInstruction> instructions){ LOG.debug("Detecting the target method call(s) ..."); BytecodeInstruction targetInstruction = getTargetInstruction(instructions, targetLine); if (!isPrivateMethod(targetInstruction.getActualCFG())){ LOG.debug("The target method is public!"); publicCallsBC.add(targetInstruction); } else { LOG.debug("The target call '{}' is private!", targetInstruction.getMethodName()); LOG.debug("Searching for public callers"); searchForNonPrivateMethods(targetInstruction, targetClass); } }  BytecodeInstruction collectPublicCalls(StackTrace trace); boolean includesPublicCall(T individual, Set<GenericAccessibleObject<?>> publicCalls); }
GuidedSearchUtility { protected void getPublicCalls(String targetClass, int targetLine, List<BytecodeInstruction> instructions){ LOG.debug("Detecting the target method call(s) ..."); BytecodeInstruction targetInstruction = getTargetInstruction(instructions, targetLine); if (!isPrivateMethod(targetInstruction.getActualCFG())){ LOG.debug("The target method is public!"); publicCallsBC.add(targetInstruction); } else { LOG.debug("The target call '{}' is private!", targetInstruction.getMethodName()); LOG.debug("Searching for public callers"); searchForNonPrivateMethods(targetInstruction, targetClass); } }  BytecodeInstruction collectPublicCalls(StackTrace trace); boolean includesPublicCall(T individual, Set<GenericAccessibleObject<?>> publicCalls); public Set<BytecodeInstruction> publicCallsBC; }