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

info.novatec.testit.livingdoc.annotation.WrongAnnotation Maven / Gradle / Ivy

package info.novatec.testit.livingdoc.annotation;

import static info.novatec.testit.livingdoc.LivingDoc.$;

import info.novatec.testit.livingdoc.Text;
import info.novatec.testit.livingdoc.TypeConversion;
import info.novatec.testit.livingdoc.expectation.Expectation;


public class WrongAnnotation implements Annotation {
    private Expectation expected;
    private Object actual;
    private boolean detailed;

    @Override
    public void writeDown(Text text) {
        text.setStyle(Styles.BACKGROUND_COLOR, Colors.RED);
        if (detailed) {
            text.setContent(message());
        }
    }

    private String message() {
        StringBuilder message = new StringBuilder();
        message.append("").append($("expected")).append(": ");
        expected.describeTo(message);
        message.append(" ").append($("received")).append(": ").append(TypeConversion.toString(actual));
        return message.toString();
    }

    public void giveDetails(Expectation paramExpected, Object paramActual) {
        this.expected = paramExpected;
        this.actual = paramActual;
        this.detailed = true;
    }

    public boolean isDetailed() {
        return detailed;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy