Search in sources :

Example 1 with PyMemberInfoStorage

use of com.jetbrains.python.refactoring.classes.PyMemberInfoStorage in project intellij-community by JetBrains.

the class PyExtractSuperclassPresenterTest method configureByClass.

/**
   * Configures presenter by class
   *
   * @param name name of class
   * @return presenter
   */
@NotNull
private PyExtractSuperclassPresenterImpl configureByClass(@NotNull final String name) {
    final PyClass childClass = getClassByName(name);
    final PyMemberInfoStorage storage = new PyMemberInfoStorage(childClass);
    return new PyExtractSuperclassPresenterImpl(myView, childClass, storage);
}
Also used : PyClass(com.jetbrains.python.psi.PyClass) PyMemberInfoStorage(com.jetbrains.python.refactoring.classes.PyMemberInfoStorage) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with PyMemberInfoStorage

use of com.jetbrains.python.refactoring.classes.PyMemberInfoStorage in project intellij-community by JetBrains.

the class PyExtractSuperclassPresenterTest method testInvalidSuperClassNameLeadsToError.

/**
   * Checks that presenter displays error if user enters invalid name for new class
   */
public void testInvalidSuperClassNameLeadsToError() {
    final String className = "Child";
    final PyClass aClass = getClassByName(className);
    final List<PyMemberInfo<PyElement>> classMemberInfos = new PyMemberInfoStorage(aClass).getClassMemberInfos(aClass);
    assert !classMemberInfos.isEmpty() : "No member infos for " + className;
    final PyMemberInfo<PyElement> pyMemberInfo = classMemberInfos.get(0);
    EasyMock.expect(myView.getSelectedMemberInfos()).andReturn(Collections.singletonList(pyMemberInfo)).anyTimes();
    EasyMock.expect(myView.getSuperClassName()).andReturn("INVALID CLASS NAME").anyTimes();
    final Capture<String> errorMessageCapture = configureViewToCaptureError();
    final PyExtractSuperclassPresenterImpl sut = configureByClass(className);
    myMocksControl.replay();
    sut.launch();
    sut.okClicked();
    Assert.assertTrue("No error displayed for invalid class name", errorMessageCapture.hasCaptured());
}
Also used : PyClass(com.jetbrains.python.psi.PyClass) PyMemberInfoStorage(com.jetbrains.python.refactoring.classes.PyMemberInfoStorage) PyMemberInfo(com.jetbrains.python.refactoring.classes.membersManager.PyMemberInfo) PyElement(com.jetbrains.python.psi.PyElement)

Example 3 with PyMemberInfoStorage

use of com.jetbrains.python.refactoring.classes.PyMemberInfoStorage in project intellij-community by JetBrains.

the class PyPullUpInfoModelTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    myFixture.configureByFile("/refactoring/pullup/pyPullUpInfoModel.py");
    final PyClass childClass = getClassByName("ChildWithDependencies");
    final PyClass parentClass = getClassByName("SomeParent");
    mySut = new PyPullUpInfoModel(childClass, new MocksControl(MocksControl.MockType.NICE).createMock(PyPullUpView.class));
    mySut.setSuperClass(parentClass);
    myMemberInfos = new PyMemberInfoStorage(childClass).getClassMemberInfos(childClass);
}
Also used : PyClass(com.jetbrains.python.psi.PyClass) MocksControl(org.easymock.internal.MocksControl) PyMemberInfoStorage(com.jetbrains.python.refactoring.classes.PyMemberInfoStorage)

Example 4 with PyMemberInfoStorage

use of com.jetbrains.python.refactoring.classes.PyMemberInfoStorage in project intellij-community by JetBrains.

the class PyPullUpPresenterTest method configureByClass.

/**
   * Creates presenter (sut) by class
   *
   * @param name name of class
   * @return presenter
   */
private PyPullUpPresenterImpl configureByClass(@NotNull final String name) {
    final PyClass childClass = getClassByName(name);
    final PyMemberInfoStorage storage = new PyMemberInfoStorage(childClass);
    return new PyPullUpPresenterImpl(myView, storage, childClass);
}
Also used : PyClass(com.jetbrains.python.psi.PyClass) PyMemberInfoStorage(com.jetbrains.python.refactoring.classes.PyMemberInfoStorage)

Aggregations

PyClass (com.jetbrains.python.psi.PyClass)4 PyMemberInfoStorage (com.jetbrains.python.refactoring.classes.PyMemberInfoStorage)4 PyElement (com.jetbrains.python.psi.PyElement)1 PyMemberInfo (com.jetbrains.python.refactoring.classes.membersManager.PyMemberInfo)1 MocksControl (org.easymock.internal.MocksControl)1 NotNull (org.jetbrains.annotations.NotNull)1