// Path: src/test/java/de/gessnerfl/fakesmtp/TestResourceUtil.java
// public class TestResourceUtil {
//     private static final String TEST_DATA_FOLDER = "/test-data/";
// 
//     public static String getTestFileContent(String testFilename) throws IOException {
//         return IOUtils.toString(getTestFile(testFilename), StandardCharsets.UTF_8);
//     }
// 
//     public static byte[] getTestFileContentBytes(String testFilename) throws IOException {
//         return IOUtils.toByteArray(getTestFile(testFilename));
//     }
// 
//     public static InputStream getTestFile(String filename) {
//         var stream = TestResourceUtil.class.getResourceAsStream(TEST_DATA_FOLDER + filename);
//         if (stream == null) {
//             stream = TestResourceUtil.class.getClassLoader().getResourceAsStream(TEST_DATA_FOLDER + filename);
//         }
//         assertNotNull(stream);
//         return stream;
//     }
// }
// 
// Path: src/main/java/de/gessnerfl/fakesmtp/repository/EmailRepository.java
// @Repository
// public interface EmailRepository extends JpaRepository<Email,Long>{
// 
//     @Transactional
//     @Modifying
//     @Query(value = "DELETE email o WHERE o.id IN ( SELECT i.id FROM email i ORDER BY i.received_on DESC OFFSET ?1)", nativeQuery = true)
//     int deleteEmailsExceedingDateRetentionLimit(int maxNumber);
// }


import de.gessnerfl.fakesmtp.TestResourceUtil;
import de.gessnerfl.fakesmtp.repository.EmailRepository;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import javax.transaction.Transactional;
import java.io.ByteArrayInputStream;
import java.nio.charset.StandardCharsets;
import static org.hamcrest.MatcherAssert.*;
import static org.hamcrest.Matchers.hasSize;
import static org.junit.jupiter.api.Assertions.*;
package de.gessnerfl.fakesmtp.server.impl;




@Transactional
@ActiveProfiles("integrationtest")
@ExtendWith(SpringExtension.class)
@SpringBootTest
class MessageListenerIntegrationTest {
    private static final String SENDER = "sender";
    private static final String RECEIVER = "receiver";

    @Autowired
// Path: src/test/java/de/gessnerfl/fakesmtp/TestResourceUtil.java
// public class TestResourceUtil {
//     private static final String TEST_DATA_FOLDER = "/test-data/";
// 
//     public static String getTestFileContent(String testFilename) throws IOException {
//         return IOUtils.toString(getTestFile(testFilename), StandardCharsets.UTF_8);
//     }
// 
//     public static byte[] getTestFileContentBytes(String testFilename) throws IOException {
//         return IOUtils.toByteArray(getTestFile(testFilename));
//     }
// 
//     public static InputStream getTestFile(String filename) {
//         var stream = TestResourceUtil.class.getResourceAsStream(TEST_DATA_FOLDER + filename);
//         if (stream == null) {
//             stream = TestResourceUtil.class.getClassLoader().getResourceAsStream(TEST_DATA_FOLDER + filename);
//         }
//         assertNotNull(stream);
//         return stream;
//     }
// }
// 
// Path: src/main/java/de/gessnerfl/fakesmtp/repository/EmailRepository.java
// @Repository
// public interface EmailRepository extends JpaRepository<Email,Long>{
// 
//     @Transactional
//     @Modifying
//     @Query(value = "DELETE email o WHERE o.id IN ( SELECT i.id FROM email i ORDER BY i.received_on DESC OFFSET ?1)", nativeQuery = true)
//     int deleteEmailsExceedingDateRetentionLimit(int maxNumber);
// }


// Path: src/test/java/de/gessnerfl/fakesmtp/server/impl/MessageListenerIntegrationTest.java
import de.gessnerfl.fakesmtp.TestResourceUtil;
import de.gessnerfl.fakesmtp.repository.EmailRepository;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import javax.transaction.Transactional;
import java.io.ByteArrayInputStream;
import java.nio.charset.StandardCharsets;
import static org.hamcrest.MatcherAssert.*;
import static org.hamcrest.Matchers.hasSize;
import static org.junit.jupiter.api.Assertions.*;

package de.gessnerfl.fakesmtp.server.impl;




@Transactional
@ActiveProfiles("integrationtest")
@ExtendWith(SpringExtension.class)
@SpringBootTest
class MessageListenerIntegrationTest {
    private static final String SENDER = "sender";
    private static final String RECEIVER = "receiver";

    @Autowired
    private EmailRepository emailRepository;