Стрим аргументов не передаётся в тестовый метод

Тестовый класс:

    import com.example.model.Order;
    import com.example.model.Payment;
    import org.junit.jupiter.api.Assertions;
    import org.junit.jupiter.api.Test;
    import org.junit.jupiter.params.ParameterizedTest;
    import org.junit.jupiter.params.provider.Arguments;
    import org.junit.jupiter.params.provider.MethodSource;

    import java.math.BigDecimal;
    import java.time.LocalDate;
    import java.time.LocalDateTime;
    import java.util.ArrayList;
    import java.util.List;
    import java.util.stream.Stream;

    class OrderServiceTest {
        private final OrderService orderService = new 
        OrderService();
        private static Order order;

        static Order createOrder(){
            OrderServiceTest.order = Order.builder()
            .createTime(LocalDateTime.of(2024, 8, 15, 9, 30, 0))
            .deadLineOfOrder(LocalDate.of(2024, 8, 15))
            .sum(new BigDecimal(0))
            .sumToPay(new BigDecimal(1000))
            .change(new BigDecimal(0))
            .numberOfPayments(0)
            .build();
            return order;
        }

        static Payment createPayment(LocalDateTime creationTime, 
        BigDecimal sum){
            return Payment.builder()
            .creationTime(creationTime)
            .sum(sum)
            .build();
        }

        static Stream<Arguments> provideOrderAndPayments() {
            Order order = createOrder();
            Payment payment1 = 
            createPayment(LocalDateTime.of(2024, 8, 
            15, 11, 22), new BigDecimal(500));
            Payment payment2 = 
            createPayment(LocalDateTime.of(2024, 8, 
            15, 11, 24), new BigDecimal(700));
            Payment payment3 = 
            createPayment(LocalDateTime.of(2024, 8, 15, 11, 26), 
            new BigDecimal(700));
            List<Payment> payments = new ArrayList<> 
            (List.of(payment1,payment2,payment3));
            return Stream.of(Arguments.of(order,payments));
        }

        @ParameterizedTest
        @MethodSource("provideOrderAndPayments")
        void parameterizedPay(Order order, List<Payment> 
        payments){
            Order testOrder = orderService.pay(order, payments);
          Assertions.assertTrue(orderService.isPaid(testOrder));
        }
    }

Код класса OrderService:

import com.example.model.Order;
import com.example.model.Payment;

import java.util.List;

public class OrderService {

public boolean isPaid(Order order) {
    return order.getSum().compareTo(order.getSumToPay())>=0;
}

public Order pay(Order order, List<Payment> payments) {
    for (int i = 0; i <= payments.size()-1; i++) {
        Payment payment = payments.get(i);
        if (payment.getCreationTime().isAfter(order.getCreateTime()) &
                payment.getCreationTime().isBefore(order.getDeadLineOfOrder().atTime(23, 59, 59)) &
                order.getSum().compareTo(order.getSumToPay())<0
        ) {
            order.setSum(order.getSum().add(payment.getSum()));
            order.setNumberOfPayments(order.getNumberOfPayments()+1);
        }
        if (order.getSum().compareTo(order.getSumToPay())>0){
            order.setChange(order.getSum().subtract(order.getSumToPay()));
        }
    }
    return order;
}

Класс Order:

import lombok.Builder;
import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;

@Data
@Builder
public class Order {
   private LocalDateTime createTime;
   private LocalDate deadLineOfOrder;
   private BigDecimal sum;
   private BigDecimal sumToPay;
   private BigDecimal change;
   private int numberOfPayments;
}

Класс Payment:

import lombok.Builder;
import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalDateTime;

@Data
@Builder
public class Payment {
private LocalDateTime creationTime;
private BigDecimal sum;
}

pom:

<?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.3.2</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<url/>
<licenses>
    <license/>
</licenses>
<developers>
    <developer/>
</developers>
<scm>
    <connection/>
    <developerConnection/>
    <tag/>
    <url/>
</scm>
<properties>
    <java.version>22</java.version>
</properties>
<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <version>1.18.34</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-params</artifactId>
        <version>5.11.0</version>
        <scope>test</scope>
    </dependency>



    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>

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

При запуске теста вылетает ошибка:

** java.lang.NoSuchMethodError: 'java.lang.Class org.junit.platform.commons.util.ReflectionUtils.loadRequiredClass(java.lang.String, java.lang.ClassLoader)'**

** Suppressed: org.junit.platform.commons.PreconditionViolationException: Configuration error: You must configure at least one set of arguments for this @ParameterizedTest at java.base/java.util.stream.AbstractPipeline.close(AbstractPipeline.java:355) at java.base/java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:288) **


Ответы (0 шт):