Skip to content
Permalink
Browse files

restored previous Base test.

  • Loading branch information...
arcuri82 committed Jul 4, 2019
1 parent 989a116 commit 8a655f77142aa5005bec09916e2e9ff4c39da77b
@@ -111,6 +111,10 @@
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
@@ -0,0 +1,46 @@
package com.foo.spring.rest.postgres.base

import com.foo.spring.rest.postgres.SwaggerConfiguration
import org.springframework.beans.factory.annotation.Autowired
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.RequestMapping
import springfox.documentation.swagger2.annotations.EnableSwagger2
import javax.persistence.EntityManager




/**
* Created by arcuri82 on 21-Jun-19.
*/
@EnableSwagger2
@SpringBootApplication(exclude = [SecurityAutoConfiguration::class])
@RequestMapping(path = ["/api/basic"])
open class BaseApp : SwaggerConfiguration() {

companion object {
@JvmStatic
fun main(args: Array<String>) {
SpringApplication.run(BaseApp::class.java, *args)
}
}

@Autowired
private lateinit var em : EntityManager


@GetMapping
open fun get() : ResponseEntity<Any> {

val query = em.createNativeQuery("select * from X where id>0")
val res = query.resultList

val status = if(res.isEmpty()) 400 else 200

return ResponseEntity.status(status).build<Any>()
}
}
@@ -1,4 +1,4 @@
package com.foo.spring.rest.postgres.basic
package com.foo.spring.rest.postgres.ind0

import com.foo.spring.rest.postgres.SwaggerConfiguration
import org.springframework.beans.factory.annotation.Autowired
@@ -19,12 +19,12 @@ import javax.persistence.EntityManager
@EnableSwagger2
@SpringBootApplication(exclude = [SecurityAutoConfiguration::class])
@RequestMapping(path = ["/api/basic"])
open class BasicApp : SwaggerConfiguration() {
open class Ind0App : SwaggerConfiguration() {

companion object {
@JvmStatic
fun main(args: Array<String>) {
SpringApplication.run(BasicApp::class.java, *args)
SpringApplication.run(Ind0App::class.java, *args)
}
}

@@ -0,0 +1,4 @@
create table X (
id BIGINT,
constraint pk_x primary key (id)
);
@@ -0,0 +1,12 @@
package com.foo.spring.rest.postgres.base


import com.foo.spring.rest.postgres.SpringRestPostgresController

/**
* Created by arcuri82 on 21-Jun-19.
*/
class BaseController : SpringRestPostgresController(BaseApp::class.java) {

override fun pathToFlywayFiles() = "classpath:/schema/base"
}

This file was deleted.

@@ -0,0 +1,11 @@
package com.foo.spring.rest.postgres.ind0

import com.foo.spring.rest.postgres.SpringRestPostgresController

/**
* Created by arcuri82 on 21-Jun-19.
*/
class Ind0Controller : SpringRestPostgresController(Ind0App::class.java) {

override fun pathToFlywayFiles() = "classpath:/schema/ind0"
}
@@ -1,6 +1,7 @@
package org.evomaster.e2etests.spring.rest.postgres.basic
package org.evomaster.e2etests.spring.rest.postgres.base

import com.foo.spring.rest.postgres.basic.BasicController

import com.foo.spring.rest.postgres.base.BaseController
import org.evomaster.core.problem.rest.HttpVerb
import org.evomaster.e2etests.spring.rest.postgres.SpringRestPostgresTestBase
import org.junit.jupiter.api.Assertions.assertTrue
@@ -15,16 +16,16 @@ class BasicEMTest : SpringRestPostgresTestBase(){
companion object {
@BeforeAll @JvmStatic
fun initClass() {
SpringRestPostgresTestBase.initKlass(BasicController())
SpringRestPostgresTestBase.initKlass(BaseController())
}
}

@Test
fun testRunEM() {

runTestHandlingFlakyAndCompilation(
"BasicEM",
"org.bar.BasicEM",
"BaseEM",
"org.bar.BaseEM",
100
) { args ->

@@ -0,0 +1,39 @@
package org.evomaster.e2etests.spring.rest.postgres.ind0

import com.foo.spring.rest.postgres.ind0.Ind0Controller
import org.evomaster.core.problem.rest.HttpVerb
import org.evomaster.e2etests.spring.rest.postgres.SpringRestPostgresTestBase
import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.BeforeAll
import org.junit.jupiter.api.Test

/**
* Created by arcuri82 on 21-Jun-19.
*/
class Ind0EMTest : SpringRestPostgresTestBase(){

companion object {
@BeforeAll @JvmStatic
fun initClass() {
SpringRestPostgresTestBase.initKlass(Ind0Controller())
}
}

@Test
fun testRunEM() {

runTestHandlingFlakyAndCompilation(
"Ind0EM",
"org.bar.Ind0EM",
100
) { args ->

val solution = initAndRun(args)

assertTrue(solution.individuals.size >= 1)

assertHasAtLeastOne(solution, HttpVerb.GET, 400)
assertHasAtLeastOne(solution, HttpVerb.GET, 200)
}
}
}

0 comments on commit 8a655f7

Please sign in to comment.
You can’t perform that action at this time.