void () { Language l = createLanguageWithNamesValidator("good", "bad"); PsiFile f = createMock(PsiFile.class); expect(f.getLanguage()).andReturn(l).anyTimes(); replay(f); PsiElement e = createMock(PsiField.class); expect(e.getContainingFile()).andStubReturn(f); expect(e.getLanguage()).andReturn(l).anyTimes(); replay(e); assertTrue(isValid(e, "good")); assertFalse(isValid(e, "bad")); }