Skip to content

Commit

Permalink
Filter by keeping query params which have impacting phenotype genes
Browse files Browse the repository at this point in the history
  • Loading branch information
Pgarrett committed Dec 20, 2024
1 parent e637061 commit 9686974
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ open class RestActionTestCaseNamingStrategy(
val result = mutableListOf<String>()

val queryParams = restAction.path.getOnlyQuery(restAction.parameters)
.filter { it.getGeneForQuery().staticCheckIfImpactPhenotype() }
result.add(with)
result.add(if (queryParams.size > 1) "${queryParam}s" else queryParam)
if (nameWithQueryParameters) {
Expand Down Expand Up @@ -226,13 +227,8 @@ open class RestActionTestCaseNamingStrategy(
}
}

private fun getWrappedGene(queryParam: QueryParam): Gene? {
val gene = queryParam.getGeneForQuery()
if (gene.staticCheckIfImpactPhenotype()) {
return gene

}
return gene.getWrappedGene(OptionalGene::class.java)?.gene
private fun getWrappedGene(queryParam: QueryParam): Gene {
return (queryParam.getGeneForQuery() as OptionalGene).gene
}

private fun isGetCall(evaluatedAction: EvaluatedAction): Boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,22 +266,6 @@ class TestCaseDisambiguationTest {
assertEquals("test_1_getOnLanguagesWithQueryParamsNegativeLimitEmptyNameReturnsEmpty", testCases[1].name)
}

@Test
fun unwrappedNegativeNumberQueryParamIsAdded() {
val simpleIndividual = getEvaluatedIndividualWith(getRestCallAction("/languages"))
val negativeQPIndividual = getEvaluatedIndividualWith(getRestCallAction("/languages", parameters = mutableListOf(getIntegerQueryParam("limit", false))))
ensureGeneValue(negativeQPIndividual, "limit", "-1")

val solution = Solution(mutableListOf(simpleIndividual, negativeQPIndividual), "suitePrefix", "suiteSuffix", Termination.NONE, emptyList(), emptyList())

val namingStrategy = RestActionTestCaseNamingStrategy(solution, javaFormatter, QUERY_PARAMS_IN_NAME)

val testCases = namingStrategy.getTestCases()
assertEquals(2, testCases.size)
assertEquals("test_0_getOnLanguagesReturnsEmpty", testCases[0].name)
assertEquals("test_1_getOnLanguagesWithQueryParamNegativeLimitReturnsEmpty", testCases[1].name)
}

private fun getPathParam(paramName: String): Param {
return PathParam(paramName, CustomMutationRateGene(paramName, StringGene(paramName), 1.0))
}
Expand Down

0 comments on commit 9686974

Please sign in to comment.