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
249 changes: 153 additions & 96 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,96 +1,153 @@
<?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>
<!-- 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>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>2.23.4</version>
<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>
</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>
<pluginManagement>
<plugins/>
</pluginManagement>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@

// ********RoostGPT********
/*
Test generated by RoostGPT for test maven-music-github using AI Type Azure Open AI and AI Model gpt-5

ROOST_METHOD_HASH=showAllLog_66d6a0e563
ROOST_METHOD_SIG_HASH=showAllLog_dafc374432

Scenario 1: Returns the same non-empty Iterable provided by the repository

Details:
TestName: returnsIterableFromRepositoryWhenNonEmpty
Description: Verify that showAllLog returns exactly the Iterable<LogModel> instance supplied by LogRepository.findAll when the repository contains one or more LogModel entries. This ensures the method is a direct pass-through without transformation.

Execution:
Arrange: Create a mock LogRepository whose findAll returns a non-empty Iterable (e.g., a List with a few LogModel instances). Inject this mock into a LogController instance.
Act: Invoke showAllLog on the LogController.
Assert: Use JUnit assertions to check that the returned object is the same reference as the Iterable returned by the repository and that the elements match the expected models.

Validation:
The assertion verifies identity equality (same reference) and content equality to confirm that the controller does not copy, wrap, or alter the Iterable. This is significant because it validates the method’s simplicity and performance characteristics (no unnecessary allocations).

*/

// ********RoostGPT********

package com.medeiros.SPRINGProject.Controllers;

import com.medeiros.SPRINGProject.Models.LogModel;
import com.medeiros.SPRINGProject.Models.LogRepository;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.ArrayList;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertIterableEquals;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.when;
import org.junit.jupiter.api.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@ExtendWith(MockitoExtension.class)
public class LogControllerShowAllLogTest {

@Mock
private LogRepository logRepository;

@InjectMocks
private LogController logController;

@Test
@Tag("valid")
public void returnsIterableFromRepositoryWhenNonEmpty() {
LogModel entry1 = new LogModel();
LogModel entry2 = new LogModel();
List<LogModel> expectedIterable = Arrays.asList(entry1, entry2);
when(logRepository.findAll()).thenReturn(expectedIterable);
Iterable<LogModel> actualIterable = logController.showAllLog();
assertSame((Object) expectedIterable, (Object) actualIterable);
List<LogModel> actualList = new ArrayList<>();
for (LogModel m : actualIterable) {
actualList.add(m);
}
assertEquals((int) expectedIterable.size(), (int) actualList.size());
for (int i = 0; i < expectedIterable.size(); i++) {
assertSame((Object) expectedIterable.get(i), (Object) actualList.get(i));
}
}

@Test
@Tag("boundary")
public void returnsSameIterableWhenEmptyRepository() {
Iterable<LogModel> expectedIterable = Collections.emptyList();
when(logRepository.findAll()).thenReturn(expectedIterable);
Iterable<LogModel> actualIterable = logController.showAllLog();
assertSame((Object) expectedIterable, (Object) actualIterable);
assertNotNull((Object) actualIterable);
Iterator<LogModel> iterator = actualIterable.iterator();
assertFalse((boolean) iterator.hasNext());
}

@Test
@Tag("invalid")
public void returnsNullWhenRepositoryReturnsNull() {
when(logRepository.findAll()).thenReturn(null);
Iterable<LogModel> actualIterable = logController.showAllLog();
assertNull((Object) actualIterable);
}

@Test
@Tag("invalid")
public void propagatesExceptionFromRepository() {
when(logRepository.findAll()).thenThrow(new RuntimeException());
assertThrows((Class<RuntimeException>) (Class<?>) RuntimeException.class, () -> logController.showAllLog());
}

}