diff --git a/pom.xml b/pom.xml index db6c2c51..3d1af2c5 100644 --- a/pom.xml +++ b/pom.xml @@ -1,89 +1,180 @@ - - - 4.0.0 - - org.springframework.boot - spring-boot-starter-parent - 3.0.5 - - - com.bootexample4 - products - 0.0.1-SNAPSHOT - products - Demo project for Spring Boot - - 17 - - - - org.springframework.boot - spring-boot-starter-data-jpa - - - - org.mock-server - mockserver-netty - 3.10.8 - - - org.mock-server - mockserver-client-java - 3.10.8 - - - org.springframework.boot - spring-boot-starter-web - - - - com.h2database - h2 - runtime - - - org.springframework.boot - spring-boot-starter-test - test - - - - io.cucumber - cucumber-spring - 7.0.0 - test + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 3.0.5 + + + + com.bootexample4 + products + 0.0.1-SNAPSHOT + products + Demo project for Spring Boot + + 17 + + + + org.springframework.boot + spring-boot-starter-data-jpa + + + + org.mock-server + mockserver-netty + 3.10.8 + + + org.mock-server + mockserver-client-java + 3.10.8 + + + org.springframework.boot + spring-boot-starter-web + + + com.h2database + h2 + runtime + + + org.springframework.boot + spring-boot-starter-test + test + + + + io.cucumber + cucumber-spring + 7.0.0 + test - io.cucumber - cucumber-java - 7.0.0 - test + io.cucumber + cucumber-java + 7.0.0 + test - io.cucumber - cucumber-junit - 7.0.0 - test + io.cucumber + cucumber-junit + 7.0.0 + test - org.assertj - assertj-core - 3.19.0 - test - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - - + org.assertj + assertj-core + 3.19.0 + test + + + org.junit.vintage + junit-vintage-engine + 5.2.0 + + + + io.spring.javaformat + spring-javaformat-formatter + 0.0.40 + + + + org.mockito + mockito-core + 4.1.0 + compile + + + + org.mockito + mockito-junit-jupiter + 4.1.0 + compile + + + + org.springframework.boot + spring-boot-starter-aop + 3.0.5 + compile + + + + org.springframework + spring-web + 5.3.15 + compile + + + + org.springframework + spring-webmvc + 5.3.15 + compile + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + org.jacoco + jacoco-maven-plugin + 0.8.7 + + + + prepare-agent + + + + report + test + + report + + + coverageReport + + + + + + + org.apache.maven.plugins + maven-surefire-report-plugin + 3.2.5 + + testReport + + + + + org.apache.maven.plugins + maven-site-plugin + 2.1 + + testReport + + + + + io.spring.javaformat + spring-javaformat-maven-plugin + 0.0.40 + + + + + \ No newline at end of file diff --git a/src/test/java/com/bootexample4/products/controller/ProductControllerCreateProductTest.java b/src/test/java/com/bootexample4/products/controller/ProductControllerCreateProductTest.java new file mode 100644 index 00000000..b30b26f7 --- /dev/null +++ b/src/test/java/com/bootexample4/products/controller/ProductControllerCreateProductTest.java @@ -0,0 +1,49 @@ +// ********RoostGPT******** +/* +Test generated by RoostGPT for test java-sample-test using AI Type Azure Open AI and AI Model roostgpt-4-32k + +ROOST_METHOD_HASH=createProduct_60409495d0 +ROOST_METHOD_SIG_HASH=createProduct_5b0158b3eb + +""" + Scenario 1: Test createProduct with valid Product object. + + Details: + TestName: testCreateProductSuccessScenario. + Description: This test is designed to validate the method's ability to create and save a new Product object when given valid input. + Execution: + Arrange: Create a valid Product object and mock the productRepository's save method to return the same product object. + Act: Invoke the createProduct method with the valid Product object. + Assert: Assert that the returned Product object matches the one passed as a parameter to the method. + Validation: + This test validates that the createProduct method can create and save a product with valid inputs. The expected result is the same product object, as the repository save method is assumed to function properly. + + Scenario 2: Test createProduct with null Product object. + + Details: + TestName: testCreateProductWithNullParameter. + Description: This test is designed to validate the method's ability to handle null input. + Execution: + Arrange: Mock the productRepository's save method to throw an exception when null is passed as a parameter. + Act: Invoke the createProduct method with null. + Assert: Assert that an IllegalArgumentException or similar exception is thrown. + Validation: + This test validates that the createProduct method handles null inputs properly to prevent persistence layer crashes. The expected result is an exception, as null is an invalid input for the save method. + + Scenario 3: Test createProduct with Product object having invalid data. + + Details: + TestName: testCreateProductWithInvalidData. + Description: This test is designed to validate the method's ability to handle a Product object with invalid fields. + Execution: + Arrange: Create a Product object with invalid fields and mock the productRepository's save method to throw a DataIntegrityViolationException or similar exception. + Act: Invoke the createProduct method with the invalid Product object. + Assert: Assert that a DataIntegrityViolationException or similar exception is thrown. + Validation: + This test validates that the createProduct method can handle and respond properly to invalid product data. The expected result is a DataIntegrityViolationException thrown, indicating violation of data integrity constraints at the persistence layer. +""" +*/ + +// ********RoostGPT******** + +import org.springframework.http.HttpStatus;