Added compilation test to cookie assertion tests

This commit is contained in:
Alex Xandra Albert Sim
2018-04-10 08:27:56 +07:00
parent c740f8b3dd
commit bca6c14350
2 changed files with 16 additions and 0 deletions

View File

@@ -1267,6 +1267,8 @@ DATA
test.contains('''.cookie("cookie-key", "cookie-value")''')
test.contains('''assertThat(response.getCookies().get("cookie-key")).isNotNull();''')
test.contains('''assertThat(response.getCookies().get("cookie-key").getValue()).isEqualTo("new-cookie-value");''')
and:
SyntaxChecker.tryToCompile("JaxRsClientJUnitMethodBodyBuilder", blockBuilder.toString())
}
def "should generate test for cookies with pattern in JAX-RS JUnit test"() {
@@ -1280,6 +1282,8 @@ DATA
test.contains('''.cookie("cookie-key", "[A-Za-z]+")''')
test.contains('''assertThat(response.getCookies().get("cookie-key")).isNotNull();''')
test.contains('''assertThat(response.getCookies().get("cookie-key").getValue()).matches("[A-Za-z]+");''')
and:
SyntaxChecker.tryToCompile("JaxRsClientJUnitMethodBodyBuilder", blockBuilder.toString())
}
def "should generate test for cookies with string value in JAX-RS Spock test"() {
@@ -1293,6 +1297,8 @@ DATA
test.contains('''.cookie('cookie-key', 'cookie-value')''')
test.contains('''response.getCookies().get('cookie-key') != null''')
test.contains("response.getCookies().get('cookie-key').getValue() == 'new-cookie-value'")
and:
SyntaxChecker.tryToCompile("JaxRsClientSpockMethodRequestProcessingBodyBuilder", blockBuilder.toString())
}
def "should generate test for cookies with pattern in JAX-RS Spock test"() {
@@ -1306,5 +1312,7 @@ DATA
test.contains('''.cookie('cookie-key', '[A-Za-z]+')''')
test.contains('''response.getCookies().get('cookie-key') != null''')
test.contains('''response.getCookies().get('cookie-key').getValue() ==~ java.util.regex.Pattern.compile('[A-Za-z]+')''')
and:
SyntaxChecker.tryToCompile("JaxRsClientSpockMethodRequestProcessingBodyBuilder", blockBuilder.toString())
}
}

View File

@@ -2472,6 +2472,8 @@ DocumentContext parsedJson = JsonPath.parse(json);
test.contains('''.cookie("cookie-key", "cookie-value")''')
test.contains('''assertThat(response.getCookie("cookie-key")).isNotNull();''')
test.contains('''assertThat(response.getCookie("cookie-key")).isEqualTo("new-cookie-value");''')
and:
SyntaxChecker.tryToCompile("MockMvcJUnitMethodBodyBuilder", blockBuilder.toString())
}
def "should generate JUnit assertions with cookies pattern"() {
@@ -2485,6 +2487,8 @@ DocumentContext parsedJson = JsonPath.parse(json);
test.contains('''.cookie("cookie-key", "[A-Za-z]+")''')
test.contains('''assertThat(response.getCookie("cookie-key")).isNotNull();''')
test.contains('''assertThat(response.getCookie("cookie-key")).matches("[A-Za-z]+");''')
and:
SyntaxChecker.tryToCompile("MockMvcJUnitMethodBodyBuilder", blockBuilder.toString())
}
def "should generate spock assertions with cookies"() {
@@ -2498,6 +2502,8 @@ DocumentContext parsedJson = JsonPath.parse(json);
test.contains('''.cookie("cookie-key", "cookie-value")''')
test.contains('''response.cookie('cookie-key') != null''')
test.contains('''response.cookie('cookie-key') == 'new-cookie-value''')
and:
SyntaxChecker.tryToCompile("MockMvcSpockMethodRequestProcessingBodyBuilder", blockBuilder.toString())
}
def "should generate spock assertions with cookies pattern"() {
@@ -2511,6 +2517,8 @@ DocumentContext parsedJson = JsonPath.parse(json);
test.contains('''.cookie("cookie-key", "[A-Za-z]+")''')
test.contains('''response.cookie('cookie-key') != null''')
test.contains('''response.cookie('cookie-key') ==~ java.util.regex.Pattern.compile('[A-Za-z]+')''')
and:
SyntaxChecker.tryToCompile("MockMvcSpockMethodRequestProcessingBodyBuilder", blockBuilder.toString())
}
}