Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@
<karate.version>1.4.1</karate.version>
</properties>
<dependencies>
<dependency>
<groupId>com.intuit.karate</groupId>
<artifactId>karate-junit5</artifactId>
<version>${karate.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.intuit.karate</groupId>
<artifactId>karate-core</artifactId>
Expand All @@ -29,6 +23,13 @@
<version>0.1.0</version>
<!--Dependency added by RoostGPT-->
</dependency>
<dependency>
<groupId>com.intuit.karate</groupId>
<artifactId>karate-junit5</artifactId>
<version>1.4.1</version>
<scope>test</scope>
<!--Dependency added by RoostGPT-->
</dependency>
</dependencies>
<build>
<testResources>
Expand Down
23 changes: 23 additions & 0 deletions src/test/java/org/springframework/api_tests/ApiTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

package org.springframework.api_tests;

import com.intuit.karate.Results;
import com.intuit.karate.Runner;
import com.intuit.karate.http.HttpServer;
import com.intuit.karate.http.ServerConfig;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;

class ApiTest {

@Test
void testAll() {
String apiHostServer = System.getenv().getOrDefault("API_HOST", "http://localhost:8080");
Results results = Runner.path("classpath:org/springframework/api_tests")
.systemProperty("url.base", apiHostServer)
.parallel(1);
assertEquals(0, results.getFailCount(), results.getErrorMessages());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# ********RoostGPT********

# Test generated by RoostGPT for test karate using AI Type Azure Open AI and AI Model roostgpt-4-32k
#
# Feature file generated for /laureate/{laureateID}_get for http method type GET
# RoostTestHash=e702c0f931
#
#

# ********RoostGPT********
Feature: Nobel Prize Laureate API

Background:
* def urlBase = karate.properties['url.base'] || karate.get('urlBase', 'http://localhost:8080')
* url urlBase

Scenario Outline: Obtain information about a specific Nobel Prize Laureate
Given path '/2.1/laureate', '<laureateID>'
When method get
Then status 200
And match response.laureate.id == '<laureateID>'
And match response.laureate == '#object'

Examples:
| laureateID |
| 1 |
| 2 |
| 3 |

Scenario Outline: Test for incorrect laureateID in the endpoint
Given path '/2.1/laureate', '<laureateID>'
When method get
Then status 404

Examples:
| laureateID |
| 99999 |
| abc |
| '' |
61 changes: 61 additions & 0 deletions src/test/java/org/springframework/api_tests/laureates_get.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# ********RoostGPT********

# Test generated by RoostGPT for test karate using AI Type Azure Open AI and AI Model roostgpt-4-32k
#
# Feature file generated for /laureates_get for http method type GET
# RoostTestHash=ff433d7857
#
#

# ********RoostGPT********

Feature: Nobel Prize Laureates API Testing

Background:
* def urlBase = karate.properties['url.base'] || karate.get('urlBase', 'http://localhost:8080')
* url urlBase
* def authToken = karate.properties['AUTH_TOKEN']

Scenario Outline: Get laureates details with valid parameters
Given path '/2.1/laureates'
And param offset = <offset>
And param limit = <limit>
And param sort = <sort>
And param ID = <ID>
And param name = <name>
And param gender = <gender>
And param motivation = <motivation>
And param affiliation = <affiliation>
And param residence = <residence>
And param birthDate = <birthDate>
And param birthDateTo = <birthDateTo>
And param deathDate = <deathDate>
And param deathDateTo = <deathDateTo>
And param foundedDate = <foundedDate>
And param birthCity = <birthCity>
And param birthCountry = <birthCountry>
And param birthContinent = <birthContinent>
And param deathCity = <deathCity>
And param deathCountry = <deathCountry>
And param deathContinent = <deathContinent>
And param foundedCity = <foundedCity>
And param foundedCountry = <foundedCountry>
And param foundedContinent = <foundedContinent>
And param HeadquartersCity = <HeadquartersCity>
And param HeadquartersCountry = <HeadquartersCountry>
And param HeadquartersContinent = <HeadquartersContinent>
And param nobelPrizeYear = <nobelPrizeYear>
And param yearTo = <yearTo>
And param nobelPrizeCategory = <nobelPrizeCategory>
And param format = <format>
And param csvLang = <csvLang>
And header Authorization = authToken

When method get
Then status 200
And match response contains {offset: '#number', limit: '#number', sort: '#string', ID: '#number', name: '#string', gender: '#string', motivation: '#string', affiliation: '#string', residence: '#string', birthDate: '#string', birthDateTo: '#string', deathDate: '#string', deathDateTo: '#string', foundedDate: '#string', birthCity: '#string', birthCountry: '#string', birthContinent: '#string', deathCity: '#string', deathCountry: '#string', deathContinent: '#string', foundedCity: '#string', foundedCountry: '#string', foundedContinent: '#string', HeadquartersCity: '#string', HeadquartersCountry: '#string', HeadquartersContinent: '#string', nobelPrizeYear: '#number', yearTo: '#number', nobelPrizeCategory: '#string', format: '#string', csvLang: '#string'}

Examples:
| offset | limit | sort | ID | name | gender | motivation | affiliation | residence | birthDate | birthDateTo | deathDate | deathDateTo | foundedDate | birthCity | birthCountry | birthContinent | deathCity | deathCountry | deathContinent | foundedCity | foundedCountry | foundedContinent | HeadquartersCity | HeadquartersCountry | HeadquartersContinent | nobelPrizeYear | yearTo | nobelPrizeCategory | format | csvLang |
| 1 | 5 | 'asc' | 1 | 'John' | 'male'| 'N/A' | 'N/A' | 'N/A' | '1945-01-01' | '2005-01-01' | '2005-01-01' | '2015-01-01' | '2000-01-01' | 'New York' | 'USA' | 'North America' | 'Chicago' | 'USA' | 'North America' | 'Chicago' | 'USA' | 'North America' | 'Chicago' | 'USA' | 'North America' | 2005 | 2010 | 'Peace' | 'json' | 'en' |

Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# ********RoostGPT********

# Test generated by RoostGPT for test karate using AI Type Azure Open AI and AI Model roostgpt-4-32k
#
# Feature file generated for /nobelPrize/{category}/{year}_get for http method type GET
# RoostTestHash=9818bf6b39
#
#

# ********RoostGPT********
Feature: Nobel Prize Information

Background:
* def urlBase = karate.properties['url.base'] || karate.get('urlBase', 'http://localhost:8080')
* url urlBase
* def authToken = karate.properties['AUTH_TOKEN']
* header Authorization = authToken

Scenario Outline: Get Nobel Prize information by category and year

Given path '2.1', 'nobelPrize', '<category>', '<year>'
When method get
Then status <expectedStatus>
And match response contains { nobelPrize: '#object' }

Examples:
| category | year | expectedStatus |
| 'phy' | 2001 | 200 |
| 'phy' | 1800 | 422 |
| 'med' | 2001 | 200 |
| 'med' | 1800 | 422 |
| 'che' | 2001 | 200 |
| 'che' | 1800 | 422 |
| 'lit' | 2001 | 200 |
| 'lit' | 1800 | 422 |
| 'pea' | 2001 | 200 |
| 'pea' | 1800 | 422 |
| 'eco' | 2001 | 200 |
| 'eco' | 1800 | 422 |

Scenario: Invalid category

Given path '2.1', 'nobelPrize', 'abc', '2001'
When method get
Then status 400

Scenario: Invalid year

Given path '2.1', 'nobelPrize', 'phy', 'abc'
When method get
Then status 400

Scenario: Missing category

Given path '2.1', 'nobelPrize', , '2001'
When method get
Then status 404

Scenario: Missing year

Given path '2.1', 'nobelPrize', 'phy',
When method get
Then status 404
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# ********RoostGPT********

# Test generated by RoostGPT for test karate using AI Type Azure Open AI and AI Model roostgpt-4-32k
#
# Feature file generated for /nobelPrizes_get for http method type GET
# RoostTestHash=977dd819cb
#
#

# ********RoostGPT********
@karate-options(tags = '@smoke')
Feature: Nobel Prizes API

Background:
* def urlBase = karate.properties['url.base'] || karate.get('urlBase', 'http://localhost:8080')
* def AUTH_TOKEN = karate.properties['AUTH_TOKEN']
* url 'http://localhost:8080/2.1/nobelPrizes'

Scenario Outline: Verify status codes for the API with different inputs
Given path '/'
And param offset = <offset>
And param limit = <limit>
And param nobelPrizeYear = <nobelPrizeYear>
And param yearTo = <yearTo>
And param nobelPrizeCategory = <nobelPrizeCategory>
And header Authorization = 'Bearer ' + AUTH_TOKEN
When method get
Then status <statusCode>
And match response == <expectedBody>

Examples:
| limit | offset | nobelPrizeYear | yearTo | nobelPrizeCategory | expectedBody | statusCode |
| 1 | 1 | 2000 | 2010 | 'phy' | '#object' | 200 |
| 1 | 1 | 1800 | 1805 | 'phy' | '#object' | 400 |
| 1 | 1 | 1950 | 1960 | 'xyz' | '#object' | 422 |
| 1 | 1 | 2025 | 2030 | 'econ' | '#object' | 404 |

Scenario: Check invalid authorization token
Given path '/'
And param offset = 1
And param limit = 1
And param nobelPrizeYear = 1995
And param yearTo = 2005
And param nobelPrizeCategory = 'phy'
And header Authorization = 'Bearer INVALID_TOKEN'
When method get
Then status 401

@karate-options(tags = '@smoke')
Scenario: Check missing authorization token
Given path '/'
And param offset = 1
And param limit = 1
And param nobelPrizeYear = 1995
And param yearTo = 2005
And param nobelPrizeCategory = 'phy'
When method get
Then status 401