diff --git a/core/src/main/kotlin/org/evomaster/core/search/gene/datetime/TimeGene.kt b/core/src/main/kotlin/org/evomaster/core/search/gene/datetime/TimeGene.kt index 3861c44ae2..3ae25cb151 100644 --- a/core/src/main/kotlin/org/evomaster/core/search/gene/datetime/TimeGene.kt +++ b/core/src/main/kotlin/org/evomaster/core/search/gene/datetime/TimeGene.kt @@ -52,6 +52,7 @@ class TimeGene( .thenBy(TimeGene::minute) .thenBy(TimeGene::second) //TODO ms and offset + //FIXME: considering offset, this check is wrong. } fun selectZ(){ diff --git a/e2e-tests/spring-rest-openapi-v3/pom.xml b/e2e-tests/spring-rest-openapi-v3/pom.xml index 9a266a5658..102ced76e8 100644 --- a/e2e-tests/spring-rest-openapi-v3/pom.xml +++ b/e2e-tests/spring-rest-openapi-v3/pom.xml @@ -145,6 +145,11 @@ auth0 + + com.ethlo.time + itu + + diff --git a/e2e-tests/spring-rest-openapi-v3/src/main/kotlin/com/foo/rest/examples/spring/openapi/v3/time/TimeApplication.kt b/e2e-tests/spring-rest-openapi-v3/src/main/kotlin/com/foo/rest/examples/spring/openapi/v3/time/TimeApplication.kt new file mode 100644 index 0000000000..597764a54a --- /dev/null +++ b/e2e-tests/spring-rest-openapi-v3/src/main/kotlin/com/foo/rest/examples/spring/openapi/v3/time/TimeApplication.kt @@ -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) { + SpringApplication.run(TimeApplication::class.java, *args) + } + } +} \ No newline at end of file diff --git a/e2e-tests/spring-rest-openapi-v3/src/main/kotlin/com/foo/rest/examples/spring/openapi/v3/time/TimeRest.kt b/e2e-tests/spring-rest-openapi-v3/src/main/kotlin/com/foo/rest/examples/spring/openapi/v3/time/TimeRest.kt new file mode 100644 index 0000000000..3970d5ae9b --- /dev/null +++ b/e2e-tests/spring-rest-openapi-v3/src/main/kotlin/com/foo/rest/examples/spring/openapi/v3/time/TimeRest.kt @@ -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 { + + 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") + } +} \ No newline at end of file diff --git a/e2e-tests/spring-rest-openapi-v3/src/main/resources/static/openapi-time.yml b/e2e-tests/spring-rest-openapi-v3/src/main/resources/static/openapi-time.yml new file mode 100644 index 0000000000..f3723faa10 --- /dev/null +++ b/e2e-tests/spring-rest-openapi-v3/src/main/resources/static/openapi-time.yml @@ -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 diff --git a/e2e-tests/spring-rest-openapi-v3/src/test/kotlin/com/foo/rest/examples/spring/openapi/v3/time/TimeController.kt b/e2e-tests/spring-rest-openapi-v3/src/test/kotlin/com/foo/rest/examples/spring/openapi/v3/time/TimeController.kt new file mode 100644 index 0000000000..c7cf84026e --- /dev/null +++ b/e2e-tests/spring-rest-openapi-v3/src/test/kotlin/com/foo/rest/examples/spring/openapi/v3/time/TimeController.kt @@ -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 + ) + } +} \ No newline at end of file diff --git a/e2e-tests/spring-rest-openapi-v3/src/test/kotlin/org/evomaster/e2etests/spring/openapi/v3/time/TimeEMTest.kt b/e2e-tests/spring-rest-openapi-v3/src/test/kotlin/org/evomaster/e2etests/spring/openapi/v3/time/TimeEMTest.kt new file mode 100644 index 0000000000..b5d6cbce8a --- /dev/null +++ b/e2e-tests/spring-rest-openapi-v3/src/test/kotlin/org/evomaster/e2etests/spring/openapi/v3/time/TimeEMTest.kt @@ -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 -> + + 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") + assertHasAtLeastOne(solution, HttpVerb.GET, 200, "/api/time", "D") + } + } +} \ No newline at end of file diff --git a/pom.xml b/pom.xml index 77d448d79b..ae2d5f7de7 100644 --- a/pom.xml +++ b/pom.xml @@ -1041,6 +1041,14 @@ ${mockserver.client.version} test + + + + com.ethlo.time + itu + 1.10.2 + +