Skip to content

Commit 1d19e97

Browse files
committed
fixed test
1 parent e603a30 commit 1d19e97

2 files changed

Lines changed: 34 additions & 2 deletions

File tree

core/src/test/kotlin/org/evomaster/core/problem/rest/RestActionBuilderV3Test.kt

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2255,7 +2255,38 @@ class RestActionBuilderV3Test{
22552255
assertEquals(3, examples["Bar"])
22562256
assertEquals(1, examples["Hello"])
22572257

2258-
2259-
//TODO apply and check examples
2258+
post.enforceNamedExample("Foo")
2259+
val withFoo = post.parameters.joinToString("\n"){it.name + ": " +it.primaryGene().getValueAsRawString()}
2260+
assertTrue(withFoo.contains("123"), withFoo)
2261+
assertTrue(withFoo.contains("nameF"), withFoo)
2262+
assertTrue(withFoo.contains("77"), withFoo)
2263+
assertTrue(withFoo.contains("xfoo"), withFoo)
2264+
2265+
post.enforceNamedExample("Bar")
2266+
val withBar = post.parameters.joinToString("\n"){it.name + ": " +it.primaryGene().getValueAsRawString()}
2267+
assertTrue(withBar.contains("42"), withBar)
2268+
assertTrue(withBar.contains("nameB"), withBar)
2269+
assertTrue(withBar.contains("xbar"), withBar)
2270+
assertTrue(withBar.contains("ybar"), withBar)
2271+
// "extra" for Foo should still be there unchanged.
2272+
// actually, that is not true... that only apply to distinct trees...
2273+
// all object examples for the same field would be separate branches in a ChoiceGene
2274+
//assertTrue(withBar.contains("77"), withBar)
2275+
2276+
post.enforceNamedExample("Hello")
2277+
val withHello = post.parameters.joinToString("\n"){it.name + ": " +it.primaryGene().getValueAsRawString()}
2278+
//only "id" should be modified
2279+
assertTrue(withHello.contains("667"), withHello)
2280+
//rest should stay in other fields, but not the body object
2281+
// assertTrue(withHello.contains("nameB"), withHello)
2282+
// assertTrue(withHello.contains("77"), withHello)
2283+
assertTrue(withHello.contains("xbar"), withHello)
2284+
assertTrue(withHello.contains("ybar"), withHello)
2285+
2286+
post.enforceNamedExample("Foo")
2287+
val withFooAgain = post.parameters.joinToString("\n"){it.name + ": " +it.primaryGene().getValueAsRawString()}
2288+
// "x" modified, but not "y"
2289+
assertTrue(withFooAgain.contains("xfoo"), withFooAgain)
2290+
assertTrue(withFooAgain.contains("ybar"), withFooAgain)
22602291
}
22612292
}

docs/options.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ There are 3 types of options:
178178
|`outputExecutedSQL`| __Enum__. Whether to output executed sql info. *DEBUG option*. *Valid values*: `NONE, ALL_AT_END, ONCE_EXECUTED`. *Default value*: `NONE`.|
179179
|`overrideAuthExternalEndpointURL`| __String__. Override the value of externalEndpointURL in auth configurations. This is useful when the auth server is running locally on an ephemeral port, or when several instances are run in parallel, to avoid creating/modifying auth configuration files. If what provided is a URL starting with 'http', then full replacement will occur. Otherwise, the input will be treated as a 'hostname:port', and only that info will be updated (e.g., path element of the URL will not change). *Default value*: `null`.|
180180
|`populationSize`| __Int__. Define the population size in the search algorithms that use populations (e.g., Genetic Algorithms, but not MIO). *Constraints*: `min=1.0`. *Default value*: `30`.|
181+
|`probNamedExamples`| __Double__. If any action contains any named example, make sure, with a given probability, that ALL fields for that example are using the provided values by the user. *Constraints*: `probability 0.0-1.0`. *Default value*: `0.5`.|
181182
|`probOfApplySQLActionToCreateResources`| __Double__. Specify a probability to apply SQL actions for preparing resources for REST Action. *Constraints*: `probability 0.0-1.0`. *Default value*: `0.1`.|
182183
|`probOfArchiveMutation`| __Double__. Specify a probability to enable archive-based mutation. *Constraints*: `probability 0.0-1.0`. *Default value*: `0.5`.|
183184
|`probOfEnablingResourceDependencyHeuristics`| __Double__. Specify whether to enable resource dependency heuristics, i.e, probOfEnablingResourceDependencyHeuristics > 0.0. Note that the option is available to be enabled only if resource-based smart sampling is enable. This option has an effect on sampling multiple resources and mutating a structure of an individual. *Constraints*: `probability 0.0-1.0`. *Default value*: `0.95`.|

0 commit comments

Comments
 (0)