@Override protected void setUp() throws Exception { super.setUp(); myModel = JpsElementFactory.getInstance().createModel(); myProject = myModel.getProject(); myDataStorageRoot = FileUtil.createTempDirectory("compile-server-" + getProjectName(), null); myLogger = new TestProjectBuilderLogger(); myBuildParams = new HashMap<String, String>(); }
@Override protected void tearDown() throws Exception { myProjectDir = null; super.tearDown(); }
private void doTestVariantsInner(@NotNull CompletionType type, int count, CheckType checkType, String... variants) { myFixture.complete(type, count); List<String> stringList = myFixture.getLookupElementStrings(); assertNotNull("\nPossibly the single variant has been completed.\nFile after:\n" + myFixture.getFile().getText(), stringList); Collection<String> varList = ContainerUtil.newArrayList(variants); if (checkType == CheckType.ORDERED_EQUALS) { UsefulTestCase.assertOrderedEquals(stringList, variants); } else if (checkType == CheckType.EQUALS) { UsefulTestCase.assertSameElements(stringList, variants); } else if (checkType == CheckType.INCLUDES) { varList.removeAll(stringList); assertTrue("Missing variants: " + varList, varList.isEmpty()); } else if (checkType == CheckType.EXCLUDES) { varList.retainAll(stringList); assertTrue("Unexpected variants: " + varList, varList.isEmpty()); } }
private void doElementDescriptionCheck() { PsiElement elementAtCaret = myFixture.getElementAtCaret(); assertNotNull(elementAtCaret); StringBuilder actualDump = new StringBuilder(); LOCATIONS.forEach( location -> { String actual = ElementDescriptionUtil.getElementDescription(elementAtCaret, location); String locationName = location.getClass().getSimpleName(); actualDump.append(locationName) .append(": ") .append(actual) .append("\n"); } ); UsefulTestCase.assertSameLinesWithFile(getTestResultsFilePath(), actualDump.toString()); }
private static void assertRelativePaths(File[] baseDirs, Collection<File> files, String[] expected){ List<String> relativePaths = new ArrayList<String>(); for (File file: files){ String path = file.getAbsolutePath(); for(File baseDir:baseDirs){ if(baseDir != null && FileUtil.isAncestor(baseDir, file, false)){ path = FileUtil.getRelativePath(baseDir, file); break; } } relativePaths.add(FileUtil.toSystemIndependentName(path)); } UsefulTestCase.assertSameElements(relativePaths, expected); } }
@Override public String fun(ResolveResult resolveResult) { PsiElement resolveResultElement = resolveResult.getElement(); assertNotNull(resolveResultElement); assertInstanceOf(resolveResultElement, PsiFileSystemItem.class); PsiFileSystemItem fileSystemItem = (PsiFileSystemItem) resolveResultElement; return VfsUtilCore.getRelativePath(fileSystemItem.getVirtualFile(), rootFile, '/'); } });
@Test public void testListsRepositories() { RepositorySelector selector = getPopulatedRepositoriesPanel(true /*openPopup*/); // Contains a repository item panel assertInstanceOf(getPanelObject(selector.getPanel()), RepositoryModelItem.class); // Contains a repository item assertNotNull(selector.getRepositories()); assertNotEmpty(Collections.list(selector.getRepositories().children())); }
@Deprecated public void assertLookupDoesntContains(List<String> expected) { List<String> lookups = myFixture.getLookupElementStrings(); assertNotNull(lookups); UsefulTestCase.assertDoesntContain(lookups, expected); }
UsefulTestCase.assertSameLinesWithFile(getTestResultsFilePath(), b.toString());
@Override public BnfExpression fun(List<BnfExpression> bnfExpressions) { assertSameElements(ContainerUtil.map(bnfExpressions, BnfIntroduceRuleHandler.RENDER_FUNCTION), "expr2", "expr2+", "expr1 expr2+", "expr1 expr2+ | expr3"); return bnfExpressions.get(2); } });
/** * Extracts the content of the repository tree e.g. a missing repositories message, or the * repositories themseleves (only the first item). */ private Object getPanelObject(JPanel panel) { // Shows the repositories panel assertInstanceOf(panel, RepositoryPanel.class); DefaultTreeModel treeModel = ((RepositoryPanel) panel).getTreeModel(); Enumeration root = ((DefaultMutableTreeNode) treeModel.getRoot()).children(); assertTrue(root.hasMoreElements()); Object repositories = root.nextElement(); assertInstanceOf(repositories, ProjectRepositoriesModelItem.class); Enumeration children = ((ProjectRepositoriesModelItem) repositories).children(); assertTrue(children.hasMoreElements()); return children.nextElement(); }
@Override protected void tearDown() throws Exception { myFixture.tearDown(); myFixture = null; ExEntryPanel.getInstance().deactivate(false); VimScriptGlobalEnvironment.getInstance().getVariables().clear(); super.tearDown(); }
@Override protected void setUp() throws Exception { super.setUp(); final IdeaTestFixtureFactory factory = IdeaTestFixtureFactory.getFixtureFactory(); final LightProjectDescriptor projectDescriptor = LightProjectDescriptor.EMPTY_PROJECT_DESCRIPTOR; final TestFixtureBuilder<IdeaProjectTestFixture> fixtureBuilder = factory.createLightFixtureBuilder(projectDescriptor); final IdeaProjectTestFixture fixture = fixtureBuilder.getFixture(); myFixture = IdeaTestFixtureFactory.getFixtureFactory().createCodeInsightFixture(fixture, new LightTempDirTestFixtureImpl(true)); myFixture.setUp(); myFixture.setTestDataPath(getTestDataPath()); KeyHandler.getInstance().fullReset(myFixture.getEditor()); Options.getInstance().resetAllOptions(); VimPlugin.getKey().resetKeyMappings(); }
protected void doTestTyping(@NotNull String toType) { initWithFileSmart(); myFixture.type(toType); UsefulTestCase.assertSameLinesWithFile(getTestResultsFilePath(), getEditorTextWithCaretsAndSelections()); }
public static void doVariantsTestInner(CodeInsightTestFixture fixture, CompletionType type, CheckType checkType, String... variants) { fixture.complete(type, 1); List<String> stringList = fixture.getLookupElementStrings(); assertNotNull(stringList); Collection<String> varList = ContainerUtil.newArrayList(variants); if (checkType == EQUALS) { UsefulTestCase.assertSameElements(stringList, variants); } else if (checkType == INCLUDES) { varList.removeAll(stringList); assertTrue("Missing: " + varList + " in " + stringList, varList.isEmpty()); } else if (checkType == EXCLUDES) { varList.retainAll(stringList); assertTrue("Unexpected: " + varList + " in " + stringList, varList.isEmpty()); } }
@Test public void testShowsMissingProjectPanel_WhenProjectIsMissing() { JPanel panel = getMissingProjectPanel(); // Shows the project not selected panel assertInstanceOf(panel, ProjectNotSelectedPanel.class); }
protected void tearDown() throws Exception { this.project = null; try { this.myFixture.tearDown(); } finally { this.myFixture = null; super.tearDown(); } }
@Override public void setUp() throws Exception { super.setUp(); myFixture = IdeaTestFixtureFactory.getFixtureFactory() .createFixtureBuilder(RandomStringUtils.randomAlphanumeric(20)) .getFixture(); myFixture.setUp(); project = myFixture.getProject(); Settings.getInstance(project).pluginEnabled = true; }
public void checkSerializedReferencesWithFile(@NotNull String appendix) { CodeInsightTestFixtureImpl.ensureIndexesUpToDate(getProject()); addVirtualFileFilter(); StringBuilder sb = new StringBuilder(); List<PsiReference> references = collectFileReferences(); for (PsiReference psiReference : references) { psiReference.resolve(); } removeVirtualFileFilter(); for (PsiReference psiReference : references) { sb.append(serializeReference(psiReference)).append("\n"); } UsefulTestCase.assertSameLinesWithFile(getTestResultsFilePath(appendix), sb.toString()); }
@Test public void testShowsNoRepositoriesMessage_WhenNoCloudReposFound() { RepositorySelector selector = getEmptyRepositoriesPanel(); // Shows a 'no repositories' message assertInstanceOf(getPanelObject(selector.getPanel()), ResourceEmptyModelItem.class); }