// Path: production-api/src/main/java/external/CurrentStock.java
// public class CurrentStock {
//     private long level;
//     private long locked;
// 
//     public CurrentStock(long level, long locked) {
//         this.level = level;
//         this.locked = locked;
//     }
// 
//     public long getLevel() {
//         return this.level;
//     }
// 
//     public long getLocked() {
//         return this.locked;
//     }
// 
//     public boolean equals(Object o) {
//         if (o == this) return true;
//         if (!(o instanceof CurrentStock)) return false;
//         final CurrentStock other = (CurrentStock) o;
//         if (this.getLevel() != other.getLevel()) return false;
//         if (this.getLocked() != other.getLocked()) return false;
//         return true;
//     }
// 
//     public int hashCode() {
//         final int PRIME = 59;
//         int result = 1;
//         final long $level = this.getLevel();
//         result = result * PRIME + (int) ($level >>> 32 ^ $level);
//         final long $locked = this.getLocked();
//         result = result * PRIME + (int) ($locked >>> 32 ^ $locked);
//         return result;
//     }
// 
//     public String toString() {
//         return "external.CurrentStock(level=" + this.getLevel() + ", locked=" + this.getLocked() + ")";
//     }
// }
// 
// Path: production-impl/src/main/java/tools/DemandsFactory.java
// public class DemandsFactory {
//     private final List<DemandEntity> demands;
// 
//     public DemandsFactory(List<DemandEntity> demands) {
//         this.demands = demands;
//     }
// 
//     public Demands createDemands() {
//         Map<LocalDate, Demands.Demand> demandsPerDay = demands.stream()
//                 .collect(Collectors.toMap(
//                         DemandEntity::getDay,
//                         demand -> new Demands.Demand(
//                                 Util.getDeliverySchema(demand),
//                                 Util.getLevel(demand))
//                 ));
// 
//         return new Demands(demandsPerDay);
//     }
// }
// 
// Path: production-impl/src/main/java/tools/ProductionOutputsFactory.java
// public class ProductionOutputsFactory {
//     private final List<ProductionEntity> productions;
// 
//     public ProductionOutputsFactory(List<ProductionEntity> productions) {
//         this.productions = productions;
//     }
// 
//     public ProductionOutputs createProductionOutputs() {
//         Map<LocalDate, Long> outputs = productions.stream()
//                 .collect(Collectors.groupingBy(
//                         production -> production.getStart().toLocalDate(),
//                         Collectors.summingLong(ProductionEntity::getOutput)
//                 ));
// 
//         String productRefNo = productions.stream()
//                 .map(production -> production.getForm().getRefNo())
//                 .findFirst()
//                 .orElse(null);
//         return new ProductionOutputs(productRefNo, outputs);
//     }
// }


import external.CurrentStock;
import tools.DemandsFactory;
import tools.ProductionOutputsFactory;
import java.time.LocalDate;
import java.util.List;
import java.util.stream.Stream;
import static java.util.stream.Collectors.toList;
package shortage.prediciton;




public class ShortagePredictionRepository {
    private CurrentStock stock;
    private ProductionOutputsFactory productionOutputsFactory;
    private DemandsFactory demandsFactory;

    public ShortagePredictionRepository(CurrentStock stock, ProductionOutputsFactory productionOutputsFactory, DemandsFactory demandsFactory) {
        this.stock = stock;
        this.productionOutputsFactory = productionOutputsFactory;
        this.demandsFactory = demandsFactory;
    }

    public ShortagePredictionAlgo get(LocalDate today, int daysAhead) {
        List<LocalDate> dates = Stream.iterate(today, date -> date.plusDays(1))
                .limit(daysAhead)
                .collect(toList());

// Path: production-api/src/main/java/external/CurrentStock.java
// public class CurrentStock {
//     private long level;
//     private long locked;
// 
//     public CurrentStock(long level, long locked) {
//         this.level = level;
//         this.locked = locked;
//     }
// 
//     public long getLevel() {
//         return this.level;
//     }
// 
//     public long getLocked() {
//         return this.locked;
//     }
// 
//     public boolean equals(Object o) {
//         if (o == this) return true;
//         if (!(o instanceof CurrentStock)) return false;
//         final CurrentStock other = (CurrentStock) o;
//         if (this.getLevel() != other.getLevel()) return false;
//         if (this.getLocked() != other.getLocked()) return false;
//         return true;
//     }
// 
//     public int hashCode() {
//         final int PRIME = 59;
//         int result = 1;
//         final long $level = this.getLevel();
//         result = result * PRIME + (int) ($level >>> 32 ^ $level);
//         final long $locked = this.getLocked();
//         result = result * PRIME + (int) ($locked >>> 32 ^ $locked);
//         return result;
//     }
// 
//     public String toString() {
//         return "external.CurrentStock(level=" + this.getLevel() + ", locked=" + this.getLocked() + ")";
//     }
// }
// 
// Path: production-impl/src/main/java/tools/DemandsFactory.java
// public class DemandsFactory {
//     private final List<DemandEntity> demands;
// 
//     public DemandsFactory(List<DemandEntity> demands) {
//         this.demands = demands;
//     }
// 
//     public Demands createDemands() {
//         Map<LocalDate, Demands.Demand> demandsPerDay = demands.stream()
//                 .collect(Collectors.toMap(
//                         DemandEntity::getDay,
//                         demand -> new Demands.Demand(
//                                 Util.getDeliverySchema(demand),
//                                 Util.getLevel(demand))
//                 ));
// 
//         return new Demands(demandsPerDay);
//     }
// }
// 
// Path: production-impl/src/main/java/tools/ProductionOutputsFactory.java
// public class ProductionOutputsFactory {
//     private final List<ProductionEntity> productions;
// 
//     public ProductionOutputsFactory(List<ProductionEntity> productions) {
//         this.productions = productions;
//     }
// 
//     public ProductionOutputs createProductionOutputs() {
//         Map<LocalDate, Long> outputs = productions.stream()
//                 .collect(Collectors.groupingBy(
//                         production -> production.getStart().toLocalDate(),
//                         Collectors.summingLong(ProductionEntity::getOutput)
//                 ));
// 
//         String productRefNo = productions.stream()
//                 .map(production -> production.getForm().getRefNo())
//                 .findFirst()
//                 .orElse(null);
//         return new ProductionOutputs(productRefNo, outputs);
//     }
// }


// Path: production-impl/src/main/java/shortage/prediciton/ShortagePredictionRepository.java
import external.CurrentStock;
import tools.DemandsFactory;
import tools.ProductionOutputsFactory;
import java.time.LocalDate;
import java.util.List;
import java.util.stream.Stream;
import static java.util.stream.Collectors.toList;

package shortage.prediciton;




public class ShortagePredictionRepository {
    private CurrentStock stock;
    private ProductionOutputsFactory productionOutputsFactory;
    private DemandsFactory demandsFactory;

    public ShortagePredictionRepository(CurrentStock stock, ProductionOutputsFactory productionOutputsFactory, DemandsFactory demandsFactory) {
        this.stock = stock;
        this.productionOutputsFactory = productionOutputsFactory;
        this.demandsFactory = demandsFactory;
    }

    public ShortagePredictionAlgo get(LocalDate today, int daysAhead) {
        List<LocalDate> dates = Stream.iterate(today, date -> date.plusDays(1))
                .limit(daysAhead)
                .collect(toList());

        ProductionOutputs outputs = productionOutputsFactory.createProductionOutputs();