diff --git a/pom.xml b/pom.xml index d5e071f..1c0acc9 100644 --- a/pom.xml +++ b/pom.xml @@ -1,96 +1,224 @@ - - - 4.0.0 - - org.springframework.boot - spring-boot-starter-parent - 3.0.6 - - - com.medeiros - SPRINGProject - 0.0.1-SNAPSHOT - SPRINGProject - Demo project for Spring Boot - - 20 - - 6.0.3 - - - - org.springframework.boot - spring-boot-starter-data-jpa - - - org.springframework.boot - spring-boot-starter-web - - - - org.springframework.boot - spring-boot-devtools - runtime - true - - - com.mysql - mysql-connector-j - runtime - - - org.springframework.boot - spring-boot-starter-test - test - - - - org.springframework.boot - spring-boot-starter-thymeleaf - 3.0.6 - - - - org.springframework.boot - spring-boot-starter-security - - - - io.jsonwebtoken - jjwt-api - 0.11.5 - - - - - - - org.springframework.security - spring-security-core - 6.0.3 - - - - - - - io.jsonwebtoken - jjwt-impl - 0.11.5 - runtime - - - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - - + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 3.0.6 + + + + com.medeiros + SPRINGProject + 0.0.1-SNAPSHOT + SPRINGProject + Demo project for Spring Boot + + 20 + + 6.0.3 + + + + org.springframework.boot + spring-boot-starter-data-jpa + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-devtools + runtime + true + + + com.mysql + mysql-connector-j + runtime + + + org.springframework.boot + spring-boot-starter-test + test + + + org.springframework.boot + spring-boot-starter-thymeleaf + 3.0.6 + + + org.springframework.boot + spring-boot-starter-security + + + org.mockito + mockito-junit-jupiter + 2.23.4 + + + + io.spring.javaformat + spring-javaformat-formatter + 0.0.40 + + + + org.junit.jupiter + junit-jupiter-api + 5.9.2 + compile + + + + org.junit.jupiter + junit-jupiter-engine + 5.9.2 + compile + + + + org.mockito + mockito-core + 4.10.0 + compile + + + + org.mockito + mockito-inline + 4.10.0 + compile + + + + + io.jsonwebtoken + jjwt-api + 0.11.5 + + + + org.springframework.security + spring-security-core + 6.0.3 + + + + + io.jsonwebtoken + jjwt-impl + 0.11.5 + runtime + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + org.jacoco + jacoco-maven-plugin + 0.8.11 + + + + prepare-agent + + + + report + test + + report + + + coverageReport + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.2.5 + + + + 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 + + + + + + + + + + + org.mockito + mockito-junit-jupiter + 2.23.4 + + + + io.spring.javaformat + spring-javaformat-formatter + 0.0.40 + + + + org.junit.jupiter + junit-jupiter-api + 5.9.2 + compile + + + + org.junit.jupiter + junit-jupiter-engine + 5.9.2 + compile + + + + org.mockito + mockito-core + 4.10.0 + compile + + + + org.mockito + mockito-inline + 4.10.0 + compile + + + + + \ No newline at end of file diff --git a/src/test/java/com/medeiros/SPRINGProject/algorithm/AlgorithmBlenderAlgorithmCalcTest.java b/src/test/java/com/medeiros/SPRINGProject/algorithm/AlgorithmBlenderAlgorithmCalcTest.java new file mode 100644 index 0000000..9aa047f --- /dev/null +++ b/src/test/java/com/medeiros/SPRINGProject/algorithm/AlgorithmBlenderAlgorithmCalcTest.java @@ -0,0 +1,223 @@ + +// ********RoostGPT******** +/* +Test generated by RoostGPT for test Rahul-jav-test-15 using AI Type Open AI and AI Model gpt-4o + +ROOST_METHOD_HASH=algorithmCalc_e489e5c1fc +ROOST_METHOD_SIG_HASH=algorithmCalc_009085eae1 + + +Scenario 1: Calculate Point Totals for a Single Music Model + +Details: + TestName: calculatePointTotalsForSingleMusicModel + Description: This test verifies that the algorithmCalc method correctly processes a single MusicModel object and calculates points based on likes and comments. +Execution: + Arrange: Create a single MusicModel instance with a specific number of likes and comments. Mock the algorithmData to return known points for likes and comments. + Act: Call the algorithmCalc method with a list containing this single MusicModel instance. + Assert: Assert that the resulting map contains the correct music name and calculated point total. +Validation: + This test ensures that the method properly calculates points for a single music piece, verifying the basic functionality and calculation logic. + +Scenario 2: Handle Multiple Music Models + +Details: + TestName: handleMultipleMusicModels + Description: This test checks how the algorithmCalc method processes multiple MusicModel objects and aggregates their calculated points accurately. +Execution: + Arrange: Create several MusicModel instances with varying numbers of likes and comments. Mock the algorithmData for return values. + Act: Invoke algorithmCalc with a list of these MusicModels. + Assert: Assert that the resulting map includes entries for each music piece with accurate calculated points. +Validation: + The test confirms that the method can handle multiple entries, returning a map with correct calculations for each music model. + +Scenario 3: No Music Models in Input List + +Details: + TestName: noMusicModelsInInputList + Description: This test examines the method's behavior when given an empty list, ensuring it returns an empty map without errors. +Execution: + Arrange: Prepare an empty list of MusicModels. + Act: Call algorithmCalc with this empty list. + Assert: Assert that the method returns an empty map. +Validation: + This test validates that the method can handle empty lists gracefully, a necessary condition for robust error handling. + +Scenario 4: Edge Case with Zero Likes and Comments + +Details: + TestName: edgeCaseWithZeroLikesAndComments + Description: Tests how the algorithmCalc method processes MusicModel objects with zero likes and comments. +Execution: + Arrange: Create a MusicModel instance with zero likes and comments. Mock the algorithmData to return zero points. + Act: Invoke algorithmCalc with a list containing this MusicModel. + Assert: Verify that the map contains the music name and a point total of zero. +Validation: + This tests the method's handling of edge cases where input values (likes/comments) are zero, ensuring it manages such situations correctly. + +Scenario 5: Extremely High Likes and Comments + +Details: + TestName: extremelyHighLikesAndComments + Description: This scenario examines the method's capability to process very high numbers of likes and comments without errors or overflow. +Execution: + Arrange: Create a MusicModel instance with very high numbers of likes and comments. Mock algorithmData to handle high input values. + Act: Pass a list containing this MusicModel to algorithmCalc. + Assert: Confirm that the map contains the expected high point total. +Validation: + This test is important for determining the method's resilience and correctness when processing extreme input values. + +Scenario 6: Identical Music Names but Different Points + +Details: + TestName: identicalMusicNamesButDifferentPoints + Description: Tests how the method deals with MusicModel objects that have identical music names but different like and comment counts. +Execution: + Arrange: Construct two MusicModel instances with the same music name but different counts of likes and comments. + Act: Supply a list including both MusicModels to algorithmCalc. + Assert: Confirm that the resulting map only holds one entry with the correct points for one of the MusicModels, as Map should aggregate based on keys. +Validation: + This scenario highlights method behavior when encountering duplicate keys, an important aspect for applications dealing with non-unique identifiers. + +*/ + +// ********RoostGPT******** + +package com.medeiros.SPRINGProject.algorithm; + +import com.medeiros.SPRINGProject.Models.MusicModel; +import com.medeiros.SPRINGProject.utils.hashMapFunctions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.Mockito.*; +import org.junit.jupiter.api.*; +import java.util.HashMap; + +class AlgorithmBlenderAlgorithmCalcTest extends algorithmData { + + @Mock + private algorithmData AD; + + @InjectMocks + private algorithmBlender algorithmBlender; + + @BeforeEach + void setUp() { + MockitoAnnotations.openMocks(this); + algorithmBlender = new algorithmBlender(); + } + + @Test + @Tag("valid") + public void calculatePointTotalsForSingleMusicModel() { + MusicModel musicModel = mock(MusicModel.class); + when(musicModel.getNumberOfLikes()).thenReturn(10); + when(musicModel.getNumberOfComents()).thenReturn(2); + when(musicModel.getMusicName()).thenReturn("SongA"); + when(AD.rithmPointsByLike(10)).thenReturn(100); + when(AD.rithmPointsByComents(2)).thenReturn(30); + List musicList = new ArrayList<>(); + musicList.add(musicModel); + Map result = algorithmBlender.algorithmCalc(musicList); + assertEquals(130, result.get("SongA")); + } + + @Test + @Tag("valid") + public void handleMultipleMusicModels() { + MusicModel musicModel1 = mock(MusicModel.class); + MusicModel musicModel2 = mock(MusicModel.class); + + when(musicModel1.getNumberOfLikes()).thenReturn(5); + when(musicModel1.getNumberOfComents()).thenReturn(3); + when(musicModel1.getMusicName()).thenReturn("SongA"); + when(musicModel2.getNumberOfLikes()).thenReturn(8); + when(musicModel2.getNumberOfComents()).thenReturn(1); + when(musicModel2.getMusicName()).thenReturn("SongB"); + when(AD.rithmPointsByLike(5)).thenReturn(50); + when(AD.rithmPointsByComents(3)).thenReturn(45); + when(AD.rithmPointsByLike(8)).thenReturn(80); + when(AD.rithmPointsByComents(1)).thenReturn(15); + List musicList = new ArrayList<>(); + musicList.add(musicModel1); + musicList.add(musicModel2); + Map result = algorithmBlender.algorithmCalc(musicList); + assertEquals(95, result.get("SongA")); + assertEquals(95, result.get("SongB")); + } + + @Test + @Tag("boundary") + public void noMusicModelsInInputList() { + List musicList = new ArrayList<>(); + Map result = algorithmBlender.algorithmCalc(musicList); + assertEquals(0, result.size()); + } + + @Test + @Tag("boundary") + public void edgeCaseWithZeroLikesAndComments() { + MusicModel musicModel = mock(MusicModel.class); + when(musicModel.getNumberOfLikes()).thenReturn(0); + when(musicModel.getNumberOfComents()).thenReturn(0); + when(musicModel.getMusicName()).thenReturn("SongZero"); + when(AD.rithmPointsByLike(0)).thenReturn(0); + when(AD.rithmPointsByComents(0)).thenReturn(0); + List musicList = new ArrayList<>(); + musicList.add(musicModel); + Map result = algorithmBlender.algorithmCalc(musicList); + assertEquals(0, result.get("SongZero")); + } + + @Test + @Tag("boundary") + public void extremelyHighLikesAndComments() { + MusicModel musicModel = mock(MusicModel.class); + when(musicModel.getNumberOfLikes()).thenReturn(1000000); // TODO: use a realistic + // high number + when(musicModel.getNumberOfComents()).thenReturn(500000); // TODO: use a realistic + // high number + when(musicModel.getMusicName()).thenReturn("HighSong"); + when(AD.rithmPointsByLike(1000000)).thenReturn(10000000); + when(AD.rithmPointsByComents(500000)).thenReturn(7500000); + List musicList = new ArrayList<>(); + musicList.add(musicModel); + Map result = algorithmBlender.algorithmCalc(musicList); + assertEquals(17500000, result.get("HighSong")); + } + + @Test + @Tag("integration") + public void identicalMusicNamesButDifferentPoints() { + MusicModel musicModel1 = mock(MusicModel.class); + MusicModel musicModel2 = mock(MusicModel.class); + + when(musicModel1.getNumberOfLikes()).thenReturn(5); + when(musicModel1.getNumberOfComents()).thenReturn(3); + when(musicModel1.getMusicName()).thenReturn("DuplicateSong"); + when(musicModel2.getNumberOfLikes()).thenReturn(8); + when(musicModel2.getNumberOfComents()).thenReturn(1); + when(musicModel2.getMusicName()).thenReturn("DuplicateSong"); + + when(AD.rithmPointsByLike(5)).thenReturn(50); + when(AD.rithmPointsByComents(3)).thenReturn(45); + when(AD.rithmPointsByLike(8)).thenReturn(80); + when(AD.rithmPointsByComents(1)).thenReturn(15); + List musicList = new ArrayList<>(); + musicList.add(musicModel1); + musicList.add(musicModel2); + Map result = algorithmBlender.algorithmCalc(musicList); + // The map will contain only one entry for "DuplicateSong". Depending on + // implementation, last duplicated key will remain + assertEquals(95, result.get("DuplicateSong")); + } + +} \ No newline at end of file diff --git a/src/test/java/com/medeiros/SPRINGProject/algorithm/AlgorithmDataGetRithmPointsTest.java b/src/test/java/com/medeiros/SPRINGProject/algorithm/AlgorithmDataGetRithmPointsTest.java new file mode 100644 index 0000000..4876249 --- /dev/null +++ b/src/test/java/com/medeiros/SPRINGProject/algorithm/AlgorithmDataGetRithmPointsTest.java @@ -0,0 +1,54 @@ + +// ********RoostGPT******** +/* +Test generated by RoostGPT for test Rahul-jav-test-15 using AI Type Open AI and AI Model gpt-4o + +ROOST_METHOD_HASH=getRithmPoints_82f961bd0d +ROOST_METHOD_SIG_HASH=getRithmPoints_728e09b79f + +Scenario 1: Test if getRithmPoints returns the correct value when initialized. + +Details: + TestName: initialRithmPointsValueCorrect + Description: This test checks if the getRithmPoints method returns the correct initial value of rithmPoints as set by calling setRithmPoints method. +Execution: + Arrange: Create an instance of algorithmData. Set an initial value for rithmPoints using the setRithmPoints method. + Act: Invoke the getRithmPoints method. + Assert: Compare the returned value with the initial value set. +Validation: + The assertion verifies that getRithmPoints accurately retrieves the rithmPoints value after being set. This is crucial to ensure the integrity of data retrieval functionality. + +*/ + +// ********RoostGPT******** + +package com.medeiros.SPRINGProject.algorithm; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.*; + +class AlgorithmDataGetRithmPointsTest { + + private algorithmData testAlgorithmData; + + @BeforeEach + void setUp() { + testAlgorithmData = new algorithmData(); + } + + @Test + @Tag("valid") + public void initialRithmPointsValueCorrect() { + // Arrange + int initialRithmPoints = 50; // TODO: Change this to the desired initial value + testAlgorithmData.setRithmPoints(initialRithmPoints); + // Act + int result = testAlgorithmData.getRithmPoints(); + // Assert + assertEquals((int) initialRithmPoints, (int) result); + } + +} \ No newline at end of file diff --git a/src/test/java/com/medeiros/SPRINGProject/algorithm/AlgorithmDataIsBlackListTest.java b/src/test/java/com/medeiros/SPRINGProject/algorithm/AlgorithmDataIsBlackListTest.java new file mode 100644 index 0000000..51bffee --- /dev/null +++ b/src/test/java/com/medeiros/SPRINGProject/algorithm/AlgorithmDataIsBlackListTest.java @@ -0,0 +1,130 @@ + +// ********RoostGPT******** +/* +Test generated by RoostGPT for test Rahul-jav-test-15 using AI Type Open AI and AI Model gpt-4o + +ROOST_METHOD_HASH=isBlack_list_560ae9db06 +ROOST_METHOD_SIG_HASH=isBlack_list_4614434c3f + + +Scenario 1: Verify black_list status when it is true + +Details: + TestName: checkBlackListWhenTrue + Description: This test checks if the method isBlack_list() returns true when the black_list attribute is set to true. +Execution: + Arrange: Instantiate algorithmData class and set the black_list attribute to true using the setBlack_list method. + Act: Call the isBlack_list() method. + Assert: Compare the returned value from the method with the expected true value. +Validation: + To confirm that the isBlack_list() method accurately reflects the object's current black list status when it is true. This ensures that the method correctly responds to changes in the black_list attribute. + +Scenario 2: Verify black_list status when it is false + +Details: + TestName: checkBlackListWhenFalse + Description: This test ensures that the method isBlack_list() returns false when the black_list attribute is set to false. +Execution: + Arrange: Create an instance of algorithmData and set the black_list attribute to false using the setBlack_list method. + Act: Invoke the isBlack_list() method. + Assert: Check that the method returns a value of false. +Validation: + This verifies that the isBlack_list() method provides an accurate representation of the black_list attribute when it is false. This validation is critical for confirming that the method handles the false condition correctly. + +Scenario 3: Validate default state of black_list attribute + +Details: + TestName: checkDefaultBlackListState + Description: This test evaluates the default state of the black_list attribute upon instantiation of the algorithmData class to ensure it behaves as expected. +Execution: + Arrange: Instantiate a new object of the algorithmData class without setting any attribute values. + Act: Call the isBlack_list() method. + Assert: Validate the method returns false (assuming the default initialization is false). +Validation: + This is to confirm the correct default initialization of the black_list field, ensuring proper adherence to expected initial conditions. The importance lies in understanding how the object behaves when no specific black_list configuration is provided. + +Scenario 4: Validation after toggling black_list from false to true + +Details: + TestName: toggleBlacklistToTrue + Description: Tests the toggling process of the black_list attribute from false to true and verifies method accuracy post-toggle. +Execution: + Arrange: Set up an instance of algorithmData, setting black_list to false initially. + Act: Change the black_list attribute to true using setBlack_list and call isBlack_list(). + Assert: Confirm the returned value is true after toggling. +Validation: + It validates the method response when the black_list status is actively modified. This scenario is significant in ensuring dynamic changes in object state are correctly reflected by the method. + +Scenario 5: Validation after toggling black_list from true to false + +Details: + TestName: toggleBlacklistToFalse + Description: Tests the change of the black_list attribute from true to false, ensuring method response accuracy post-modification. +Execution: + Arrange: Initialize an algorithmData instance with black_list set to true. + Act: Change the black_list attribute to false using setBlack_list and invoke isBlack_list(). + Assert: Verify the method outputs false post-toggle. +Validation: + Confirms correct method behavior when transitioning black_list status from true to false, underlining the reliability of the method in reflecting changes in real-time object status. + +*/ + +// ********RoostGPT******** + +package com.medeiros.SPRINGProject.algorithm; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import org.junit.jupiter.api.*; + +class AlgorithmDataIsBlackListTest { + + @Test + @Tag("valid") + public void checkBlackListWhenTrue() { + algorithmData data = new algorithmData(); + data.setBlack_list(true); + boolean result = data.isBlack_list(); + assertTrue(result, "isBlack_list should return true when black_list is set to true."); + } + + @Test + @Tag("valid") + public void checkBlackListWhenFalse() { + algorithmData data = new algorithmData(); + data.setBlack_list(false); + boolean result = data.isBlack_list(); + assertFalse(result, "isBlack_list should return false when black_list is set to false."); + } + + @Test + @Tag("boundary") + public void checkDefaultBlackListState() { + algorithmData data = new algorithmData(); + boolean result = data.isBlack_list(); + assertFalse(result, "By default, isBlack_list should return false."); + } + + @Test + @Tag("valid") + public void toggleBlacklistToTrue() { + algorithmData data = new algorithmData(); + data.setBlack_list(false); + data.setBlack_list(true); + boolean result = data.isBlack_list(); + assertTrue(result, "isBlack_list should return true after toggling from false to true."); + } + + @Test + @Tag("valid") + public void toggleBlacklistToFalse() { + algorithmData data = new algorithmData(); + data.setBlack_list(true); + data.setBlack_list(false); + boolean result = data.isBlack_list(); + assertFalse(result, "isBlack_list should return false after toggling from true to false."); + } + +} \ No newline at end of file diff --git a/src/test/java/com/medeiros/SPRINGProject/algorithm/AlgorithmDataIsBlockedTest.java b/src/test/java/com/medeiros/SPRINGProject/algorithm/AlgorithmDataIsBlockedTest.java new file mode 100644 index 0000000..9de0615 --- /dev/null +++ b/src/test/java/com/medeiros/SPRINGProject/algorithm/AlgorithmDataIsBlockedTest.java @@ -0,0 +1,171 @@ + +// ********RoostGPT******** +/* +Test generated by RoostGPT for test Rahul-jav-test-15 using AI Type Open AI and AI Model gpt-4o + +ROOST_METHOD_HASH=isBlocked_47b7fd7aa5 +ROOST_METHOD_SIG_HASH=isBlocked_75b5602366 + +Scenario 1: Verify isBlocked method returns true when the blocked field is set to true + +Details: + TestName: isBlockedReturnsTrue + Description: This test checks if the isBlocked method returns true when the blocked field is set to true. +Execution: + Arrange: Create an instance of the algorithmData class and set the blocked field to true using the setBlocked method. + Act: Call the isBlocked method. + Assert: Use Assert.assertTrue to verify that the result is true. +Validation: + The assertion verifies that the isBlocked method correctly reflects the state of the blocked field. This confirms that the method behaves as expected when the blocked status is true, ensuring consistent application behavior. + +Scenario 2: Verify isBlocked method returns false when the blocked field is set to false + +Details: + TestName: isBlockedReturnsFalse + Description: This test checks if the isBlocked method returns false when the blocked field is set to false. +Execution: + Arrange: Create an instance of the algorithmData class and set the blocked field to false using the setBlocked method. + Act: Call the isBlocked method. + Assert: Use Assert.assertFalse to verify that the result is false. +Validation: + The assertion verifies that the isBlocked method correctly reflects the state of the blocked field. This confirms that the method behaves as expected when the blocked status is false, ensuring consistent application behavior. + +Scenario 3: Verify isBlocked method when no explicit setBlocked method is called + +Details: + TestName: isBlockedDefaultValue + Description: This test checks the default behavior of the isBlocked method when the blocked field is not explicitly set. +Execution: + Arrange: Create an instance of the algorithmData class without setting the blocked field explicitly. + Act: Call the isBlocked method. + Assert: Use Assert.assertFalse if the default initialization is expected to be false or assert based on the class's field initialization. +Validation: + This test verifies the default state of a newly created algorithmData object. Understanding the default behavior ensures that uninitialized instances handle the blocked field consistently. + +Scenario 4: Verify that setting rithmPoints or black_list does not affect isBlocked + +Details: + TestName: unrelatedFieldsDoNotAffectIsBlocked + Description: This test checks if unrelated fields like rithmPoints and black_list affect the isBlocked method's return value. +Execution: + Arrange: Create an instance of the algorithmData class, set rithmPoints and black_list using their respective setter methods without altering the blocked field. + Act: Call the isBlocked method. + Assert: Depending on the previous state of the blocked field, verify it hasn't changed due to unrelated field modifications. +Validation: + This test ensures that changes to other independent fields (rithmPoints, black_list) do not inadvertently affect the blocked status. It affirms the encapsulation and independence of class properties. + +*/ + +// ********RoostGPT******** + +package com.medeiros.SPRINGProject.algorithm; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.*; + +public class AlgorithmDataIsBlockedTest { + + private algorithmData data; + + @BeforeEach + public void setUp() { + data = new algorithmData(); + } + + @Test + @Tag("valid") + public void isBlockedReturnsTrue() { + // Arrange + data.setBlocked(true); + + // Act + boolean result = data.isBlocked(); + + // Assert + assertTrue(result); + } + + @Test + @Tag("valid") + public void isBlockedReturnsFalse() { + // Arrange + data.setBlocked(false); + + // Act + boolean result = data.isBlocked(); + + // Assert + assertFalse(result); + } + + @Test + @Tag("boundary") + public void isBlockedDefaultValue() { + // Act + boolean result = data.isBlocked(); + + // Assert + assertFalse(result); // Assuming the default state of blocked is false + } + + @Test + @Tag("boundary") + public void unrelatedFieldsDoNotAffectIsBlocked() { + // Arrange + data.setRithmPoints(100); // Set some random rithm points + data.setBlack_list(true); // Arbitrarily set black_list to true + data.setBlocked(false); // Explicitly setting to false to verify state remains + // Act + boolean result = data.isBlocked(); + + // Assert + assertFalse(result); // Ensure setBlocked(false) remains unaffected by other + // changes + } + +} + +class algorithmData { + + private int rithmPoints; + + private boolean black_list; + + private boolean blocked; + + public int getRithmPoints() { + return rithmPoints; + } + + public void setRithmPoints(int rithmPoints) { + this.rithmPoints = rithmPoints; + } + + public boolean isBlack_list() { + return black_list; + } + + public void setBlack_list(boolean black_list) { + this.black_list = black_list; + } + + public boolean isBlocked() { + return blocked; + } + + public void setBlocked(boolean blocked) { + this.blocked = blocked; + } + + public int rithmPointsByLike(int likes) { + return likes * 10; + } + + public int rithmPointsByComents(int coments) { + return coments * 15; + } + +} \ No newline at end of file diff --git a/src/test/java/com/medeiros/SPRINGProject/algorithm/AlgorithmDataRithmPointsByComentsTest.java b/src/test/java/com/medeiros/SPRINGProject/algorithm/AlgorithmDataRithmPointsByComentsTest.java new file mode 100644 index 0000000..6bdee94 --- /dev/null +++ b/src/test/java/com/medeiros/SPRINGProject/algorithm/AlgorithmDataRithmPointsByComentsTest.java @@ -0,0 +1,218 @@ + +// ********RoostGPT******** +/* +Test generated by RoostGPT for test Rahul-jav-test-15 using AI Type Open AI and AI Model gpt-4o + +ROOST_METHOD_HASH=rithmPointsByComents_bf0560ce74 +ROOST_METHOD_SIG_HASH=rithmPointsByComents_16f69f99ca + + +Scenario 1: Test calculation of rithm points for a basic positive number of comments. + +Details: + TestName: calculateRithmPointsForPositiveComments + Description: Verify that the method calculates the rithm points correctly when a positive number of comments is provided. The rithm points should be the number of comments multiplied by 15. +Execution: + Arrange: Set a positive number of comments, e.g., 10. + Act: Call rithmPointsByComents with the arranged number of comments. + Assert: Check that the returned value is 150. +Validation: + This verifies basic multiplication within the method, ensuring that the functional logic for calculating rithm points from comments is correct. + +Scenario 2: Test calculation of rithm points for zero comments. + +Details: + TestName: calculateRithmPointsForZeroComments + Description: Check that the rithm points calculation returns zero when the number of comments is zero, indicating a neutral scenario where no engagement has occurred. +Execution: + Arrange: Set the number of comments to zero. + Act: Call rithmPointsByComents with zero comments. + Assert: Verify that the returned value is 0. +Validation: + This ensures that the method handles the edge case of zero input correctly, which is important for accurate rithm point calculations when no comments are made. + +Scenario 3: Test how rithm points calculation handles negative comments. + +Details: + TestName: calculateRithmPointsForNegativeComments + Description: Explore how the method behaves when provided with a negative number of comments, which might signify an error or unexpected input, to ensure robustness against invalid data. +Execution: + Arrange: Set the number of comments to -5. + Act: Call rithmPointsByComents with the negative number of comments. + Assert: Confirm that the returned value is -75. +Validation: + The purpose is to ascertain that the method multiplies negative values correctly, maintaining function integrity even for atypical or erroneous inputs. + +Scenario 4: Test calculation of rithm points when the user is blacklisted. + +Details: + TestName: calculateRithmPointsWhileBlacklisted + Description: Ensure that if the user is blacklisted, the method either disallows point accumulation or behaves consistently according to existing business rules concerning blacklisted users. +Execution: + Arrange: Set the black_list field to true and provide a valid comment count, e.g., 5. + Act: Call rithmPointsByComents with these conditions. + Assert: Validate that the points calculation either proceeds unaltered or acknowledges the blacklist status in expected ways. +Validation: + It reconfirms the system maintains coherent logic or consistent reactions even when the user is flagged as blacklisted. If no behavior change is predefined, the regular output (75) is still important to affirm. + +Scenario 5: Test calculation of rithm points when the user is blocked. + +Details: + TestName: calculateRithmPointsWhileBlocked + Description: Check that if the user is blocked, the behavior of the function conforms to any rules about blocked users, like restricting point computation or recording, if applicable. +Execution: + Arrange: Set the blocked field to true and provide a non-zero number of comments, e.g., 8. + Act: Call rithmPointsByComents in this context. + Assert: Determine if the result respects the blocking, whether through standard computation (120) or another defined rule. +Validation: + Ensures handling user status restrictions consistently, reflecting application rules or assumptions for blocked users properly. + +Scenario 6: Test calculation of rithm points for large numbers of comments. + +Details: + TestName: calculateRithmPointsForLargeCommentCount + Description: Examine if the method can handle very large input values for comments correctly, ensuring it scales and performs calculations without error or overflow. +Execution: + Arrange: Set an extremely high number of comments, e.g., 1,000,000. + Act: Invoke rithmPointsByComents with this large value. + Assert: Confirm that the calculation result is 15,000,000. +Validation: + Verifies that calculations sustain large workloads, demonstrating efficiency and adequate data management for high engagement scenarios. + +Scenario 7: Test interaction invariant between likes and comments. + +Details: + TestName: consistencyBetweenLikesAndCommentsPoints + Description: Validate consistent behavior across methods rithmPointsByLike and rithmPointsByComents, comparing result proportions against points gained through separate user actions to ensure coherent scoring. +Execution: + Arrange: Assign equal value to likes and comments, e.g., 10 each. + Act: Calculate points separately using rithmPointsByLike and rithmPointsByComents. + Assert: Ensure that points via comments (150) reflect an expected ratio or correspondence with likes (100). +Validation: + Reinforces synchronized logic across different point accumulation actions, sustaining reliability and fairness in the application’s engagement scoring logic. + +*/ + +// ********RoostGPT******** + +package com.medeiros.SPRINGProject.algorithm; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Tag; +import org.mockito.Mockito; +import org.mockito.InjectMocks; +import org.junit.jupiter.api.*; + +public class AlgorithmDataRithmPointsByComentsTest { + + @InjectMocks + private algorithmData algorithmDataInstance; + + @BeforeEach + public void setUp() { + algorithmDataInstance = new algorithmData(); + } + + @Test + @Tag("valid") + public void calculateRithmPointsForPositiveComments() { + // Arrange + int comments = 10; + + // Act + int result = algorithmDataInstance.rithmPointsByComents(comments); + + // Assert + assertEquals(150, result); + } + + @Test + @Tag("boundary") + public void calculateRithmPointsForZeroComments() { + // Arrange + int comments = 0; + + // Act + int result = algorithmDataInstance.rithmPointsByComents(comments); + + // Assert + assertEquals(0, result); + } + + @Test + @Tag("invalid") + public void calculateRithmPointsForNegativeComments() { + // Arrange + int comments = -5; + + // Act + int result = algorithmDataInstance.rithmPointsByComents(comments); + + // Assert + assertEquals(-75, result); + } + + @Test + @Tag("valid") + public void calculateRithmPointsWhileBlacklisted() { + // Arrange + algorithmDataInstance.setBlack_list(true); + int comments = 5; + + // Act + int result = algorithmDataInstance.rithmPointsByComents(comments); + + // Assert + assertEquals(75, result); + } + + @Test + @Tag("valid") + public void calculateRithmPointsWhileBlocked() { + // Arrange + algorithmDataInstance.setBlocked(true); + int comments = 8; + + // Act + int result = algorithmDataInstance.rithmPointsByComents(comments); + + // Assert + assertEquals(120, result); + } + + @Test + @Tag("boundary") + public void calculateRithmPointsForLargeCommentCount() { + // Arrange + int comments = 1_000_000; + + // Act + int result = algorithmDataInstance.rithmPointsByComents(comments); + + // Assert + assertEquals(15_000_000, result); + } + + @Test + @Tag("integration") + public void consistencyBetweenLikesAndCommentsPoints() { + // Arrange + int likes = 10; + int comments = 10; + + // Mocking likes calculation + algorithmData spyAlgorithmData = Mockito.spy(algorithmDataInstance); + Mockito.when(spyAlgorithmData.rithmPointsByLike(likes)).thenReturn(likes * 10); + // Act & Assert + // Likes comparison + int likePoints = spyAlgorithmData.rithmPointsByLike(likes); + assertEquals(100, likePoints); + + // Comments comparison + int commentPoints = spyAlgorithmData.rithmPointsByComents(comments); + assertEquals(150, commentPoints); + } + +} \ No newline at end of file diff --git a/src/test/java/com/medeiros/SPRINGProject/algorithm/AlgorithmDataRithmPointsByLikeTest.java b/src/test/java/com/medeiros/SPRINGProject/algorithm/AlgorithmDataRithmPointsByLikeTest.java new file mode 100644 index 0000000..de277a1 --- /dev/null +++ b/src/test/java/com/medeiros/SPRINGProject/algorithm/AlgorithmDataRithmPointsByLikeTest.java @@ -0,0 +1,157 @@ + +// ********RoostGPT******** +/* +Test generated by RoostGPT for test Rahul-jav-test-15 using AI Type Open AI and AI Model gpt-4o + +ROOST_METHOD_HASH=rithmPointsByLike_f1d922798a +ROOST_METHOD_SIG_HASH=rithmPointsByLike_817b4e8687 + + +Scenario 1: Validate rithmPointsByLike with a Positive Number of Likes + +Details: + TestName: validatePositiveLikes + Description: This test checks whether the `rithmPointsByLike` method accurately calculates rithm points when given a positive number of likes. It evaluates the functionality where each like should be converted into 10 points. +Execution: + Arrange: Prepare an instance of the `algorithmData` class and ensure the `black_list` and `blocked` flags do not interfere with the method. Provide a positive number of likes. + Act: Invoke the `rithmPointsByLike` method with the positive likes input. + Assert: Use JUnit assertions to verify if the returned value equals the number of likes multiplied by 10. +Validation: + This assertion verifies that the method correctly translates likes into rithm points as intended and functions as expected when processing positive input. + +Scenario 2: Validate rithmPointsByLike with Zero Likes + +Details: + TestName: validateZeroLikes + Description: This test confirms the behavior of the `rithmPointsByLike` method when zero likes are provided, ensuring it returns zero points. +Execution: + Arrange: Create an instance of the `algorithmData` class with `black_list` and `blocked` attributes configured to ensure they do not affect the result. Use zero as the input. + Act: Call the `rithmPointsByLike` method with zero as the input. + Assert: Check with JUnit assertions if the returned value is zero. +Validation: + The assertion ensures that the method handles the zero case correctly, providing baseline functioning verification for no likes scenario. + +Scenario 3: Validate rithmPointsByLike with a Negative Number of Likes + +Details: + TestName: validateNegativeLikes + Description: This test examines the handling of the `rithmPointsByLike` method when provided with a negative number of likes, expecting a negative point result. +Execution: + Arrange: Instantiate the `algorithmData` class without any restrictive conditions imposed by `black_list` or `blocked`. Input a negative number of likes. + Act: Use the `rithmPointsByLike` method with the negative likes input. + Assert: Use JUnit assertions to verify if the result is the negative likes value multiplied by 10. +Validation: + This validates that the method is consistently processing input and output signs, crucial for application logic that may involve negative or erroneous likes data. + +Scenario 4: Validate rithmPointsByLike for Black-listed Context + +Details: + TestName: validateLikesForBlackListed + Description: This test evaluates if the systemic behavior remains unaffected by potential black-list constraints, ensuring points calculation solely based on likes. +Execution: + Arrange: Set up an `algorithmData` instance, and set `black_list` to true while keeping a sensible likes number. + Act: Call `rithmPointsByLike` with a specific likes number. + Assert: Check whether the resulting points reflect the standard calculation (likes * 10). +Validation: + The primary objective is to ensure the black_list status doesn't affect the `rithmPointsByLike` functionality, critical for maintaining expected performance regardless of internal state flags. + +Scenario 5: Validate rithmPointsByLike when User is Blocked + +Details: + TestName: validateLikesWhenBlocked + Description: This test checks if the `blocked` status impacts the result of `rithmPointsByLike`, verifying that likes are transformed into points regardless of user restrictions. +Execution: + Arrange: Configure an `algorithmData` instance with `blocked` set to true. Input a definitive likes amount. + Act: Execute the `rithmPointsByLike` method. + Assert: Use assertions to ensure the outcome equals likes multiplied by 10. +Validation: + The critical verification here is the method's correct processing of inputs even when the user is blocked, ensuring isolation from status-related variables in point calculations. + +Scenario 6: Validate Large Number of Likes in rithmPointsByLike + +Details: + TestName: validateLargeLikes + Description: This test confirms the function's robustness by processing a large number of likes, assessing computational stability and accuracy. +Execution: + Arrange: Create the `algorithmData` instance, input a large integer for likes, ensuring no interference from `black_list` or `blocked`. + Act: Invoke the method with the large number of likes. + Assert: Check the output matches the expected points (large likes number * 10). +Validation: + This confirms computational capacity for high data loads, significant for performance testing and ensuring accurate large-scale data handling. + +*/ + +// ********RoostGPT******** + +package com.medeiros.SPRINGProject.algorithm; + +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.*; + +class AlgorithmDataRithmPointsByLikeTest { + + @Test + @Tag("valid") + public void validatePositiveLikes() { + algorithmData data = new algorithmData(); + int likes = 5; // TODO: change this to a different positive number for variety + int expectedPoints = likes * 10; + int actualPoints = data.rithmPointsByLike(likes); + assertEquals(expectedPoints, actualPoints); + } + + @Test + @Tag("boundary") + public void validateZeroLikes() { + algorithmData data = new algorithmData(); + int likes = 0; + int expectedPoints = 0; + int actualPoints = data.rithmPointsByLike(likes); + assertEquals(expectedPoints, actualPoints); + } + + @Test + @Tag("invalid") + public void validateNegativeLikes() { + algorithmData data = new algorithmData(); + int likes = -3; // TODO: change this to explore other negative numbers + int expectedPoints = likes * 10; + int actualPoints = data.rithmPointsByLike(likes); + assertEquals(expectedPoints, actualPoints); + } + + @Test + @Tag("integration") + public void validateLikesForBlackListed() { + algorithmData data = new algorithmData(); + data.setBlack_list(true); + int likes = 7; // TODO: adjust likes count if necessary + int expectedPoints = likes * 10; + int actualPoints = data.rithmPointsByLike(likes); + assertEquals(expectedPoints, actualPoints); + } + + @Test + @Tag("integration") + public void validateLikesWhenBlocked() { + algorithmData data = new algorithmData(); + data.setBlocked(true); + int likes = 8; // TODO: adjust likes count if necessary + int expectedPoints = likes * 10; + int actualPoints = data.rithmPointsByLike(likes); + assertEquals(expectedPoints, actualPoints); + } + + @Test + @Tag("boundary") + public void validateLargeLikes() { + algorithmData data = new algorithmData(); + int likes = 10000; // TODO: change this to different large numbers for variety + int expectedPoints = likes * 10; + int actualPoints = data.rithmPointsByLike(likes); + assertEquals(expectedPoints, actualPoints); + } + +} \ No newline at end of file