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 generated by RoostGPT #16

Open
wants to merge 1 commit into
base: main
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
59 changes: 59 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,59 @@
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration/>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.7</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<outputDirectory>coverageReport</outputDirectory>
</configuration>
</execution>
</executions>
<!--Plugin added by RoostGPT-->
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.5</version>
<!--Plugin added by RoostGPT-->
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>3.2.5</version>
<configuration>
<outputDirectory>testReport</outputDirectory>
</configuration>
<!--Plugin added by RoostGPT-->
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>2.1</version>
<configuration>
<outputDirectory>testReport</outputDirectory>
</configuration>
<!--Plugin added by RoostGPT-->
</plugin>
<plugin>
<groupId>io.spring.javaformat</groupId>
<artifactId>spring-javaformat-maven-plugin</artifactId>
<version>0.0.40</version>
<!--Plugin added by RoostGPT-->
</plugin>
</plugins>
</build>
<dependencies>
Expand Down Expand Up @@ -59,6 +112,12 @@
<scope>test</scope>
<!--Dependency added by RoostGPT-->
</dependency>
<dependency>
<groupId>io.spring.javaformat</groupId>
<artifactId>spring-javaformat-formatter</artifactId>
<version>0.0.40</version>
<!--Dependency added by RoostGPT-->
</dependency>
<!--SpringDoc dependencies -->
<dependency>
<groupId>org.springdoc</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
// ********RoostGPT********
/*
Test generated by RoostGPT for test CreditCard-Unit using AI Type Claude AI and AI Model claude-3-opus-20240229

ROOST_METHOD_HASH=cardLast4_3d92b3ad7d
ROOST_METHOD_SIG_HASH=cardLast4_cf18daeacc

Here are the JUnit test scenarios for the provided `cardLast4` method:

Scenario 1: Valid Card Last 4 Digits

Details:
TestName: validCardLast4SetsValueAndReturnsRequest
Description: This test verifies that providing a valid card last 4 digits string sets the corresponding private field and returns the BalanceAlertRequest instance.
Execution:
Arrange: Create a new instance of the BalanceAlertRequest class.
Act: Invoke the cardLast4 method with a valid string representing the last 4 digits of a card.
Assert: Assert that the private cardLast4 field is set to the provided value and the method returns the same BalanceAlertRequest instance.
Validation:
The assertion ensures that the cardLast4 method correctly sets the private field and maintains the fluent API by returning the request instance. This test is important to validate the basic functionality and chaining behavior of the method.

Scenario 2: Null Card Last 4 Digits

Details:
TestName: nullCardLast4SetsValueToNullAndReturnsRequest
Description: This test checks that passing a null value to the cardLast4 method sets the corresponding private field to null and returns the BalanceAlertRequest instance.
Execution:
Arrange: Create a new instance of the BalanceAlertRequest class.
Act: Invoke the cardLast4 method with a null value.
Assert: Assert that the private cardLast4 field is set to null and the method returns the same BalanceAlertRequest instance.
Validation:
The assertion verifies that the cardLast4 method handles null values gracefully by setting the private field to null and maintaining the fluent API. This test ensures the method's behavior remains consistent even when provided with null input.

Scenario 3: Empty Card Last 4 Digits

Details:
TestName: emptyCardLast4SetsValueToEmptyStringAndReturnsRequest
Description: This test validates that providing an empty string to the cardLast4 method sets the corresponding private field to an empty string and returns the BalanceAlertRequest instance.
Execution:
Arrange: Create a new instance of the BalanceAlertRequest class.
Act: Invoke the cardLast4 method with an empty string.
Assert: Assert that the private cardLast4 field is set to an empty string and the method returns the same BalanceAlertRequest instance.
Validation:
The assertion confirms that the cardLast4 method handles empty strings by setting the private field accordingly and maintaining the fluent API. This test ensures the method's behavior remains predictable when provided with an empty string input.

Scenario 4: Card Last 4 Digits with Leading/Trailing Whitespace

Details:
TestName: cardLast4WithWhitespaceSetsValueWithoutWhitespaceAndReturnsRequest
Description: This test verifies that providing a card last 4 digits string with leading/trailing whitespace to the cardLast4 method sets the corresponding private field with the whitespace trimmed and returns the BalanceAlertRequest instance.
Execution:
Arrange: Create a new instance of the BalanceAlertRequest class.
Act: Invoke the cardLast4 method with a string containing leading/trailing whitespace.
Assert: Assert that the private cardLast4 field is set to the trimmed value and the method returns the same BalanceAlertRequest instance.
Validation:
The assertion ensures that the cardLast4 method handles input with leading/trailing whitespace by trimming the value before setting the private field. This test validates the method's ability to sanitize input and maintain data consistency.

Note: The provided test scenarios assume that the BalanceAlertRequest class has appropriate getter methods or reflection capabilities to access the private fields for assertion purposes.
*/

// ********RoostGPT********
package org.openapitools.model;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import org.junit.jupiter.params.provider.ValueSource;
import java.util.stream.Stream;
import static org.junit.jupiter.api.Assertions.*;

class BalanceAlertRequestCardLast4Test {

private BalanceAlertRequest balanceAlertRequest;

@BeforeEach
void setUp() {
balanceAlertRequest = new BalanceAlertRequest();
}

@ParameterizedTest
@ValueSource(strings = { "1234", "5678", "9012" })
void validCardLast4SetsValueAndReturnsRequest(String cardLast4) {
BalanceAlertRequest result = balanceAlertRequest.cardLast4(cardLast4);
assertEquals(cardLast4, balanceAlertRequest.getCardLast4());
assertSame(balanceAlertRequest, result);
}

@Test
void nullCardLast4SetsValueToNullAndReturnsRequest() {
BalanceAlertRequest result = balanceAlertRequest.cardLast4(null);
assertNull(balanceAlertRequest.getCardLast4());
assertSame(balanceAlertRequest, result);
}

@Test
void emptyCardLast4SetsValueToEmptyStringAndReturnsRequest() {
BalanceAlertRequest result = balanceAlertRequest.cardLast4("");
assertEquals("", balanceAlertRequest.getCardLast4());
assertSame(balanceAlertRequest, result);
}

@ParameterizedTest
@MethodSource("provideCardLast4WithWhitespace")
void cardLast4WithWhitespaceSetsValueWithoutWhitespaceAndReturnsRequest(String input, String expected) {
BalanceAlertRequest result = balanceAlertRequest.cardLast4(input);
assertEquals(expected, balanceAlertRequest.getCardLast4());
assertSame(balanceAlertRequest, result);
}

private static Stream<Arguments> provideCardLast4WithWhitespace() {
return Stream.of(Arguments.of(" 1234 ", "1234"), Arguments.of("\t5678\t", "5678"),
Arguments.of("\n9012\n", "9012"));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
// ********RoostGPT********
/*
Test generated by RoostGPT for test CreditCard-Unit using AI Type Claude AI and AI Model claude-3-opus-20240229

ROOST_METHOD_HASH=currentDate_a57647b643
ROOST_METHOD_SIG_HASH=currentDate_78774936c5

Here are the generated test scenarios for the provided currentDate method:

Scenario 1: Setting Current Date

Details:
TestName: currentDateSetSuccessfully()
Description: This test verifies that the currentDate method correctly sets the current date in the BalanceAlertRequest object and returns the same object.
Execution:
Arrange: Create a BalanceAlertRequest object.
Act: Invoke the currentDate method with a specific LocalDate value.
Assert: Assert that the returned object is the same as the original BalanceAlertRequest object and that the currentDate field is set to the provided LocalDate value.
Validation:
The assertion ensures that the currentDate method properly sets the currentDate field and returns the BalanceAlertRequest object, maintaining the fluent API pattern. This test is important to validate the basic functionality of setting the current date in the request object.

Scenario 2: Setting Current Date to Null

Details:
TestName: currentDateSetToNull()
Description: This test checks the behavior of the currentDate method when passing a null value as the current date.
Execution:
Arrange: Create a BalanceAlertRequest object.
Act: Invoke the currentDate method with a null value.
Assert: Assert that the returned object is the same as the original BalanceAlertRequest object and that the currentDate field is set to null.
Validation:
The assertion verifies that the currentDate method handles null values correctly by setting the currentDate field to null and returning the BalanceAlertRequest object. This test is important to ensure that the method does not throw any exceptions and allows setting the current date to null if needed.

Scenario 3: Setting Current Date Before Payment Due Date

Details:
TestName: currentDateBeforePaymentDueDate()
Description: This test validates the behavior of the currentDate method when the provided current date is before the payment due date.
Execution:
Arrange: Create a BalanceAlertRequest object and set the paymentDueDate to a future date.
Act: Invoke the currentDate method with a LocalDate value that is before the payment due date.
Assert: Assert that the returned object is the same as the original BalanceAlertRequest object and that the currentDate field is set to the provided LocalDate value.
Validation:
The assertion confirms that the currentDate method allows setting the current date to a value before the payment due date. This test is important to ensure that the method does not enforce any restrictions on the relationship between the current date and the payment due date.

Scenario 4: Setting Current Date After Payment Due Date

Details:
TestName: currentDateAfterPaymentDueDate()
Description: This test checks the behavior of the currentDate method when the provided current date is after the payment due date.
Execution:
Arrange: Create a BalanceAlertRequest object and set the paymentDueDate to a past date.
Act: Invoke the currentDate method with a LocalDate value that is after the payment due date.
Assert: Assert that the returned object is the same as the original BalanceAlertRequest object and that the currentDate field is set to the provided LocalDate value.
Validation:
The assertion verifies that the currentDate method allows setting the current date to a value after the payment due date. This test is important to ensure that the method does not impose any constraints on the relationship between the current date and the payment due date.

These test scenarios cover different aspects of the currentDate method, including setting the current date successfully, handling null values, and testing the behavior when the current date is before or after the payment due date. The scenarios aim to validate the basic functionality and edge cases of the method.
*/

// ********RoostGPT********
package org.openapitools.model;

import java.time.LocalDate;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
import java.net.URI;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonTypeName;
import org.springframework.format.annotation.DateTimeFormat;
import org.openapitools.jackson.nullable.JsonNullable;
import java.time.OffsetDateTime;
import javax.validation.Valid;
import javax.validation.constraints.*;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.*;
import javax.annotation.Generated;

class BalanceAlertRequestCurrentDateTest {

private BalanceAlertRequest balanceAlertRequest;

@BeforeEach
void setUp() {
balanceAlertRequest = new BalanceAlertRequest();
}

@Test
void currentDateSetSuccessfully() {
LocalDate currentDate = LocalDate.of(2023, 6, 10);
BalanceAlertRequest result = balanceAlertRequest.currentDate(currentDate);
assertSame(balanceAlertRequest, result);
assertEquals(currentDate, balanceAlertRequest.getCurrentDate());
}

@Test
void currentDateSetToNull() {
BalanceAlertRequest result = balanceAlertRequest.currentDate(null);
assertSame(balanceAlertRequest, result);
assertNull(balanceAlertRequest.getCurrentDate());
}

@Test
void currentDateBeforePaymentDueDate() {
LocalDate paymentDueDate = LocalDate.of(2023, 6, 15);
LocalDate currentDate = LocalDate.of(2023, 6, 10);
balanceAlertRequest.setPaymentDueDate(paymentDueDate);
BalanceAlertRequest result = balanceAlertRequest.currentDate(currentDate);
assertSame(balanceAlertRequest, result);
assertEquals(currentDate, balanceAlertRequest.getCurrentDate());
}

@Test
void currentDateAfterPaymentDueDate() {
LocalDate paymentDueDate = LocalDate.of(2023, 6, 5);
LocalDate currentDate = LocalDate.of(2023, 6, 10);
balanceAlertRequest.setPaymentDueDate(paymentDueDate);
BalanceAlertRequest result = balanceAlertRequest.currentDate(currentDate);
assertSame(balanceAlertRequest, result);
assertEquals(currentDate, balanceAlertRequest.getCurrentDate());
}

}
Loading