-
Notifications
You must be signed in to change notification settings - Fork 108
http oracle partial update put #1471
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
omursahin
wants to merge
5
commits into
master
Choose a base branch
from
oracle-partial-update-put
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b0d00c4
oracle partial update put
omursahin ec7b17f
fix comment
omursahin b860953
Merge branch 'master' into oracle-partial-update-put
omursahin 1d8af7f
Merge branch 'master' into oracle-partial-update-put
omursahin 749872e
adding xml and url-encoded
omursahin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
73 changes: 73 additions & 0 deletions
73
...xamples/spring/openapi/v3/httporacle/partialupdateput/json/PartialUpdatePutApplication.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| package com.foo.rest.examples.spring.openapi.v3.httporacle.partialupdateput.json | ||
|
|
||
| import org.springframework.boot.SpringApplication | ||
| import org.springframework.boot.autoconfigure.SpringBootApplication | ||
| import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration | ||
| import org.springframework.http.ResponseEntity | ||
| import org.springframework.web.bind.annotation.GetMapping | ||
| import org.springframework.web.bind.annotation.PathVariable | ||
| import org.springframework.web.bind.annotation.PostMapping | ||
| import org.springframework.web.bind.annotation.PutMapping | ||
| import org.springframework.web.bind.annotation.RequestBody | ||
| import org.springframework.web.bind.annotation.RequestMapping | ||
| import org.springframework.web.bind.annotation.RestController | ||
|
|
||
| @SpringBootApplication(exclude = [SecurityAutoConfiguration::class]) | ||
| @RequestMapping(path = ["/api/resources"]) | ||
| @RestController | ||
| open class PartialUpdatePutApplication { | ||
|
|
||
| companion object { | ||
| @JvmStatic | ||
| fun main(args: Array<String>) { | ||
| SpringApplication.run(PartialUpdatePutApplication::class.java, *args) | ||
| } | ||
|
|
||
| private val data = mutableMapOf<Int, ResourceData>() | ||
|
|
||
| fun reset(){ | ||
| data.clear() | ||
| } | ||
| } | ||
|
|
||
| data class ResourceData( | ||
| var name: String, | ||
| var value: Int | ||
| ) | ||
|
|
||
| data class UpdateRequest( | ||
| val name: String, | ||
| val value: Int | ||
| ) | ||
|
|
||
|
|
||
| @PostMapping() | ||
| open fun create(@RequestBody body: ResourceData): ResponseEntity<ResourceData> { | ||
| val id = data.size + 1 | ||
| data[id] = body.copy() | ||
| return ResponseEntity.status(201).body(data[id]) | ||
| } | ||
|
|
||
| @GetMapping(path = ["/{id}"]) | ||
| open fun get(@PathVariable("id") id: Int): ResponseEntity<ResourceData> { | ||
| val resource = data[id] | ||
| ?: return ResponseEntity.status(404).build() | ||
| return ResponseEntity.status(200).body(resource) | ||
| } | ||
|
|
||
| @PutMapping(path = ["/{id}"]) | ||
| open fun put( | ||
| @PathVariable("id") id: Int, | ||
| @RequestBody body: UpdateRequest | ||
| ): ResponseEntity<Any> { | ||
|
|
||
| val resource = data[id] | ||
| ?: return ResponseEntity.status(404).build() | ||
|
|
||
| if(body.name != null) { | ||
| resource.name = body.name | ||
| } | ||
|
|
||
| return ResponseEntity.status(200).body(resource) | ||
| } | ||
| } |
84 changes: 84 additions & 0 deletions
84
...penapi/v3/httporacle/partialupdateput/urlencoded/PartialUpdatePutUrlEncodedApplication.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| package com.foo.rest.examples.spring.openapi.v3.httporacle.partialupdateput.urlencoded | ||
|
|
||
| import org.springframework.boot.SpringApplication | ||
| import org.springframework.boot.autoconfigure.SpringBootApplication | ||
| import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration | ||
| import org.springframework.http.MediaType | ||
| import org.springframework.http.ResponseEntity | ||
| import org.springframework.web.bind.annotation.GetMapping | ||
| import org.springframework.web.bind.annotation.ModelAttribute | ||
| import org.springframework.web.bind.annotation.PathVariable | ||
| import org.springframework.web.bind.annotation.PostMapping | ||
| import org.springframework.web.bind.annotation.PutMapping | ||
| import org.springframework.web.bind.annotation.RequestMapping | ||
| import org.springframework.web.bind.annotation.RestController | ||
|
|
||
| @SpringBootApplication(exclude = [SecurityAutoConfiguration::class]) | ||
| @RequestMapping(path = ["/api/resources"]) | ||
| @RestController | ||
| open class PartialUpdatePutUrlEncodedApplication { | ||
|
|
||
| companion object { | ||
| @JvmStatic | ||
| fun main(args: Array<String>) { | ||
| SpringApplication.run(PartialUpdatePutUrlEncodedApplication::class.java, *args) | ||
| } | ||
|
|
||
| private val data = mutableMapOf<Int, ResourceData>() | ||
|
|
||
| fun reset(){ | ||
| data.clear() | ||
| } | ||
| } | ||
|
|
||
| open class ResourceData( | ||
| var name: String = "", | ||
| var value: Int = 0 | ||
| ) | ||
|
|
||
| open class UpdateRequest( | ||
| var name: String = "", | ||
| var value: Int = 0 | ||
| ) | ||
|
|
||
|
|
||
| @PostMapping( | ||
| consumes = [MediaType.APPLICATION_FORM_URLENCODED_VALUE], | ||
| produces = [MediaType.APPLICATION_JSON_VALUE] | ||
| ) | ||
| open fun create(@ModelAttribute body: ResourceData): ResponseEntity<ResourceData> { | ||
| val id = data.size + 1 | ||
| data[id] = ResourceData(name = body.name, value = body.value) | ||
| return ResponseEntity.status(201).body(data[id]) | ||
| } | ||
|
|
||
| @GetMapping( | ||
| path = ["/{id}"], | ||
| produces = [MediaType.APPLICATION_JSON_VALUE] | ||
| ) | ||
| open fun get(@PathVariable("id") id: Int): ResponseEntity<ResourceData> { | ||
| val resource = data[id] | ||
| ?: return ResponseEntity.status(404).build() | ||
| return ResponseEntity.status(200).body(resource) | ||
| } | ||
|
|
||
| @PutMapping( | ||
| path = ["/{id}"], | ||
| consumes = [MediaType.APPLICATION_FORM_URLENCODED_VALUE], | ||
| produces = [MediaType.APPLICATION_JSON_VALUE] | ||
| ) | ||
| open fun put( | ||
| @PathVariable("id") id: Int, | ||
| @ModelAttribute body: UpdateRequest | ||
| ): ResponseEntity<Any> { | ||
|
|
||
| val resource = data[id] | ||
| ?: return ResponseEntity.status(404).build() | ||
|
|
||
| if(body.name != null) { | ||
| resource.name = body.name | ||
| } | ||
|
|
||
| return ResponseEntity.status(200).body(resource) | ||
| } | ||
| } |
91 changes: 91 additions & 0 deletions
91
...mples/spring/openapi/v3/httporacle/partialupdateput/xml/PartialUpdatePutXMLApplication.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| package com.foo.rest.examples.spring.openapi.v3.httporacle.partialupdateput.xml | ||
|
|
||
| import org.springframework.boot.SpringApplication | ||
| import org.springframework.boot.autoconfigure.SpringBootApplication | ||
| import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration | ||
| import org.springframework.http.MediaType | ||
| import org.springframework.http.ResponseEntity | ||
| import org.springframework.web.bind.annotation.GetMapping | ||
| import org.springframework.web.bind.annotation.PathVariable | ||
| import org.springframework.web.bind.annotation.PostMapping | ||
| import org.springframework.web.bind.annotation.PutMapping | ||
| import org.springframework.web.bind.annotation.RequestBody | ||
| import org.springframework.web.bind.annotation.RequestMapping | ||
| import org.springframework.web.bind.annotation.RestController | ||
| import javax.xml.bind.annotation.XmlAccessType | ||
| import javax.xml.bind.annotation.XmlAccessorType | ||
| import javax.xml.bind.annotation.XmlRootElement | ||
|
|
||
| @SpringBootApplication(exclude = [SecurityAutoConfiguration::class]) | ||
| @RequestMapping(path = ["/api/resources"]) | ||
| @RestController | ||
| open class PartialUpdatePutXMLApplication { | ||
|
|
||
| companion object { | ||
| @JvmStatic | ||
| fun main(args: Array<String>) { | ||
| SpringApplication.run(PartialUpdatePutXMLApplication::class.java, *args) | ||
| } | ||
|
|
||
| private val data = mutableMapOf<Int, ResourceData>() | ||
|
|
||
| fun reset(){ | ||
| data.clear() | ||
| } | ||
| } | ||
|
|
||
| @XmlRootElement(name = "resourceData") | ||
| @XmlAccessorType(XmlAccessType.FIELD) | ||
| open class ResourceData( | ||
| var name: String = "", | ||
| var value: Int = 0 | ||
| ) | ||
|
|
||
| @XmlRootElement(name = "updateRequest") | ||
| @XmlAccessorType(XmlAccessType.FIELD) | ||
| open class UpdateRequest( | ||
| var name: String = "", | ||
| var value: Int = 0 | ||
| ) | ||
|
|
||
|
|
||
| @PostMapping( | ||
| consumes = [MediaType.APPLICATION_XML_VALUE], | ||
| produces = [MediaType.APPLICATION_XML_VALUE] | ||
| ) | ||
| open fun create(@RequestBody body: ResourceData): ResponseEntity<ResourceData> { | ||
| val id = data.size + 1 | ||
| data[id] = ResourceData(name = body.name, value = body.value) | ||
| return ResponseEntity.status(201).body(data[id]) | ||
| } | ||
|
|
||
| @GetMapping( | ||
| path = ["/{id}"], | ||
| produces = [MediaType.APPLICATION_XML_VALUE] | ||
| ) | ||
| open fun get(@PathVariable("id") id: Int): ResponseEntity<ResourceData> { | ||
| val resource = data[id] | ||
| ?: return ResponseEntity.status(404).build() | ||
| return ResponseEntity.status(200).body(resource) | ||
| } | ||
|
|
||
| @PutMapping( | ||
| path = ["/{id}"], | ||
| consumes = [MediaType.APPLICATION_XML_VALUE], | ||
| produces = [MediaType.APPLICATION_XML_VALUE] | ||
| ) | ||
| open fun put( | ||
| @PathVariable("id") id: Int, | ||
| @RequestBody body: UpdateRequest | ||
| ): ResponseEntity<Any> { | ||
|
|
||
| val resource = data[id] | ||
| ?: return ResponseEntity.status(404).build() | ||
|
|
||
| if(body.name != null) { | ||
| resource.name = body.name | ||
| } | ||
|
|
||
| return ResponseEntity.status(200).body(resource) | ||
| } | ||
| } |
12 changes: 12 additions & 0 deletions
12
.../examples/spring/openapi/v3/httporacle/partialupdateput/HttpPartialUpdatePutController.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package com.foo.rest.examples.spring.openapi.v3.httporacle.partialupdateput | ||
|
|
||
| import com.foo.rest.examples.spring.openapi.v3.SpringController | ||
| import com.foo.rest.examples.spring.openapi.v3.httporacle.partialupdateput.json.PartialUpdatePutApplication | ||
|
|
||
|
|
||
| class HttpPartialUpdatePutController: SpringController(PartialUpdatePutApplication::class.java){ | ||
|
|
||
| override fun resetStateOfSUT() { | ||
| PartialUpdatePutApplication.reset() | ||
| } | ||
| } |
12 changes: 12 additions & 0 deletions
12
...spring/openapi/v3/httporacle/partialupdateput/HttpPartialUpdatePutURLEncodedController.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package com.foo.rest.examples.spring.openapi.v3.httporacle.partialupdateput | ||
|
|
||
| import com.foo.rest.examples.spring.openapi.v3.SpringController | ||
| import com.foo.rest.examples.spring.openapi.v3.httporacle.partialupdateput.urlencoded.PartialUpdatePutUrlEncodedApplication | ||
|
|
||
|
|
||
| class HttpPartialUpdatePutURLEncodedController: SpringController(PartialUpdatePutUrlEncodedApplication::class.java){ | ||
|
|
||
| override fun resetStateOfSUT() { | ||
| PartialUpdatePutUrlEncodedApplication.reset() | ||
| } | ||
| } |
12 changes: 12 additions & 0 deletions
12
...amples/spring/openapi/v3/httporacle/partialupdateput/HttpPartialUpdatePutXMLController.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package com.foo.rest.examples.spring.openapi.v3.httporacle.partialupdateput | ||
|
|
||
| import com.foo.rest.examples.spring.openapi.v3.SpringController | ||
| import com.foo.rest.examples.spring.openapi.v3.httporacle.partialupdateput.xml.PartialUpdatePutXMLApplication | ||
|
|
||
|
|
||
| class HttpPartialUpdatePutXMLController: SpringController(PartialUpdatePutXMLApplication::class.java){ | ||
|
|
||
| override fun resetStateOfSUT() { | ||
| PartialUpdatePutXMLApplication.reset() | ||
| } | ||
| } |
48 changes: 48 additions & 0 deletions
48
...ster/e2etests/spring/openapi/v3/httporacle/partialupdateput/HttpPartialUpdatePutEMTest.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| package org.evomaster.e2etests.spring.openapi.v3.httporacle.partialupdateput | ||
|
|
||
| import com.foo.rest.examples.spring.openapi.v3.httporacle.partialupdateput.HttpPartialUpdatePutController | ||
| import org.evomaster.core.problem.enterprise.DetectedFaultUtils | ||
| import org.evomaster.core.problem.enterprise.ExperimentalFaultCategory | ||
| import org.evomaster.core.problem.rest.data.HttpVerb | ||
| import org.evomaster.e2etests.spring.openapi.v3.SpringTestBase | ||
| import org.junit.jupiter.api.Assertions.assertEquals | ||
| import org.junit.jupiter.api.Assertions.assertTrue | ||
| import org.junit.jupiter.api.BeforeAll | ||
| import org.junit.jupiter.api.Test | ||
|
|
||
| class HttpPartialUpdatePutEMTest : SpringTestBase(){ | ||
|
|
||
| companion object { | ||
| @BeforeAll | ||
| @JvmStatic | ||
| fun init() { | ||
| initClass(HttpPartialUpdatePutController()) | ||
| } | ||
| } | ||
|
|
||
|
|
||
| @Test | ||
| fun testRunEM() { | ||
|
|
||
| runTestHandlingFlakyAndCompilation( | ||
| "HttpPartialUpdatePutEM", | ||
| 1000 | ||
| ) { args: MutableList<String> -> | ||
|
|
||
| setOption(args, "security", "false") | ||
| setOption(args, "schemaOracles", "false") | ||
| setOption(args, "httpOracles", "true") | ||
| setOption(args, "useExperimentalOracles", "true") | ||
|
|
||
| val solution = initAndRun(args) | ||
|
|
||
| assertTrue(solution.individuals.size >= 1) | ||
|
|
||
| assertHasAtLeastOne(solution, HttpVerb.PUT, 200, "/api/resources/{id}", null) | ||
|
|
||
| val faults = DetectedFaultUtils.getDetectedFaultCategories(solution) | ||
| assertEquals(1, faults.size) | ||
| assertEquals(ExperimentalFaultCategory.HTTP_PARTIAL_UPDATE_PUT, faults.first()) | ||
| } | ||
| } | ||
| } | ||
48 changes: 48 additions & 0 deletions
48
...sts/spring/openapi/v3/httporacle/partialupdateput/HttpPartialUpdatePutURLEncodedEMTest.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| package org.evomaster.e2etests.spring.openapi.v3.httporacle.partialupdateput | ||
|
|
||
| import com.foo.rest.examples.spring.openapi.v3.httporacle.partialupdateput.HttpPartialUpdatePutURLEncodedController | ||
| import org.evomaster.core.problem.enterprise.DetectedFaultUtils | ||
| import org.evomaster.core.problem.enterprise.ExperimentalFaultCategory | ||
| import org.evomaster.core.problem.rest.data.HttpVerb | ||
| import org.evomaster.e2etests.spring.openapi.v3.SpringTestBase | ||
| import org.junit.jupiter.api.Assertions.assertEquals | ||
| import org.junit.jupiter.api.Assertions.assertTrue | ||
| import org.junit.jupiter.api.BeforeAll | ||
| import org.junit.jupiter.api.Test | ||
|
|
||
| class HttpPartialUpdatePutURLEncodedEMTest : SpringTestBase(){ | ||
|
|
||
| companion object { | ||
| @BeforeAll | ||
| @JvmStatic | ||
| fun init() { | ||
| initClass(HttpPartialUpdatePutURLEncodedController()) | ||
| } | ||
| } | ||
|
|
||
|
|
||
| @Test | ||
| fun testRunEM() { | ||
|
|
||
| runTestHandlingFlakyAndCompilation( | ||
| "HttpPartialUpdatePutURLEncodedEM", | ||
| 1000 | ||
| ) { args: MutableList<String> -> | ||
|
|
||
| setOption(args, "security", "false") | ||
| setOption(args, "schemaOracles", "false") | ||
| setOption(args, "httpOracles", "true") | ||
| setOption(args, "useExperimentalOracles", "true") | ||
|
|
||
| val solution = initAndRun(args) | ||
|
|
||
| assertTrue(solution.individuals.size >= 1) | ||
|
|
||
| assertHasAtLeastOne(solution, HttpVerb.PUT, 200, "/api/resources/{id}", null) | ||
|
|
||
| val faults = DetectedFaultUtils.getDetectedFaultCategories(solution) | ||
| assertEquals(1, faults.size) | ||
| assertEquals(ExperimentalFaultCategory.HTTP_PARTIAL_UPDATE_PUT, faults.first()) | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure if best in a E2E or an integration test, but check to verify the example discussed in
2026/httporacles/notes.txt, especially making sure that K does not lead to flag a fault (ie false positive)