void () { myFixture.enableInspections(new PublicFieldInspection()); myFixture.configureByText("Test.java", """ class A { public String name<caret>; } class B { void foo(A a) { System.out.println(a.name); } }"""); IntentionAction action = myFixture.findSingleIntention("Encapsulate field 'name'"); String text = myFixture.getIntentionPreviewText(action); assertEquals(""" class A { private String name; public String getName() { return name; } public void setName(String name) { this.name = name; } } class B { void foo(A a) { System.out.println(a.getName()); } }""", text); }