/** * If tester is an instance of {@link TestSuiteMethod} and tested method object in tester is equal to tested we * consider tester is test for tested method. * * @param tester * @param tested * @return */ private static boolean isTestForMethod(IOpenMethod tester, IOpenMethod tested) { if (!(tester instanceof TestSuiteMethod)) { return false; } IOpenMethod toTest = ((TestSuiteMethod) tester).getTestedMethod(); return toTest == tested; }
public static boolean isMethodRunnedBy(IOpenMethod tested, IOpenMethod runner) { if (!(runner instanceof TestSuiteMethod)) { return false; } if (runner == tested) { return true; } IOpenMethod toTest = ((TestSuiteMethod) runner).getTestedMethod(); return toTest == tested && ((TestSuiteMethod) runner).isRunmethod(); }
public static boolean isMethodTestedBy(IOpenMethod tested, IOpenMethod tester) { if (!(tester instanceof TestSuiteMethod)) { return false; } IOpenMethod toTest = ((TestSuiteMethod) tester).getTestedMethod(); return toTest == tested && isTester(tester); }
public IOpenMethod getTestedMethod() { if (testSuiteMethod != null) { return testSuiteMethod.getTestedMethod(); } else { return tests[0].getTestedMethod(); } }
public List<IOpenMethod> getTargetMethods(String testOrRunUri) { List<IOpenMethod> targetMethods = new ArrayList<IOpenMethod>(); IOpenMethod testMethod = getMethod(testOrRunUri); if (testMethod instanceof TestSuiteMethod) { IOpenMethod targetMethod = ((TestSuiteMethod) testMethod).getTestedMethod(); // Overloaded methods if (targetMethod instanceof OpenMethodDispatcher) { List<IOpenMethod> overloadedMethods = ((OpenMethodDispatcher) targetMethod).getCandidates(); targetMethods.addAll(overloadedMethods); } else { targetMethods.add(targetMethod); } } return targetMethods; }
public List<IOpenMethod> getTargetMethods(String testOrRunUri) { List<IOpenMethod> targetMethods = new ArrayList<IOpenMethod>(); IOpenMethod testMethod = getMethod(testOrRunUri); if (testMethod instanceof TestSuiteMethod) { IOpenMethod targetMethod = ((TestSuiteMethod) testMethod).getTestedMethod(); // Overloaded methods if (targetMethod instanceof OpenMethodDispatcher) { List<IOpenMethod> overloadedMethods = ((OpenMethodDispatcher) targetMethod).getCandidates(); targetMethods.addAll(overloadedMethods); } else { targetMethods.add(targetMethod); } } return targetMethods; }
public List<IOpenMethod> getTargetMethods(String testOrRunUri) { List<IOpenMethod> targetMethods = new ArrayList<IOpenMethod>(); IOpenMethod testMethod = getMethod(testOrRunUri); if (testMethod instanceof TestSuiteMethod) { IOpenMethod targetMethod = ((TestSuiteMethod) testMethod).getTestedMethod(); // Overloaded methods if (targetMethod instanceof OpenMethodDispatcher) { List<IOpenMethod> overloadedMethods = ((OpenMethodDispatcher) targetMethod).getCandidates(); targetMethods.addAll(overloadedMethods); } else { targetMethods.add(targetMethod); } } return targetMethods; }
private void updateDependency(BindingDependencies bindingDependencies) { IOpenMethod testedMethod = getTestedMethod(); if (testedMethod instanceof ExecutableRulesMethod || testedMethod instanceof OpenMethodDispatcher) { bindingDependencies.addMethodDependency(testedMethod, getBoundNode()); } }
private TestDescription[] initTestsAndIndexes() { DynamicObject[] testObjects = getTestObjects(); TestDescription[] tests = new TestDescription[testObjects.length]; indeces = new HashMap<>(tests.length); Map<String, Object> properties = getProperties(); Integer precision = null; if (properties != null && properties.containsKey(PRECISION_PARAM)) { precision = Integer.parseInt(properties.get(PRECISION_PARAM).toString()); } IOpenMethod testedMethod = getTestedMethod(); ColumnDescriptor[] descriptors = getDescriptors(); List<IOpenField> fields = createFieldsToTest(testedMethod, descriptors, precision); for (int i = 0; i < tests.length; i++) { tests[i] = new TestDescription(testedMethod, testObjects[i], fields, descriptors, db); tests[i].setIndex(i); indeces.put(tests[i].getId(), i); } return tests; }
/** * If tester is an instance of {@link TestSuiteMethod} and tested method * object in tester is equal to tested we consider tester is test for tested * method. */ public static boolean isTestForMethod(IOpenMethod tester, IOpenMethod tested) { if (!(tester instanceof TestSuiteMethod)) { return false; } IOpenMethod toTest = ((TestSuiteMethod) tester).getTestedMethod(); if (toTest == tested) { return true; } if (toTest instanceof OpenMethodDispatcher) { if (((OpenMethodDispatcher) toTest).getCandidates().contains(tested)) { return true; } } if (tested instanceof MethodDelegator) { return isTestForMethod(tester, tested.getMethod()); } if (tested instanceof OpenMethodDispatcher) { return isTestForMethod(tester, ((OpenMethodDispatcher) tested).getTargetMethod()); } return false; }
private TestSuiteMethod createNewTestSuiteMethod(TestSuiteMethod testSuiteMethod) { IOpenMethod method = testSuiteMethod.getTestedMethod(); IOpenMethod newTargetMethod = getDeclaredMethod(method.getName(), method.getSignature().getParameterTypes()); TestSuiteMethod copy = new TestSuiteMethod(newTargetMethod, testSuiteMethod); copy.setModuleName(testSuiteMethod.getModuleName()); return copy; }