Search in sources :

Example 16 with MethodOrder

use of com.github.sevntu.checkstyle.ordering.MethodOrder in project methods-distance by sevntu-checkstyle.

the class MethodDefinitionTest method testGetterSetterRecognitionsWithCtors.

@Test
public void testGetterSetterRecognitionsWithCtors() throws Exception {
    final MethodOrder dc = withDefaultConfigOrdering("InputMethodDefinition2.java");
    final Method noArgCtor = dc.getMethodByInitialIndex(0);
    assertFalse(noArgCtor.isGetter());
    assertFalse(noArgCtor.isSetter());
    final Method singleArgCtor = dc.getMethodByInitialIndex(1);
    assertFalse(singleArgCtor.isGetter());
    assertFalse(singleArgCtor.isSetter());
}
Also used : MethodOrder(com.github.sevntu.checkstyle.ordering.MethodOrder) Method(com.github.sevntu.checkstyle.ordering.Method) Test(org.junit.Test)

Example 17 with MethodOrder

use of com.github.sevntu.checkstyle.ordering.MethodOrder in project methods-distance by sevntu-checkstyle.

the class MethodOrderTest method testAccessorsSplit.

@Test
public void testAccessorsSplit() throws Exception {
    final MethodOrder ds = withDefaultConfigOrdering("InputDependenciesAccessorsSplit.java");
    assertEquals(3, ds.getAccessorsSplitCases());
}
Also used : MethodOrder(com.github.sevntu.checkstyle.ordering.MethodOrder) Test(org.junit.Test)

Example 18 with MethodOrder

use of com.github.sevntu.checkstyle.ordering.MethodOrder in project methods-distance by sevntu-checkstyle.

the class MethodOrderTest method testConstructorsSplit.

@Test
public void testConstructorsSplit() throws Exception {
    final MethodOrder order = withDefaultConfigOrdering("InputDependenciesConstructorsSplit.java");
    assertEquals(3, order.getCtorGroupsSplitCases());
}
Also used : MethodOrder(com.github.sevntu.checkstyle.ordering.MethodOrder) Test(org.junit.Test)

Example 19 with MethodOrder

use of com.github.sevntu.checkstyle.ordering.MethodOrder in project methods-distance by sevntu-checkstyle.

the class MethodOrderTest method testCallsBetweenDistantMethods.

@Test
public void testCallsBetweenDistantMethods() throws Exception {
    final int screenLinesCount = 5;
    final Map<String, Integer> expected = new TreeMap<>();
    expected.put("InputDependenciesDistantMethodCall1.java", 1);
    expected.put("InputDependenciesDistantMethodCall2.java", 2);
    expected.put("InputDependenciesDistantMethodCall3.java", 1);
    expected.put("InputDependenciesDistantMethodCall4.java", 0);
    for (final Map.Entry<String, Integer> e : expected.entrySet()) {
        final MethodOrder dependencies = withDefaultConfigOrdering(e.getKey());
        final String msg = String.format("Incorrect result for input \"%s\"", e.getKey());
        assertEquals(msg, e.getValue().intValue(), dependencies.getDependenciesBetweenDistantMethodsCases(screenLinesCount));
    }
}
Also used : MethodOrder(com.github.sevntu.checkstyle.ordering.MethodOrder) TreeMap(java.util.TreeMap) TreeMap(java.util.TreeMap) Map(java.util.Map) Test(org.junit.Test)

Example 20 with MethodOrder

use of com.github.sevntu.checkstyle.ordering.MethodOrder in project methods-distance by sevntu-checkstyle.

the class MethodOrderTest method testOverrideSplit2.

@Test
public void testOverrideSplit2() throws Exception {
    final MethodOrder ds = withDefaultConfigOrdering("InputDependenciesOverrideSplit2.java");
    assertEquals(0, ds.getOverrideGroupSplitCases());
}
Also used : MethodOrder(com.github.sevntu.checkstyle.ordering.MethodOrder) Test(org.junit.Test)

Aggregations

MethodOrder (com.github.sevntu.checkstyle.ordering.MethodOrder)23 Test (org.junit.Test)15 Method (com.github.sevntu.checkstyle.ordering.Method)10 ArrayList (java.util.ArrayList)4 Dependencies (com.github.sevntu.checkstyle.domain.Dependencies)3 Configuration (com.puppycrawl.tools.checkstyle.api.Configuration)3 List (java.util.List)3 Map (java.util.Map)3 DependencyInformationConsumer (com.github.sevntu.checkstyle.module.DependencyInformationConsumer)2 Function (java.util.function.Function)2 Collectors (java.util.stream.Collectors)2 DependencyInformationConsumerInjector (com.github.sevntu.checkstyle.common.DependencyInformationConsumerInjector)1 MethodCallDependencyCheckInvoker (com.github.sevntu.checkstyle.common.MethodCallDependencyCheckInvoker)1 BaseCheckTestSupport (com.github.sevntu.checkstyle.domain.BaseCheckTestSupport)1 ExpectedDependencies (com.github.sevntu.checkstyle.domain.ExpectedDependencies)1 AttributeHolder (com.github.sevntu.checkstyle.dot.domain.AttributeHolder)1 Cluster (com.github.sevntu.checkstyle.dot.domain.Cluster)1 Colors (com.github.sevntu.checkstyle.dot.domain.Colors)1 Comment (com.github.sevntu.checkstyle.dot.domain.Comment)1 Edge (com.github.sevntu.checkstyle.dot.domain.Edge)1