Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
65,400
void () { PsiClass aClass = myFixture.addClass(""" @org.junit.Ignorepublic class TestClass { @org.junit.Test public void testFoo() throws Exception {} }"""); final SMTestProxy testProxy = new SMTestProxy("TestClass", false, "java:test://TestClass/TestClass"); final Project project = getProject(); final GlobalSearchScop...
testLocatorForIgnoredClass
65,401
void () { myFixture.addClass(""" class A {}public class TestClass { @org.junit.platform.commons.annotation.Testable public void testFoo(A a) throws Exception {} }"""); final SMTestProxy testProxy = new SMTestProxy("testFoo", false, "java:test://TestClass/testFoo"); testProxy.setLocator(JavaTestLocator.INSTANCE); final ...
testPresentationForJunit5MethodsWithParameters
65,402
void () { myFixture.configureByText("a.java", "public class Test1 {<caret>} public class Test2 {}"); TestApplicationManager testApplication = TestApplicationManager.getInstance(); try { testApplication.setDataProvider(new TestDataProvider(myFixture.getProject()) { @Override public Object getData(@NotNull @NonNls String...
testMultipleClassesInOneFile
65,403
Object (@NotNull @NonNls String dataId) { if (CommonDataKeys.VIRTUAL_FILE_ARRAY.is(dataId)) { return new VirtualFile[] {myFixture.getFile().getVirtualFile()}; } return super.getData(dataId); }
getData
65,404
boolean () { return true; }
createTempFiles
65,405
String (String fileContent, Module mod1, Module mod2) { fileContent = FileUtil.toSystemIndependentName(fileContent); fileContent = replace(fileContent, ModuleRootManager.getInstance(mod1).getContentRoots()[0].getPath(), "MODULE_1"); fileContent = replace(fileContent, ModuleRootManager.getInstance(mod2).getContentRoots(...
preparePathsForComparison
65,406
String (String fileContent, String regex, String home) { return fileContent.replaceAll(StringUtil.escapePattern(FileUtil.toSystemIndependentName(regex)), home); }
replace
65,407
void () { myFixture.configureByText("ExampleTest.java", """ import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; public class ExampleTest { abstract class BaseTest { @Test public void runTest() {} } @Nested class ChildTest extends BaseTest {} } """); myFixture.testHighlighting(true, false, false); }
testRecognizeNestedAbstractClass
65,408
void () {}
runTest
65,409
void () { myFixture.configureByText("A.java", """ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import java.util.*; @RunWith(Parameterized.class) public class A { @Parameterized.Parameters public static Collection<Object[]> data() { return Arrays.asList(new Object[] {"1...
testRecognizeTestMethodInParameterizedClass
65,410
Collection<Object[]> () { return Arrays.asList(new Object[] {"11"}, new Object[] {"12"}); }
data
65,411
void () { doTest(Description.createSuiteDescription("empty suite"), """ ##teamcity[enteredTheMatrix] ##teamcity[suiteTreeStarted name='empty suite' locationHint='java:suite://empty suite'] ##teamcity[suiteTreeEnded name='empty suite'] ##teamcity[treeEnded] """); }
testEmptySuite
65,412
void () { StringBuilder buf = new StringBuilder(); for (int i = 0; i < 1000; i++) { buf.append(DebugUtil.currentStackTrace()); } final StringBuffer output = new StringBuffer(); final JUnit4TestListener sender = createListener(output); final Description description = Description.createTestDescription("A", "a"); sender.t...
testLongOutputPreservesTestName
65,413
void () { final Description root = Description.createSuiteDescription("root"); Description testA = Description.createTestDescription("TestA", "test1"); root.addChild(testA); final StringBuffer buf = new StringBuffer(); final JUnit4TestListener sender = createListener(buf); sender.testRunStarted(root); sender.testStarte...
testMultipleFailures
65,414
JUnit4TestListener (final StringBuffer buf) { return new JUnit4TestListener(new PrintStream(new OutputStream() { @Override public void write(int b) { buf.append(new String(new byte[]{(byte)b}, StandardCharsets.UTF_8)); } })) { @Override protected long currentTime() { return 0; } @Override protected String getTrace(Fail...
createListener
65,415
void (int b) { buf.append(new String(new byte[]{(byte)b}, StandardCharsets.UTF_8)); }
write
65,416
long () { return 0; }
currentTime
65,417
String (Failure failure) { return StringUtil.convertLineSeparators(super.getTrace(failure)); }
getTrace
65,418
void (String className, Description aTestClass, List<Description> tests) { for (String paramName : new String[]{"[0]", "[1]"}) { final Description param1 = Description.createSuiteDescription(paramName); aTestClass.addChild(param1); final Description testDescription = Description.createTestDescription(className, "testNa...
attachParameterizedTests
65,419
void (Description description, String expected) { final StringBuffer buf = new StringBuffer(); createListener(buf).sendTree(description); Assert.assertEquals("output: " + buf, expected, StringUtil.convertLineSeparators(buf.toString())); }
doTest
65,420
void () { Assert.assertNotNull(createNotification("arrays first differed at element [0]; expected: java.lang.String<Text> but was: java.lang.StringBuilder<Text>")); }
testArrayComparison
65,421
void () { Assert.assertNull(createNotification("line1 expected:<java.lang.String<Text>> but was:<java.lang.StringBuilder<Text>> and here some very important tail")); }
testWithTailNotMatch
65,422
void () { Assert.assertNull(createNotification("line1 expected:<java.lang.String<Text>> but was:<java.lang.StringBuilder<Text>>\n" + "line2 expected:<java.lang.String<Text1>> but was:<java.lang.StringBuilder<Text1>>")); }
testMultiplePatternsInOneAssertion
65,423
void () { Assert.assertNotNull(createNotification(""" reason Expected: is "aaa\\naa" but: was "bbb\\nbb\"""")); }
testHamcrestAssertThatWithReason
65,424
void () { Assert.assertNotNull(createNotification(""" reason Expected: "aaa\\naa" got: "bbb\\nbb\"""")); }
testHamcrestAssertThatEqWithReason
65,425
void () { ComparisonFailureData notification = createNotification(""" Expected: is <2> but: was <1>"""); Assert.assertNotNull(notification); Assert.assertEquals("is <2>", notification.getExpected()); }
testHamcrestAssertThatEqWithReasonTrim
65,426
void () { ComparisonFailureData notification = createNotification("expected:<<foo>> but was:<hi with <brackets>>"); Assert.assertNotNull(notification); Assert.assertEquals("<foo>", notification.getExpected()); Assert.assertEquals("hi with <brackets>", notification.getActual()); }
testNonGreedyGt
65,427
void () { ComparisonFailureData notification = createNotification("expected: com.google.common.collect.SingletonImmutableList<[1]> but was: com.google.common.collect.SingletonImmutableList<[1]>"); Assert.assertNotNull(notification); Assert.assertEquals("com.google.common.collect.SingletonImmutableList<[1]>", notificati...
testJunitGuava
65,428
void () { ComparisonFailureData notification = createNotification( new CustomComparisonFailure("message", "expected", "actual") ); Assert.assertNotNull(notification); Assert.assertEquals("expected", notification.getExpected()); Assert.assertEquals("actual", notification.getActual()); }
testCustomComparisonException
65,429
ComparisonFailureData (String message) { return ExpectedPatterns.createExceptionNotification(new Throwable(message)); }
createNotification
65,430
ComparisonFailureData (Throwable throwable) { return ExpectedPatterns.createExceptionNotification(throwable); }
createNotification
65,431
JavaCodeInsightTestFixture (JavaCodeInsightTestFixture fixture) { fixture.addClass( "package org.junit.jupiter.params.provider;\n" + "public @interface MethodSource {String[] value() default \"\";}"); fixture.addClass( "package org.junit.jupiter.params.provider;\n" + "public @interface EmptySource {}"); fixture.addClas...
setupJUnit5Library
65,432
boolean (@NotNull final TestClassFilter testClassFilter, @Nullable final Module module, @NotNull final Set<? super PsiClass> found) { final PsiManager manager = testClassFilter.getPsiManager(); final Project project = manager.getProject(); GlobalSearchScope projectScopeWithoutLibraries = GlobalSearchScope.projectScope(...
findAllTestClasses
65,433
boolean (PsiClass aClass) { if (testClassFilter.isAccepted(aClass)) found.add(aClass); return true; }
processInReadAction
65,434
boolean (final GlobalSearchScope scope, final TestClassFilter testClassFilter, @Nullable final Module module, final Set<? super PsiClass> found, final Set<? super PsiClass> processed, final String annotation, final Project project) { final Ref<Boolean> isJUnit4 = new Ref<>(Boolean.FALSE); // annotated with @Test final ...
addAnnotatedMethodsAnSubclasses
65,435
boolean (PsiClass aClass) { if (testClassFilter.isAccepted(aClass)) { found.add(aClass); processed.add(aClass); isJUnit4.set(Boolean.TRUE); } return true; }
processInReadAction
65,436
void (ActionEvent e) { myCommonJavaParameters.setModuleContext(myModuleSelector.getModule()); myModel.reloadTestKindModel(JUnitConfigurable.this.myTypeChooser, myModuleSelector.getModule(), null); }
actionPerformed
65,437
void (ActionEvent e) { myRepeatCountField.setEnabled(RepeatCount.N.equals(myRepeatCb.getSelectedItem())); }
actionPerformed
65,438
void (ActionEvent e) { Integer item = (Integer)myTypeChooser.getSelectedItem(); if (item != null) { myModel.setType(item); changePanel(); } }
actionPerformed
65,439
void (final ChangeEvent e) { onScopeChanged(); }
stateChanged
65,440
boolean () { return false; }
productionOnly
65,441
void () { myRepeatCb.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int testType = (Integer)Objects.requireNonNull(myTypeChooser.getSelectedItem()); if (testType == JUnitConfigurationModel.CLASS || testType == JUnitConfigurationModel.METHOD) { String[] model = getForkMod...
addListeners
65,442
void (ActionEvent e) { int testType = (Integer)Objects.requireNonNull(myTypeChooser.getSelectedItem()); if (testType == JUnitConfigurationModel.CLASS || testType == JUnitConfigurationModel.METHOD) { String[] model = getForkModel(testType, JUnitConfigurable.this.myRepeatCb.getSelectedItem()); myForkCb.setModel(new Defau...
actionPerformed
65,443
void (Project project, JComboBox<String> comboBox) { final DefaultComboBoxModel<String> model = new DefaultComboBoxModel<>(); comboBox.setModel(model); model.addElement(JUnitBundle.message("test.discovery.by.all.changes.combo.item")); if (!project.isDefault()) { final List<LocalChangeList> changeLists = ChangeListManag...
setupChangeLists
65,444
BrowseModuleValueActionListener[] (Project project, ConfigurationModuleSelector moduleSelector, EditorTextFieldWithBrowseButton packageField, TextFieldWithBrowseButton patternField, EditorTextFieldWithBrowseButton categoryField, Supplier<String> className) { return new BrowseModuleValueActionListener[]{ new PackageChoo...
createBrowsers
65,445
Condition<PsiMethod> (PsiClass testClass) { return new JUnitUtil.TestMethodFilter(testClass); }
getFilter
65,446
String () { return className.get(); }
getClassName
65,447
ConfigurationModuleSelector () { return moduleSelector; }
getModuleSelector
65,448
String () { final VirtualFile virtualFile = FileChooser.chooseFile(FileChooserDescriptorFactory.createSingleFolderDescriptor(), project, null); if (virtualFile != null) { return FileUtil.toSystemDependentName(virtualFile.getPath()); } return null; }
showDialog
65,449
void (final JRadioButton[] radioButtons, ChangeListener listener) { final ButtonGroup group = new ButtonGroup(); for (final JRadioButton radioButton : radioButtons) { radioButton.getModel().addChangeListener(listener); group.add(radioButton); } if (group.getSelection() == null) group.setSelected(radioButtons[0].getMode...
addRadioButtonsListeners
65,450
void (@NotNull final JUnitConfiguration configuration) { configuration.setRepeatMode((String)myRepeatCb.getSelectedItem()); try { configuration.setRepeatCount(Integer.parseInt(myRepeatCountField.getText())); } catch (NumberFormatException e) { configuration.setRepeatCount(1); } configuration.getPersistentData().setUniq...
applyEditorTo
65,451
String[] (String text) { if (text.isEmpty()) { return ArrayUtilRt.EMPTY_STRING_ARRAY; } return text.split("\u001B"); }
setArrayFromText
65,452
void (@NotNull final JUnitConfiguration configuration) { final int count = configuration.getRepeatCount(); myRepeatCountField.setText(String.valueOf(count)); myRepeatCountField.setEnabled(count > 1); //noinspection HardCodedStringLiteral myRepeatCb.setSelectedItem(configuration.getRepeatMode()); myModel.reset(configura...
resetEditorFrom
65,453
void () { final Integer selectedType = (Integer)myTypeChooser.getSelectedItem(); if (selectedType == null) return; myPackagePanel.setVisible(selectedType == JUnitConfigurationModel.ALL_IN_PACKAGE); myScopesPanel.setVisible(selectedType == JUnitConfigurationModel.PATTERN || selectedType == JUnitConfigurationModel.ALL_IN...
changePanel
65,454
String (Integer selectedType, String forkMethod, Object repeat) { if (forkMethod == null) { forkMethod = JUnitConfiguration.FORK_NONE; } else if (selectedType == JUnitConfigurationModel.CLASS && JUnitConfiguration.FORK_KLASS.equals(forkMethod) && RepeatCount.ONCE.equals(repeat)) { forkMethod = JUnitConfiguration.FORK_M...
updateForkMethod
65,455
String[] (int selectedType, Object repeat) { if (selectedType != JUnitConfigurationModel.CLASS && selectedType != JUnitConfigurationModel.METHOD && selectedType != JUnitConfigurationModel.BY_SOURCE_POSITION) { return FORK_MODE_ALL; } boolean isMethod = selectedType == JUnitConfigurationModel.METHOD || selectedType == J...
getForkModel
65,456
ModuleDescriptionsComboBox () { return myModule.getComponent(); }
getModulesComponent
65,457
ConfigurationModuleSelector () { return myModuleSelector; }
getModuleSelector
65,458
void () { for (int i = 0; i < myTestLocations.length; i++) { final LabeledComponent testLocation = getTestLocation(i); final JComponent component = testLocation.getComponent(); final ComponentWithBrowseButton<? extends JComponent> field; Object document; if (component instanceof TextFieldWithBrowseButton) { field = (Te...
installDocuments
65,459
LabeledComponent (final int index) { return myTestLocations[index]; }
getTestLocation
65,460
void () { myPackage = new LabeledComponent<>(); myPackage.setComponent(new EditorTextFieldWithBrowseButton(myProject, false)); myCategory = new LabeledComponent<>(); myCategory.setComponent(new EditorTextFieldWithBrowseButton(myProject, true, new JavaCodeFragment.VisibilityChecker() { @Override public Visibility isDecl...
createUIComponents
65,461
Visibility (PsiElement declaration, PsiElement place) { if (declaration instanceof PsiClass) { return Visibility.VISIBLE; } return Visibility.NOT_VISIBLE; }
isDeclarationVisible
65,462
Visibility (PsiElement declaration, PsiElement place) { try { if (declaration instanceof PsiClass && (classBrowser.getFilter().isAccepted(((PsiClass)declaration)) || classBrowser.findClass(((PsiClass)declaration).getQualifiedName()) != null && place.getParent() != null)) { return Visibility.VISIBLE; } } catch (ClassBro...
isDeclarationVisible
65,463
JComponent () { return anchor; }
getAnchor
65,464
void (JComponent anchor) { this.anchor = anchor; mySearchForTestsLabel.setAnchor(anchor); myTestLabel.setAnchor(anchor); myClass.setAnchor(anchor); myDir.setAnchor(anchor); myMethod.setAnchor(anchor); myPattern.setAnchor(anchor); myPackage.setAnchor(anchor); myCategory.setAnchor(anchor); myUniqueIdField.setAnchor(ancho...
setAnchor
65,465
void (final int newType) { myTypeChooser.setSelectedItem(newType); final IntList enabledFields = ourEnabledFields.size() > newType ? ourEnabledFields.get(newType) : null; for (int i = 0; i < myTestLocations.length; i++) getTestLocation(i).setEnabled(enabledFields != null && enabledFields.contains(i)); /*if (newType == ...
onTypeChanged
65,466
void () { final boolean allInPackageAllInProject = myModel.disableModuleClasspath(myWholeProjectScope.isSelected()); myModule.setEnabled(!allInPackageAllInProject); if (allInPackageAllInProject) { myModule.getComponent().setSelectedItem(null); } }
onScopeChanged
65,467
String () { return ((LabeledComponent<EditorTextFieldWithBrowseButton>)getTestLocation(JUnitConfigurationModel.CLASS)).getComponent().getText(); }
getClassName
65,468
JComponent () { return myWholePanel; }
createEditor
65,469
void (final JUnitConfiguration currentState) { myCommonJavaParameters.applyTo(currentState); getModuleSelector().applyTo(currentState); }
applyHelpersTo
65,470
String () { final PackageChooserDialog dialog = new PackageChooserDialog(ExecutionBundle.message("choose.package.dialog.title"), getProject()); dialog.show(); final PsiPackage aPackage = dialog.getSelectedPackage(); return aPackage != null ? aPackage.getQualifiedName() : null; }
showDialog
65,471
void (@NotNull PsiClass psiClass) { final JTextField textField = myPatternTextField.getTextField(); final String text = textField.getText(); textField.setText(text + (!text.isEmpty() ? "||" : "") + psiClass.getQualifiedName()); }
onClassChosen
65,472
void (ActionEvent e) { showDialog(); }
actionPerformed
65,473
void (@NotNull PsiClass psiClass) { myPackageTextField.setText(StringUtil.getPackageName(Objects.requireNonNull(psiClass.getQualifiedName()))); }
onClassChosen
65,474
PsiClass (final String className) { return myModuleSelector.findClass(className); }
findClass
65,475
GlobalSearchScope () { return globalSearchScope; }
getScope
65,476
boolean (PsiClass aClass) { return JUnitUtil.isTestClass(aClass,true, true); }
isAccepted
65,477
PsiClass (final String className) { return myModuleSelector.findClass(className); }
findClass
65,478
GlobalSearchScope () { return scope; }
getScope
65,479
boolean (final PsiClass aClass) { return true; }
isAccepted
65,480
void (@NotNull PsiClass psiClass) { myCategoryField.setText(psiClass.getQualifiedName()); }
onClassChosen
65,481
Visibility (PsiElement declaration, PsiElement place) { if (declaration instanceof PsiClass) { return Visibility.VISIBLE; } return Visibility.NOT_VISIBLE; }
isDeclarationVisible
65,482
JComponent[] () { return ArrayUtil.append(myFields, myTypeChooser); }
getAllComponents
65,483
int () { Integer item = myTypeChooser.getItem(); return item == null ? 0 : item; }
getTestKind
65,484
boolean (boolean wholeProjectSelected) { return myModel.disableModuleClasspath(wholeProjectSelected); }
disableModuleClasspath
65,485
void (int oldKind, int kind) { myTypeChooser.setItem(kind); Arrays.stream(myFields).forEach(field -> field.setVisible(false)); myFields[kind].setVisible(true); if (METHOD == kind) { myFields[CLASS].setVisible(true); } if (PATTERN == kind && (oldKind == CLASS || oldKind == METHOD) && StringUtil.isEmpty(((TextAccessor)my...
kindChanged
65,486
String () { return ((TextAccessor)myFields[CLASS]).getText(); }
getClassName
65,487
void (@NotNull JUnitConfiguration s) { String[] ids = s.getPersistentData().getUniqueIds(); myUniqueIdField.setText(ids != null ? StringUtil.join(ids, "\u001B") : null); myTagsField.setText(s.getPersistentData().getTags()); myChangeLists.setSelectedItem(s.getPersistentData().getChangeList()); myModel.reset(s); }
resetEditorFrom
65,488
void (@NotNull JUnitConfiguration s) { s.getPersistentData().setUniqueIds(JUnitConfigurable.setArrayFromText(myUniqueIdField.getText())); s.getPersistentData().setTags(myTagsField.getText()); s.getPersistentData().setChangeList(myChangeLists.getItem()); myModel.apply(myModuleSelector.getModule(), s, myClassField); vali...
applyEditorTo
65,489
boolean (int type) { if (type == myType) return false; int oldType = myType; if (type < 0 || type >= ourTestObjects.size()) type = CLASS; myType = type; fireTypeChanged(oldType, type); return true; }
setType
65,490
void (final int oldType, final int newType) { myListener.accept(oldType, newType); }
fireTypeChanged
65,491
void (final BiConsumer<Integer, Integer> listener) { myListener = listener; }
setListener
65,492
void (final int i, Object doc) { myJUnitDocuments[i] = doc; }
setJUnitDocument
65,493
void (final Module module, final JUnitConfiguration configuration, @Nullable ClassEditorField classField) { final boolean shouldUpdateName = configuration.isGeneratedName(); applyTo(configuration.getPersistentData(), module, classField); if (shouldUpdateName && !JavaExecutionUtil.isNewName(configuration.getName())) { c...
apply
65,494
void (final JUnitConfiguration.Data data, final Module module, @Nullable ClassEditorField classField) { final String testObject = getTestObject(); final String className = getJUnitTextValue(CLASS); data.TEST_OBJECT = testObject; if (!JUnitConfiguration.TEST_PACKAGE.equals(testObject) && !JUnitConfiguration.TEST_PATTERN...
applyTo
65,495
String () { return ourTestObjects.get(myType); }
getTestObject
65,496
String (final int index) { return getDocumentText(index, myJUnitDocuments); }
getJUnitTextValue
65,497
String (final int index, final Object[] documents) { final Object document = documents[index]; if (document instanceof PlainDocument) { try { return ((PlainDocument)document).getText(0, ((PlainDocument)document).getLength()); } catch (BadLocationException e) { throw new RuntimeException(e); } } return ((Document)docume...
getDocumentText
65,498
void (final JUnitConfiguration configuration) { final JUnitConfiguration.Data data = configuration.getPersistentData(); setTestType(data.TEST_OBJECT); setJUnitTextValue(ALL_IN_PACKAGE, data.getPackageName()); setJUnitTextValue(CLASS, replaceRuntimeClassName(data.getMainClassName())); setJUnitTextValue(METHOD, data.getM...
reset
65,499
String (String mainClassName) { return mainClassName.replace('$', '.'); }
replaceRuntimeClassName