aboutsummaryrefslogtreecommitdiffstats
path: root/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/resource/CostReportConsumerMock.java
blob: 40637065f7ea8801876fb2b04cb15256db49103d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.controller.api.integration.resource;

import com.yahoo.vespa.hosted.controller.api.identifiers.Property;

import java.util.Map;
import java.util.function.Consumer;

/**
 * @author ldalves
 */
public class CostReportConsumerMock implements CostReportConsumer {

    private final Consumer<String> csvConsumer;
    private final Map<Property, ResourceAllocation> fixedAllocations;

    public CostReportConsumerMock() {
        this.csvConsumer = (ignored) -> {};
        this.fixedAllocations = Map.of();
    }

    public CostReportConsumerMock(Consumer<String> csvConsumer, Map<Property, ResourceAllocation> fixedAllocations) {
        this.csvConsumer = csvConsumer;
        this.fixedAllocations = Map.copyOf(fixedAllocations);
    }

    @Override
    public void consume(String csv) {
        csvConsumer.accept(csv);
    }

    @Override
    public Map<Property, ResourceAllocation> fixedAllocations() {
        return fixedAllocations;
    }

}