/******************************************************************************* * Copyright (c) 2000, 2014 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.che.plugin.java.server.jdt.core; import org.eclipse.che.plugin.java.server.che.BaseTest; import org.eclipse.che.plugin.java.server.jdt.testplugin.ProjectTestSetup; import org.eclipse.che.plugin.java.server.jdt.testplugin.StringAsserts; import org.eclipse.core.runtime.CoreException; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jdt.core.dom.rewrite.ImportRewrite; import org.eclipse.jdt.internal.corext.codemanipulation.StubUtility; import org.junit.After; import org.junit.Before; import java.io.IOException; import static org.junit.Assert.assertTrue; public class CoreTests extends BaseTest { private ProjectTestSetup setup; public CoreTests(ProjectTestSetup setup) { this.setup = setup; } @Before public void setUp() throws Exception { setup.setUp(); } @After public void tearDown() throws Exception { setup.tearDown(); } public static void assertEqualString(String actual, String expected) { StringAsserts.assertEqualString(actual, expected); } public static void assertEqualStringIgnoreDelim(String actual, String expected) throws IOException { StringAsserts.assertEqualStringIgnoreDelim(actual, expected); } public static void assertEqualStringsIgnoreOrder(String[] actuals, String[] expecteds) { StringAsserts.assertEqualStringsIgnoreOrder(actuals, expecteds); } public static void assertNumberOf(String name, int is, int expected) { assertTrue("Wrong number of " + name + ", is: " + is + ", expected: " + expected, is == expected); } protected ImportRewrite newImportsRewrite(ICompilationUnit cu, String[] order, int normalThreshold, int staticThreshold, boolean restoreExistingImports) throws CoreException { ImportRewrite rewrite= StubUtility.createImportRewrite(cu, restoreExistingImports); rewrite.setImportOrder(order); rewrite.setOnDemandImportThreshold(normalThreshold); rewrite.setStaticOnDemandImportThreshold(staticThreshold); return rewrite; } protected ImportRewrite newImportsRewrite(CompilationUnit cu, String[] order, int normalThreshold, int staticThreshold, boolean restoreExistingImports) { ImportRewrite rewrite= ImportRewrite.create(cu, restoreExistingImports); rewrite.setImportOrder(order); rewrite.setOnDemandImportThreshold(normalThreshold); rewrite.setStaticOnDemandImportThreshold(staticThreshold); return rewrite; } }