summaryrefslogtreecommitdiffstats
path: root/integration/intellij/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'integration/intellij/src/test')
-rw-r--r--integration/intellij/src/test/applications/schemainheritance/child.sd5
-rw-r--r--integration/intellij/src/test/applications/simple/simple.sd15
-rw-r--r--integration/intellij/src/test/java/ai/vespa/intellij/model/MockProject.java147
-rw-r--r--integration/intellij/src/test/java/ai/vespa/intellij/model/RankProfileTest.java32
-rw-r--r--integration/intellij/src/test/java/ai/vespa/intellij/model/SchemaTest.java59
-rw-r--r--integration/intellij/src/test/java/ai/vespa/intellij/model/TestProjectDescriptor.java4
6 files changed, 79 insertions, 183 deletions
diff --git a/integration/intellij/src/test/applications/schemainheritance/child.sd b/integration/intellij/src/test/applications/schemainheritance/child.sd
index a209919763d..e45f5cb3991 100644
--- a/integration/intellij/src/test/applications/schemainheritance/child.sd
+++ b/integration/intellij/src/test/applications/schemainheritance/child.sd
@@ -22,7 +22,10 @@ schema child inherits parent {
indexing: input pf1 | lowercase | index | attribute | summary
}
- rank-profile child_profile inherits parent_profile {
+ rank-profile child_profile inherits other_child_profile, parent_profile {
+ }
+
+ rank-profile other_child_profile {
}
constant child_constant {
diff --git a/integration/intellij/src/test/applications/simple/simple.sd b/integration/intellij/src/test/applications/simple/simple.sd
new file mode 100644
index 00000000000..21e683b3ee4
--- /dev/null
+++ b/integration/intellij/src/test/applications/simple/simple.sd
@@ -0,0 +1,15 @@
+schema simple {
+
+ document simple {
+ }
+
+ rank-profile simple-profile inherits parent-profile1, parent-profile2 {
+ }
+
+ rank-profile parent-profile1 {
+ }
+
+ rank-profile parent-profile2 {
+ }
+
+} \ No newline at end of file
diff --git a/integration/intellij/src/test/java/ai/vespa/intellij/model/MockProject.java b/integration/intellij/src/test/java/ai/vespa/intellij/model/MockProject.java
deleted file mode 100644
index f54dfdee2ef..00000000000
--- a/integration/intellij/src/test/java/ai/vespa/intellij/model/MockProject.java
+++ /dev/null
@@ -1,147 +0,0 @@
-// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package ai.vespa.intellij.model;
-
-import com.intellij.diagnostic.ActivityCategory;
-import com.intellij.openapi.extensions.PluginDescriptor;
-import com.intellij.openapi.extensions.PluginId;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.Condition;
-import com.intellij.openapi.util.Key;
-import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.util.messages.MessageBus;
-import org.picocontainer.PicoContainer;
-
-import java.io.File;
-import java.util.Map;
-
-public class MockProject implements Project {
-
- private final File schemasDir;
-
- public MockProject(File schemasDir) {
- this.schemasDir = schemasDir;
- }
-
- @Override
- public String getName() { return "mock project"; }
-
- @Override
- public VirtualFile getBaseDir() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String getBasePath() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public VirtualFile getProjectFile() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String getProjectFilePath() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public VirtualFile getWorkspaceFile() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String getLocationHash() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void save() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean isOpen() { return true; }
-
- @Override
- public boolean isInitialized() { return true; }
-
- @Override
- public <T> T getComponent(Class<T> interfaceClass) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public <T> T[] getComponents(Class<T> baseClass) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public PicoContainer getPicoContainer() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean isInjectionForExtensionSupported() { return false; }
-
- @Override
- public MessageBus getMessageBus() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean isDisposed() { return false; }
-
- @Override
- public Condition<?> getDisposed() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public <T> T getService(Class<T> serviceClass) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public <T> T instantiateClassWithConstructorInjection(Class<T> aClass, Object key, PluginId pluginId) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public RuntimeException createError(Throwable error, PluginId pluginId) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public RuntimeException createError(String message, PluginId pluginId) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public RuntimeException createError(String message, Throwable error, PluginId pluginId, Map<String, String> attachments) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public <T> Class<T> loadClass(String className, PluginDescriptor pluginDescriptor) throws ClassNotFoundException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public ActivityCategory getActivityCategory(boolean isExtension) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void dispose() {
- }
-
- @Override
- public <T> T getUserData(Key<T> key) { return null; }
-
- @Override
- public <T> void putUserData(Key<T> key, T value) {
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/integration/intellij/src/test/java/ai/vespa/intellij/model/RankProfileTest.java b/integration/intellij/src/test/java/ai/vespa/intellij/model/RankProfileTest.java
deleted file mode 100644
index c0b4902c002..00000000000
--- a/integration/intellij/src/test/java/ai/vespa/intellij/model/RankProfileTest.java
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package ai.vespa.intellij.model;
-
-import ai.vespa.intellij.schema.model.RankProfile;
-import com.intellij.testFramework.LightProjectDescriptor;
-import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase;
-import org.junit.Test;
-
-import java.io.File;
-
-/**
- * @author bratseth
- */
-public class RankProfileTest extends LightJavaCodeInsightFixtureTestCase {
-
- @Override
- protected LightProjectDescriptor getProjectDescriptor() {
- // Store the descriptor between tests to make this faster
- return new TestProjectDescriptor();
- }
-
- @Override
- protected String getTestDataPath() { return "."; }
-
- @Test
- public void testFindDefinition() {
- super.myFixture.copyDirectoryToProject("src/test/applications/schemainheritance", "/");
- RankProfile profile = RankProfile.fromProjectFile(getProject(), "child.sd", "child_profile");
- assertEquals("child_profile", profile.definition().getName());
- }
-
-}
diff --git a/integration/intellij/src/test/java/ai/vespa/intellij/model/SchemaTest.java b/integration/intellij/src/test/java/ai/vespa/intellij/model/SchemaTest.java
new file mode 100644
index 00000000000..38fd9a97a5b
--- /dev/null
+++ b/integration/intellij/src/test/java/ai/vespa/intellij/model/SchemaTest.java
@@ -0,0 +1,59 @@
+// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package ai.vespa.intellij.model;
+
+import ai.vespa.intellij.schema.SdUtil;
+import ai.vespa.intellij.schema.model.RankProfile;
+import ai.vespa.intellij.schema.model.Schema;
+import ai.vespa.intellij.schema.psi.SdRankProfileDefinition;
+import com.intellij.testFramework.LightProjectDescriptor;
+import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase;
+import org.junit.Test;
+
+import java.util.List;
+
+/**
+ * @author bratseth
+ */
+public class SchemaTest extends LightJavaCodeInsightFixtureTestCase {
+
+ private final TestProjectDescriptor descriptor;
+
+ public SchemaTest() {
+ descriptor = new TestProjectDescriptor(); // Expensive instance
+ }
+
+ @Override
+ protected LightProjectDescriptor getProjectDescriptor() { return descriptor; }
+
+ @Override
+ protected String getTestDataPath() { return "."; }
+
+ @Test
+ public void testSimple() {
+ super.myFixture.copyDirectoryToProject("src/test/applications/simple", "/");
+ Schema schema = Schema.fromProjectFile(getProject(), "simple.sd");
+ assertNotNull(schema);
+ assertEquals("simple.sd", schema.definition().getName());
+ RankProfile profile = RankProfile.fromProjectFile(getProject(), "simple.sd", "simple-profile");
+ assertEquals("simple-profile", profile.definition().getName());
+ List<SdRankProfileDefinition> parents = SdUtil.getRankProfileParents(profile.definition());
+ assertEquals(2, parents.size());
+ assertEquals("parent-profile1", parents.get(0).getName());
+ assertEquals("parent-profile2", parents.get(1).getName());
+ }
+
+ @Test
+ public void testSchemaInheritance() {
+ super.myFixture.copyDirectoryToProject("src/test/applications/schemainheritance", "/");
+ Schema schema = Schema.fromProjectFile(getProject(), "child.sd");
+ assertNotNull(schema);
+ assertEquals("child.sd", schema.definition().getName());
+ RankProfile profile = RankProfile.fromProjectFile(getProject(), "child.sd", "child_profile");
+ assertEquals("child_profile", profile.definition().getName());
+ List<SdRankProfileDefinition> parents = SdUtil.getRankProfileParents(profile.definition());
+ assertEquals(2, parents.size());
+ assertEquals("other_child_profile", parents.get(0).getName());
+ // assertEquals("parent-profile", parents.get(1).getName()); TODO
+ }
+
+}
diff --git a/integration/intellij/src/test/java/ai/vespa/intellij/model/TestProjectDescriptor.java b/integration/intellij/src/test/java/ai/vespa/intellij/model/TestProjectDescriptor.java
index ae36c16ce67..5952b17a642 100644
--- a/integration/intellij/src/test/java/ai/vespa/intellij/model/TestProjectDescriptor.java
+++ b/integration/intellij/src/test/java/ai/vespa/intellij/model/TestProjectDescriptor.java
@@ -3,8 +3,6 @@ package ai.vespa.intellij.model;
import com.intellij.testFramework.LightProjectDescriptor;
-import java.io.File;
-
/**
* Describes a project used in unit tests.
* https://plugins.jetbrains.com/docs/intellij/light-and-heavy-tests.html
@@ -12,5 +10,5 @@ import java.io.File;
* @author bratseth
*/
public class TestProjectDescriptor extends LightProjectDescriptor {
-
+
}