Fixed Jaxrs imports for JUnit in SingleTestGenerator.

This commit is contained in:
Olga Maciaszek-Sharma
2016-02-22 16:36:02 +01:00
parent 853a395309
commit 28bc9225a8
2 changed files with 5 additions and 3 deletions

View File

@@ -53,7 +53,7 @@ class SingleTestGenerator {
if (configProperties.testMode == TestMode.JAXRSCLIENT) {
clazz.addStaticImport('javax.ws.rs.client.Entity.*')
if (configProperties.targetFramework == TestFramework.JUNIT) {
clazz.addImport('import javax.ws.rs.core.Response')
clazz.addImport('javax.ws.rs.core.Response')
}
} else if (configProperties.testMode == TestMode.MOCKMVC) {
clazz.addStaticImport('com.jayway.restassured.module.mockmvc.RestAssuredMockMvc.*')

View File

@@ -1,6 +1,7 @@
package io.codearte.accurest
import io.codearte.accurest.config.AccurestConfigProperties
import io.codearte.accurest.config.TestMode
import io.codearte.accurest.file.Contract
import org.junit.Rule
import org.junit.rules.TemporaryFolder
@@ -67,6 +68,7 @@ class SingleTestGeneratorSpec extends Specification {
def "should build JaxRs test class for #testFramework"() {
given:
AccurestConfigProperties properties = new AccurestConfigProperties();
properties.testMode = TestMode.JAXRSCLIENT
properties.targetFramework = testFramework
Contract contract = new Contract(file.toPath(), true, 1, 2)
contract.ignored >> true
@@ -81,8 +83,8 @@ class SingleTestGeneratorSpec extends Specification {
where:
testFramework | classStrings
JUNIT | jUnitClassStrings
SPOCK | spockClassStrings
JUNIT | ['import static javax.ws.rs.client.Entity.*;', 'import javax.ws.rs.core.Response;']
SPOCK | ['import static javax.ws.rs.client.Entity.*;']
}