use of com.intellij.refactoring.replaceConstructorWithBuilder.ReplaceConstructorWithBuilderProcessor in project intellij-community by JetBrains.
the class ReplaceConstructorWithBuilderTest method doTest.
private void doTest(final boolean createNewBuilderClass, final Map<String, String> expectedDefaults, final String conflicts, final String packageName) throws Exception {
doTest((rootDir, rootAfter) -> {
final PsiClass aClass = myJavaFacade.findClass("Test", GlobalSearchScope.projectScope(getProject()));
assertNotNull("Class Test not found", aClass);
final LinkedHashMap<String, ParameterData> map = new LinkedHashMap<>();
final PsiMethod[] constructors = aClass.getConstructors();
for (PsiMethod constructor : constructors) {
ParameterData.createFromConstructor(constructor, "set", map);
}
if (expectedDefaults != null) {
for (Map.Entry<String, String> entry : expectedDefaults.entrySet()) {
final ParameterData parameterData = map.get(entry.getKey());
assertNotNull(parameterData);
assertEquals(entry.getValue(), parameterData.getDefaultValue());
}
}
try {
new ReplaceConstructorWithBuilderProcessor(getProject(), constructors, map, "Builder", packageName, null, createNewBuilderClass).run();
if (conflicts != null) {
fail("Conflicts were not detected:" + conflicts);
}
} catch (BaseRefactoringProcessor.ConflictsInTestsException e) {
if (conflicts == null) {
fail("Conflict detected:" + e.getMessage());
}
}
LocalFileSystem.getInstance().refresh(false);
FileDocumentManager.getInstance().saveAllDocuments();
});
}
Aggregations