diff --git a/platform/vcs-log/graph/test/com/intellij/vcs/log/graph/impl/permanent/GraphBuilderTest.java b/platform/vcs-log/graph/test/com/intellij/vcs/log/graph/impl/permanent/GraphBuilderTest.java deleted file mode 100644 index f8401386e8eb..000000000000 --- a/platform/vcs-log/graph/test/com/intellij/vcs/log/graph/impl/permanent/GraphBuilderTest.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright 2000-2014 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.intellij.vcs.log.graph.impl.permanent; - -import com.intellij.util.NotNullFunction; -import com.intellij.vcs.log.graph.AbstractTestWithTwoTextFile; -import com.intellij.vcs.log.graph.GraphCommit; -import com.intellij.vcs.log.graph.GraphPackage; -import com.intellij.vcs.log.graph.impl.CommitIdManager; -import org.jetbrains.annotations.NotNull; -import org.junit.Test; - -import java.io.IOException; -import java.util.List; - -import static org.junit.Assert.assertEquals; - -public abstract class GraphBuilderTest> extends AbstractTestWithTwoTextFile { - public GraphBuilderTest() { - super("graphBuilder/"); - } - - @Override - protected void runTest(String in, String out) { - List> commits = getCommitIdManager().parseCommitList(in); - - PermanentLinearGraphBuilder graphBuilder = PermanentLinearGraphBuilder.newInstance(commits); - PermanentLinearGraphImpl graph = graphBuilder.build(new NotNullFunction() { - @NotNull - @Override - public Integer fun(CommitId dom) { - return - getCommitIdManager().toInt(dom); - } - }); - - String actual = GraphPackage.asString(graph, false); - assertEquals(out, actual); - } - - protected abstract CommitIdManager getCommitIdManager(); - - @Test - public void simple() throws IOException { - doTest("simple"); - } - - @Test - public void manyNodes() throws IOException { - doTest("manyNodes"); - } - - @Test - public void manyUpNodes() throws IOException { - doTest("manyUpNodes"); - } - - @Test - public void manyDownNodes() throws IOException { - doTest("manyDownNodes"); - } - - @Test - public void oneNode() throws IOException { - doTest("oneNode"); - } - - @Test - public void oneNodeNotFullGraph() throws IOException { - doTest("oneNodeNotFullGraph"); - } - - @Test - public void notFullGraph() throws IOException { - doTest("notFullGraph"); - } - - @Test - public void parentsOrder() throws IOException { - doTest("parentsOrder"); - } - - @Test - public void duplicateParents() throws IOException { - doTest("duplicateParents"); - } - - public static class StringTest extends GraphBuilderTest { - @Override - protected CommitIdManager getCommitIdManager() { - return CommitIdManager.STRING_COMMIT_ID_MANAGER; - } - } - - public static class IntegerTest extends GraphBuilderTest { - @Override - protected CommitIdManager getCommitIdManager() { - return CommitIdManager.INTEGER_COMMIT_ID_MANAGER; - } - } -} diff --git a/platform/vcs-log/graph/test/com/intellij/vcs/log/graph/impl/permanent/GraphBuilderTest.kt b/platform/vcs-log/graph/test/com/intellij/vcs/log/graph/impl/permanent/GraphBuilderTest.kt new file mode 100644 index 000000000000..009bbee0cb45 --- /dev/null +++ b/platform/vcs-log/graph/test/com/intellij/vcs/log/graph/impl/permanent/GraphBuilderTest.kt @@ -0,0 +1,113 @@ +/* + * Copyright 2000-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.intellij.vcs.log.graph.impl.permanent + +import com.intellij.util.NotNullFunction +import com.intellij.vcs.log.graph.AbstractTestWithTwoTextFile +import com.intellij.vcs.log.graph.GraphCommit +import com.intellij.vcs.log.graph.* +import com.intellij.vcs.log.graph.impl.CommitIdManager +import org.junit.Test + +import java.io.IOException + +import org.junit.Assert.assertEquals + +public abstract class GraphBuilderTest> : AbstractTestWithTwoTextFile("graphBuilder/") { + + override fun runTest(`in`: String, out: String) { + val commits = getCommitIdManager().parseCommitList(`in`) + + val graphBuilder = PermanentLinearGraphBuilder.newInstance(commits) + val graph = graphBuilder.build(object : NotNullFunction { + override fun `fun`(dom: CommitId): Int { + return -getCommitIdManager().toInt(dom) + } + }) + + val actual = graph.asString(false) + assertEquals(out, actual) + } + + protected abstract fun getCommitIdManager(): CommitIdManager + + Test + throws(javaClass()) + public fun simple() { + doTest("simple") + } + + Test + throws(javaClass()) + public fun manyNodes() { + doTest("manyNodes") + } + + Test + throws(javaClass()) + public fun manyUpNodes() { + doTest("manyUpNodes") + } + + Test + throws(javaClass()) + public fun manyDownNodes() { + doTest("manyDownNodes") + } + + Test + throws(javaClass()) + public fun oneNode() { + doTest("oneNode") + } + + Test + throws(javaClass()) + public fun oneNodeNotFullGraph() { + doTest("oneNodeNotFullGraph") + } + + Test + throws(javaClass()) + public fun notFullGraph() { + doTest("notFullGraph") + } + + Test + throws(javaClass()) + public fun parentsOrder() { + doTest("parentsOrder") + } + + Test + throws(javaClass()) + public fun duplicateParents() { + doTest("duplicateParents") + } + + public class StringTest : GraphBuilderTest() { + override fun getCommitIdManager(): CommitIdManager { + return CommitIdManager.STRING_COMMIT_ID_MANAGER + } + } + + public class IntegerTest : GraphBuilderTest() { + override fun getCommitIdManager(): CommitIdManager { + return CommitIdManager.INTEGER_COMMIT_ID_MANAGER + } + } +} diff --git a/platform/vcs-log/graph/test/com/intellij/vcs/log/graph/impl/print/TestGraphBuilderTest.java b/platform/vcs-log/graph/test/com/intellij/vcs/log/graph/impl/print/TestGraphBuilderTest.java deleted file mode 100644 index f0329446afa6..000000000000 --- a/platform/vcs-log/graph/test/com/intellij/vcs/log/graph/impl/print/TestGraphBuilderTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2000-2014 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.vcs.log.graph.impl.print; - -import com.intellij.vcs.log.graph.AbstractTestWithTwoTextFile; -import com.intellij.vcs.log.graph.GraphPackage; -import com.intellij.vcs.log.graph.api.LinearGraph; -import com.intellij.vcs.log.graph.parser.LinearGraphParser; -import org.junit.Test; - -import java.io.IOException; - -import static org.junit.Assert.assertEquals; - -public class TestGraphBuilderTest extends AbstractTestWithTwoTextFile { - public TestGraphBuilderTest() { - super("testParser"); - } - - @Override - protected void runTest(String in, String out) { - LinearGraph graph = LinearGraphParser.parse(in); - assertEquals(out, GraphPackage.asString(graph, false)); - } - - @Test - public void specialElements() throws IOException { - doTest("specialElements"); - } - - @Test - public void manyNodes() throws IOException { - doTest("manyNodes"); - } - - @Test - public void notLoadNode() throws IOException { - doTest("notLoadNode"); - } -} diff --git a/platform/vcs-log/graph/test/com/intellij/vcs/log/graph/impl/print/TestGraphBuilderTest.kt b/platform/vcs-log/graph/test/com/intellij/vcs/log/graph/impl/print/TestGraphBuilderTest.kt new file mode 100644 index 000000000000..3f5f42434e31 --- /dev/null +++ b/platform/vcs-log/graph/test/com/intellij/vcs/log/graph/impl/print/TestGraphBuilderTest.kt @@ -0,0 +1,52 @@ +/* + * Copyright 2000-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.vcs.log.graph.impl.print + +import com.intellij.vcs.log.graph.AbstractTestWithTwoTextFile +import com.intellij.vcs.log.graph.* +import com.intellij.vcs.log.graph.api.LinearGraph +import com.intellij.vcs.log.graph.parser.LinearGraphParser +import org.junit.Test + +import java.io.IOException + +import org.junit.Assert.assertEquals + +public class TestGraphBuilderTest : AbstractTestWithTwoTextFile("testParser") { + + override fun runTest(`in`: String, out: String) { + val graph = LinearGraphParser.parse(`in`) + assertEquals(out, graph.asString(false)) + } + + Test + throws(javaClass()) + public fun specialElements() { + doTest("specialElements") + } + + Test + throws(javaClass()) + public fun manyNodes() { + doTest("manyNodes") + } + + Test + throws(javaClass()) + public fun notLoadNode() { + doTest("notLoadNode") + } +}