All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.specto.hoverfly.junit.api.view.DiffReport Maven / Gradle / Ivy

There is a newer version: 0.19.1
Show newest version
package io.specto.hoverfly.junit.api.view;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;

@JsonIgnoreProperties(ignoreUnknown = true)
public class DiffReport {

    private final String timestamp;
    private final List entries;

    @JsonCreator
    public DiffReport(
        @JsonProperty("timestamp") String timestamp,
        @JsonProperty("diffEntries") List entries){
        this.timestamp = timestamp;
        this.entries = entries;
    }

    public String createDiffMessage() {
        String msgTemplate = "(%s.) The \"%s\" parameter is not same - the expected value was [%s], but the actual one [%s]\n";
        StringBuilder sb = new StringBuilder();
        for (int i = 1; i <= entries.size(); i++){
            DiffReportEntry entry = entries.get(i - 1);
            sb.append(String.format(msgTemplate, i, entry.getField(), entry.getExpected(), entry.getActual()));
        }
        return sb.toString();
    }

    public String getTimestamp() {
        return timestamp;
    }

    public List getEntries() {
        return entries;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy