use of com.github.sevntu.checkstyle.domain.ExpectedDependencies in project methods-distance by sevntu-checkstyle.
the class MethodCallDependenciesModuleTestSupport method mustBeSame.
private static void mustBeSame(final ExpectedDependencies expected, final MethodOrder actual) {
for (final String expectedMethod : expected.getMethods()) {
assertTrue("Method " + expectedMethod + " is not present is actual info", actual.getMethods().stream().anyMatch(md -> expectedMethod.equals(md.getSignature())));
}
for (final Method actualMethod : actual.getMethods()) {
assertTrue("Method " + actualMethod.getSignature() + " is not present in expected info", expected.getMethods().stream().anyMatch(mi -> mi.equals(actualMethod.getSignature())));
}
for (final String method : expected.getMethods()) {
final Method caller = actual.getMethods().stream().filter(m -> m.getSignature().equals(method)).findFirst().get();
final List<Method> dependencies = actual.getMethodDependenciesInAppearanceOrder(caller);
final List<ExpectedDependencies.MethodInvocation> invocations = expected.getInvocationsFromMethod(method);
assertEquals("Actual method dependencies count and count of invocations from method " + method + " does not match", invocations.size(), dependencies.size());
for (int i = 0; i < invocations.size(); ++i) {
final Method calledMethod = dependencies.get(i);
final ExpectedDependencies.MethodInvocation invocationOfMethod = invocations.get(i);
assertTrue("Method " + calledMethod.getSignature() + " is present as actual " + i + " dependency of " + method + " but should not be!", calledMethod.getSignature().equals(expected.getMethodByIndex(invocationOfMethod.callee)));
}
}
}
use of com.github.sevntu.checkstyle.domain.ExpectedDependencies in project methods-distance by sevntu-checkstyle.
the class MethodCallDependencyCheckstyleModuleTest method testAnonymousClasses.
@Test
public void testAnonymousClasses() throws Exception {
final DefaultConfiguration dc = createCheckConfig(MethodCallDependencyCheckstyleModule.class);
final ExpectedDependencies expected = ExpectedDependencies.build().method("method()").method("a()").method("a(String)").method("topLevelMethod()").get();
verifyInfo(dc, "InputAnonymousClasses.java", expected);
}
use of com.github.sevntu.checkstyle.domain.ExpectedDependencies in project methods-distance by sevntu-checkstyle.
the class MethodCallDependencyCheckstyleModuleTest method testVarargMethodCall.
@Test
public void testVarargMethodCall() throws Exception {
final DefaultConfiguration dc = createCheckConfig(MethodCallDependencyCheckstyleModule.class);
final ExpectedDependencies expected = ExpectedDependencies.build().method("c1()").callsTo(3).at(6, 20).method("c2()").callsTo(3).at(10, 20).method("c3()").callsTo(3).at(14, 20).method("varargMethod(Integer...)").get();
verifyInfo(dc, "InputVarargMethodCall.java", expected);
}
use of com.github.sevntu.checkstyle.domain.ExpectedDependencies in project methods-distance by sevntu-checkstyle.
the class MethodCallDependencyCheckstyleModuleTest method testOverloadedMethods2.
@Test
public void testOverloadedMethods2() throws Exception {
final DefaultConfiguration dc = createCheckConfig(MethodCallDependencyCheckstyleModule.class);
final ExpectedDependencies expected = ExpectedDependencies.build().method("b1()").method("b1(String)").method("b1(String,String)").method("b1(String,String,String...)").method("a1()").callsTo(0).at(14, 10).method("a2()").callsTo(1).at(18, 10).method("a3()").callsTo(2).at(22, 10).method("a4()").callsTo(3).at(26, 10).method("c1()").method("c1(String...)").method("d1()").callsTo(9).at(34, 10).get();
verifyInfo(dc, "InputOverloadedMethods2.java", expected);
}
use of com.github.sevntu.checkstyle.domain.ExpectedDependencies in project methods-distance by sevntu-checkstyle.
the class MethodCallDependencyCheckstyleModuleTest method testAppearanceOrder.
@Test
public void testAppearanceOrder() throws Exception {
final DefaultConfiguration dc = createCheckConfig(MethodCallDependencyCheckstyleModule.class);
final ExpectedDependencies expected = ExpectedDependencies.build().method("b1()").method("b2()").method("b3()").method("a()").callsTo(2).at(12, 10).callsTo(1).at(13, 10).callsTo(0).at(15, 10).method("c1(String)").method("c2()").method("d()").callsTo(5).at(24, 13).callsTo(4).at(24, 10).method("e1(String)").method("e2(Integer)").method("e3()").method("f()").callsTo(9).at(34, 16).callsTo(8).at(34, 13).callsTo(7).at(34, 10).get();
verifyInfo(dc, "InputAppearanceOrder.java", expected);
}
Aggregations