use of com.github.sevntu.checkstyle.ordering.MethodOrder 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.ordering.MethodOrder in project methods-distance by sevntu-checkstyle.
the class MethodDefinitionTest method testGetterSetterRecognition.
@Test
public void testGetterSetterRecognition() throws Exception {
final MethodOrder dc = withDefaultConfigOrdering("InputMethodDefinition1.java");
for (final int index : new int[] { 0, 1, 2, 3, 4 }) {
final Method method = dc.getMethodByInitialIndex(index);
assertTrue(method.isGetter());
assertFalse(method.isSetter());
}
for (final int index : new int[] { 7 }) {
final Method method = dc.getMethodByInitialIndex(index);
assertFalse(method.isGetter());
assertTrue(method.isSetter());
}
for (final int index : new int[] { 5, 6, 8, 9, 10, 11 }) {
final Method method = dc.getMethodByInitialIndex(index);
assertFalse(method.isGetter());
assertFalse(method.isSetter());
}
}
use of com.github.sevntu.checkstyle.ordering.MethodOrder in project methods-distance by sevntu-checkstyle.
the class MethodOrderReorderTest method testReordering.
@Test
public void testReordering() throws Exception {
final int screenLinesCount = 5;
final MethodOrder first = withDefaultConfigOrdering("InputOrderingReordering1.java");
final Method b = first.getMethodByInitialIndex(3);
final Method c = first.getMethodByInitialIndex(6);
final Method d3 = first.getMethodByInitialIndex(9);
final Method e = first.getMethodByInitialIndex(13);
final Method f = first.getMethodByInitialIndex(15);
final Method h = first.getMethodByInitialIndex(17);
final MethodOrder firstStep1 = first.moveMethodBy(b, -3);
final MethodOrder firstStep2 = firstStep1.moveMethodBy(c, -1);
final MethodOrder firstStep3 = firstStep2.moveMethodBy(d3, 2);
final MethodOrder firstStep4 = firstStep3.moveMethodBy(e, 1);
final MethodOrder firstStep5 = firstStep4.moveMethodBy(f, 1);
final MethodOrder firstLikeSecond = firstStep5.moveMethodBy(h, 1);
final MethodOrder second = withDefaultConfigOrdering("InputOrderingReordering2.java");
compare(second, firstLikeSecond, screenLinesCount);
}
use of com.github.sevntu.checkstyle.ordering.MethodOrder in project methods-distance by sevntu-checkstyle.
the class MethodOrderTest method testOverloadSplit1.
@Test
public void testOverloadSplit1() throws Exception {
final MethodOrder ds = withDefaultConfigOrdering("InputDependenciesOverloadSplit1.java");
assertEquals(5, ds.getOverloadGroupsSplitCases());
}
use of com.github.sevntu.checkstyle.ordering.MethodOrder in project methods-distance by sevntu-checkstyle.
the class MethodOrderTest method testOverrideSplit3.
@Test
public void testOverrideSplit3() throws Exception {
final MethodOrder ds = withDefaultConfigOrdering("InputDependenciesOverrideSplit3.java");
assertEquals(0, ds.getOverrideGroupSplitCases());
}
Aggregations