diff --git a/lapis2/src/test/kotlin/org/genspectrum/lapis/model/SiloFilterExpressionMapperTest.kt b/lapis2/src/test/kotlin/org/genspectrum/lapis/model/SiloFilterExpressionMapperTest.kt index 4251d728..261802d2 100644 --- a/lapis2/src/test/kotlin/org/genspectrum/lapis/model/SiloFilterExpressionMapperTest.kt +++ b/lapis2/src/test/kotlin/org/genspectrum/lapis/model/SiloFilterExpressionMapperTest.kt @@ -157,6 +157,36 @@ class SiloFilterExpressionMapperTest { assertThat(result, equalTo(expectedResult)) } + @Test + fun `given a query with an empty variantQuery then it should throw an error`() { + val filterParameter = mapOf("variantQuery" to "") + + val exception = assertThrows { underTest.map(filterParameter) } + assertThat(exception.message, containsString("variantQuery cannot be empty")) + } + + @Test + fun `given a query with a variantQuery alongside nucleotideMutation filter then it should throw an error`() { + val filterParameter = mapOf( + "nucleotideMutations" to "A123T", + "variantQuery" to "A123T", + ) + + val exception = assertThrows { underTest.map(filterParameter) } + assertThat(exception.message, containsString("variantQuery cannot be used with other variant filters")) + } + + @Test + fun `given a query with a variantQuery alongside pangoLineage filter then it should throw an error`() { + val filterParameter = mapOf( + "pangoLineage" to "A.1.2.3", + "variantQuery" to "A123T", + ) + + val exception = assertThrows { underTest.map(filterParameter) } + assertThat(exception.message, containsString("variantQuery cannot be used with other variant filters")) + } + companion object { @JvmStatic fun getFilterParametersWithExpectedSiloQuery() = listOf( @@ -260,6 +290,33 @@ class SiloFilterExpressionMapperTest { ), ), ), + Arguments.of( + mapOf( + "variantQuery" to "300G & 400A", + ), + And( + listOf( + And( + listOf( + NucleotideSymbolEquals(300, "G"), + NucleotideSymbolEquals(400, "A"), + ), + ), + ), + ), + ), + Arguments.of( + mapOf( + "variantQuery" to "300G", + "some_metadata" to "ABC", + ), + And( + listOf( + StringEquals("some_metadata", "ABC"), + NucleotideSymbolEquals(300, "G"), + ), + ), + ), ) @JvmStatic diff --git a/siloLapisTests/test/aggregatedQueries/variantQuery.json b/siloLapisTests/test/aggregatedQueries/variantQuery.json new file mode 100644 index 00000000..34c599e5 --- /dev/null +++ b/siloLapisTests/test/aggregatedQueries/variantQuery.json @@ -0,0 +1,9 @@ +{ + "testCaseName": "variant query", + "lapisRequest": { + "variantQuery": "B.1.1.7" + }, + "expected": { + "count": 48 + } +}