-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
134 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
16 changes: 16 additions & 0 deletions
16
...penapi-v3/src/main/kotlin/com/foo/rest/examples/spring/openapi/v3/time/TimeApplication.kt
This file contains 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,16 @@ | ||
package com.foo.rest.examples.spring.openapi.v3.time | ||
|
||
import org.springframework.boot.SpringApplication | ||
import org.springframework.boot.autoconfigure.SpringBootApplication | ||
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration | ||
|
||
@SpringBootApplication(exclude = [SecurityAutoConfiguration::class]) | ||
open class TimeApplication { | ||
|
||
companion object { | ||
@JvmStatic | ||
fun main(args: Array<String>) { | ||
SpringApplication.run(TimeApplication::class.java, *args) | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...-rest-openapi-v3/src/main/kotlin/com/foo/rest/examples/spring/openapi/v3/time/TimeRest.kt
This file contains 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,33 @@ | ||
package com.foo.rest.examples.spring.openapi.v3.time | ||
|
||
import com.ethlo.time.ITU | ||
import org.springframework.http.ResponseEntity | ||
import org.springframework.web.bind.annotation.* | ||
|
||
@RestController | ||
@RequestMapping(path = ["/api/time"]) | ||
class TimeRest { | ||
|
||
|
||
@GetMapping | ||
open fun get(@RequestParam x: String) : ResponseEntity<String> { | ||
|
||
try{ | ||
ITU.parseDateTime(x) | ||
}catch (e:Exception){ | ||
return ResponseEntity.badRequest().body(e.message) | ||
} | ||
|
||
if(x.contains("Z") ){ | ||
return ResponseEntity.ok("A") | ||
} | ||
if(x.contains("-") ){ | ||
return ResponseEntity.ok("B") | ||
} | ||
if(x.contains("+") ){ | ||
return ResponseEntity.ok("C") | ||
} | ||
|
||
return ResponseEntity.ok("D") | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
e2e-tests/spring-rest-openapi-v3/src/main/resources/static/openapi-time.yml
This file contains 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,17 @@ | ||
openapi: 3.0.0 | ||
info: | ||
title: time | ||
version: "1" | ||
paths: | ||
/api/time: | ||
get: | ||
parameters: | ||
- in: query | ||
name: x | ||
required: true | ||
schema: | ||
type: string | ||
format: 'date-time' | ||
responses: | ||
200: | ||
description: ok |
16 changes: 16 additions & 0 deletions
16
...openapi-v3/src/test/kotlin/com/foo/rest/examples/spring/openapi/v3/time/TimeController.kt
This file contains 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,16 @@ | ||
package com.foo.rest.examples.spring.openapi.v3.time | ||
|
||
import com.foo.rest.examples.spring.openapi.v3.SpringController | ||
import org.evomaster.client.java.controller.problem.ProblemInfo | ||
import org.evomaster.client.java.controller.problem.RestProblem | ||
|
||
class TimeController : SpringController(TimeApplication::class.java){ | ||
|
||
|
||
override fun getProblemInfo(): ProblemInfo { | ||
return RestProblem( | ||
"http://localhost:$sutPort/openapi-time.yml", | ||
null | ||
) | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
...st-openapi-v3/src/test/kotlin/org/evomaster/e2etests/spring/openapi/v3/time/TimeEMTest.kt
This file contains 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,38 @@ | ||
package org.evomaster.e2etests.spring.openapi.v3.time | ||
|
||
|
||
import com.foo.rest.examples.spring.openapi.v3.time.TimeController | ||
import org.evomaster.core.problem.rest.HttpVerb | ||
import org.evomaster.e2etests.spring.openapi.v3.SpringTestBase | ||
import org.junit.jupiter.api.Assertions | ||
import org.junit.jupiter.api.BeforeAll | ||
import org.junit.jupiter.api.Test | ||
|
||
class TimeEMTest : SpringTestBase(){ | ||
|
||
companion object { | ||
@BeforeAll | ||
@JvmStatic | ||
fun init() { | ||
initClass(TimeController()) | ||
} | ||
} | ||
|
||
@Test | ||
fun testRunEM() { | ||
|
||
runTestHandlingFlakyAndCompilation( | ||
"TimeEM", | ||
100 | ||
) { args: MutableList<String> -> | ||
|
||
val solution = initAndRun(args) | ||
|
||
Assertions.assertTrue(solution.individuals.size >= 1) | ||
assertHasAtLeastOne(solution, HttpVerb.GET, 200, "/api/time", "A") | ||
assertHasAtLeastOne(solution, HttpVerb.GET, 200, "/api/time", "B") | ||
assertHasAtLeastOne(solution, HttpVerb.GET, 200, "/api/time", "C") | ||
Check failure on line 34 in e2e-tests/spring-rest-openapi-v3/src/test/kotlin/org/evomaster/e2etests/spring/openapi/v3/time/TimeEMTest.kt GitHub Actions / JUnit Test ReportTimeEMTest.testRunEM
Raw output
|
||
assertHasAtLeastOne(solution, HttpVerb.GET, 200, "/api/time", "D") | ||
} | ||
} | ||
} |
This file contains 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