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
239 changes: 143 additions & 96 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,96 +1,143 @@
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.0.6</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.medeiros</groupId>
<artifactId>SPRINGProject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>SPRINGProject</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>20</java.version>
<!-- ... -->
<spring-security.version>6.0.3</spring-security.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
<version>3.0.6</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/io.jsonwebtoken/jjwt-api -->
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-api</artifactId>
<version>0.11.5</version>
</dependency>



<!-- https://mvnrepository.com/artifact/org.springframework.security/spring-security-core -->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>6.0.3</version>
</dependency>

<!-- https://mvnrepository.com/artifact/io.jsonwebtoken/jjwt-orgjson -->

<!-- https://mvnrepository.com/artifact/io.jsonwebtoken/jjwt-impl -->
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-impl</artifactId>
<version>0.11.5</version>
<scope>runtime</scope>
</dependency>


</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

</project>
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.0.6</version>
<relativePath/>
<!-- lookup parent from repository -->
</parent>
<groupId>com.medeiros</groupId>
<artifactId>SPRINGProject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>SPRINGProject</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>20</java.version>
<!-- ... -->
<spring-security.version>6.0.3</spring-security.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
<version>3.0.6</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>io.spring.javaformat</groupId>
<artifactId>spring-javaformat-formatter</artifactId>
<version>0.0.40</version>
<!--Dependency added by RoostGPT-->
</dependency>
<!-- https://mvnrepository.com/artifact/io.jsonwebtoken/jjwt-api -->
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-api</artifactId>
<version>0.11.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.security/spring-security-core -->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>6.0.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.jsonwebtoken/jjwt-orgjson -->
<!-- https://mvnrepository.com/artifact/io.jsonwebtoken/jjwt-impl -->
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-impl</artifactId>
<version>0.11.5</version>
<scope>runtime</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.11</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>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@

// ********RoostGPT********
/*
Test generated by RoostGPT for test musicBlenderJava using AI Type Azure Open AI and AI Model roostgpt-4-32k

ROOST_METHOD_HASH=algorithmCalc_e489e5c1fc
ROOST_METHOD_SIG_HASH=algorithmCalc_009085eae1

Scenario 1: Verify correct calculation of rhythm points for a valid list of music models

Details:
TestName: validateCalculationForValidInput
Description: This test checks if the algorithmCalc method correctly calculates and returns rhythm points when passed a valid Iterable object containing MusicModel instances. The test ensures proper functionality for typical input scenarios.
Execution:
Arrange: Create a list of MusicModel objects with predefined values for number of likes and comments. Mock AD methods (rithmPointsByLike and rithmPointsByComents) to return deterministic values based on the input.
Act: Invoke algorithmCalc with the mock data.
Assert: Assert that the result is consistent with expected rhythm points calculations based on input music models.
Validation:
The assertion verifies correct functionality of the algorithmCalc method for normal conditions. This ensures that rhythm points are calculated accurately based on likes and comments, which is a critical part of the application's business logic.

*/

// ********RoostGPT********
package com.medeiros.SPRINGProject.algorithm;

import com.medeiros.SPRINGProject.Models.MusicModel;
import com.medeiros.SPRINGProject.utils.hashMapFunctions;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import java.util.Arrays;
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 {

@Test
@Tag("valid")
public void validateCalculationForValidInput() {
// Arrange
MusicModel music1 = mock(MusicModel.class);
when(music1.getNumberOfLikes()).thenReturn(10);
when(music1.getNumberOfComents()).thenReturn(5);
when(music1.getMusicName()).thenReturn("Song1");

MusicModel music2 = mock(MusicModel.class);
when(music2.getNumberOfLikes()).thenReturn(8);
when(music2.getNumberOfComents()).thenReturn(12);
when(music2.getMusicName()).thenReturn("Song2");

Iterable<MusicModel> listMusics = Arrays.asList(music1, music2);

// Mock the methods defined in the algorithmData superclass
algorithmBlender algorithmBlenderInstance = mock(algorithmBlender.class, CALLS_REAL_METHODS);

// Using real methods from algorithmData, as algorithmData has defined
// rithmPointsByLike and rithmPointsByComents
algorithmData AD = spy(new algorithmData());
when(AD.rithmPointsByLike(10)).thenReturn(100); // Mock likes -> points
// calculation according to logic
// in function
when(AD.rithmPointsByComents(5)).thenReturn(50); // Mock comments -> points
// calculation
when(AD.rithmPointsByLike(8)).thenReturn(80); // Mock likes -> points calculation
when(AD.rithmPointsByComents(12)).thenReturn(120); // Mock comments -> points
// calculation

// Act
Map<String, Integer> result = algorithmBlenderInstance.algorithmCalc(listMusics);

// Assert
assertEquals((int) result.get("Song1"), 150); // 100 + 50
assertEquals((int) result.get("Song2"), 200); // 80 + 120
}

// Additional safety checks to validate handling black-listed musics or blocked musics
@Test
@Tag("black-list")
public void validateBlackListedMusic() {
// Arrange
MusicModel music = mock(MusicModel.class);
when(music.getNumberOfLikes()).thenReturn(10);
when(music.getNumberOfComents()).thenReturn(5);
when(music.getMusicName()).thenReturn("BlackListedMusic");

algorithmData AD = spy(new algorithmData());
AD.setBlack_list(true); // Set the music as black-listed
Iterable<MusicModel> listMusics = Arrays.asList(music);
algorithmBlender algorithmBlenderInstance = mock(algorithmBlender.class, CALLS_REAL_METHODS);
// Act
Map<String, Integer> result = algorithmBlenderInstance.algorithmCalc(listMusics);
// Assert
// If black-listed, we may expect that points calculation should not proceed
// (assuming business logic for black-listed musics)
assertEquals((int) result.getOrDefault("BlackListedMusic", 0), 0);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@

// ********RoostGPT********
/*
Test generated by RoostGPT for test musicBlenderJava using AI Type Azure Open AI and AI Model roostgpt-4-32k

ROOST_METHOD_HASH=getRithmPoints_82f961bd0d
ROOST_METHOD_SIG_HASH=getRithmPoints_728e09b79f


Scenario 1: Valid retrieval of rithmPoints when it is set to a positive value.

Details:
TestName: retrievePositiveRithmPoints
Description: Verifies that getRithmPoints accurately retrieves the value of rithmPoints when a positive integer has been set using setRithmPoints.

Execution:
Arrange: An instance of algorithmData is created, and rithmPoints is set to 30 using the setRithmPoints method.
Act: The value of rithmPoints is retrieved using the getRithmPoints method.
Assert: Assert that the value returned by getRithmPoints is equal to 30.

Validation:
Confirms that getRithmPoints correctly retrieves the assigned value. This test ensures that the getter method functions as expected for typical use cases with positive values.

*/

// ********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.assertEquals;
import org.junit.jupiter.api.*;

class AlgorithmDataGetRithmPointsTest {

@Test
@Tag("valid")
public void retrievePositiveRithmPoints() {
// Arrange
algorithmData algorithmDataInstance = new algorithmData();
algorithmDataInstance.setRithmPoints(30);
// Act
int actualValue = algorithmDataInstance.getRithmPoints();
// Assert
assertEquals(30, actualValue, "Expected rithmPoints to be 30 but was " + actualValue);
}

}
Loading