Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unit test case generated by roostGpt #99

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
223 changes: 106 additions & 117 deletions spring-boot-tutorial-soap-web-services/pom.xml
Original file line number Diff line number Diff line change
@@ -1,119 +1,108 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.in28minutes.springboot.soap.web.services.example</groupId>
<artifactId>spring-boot-tutorial-soap-web-services</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>spring-boot-tutorial-soap-web-services</name>
<description>SOAP Web Services with Spring Boot</description>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.0.2</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>17</java.version>
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web-services</artifactId>
</dependency>
<dependency>
<groupId>wsdl4j</groupId>
<artifactId>wsdl4j</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>xjc</id>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<sources>
<source>${project.basedir}/src/main/resources/student-details.xsd</source>
</sources>
<outputDirectory>${project.basedir}/src/main/java</outputDirectory>
<clearOutputDir>false</clearOutputDir>
</configuration>
</plugin>
</plugins>
</build>

<repositories>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>

<pluginRepositories>
<pluginRepository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>


<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.in28minutes.springboot.soap.web.services.example</groupId>
<artifactId>spring-boot-tutorial-soap-web-services</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>spring-boot-tutorial-soap-web-services</name>
<description>SOAP Web Services with Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.0.2</version>
<relativePath/>
<!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>17</java.version>
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web-services</artifactId>
</dependency>
<dependency>
<groupId>wsdl4j</groupId>
<artifactId>wsdl4j</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>xjc</id>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<sources>
<source>${project.basedir}/src/main/resources/student-details.xsd</source>
</sources>
<outputDirectory>${project.basedir}/src/main/java</outputDirectory>
<clearOutputDir>false</clearOutputDir>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</project>

<!-- http://localhost:8080/ws/students.wsdl -->
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file was generated by the Eclipse Implementation of JAXB, v3.0.0
// See https://eclipse-ee4j.github.io/jaxb-ri
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2023.02.12 at 12:32:21 PM IST
// Generated on: 2024.01.17 at 10:12:28 AM IST
//


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file was generated by the Eclipse Implementation of JAXB, v3.0.0
// See https://eclipse-ee4j.github.io/jaxb-ri
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2023.02.12 at 12:32:21 PM IST
// Generated on: 2024.01.17 at 10:12:28 AM IST
//


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file was generated by the Eclipse Implementation of JAXB, v3.0.0
// See https://eclipse-ee4j.github.io/jaxb-ri
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2023.02.12 at 12:32:21 PM IST
// Generated on: 2024.01.17 at 10:12:28 AM IST
//


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file was generated by the Eclipse Implementation of JAXB, v3.0.0
// See https://eclipse-ee4j.github.io/jaxb-ri
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2023.02.12 at 12:32:21 PM IST
// Generated on: 2024.01.17 at 10:12:28 AM IST
//


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file was generated by the Eclipse Implementation of JAXB, v3.0.0
// See https://eclipse-ee4j.github.io/jaxb-ri
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2023.02.12 at 12:32:21 PM IST
// Generated on: 2024.01.17 at 10:12:28 AM IST
//

@jakarta.xml.bind.annotation.XmlSchema(namespace = "http://in28minutes.com/students", elementFormDefault = jakarta.xml.bind.annotation.XmlNsForm.QUALIFIED)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
Test generated by RoostGPT for test java-web-service using AI Type Open AI and AI Model gpt-4

Scenario 1: Valid ID Request
- Description: Validate that the function is able to process a valid ID request and return the correct student details.
- Steps: Pass a valid ID in the GetStudentDetailsRequest payload.

Scenario 2: Invalid ID Request
- Description: Validate that the function handles invalid ID requests appropriately, either by returning an error message or a null response.
- Steps: Pass an invalid ID in the GetStudentDetailsRequest payload.

Scenario 3: Null ID Request
- Description: Validate that the function handles null ID requests without breaking.
- Steps: Pass a null ID in the GetStudentDetailsRequest payload.

Scenario 4: Check student details
- Description: Validate that the function always returns the student details for 'Adam' with passport number 'E1234567', regardless of the ID passed.
- Steps: Pass any ID in the GetStudentDetailsRequest payload and check if the returned student details are for 'Adam' with passport number 'E1234567'.

Scenario 5: Check returned student ID
- Description: Validate that the returned student ID is the same as the one passed in the request.
- Steps: Pass any valid ID in the GetStudentDetailsRequest payload and check if the returned student ID is the same as the one passed in the request.

Scenario 6: Check if response is not null
- Description: Validate that the function does not return a null response.
- Steps: Pass any ID in the GetStudentDetailsRequest payload and check if the returned response is not null.

Scenario 7: Check if StudentDetails in response is not null
- Description: Validate that the StudentDetails object in the response is not null.
- Steps: Pass any ID in the GetStudentDetailsRequest payload and check if the StudentDetails object in the response is not null.
*/
package com.in28minutes.springboot.soap.web.services.example.student;

import com.in28minutes.students.GetStudentDetailsRequest;
import com.in28minutes.students.GetStudentDetailsResponse;
import org.junit.Before;
import org.junit.Test;
import org.mockito.InjectMocks;
import org.mockito.MockitoAnnotations;
import static org.junit.Assert.*;

public class StudentDetailsEndpoint_processCourseDetailsRequest_6c0bcc5b42_Test {

@InjectMocks
private StudentDetailsEndpoint studentDetailsEndpoint;

@Before
public void setup() {
MockitoAnnotations.openMocks(this);
}


@Test
public void testProcessCourseDetailsRequest_ValidID() {
GetStudentDetailsRequest request = new GetStudentDetailsRequest();
request.setId(123456);

GetStudentDetailsResponse response = studentDetailsEndpoint.processCourseDetailsRequest(request);

assertNotNull(response);
assertNotNull(response.getStudentDetails());
assertEquals("123456", response.getStudentDetails().getId());
assertEquals("Adam", response.getStudentDetails().getName());
assertEquals("E1234567", response.getStudentDetails().getPassportNumber());
}

@Test
public void testProcessCourseDetailsRequest_InvalidID() {
GetStudentDetailsRequest request = new GetStudentDetailsRequest();
request.setId(1);

GetStudentDetailsResponse response = studentDetailsEndpoint.processCourseDetailsRequest(request);

assertNotNull(response);
assertNotNull(response.getStudentDetails());
assertNotEquals("invalid", response.getStudentDetails().getId());
}
}
Loading