aboutsummaryrefslogtreecommitdiffstats
path: root/integration/intellij/src/test
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2022-02-17 08:45:54 +0100
committerJon Bratseth <bratseth@gmail.com>2022-02-17 08:45:54 +0100
commite2d129c3a69d972b6a1b2d4d4d4d036ca395ebca (patch)
tree9dc1b4ebf6a17bd088a6b5cdec7b6b2303cf79ad /integration/intellij/src/test
parentd3576021513cfd0f2df9fd9157fbce4bef6376f0 (diff)
Find usages in child schemas
Diffstat (limited to 'integration/intellij/src/test')
-rw-r--r--integration/intellij/src/test/applications/schemainheritance/child.sd3
-rw-r--r--integration/intellij/src/test/applications/schemainheritance/parent.sd3
-rw-r--r--integration/intellij/src/test/java/ai/vespa/intellij/findUsages/FindUsagesTest.java9
-rw-r--r--integration/intellij/src/test/java/ai/vespa/intellij/model/SchemaTest.java38
4 files changed, 38 insertions, 15 deletions
diff --git a/integration/intellij/src/test/applications/schemainheritance/child.sd b/integration/intellij/src/test/applications/schemainheritance/child.sd
index e45f5cb3991..ff09bad4442 100644
--- a/integration/intellij/src/test/applications/schemainheritance/child.sd
+++ b/integration/intellij/src/test/applications/schemainheritance/child.sd
@@ -23,6 +23,9 @@ schema child inherits parent {
}
rank-profile child_profile inherits other_child_profile, parent_profile {
+ second-phase {
+ expression: parentFunction
+ }
}
rank-profile other_child_profile {
diff --git a/integration/intellij/src/test/applications/schemainheritance/parent.sd b/integration/intellij/src/test/applications/schemainheritance/parent.sd
index 51b11dad444..ba666313af1 100644
--- a/integration/intellij/src/test/applications/schemainheritance/parent.sd
+++ b/integration/intellij/src/test/applications/schemainheritance/parent.sd
@@ -23,6 +23,9 @@ schema parent {
indexing: input pf1 | lowercase | index | attribute | summary
}
rank-profile parent_profile {
+ function parentFunction() {
+ expression: random
+ }
}
constant parent_constant {
file: constants/my_constant_tensor_file.json
diff --git a/integration/intellij/src/test/java/ai/vespa/intellij/findUsages/FindUsagesTest.java b/integration/intellij/src/test/java/ai/vespa/intellij/findUsages/FindUsagesTest.java
index bc9c7959506..41a216bb0be 100644
--- a/integration/intellij/src/test/java/ai/vespa/intellij/findUsages/FindUsagesTest.java
+++ b/integration/intellij/src/test/java/ai/vespa/intellij/findUsages/FindUsagesTest.java
@@ -20,7 +20,7 @@ import java.util.List;
public class FindUsagesTest extends PluginTestBase {
@Test
- public void testFindUsages() {
+ public void testFindUsagesInRankProfileModularity() {
useDir("src/test/applications/rankprofilemodularity");
var tester = new UsagesTester("test.sd", getProject());
tester.assertFunctionUsages("0 refs", 0, "in_schema1", "tensorFunction");
@@ -33,6 +33,13 @@ public class FindUsagesTest extends PluginTestBase {
}
@Test
+ public void testFindUsagesInSchemaInheritance() {
+ useDir("src/test/applications/schemainheritance");
+ var tester = new UsagesTester("parent.sd", getProject());
+ tester.assertFunctionUsages("1 ref in schild schema", 1, "parent_profile", "parentFunction");
+ }
+
+ @Test
public void testUsageDetails() {
useDir("src/test/applications/rankprofilemodularity");
var tester = new UsagesTester("test.sd", getProject());
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
index 9cf10cdffa2..52b1ea6fd45 100644
--- a/integration/intellij/src/test/java/ai/vespa/intellij/model/SchemaTest.java
+++ b/integration/intellij/src/test/java/ai/vespa/intellij/model/SchemaTest.java
@@ -20,24 +20,34 @@ public class SchemaTest extends PluginTestBase {
assertEquals("simple", schema.name());
RankProfile profile = schema.rankProfiles().get("simple-profile");
assertEquals("simple-profile", profile.name());
- assertEquals(2, profile.inherited().size());
- assertEquals("parent-profile1", profile.inherited().get("parent-profile1").name());
- assertEquals("parent-profile2", profile.inherited().get("parent-profile2").name());
+ assertEquals(2, profile.parents().size());
+ assertEquals("parent-profile1", profile.parents().get("parent-profile1").name());
+ assertEquals("parent-profile2", profile.parents().get("parent-profile2").name());
assertEquals(0, schema.functions().size());
}
@Test
public void testSchemaInheritance() {
useDir("src/test/applications/schemaInheritance");
- Schema schema = Schema.fromProjectFile(getProject(), Path.fromString("child.sd"));
- assertNotNull(schema);
- assertEquals("child", schema.name());
- RankProfile profile = schema.rankProfiles().get("child_profile");
+ Schema child = Schema.fromProjectFile(getProject(), Path.fromString("child.sd"));
+ assertNotNull(child);
+ assertEquals("child", child.name());
+ assertEquals("parent", child.parent().get().name());
+ Schema parent = child.parent().get();
+ assertEquals("child", parent.children().get("child").name());
+
+ assertEquals(3, child.rankProfiles().size());
+ assertTrue(child.rankProfiles().containsKey("child_profile"));
+ assertTrue(child.rankProfiles().containsKey("other_child_profile"));
+ assertTrue(child.rankProfiles().containsKey("parent_profile"));
+
+ RankProfile profile = child.rankProfiles().get("child_profile");
assertEquals("child_profile", profile.name());
- assertEquals(2, profile.inherited().size());
- assertEquals("other_child_profile", profile.inherited().get("other_child_profile").name());
- assertEquals("parent_profile", profile.inherited().get("parent_profile").name());
- assertEquals(0, schema.functions().size());
+ assertEquals(2, profile.parents().size());
+ assertEquals("other_child_profile", profile.parents().get("other_child_profile").name());
+ assertEquals("parent_profile", profile.parents().get("parent_profile").name());
+ assertEquals("child_profile", profile.parents().get("parent_profile").children().get(0).name());
+ assertEquals(2, child.functions().size());
}
@Test
@@ -48,9 +58,9 @@ public class SchemaTest extends PluginTestBase {
assertEquals("test", schema.name());
RankProfile profile = schema.rankProfiles().get("in_schema3");
assertEquals("in_schema3", profile.name());
- assertEquals(2, profile.inherited().size());
- assertEquals("outside_schema1", profile.inherited().get("outside_schema1").name());
- assertEquals("outside_schema2", profile.inherited().get("outside_schema2").name());
+ assertEquals(2, profile.parents().size());
+ assertEquals("outside_schema1", profile.parents().get("outside_schema1").name());
+ assertEquals("outside_schema2", profile.parents().get("outside_schema2").name());
assertEquals("8 proper functions + first-phase", 9, schema.functions().size());
assertEquals(schema.rankProfiles().get("in_schema2").definedFunctions().get("ff1"),
schema.functions().get("ff1"));