Skip to content

MoveMethod test

Artyom Lobanov edited this page Jul 11, 2017 · 2 revisions

Simple test, where static method from one class use members from another class.

Expected refactorings
Member Move to
ClassB.methodB1() ClassA
package moveMethod;

public class ClassA {
    static int attributeA1;
    static int attributeA2;

    static void methodA1() {
        attributeA1 = 0;
        methodA2();
    }

    static void methodA2() {
        attributeA2 = 0;
        attributeA1 = 0;
    }

    static void methodA3() {
        attributeA1 = 0;
        attributeA2 = 0;
        methodA1();
        methodA2();
    }
}
package moveMethod;

public class ClassB {
    static int attributeB1;
    static int attributeB2;

    static void methodB1() {
        ClassA.attributeA1 = 0;
        ClassA.attributeA2 = 0;
        ClassA.methodA1();
    }

    static void methodB2() {
        attributeB1 = 0;
        attributeB2 = 0;
    }

    static void methodB3() {
        attributeB1 = 0;
        methodB1();
        methodB2();
    }
}
Clone this wiki locally