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

io.qameta.allure.entity.WithSummary Maven / Gradle / Ivy

There is a newer version: 2.30.0
Show newest version
package io.qameta.allure.entity;

import javax.xml.bind.annotation.XmlElement;
import java.util.List;

import static java.util.Collections.emptyList;
import static java.util.Objects.isNull;

/**
 * @author charlie (Dmitry Baev).
 */
public interface WithSummary {

    List getSteps();

    List getAttachments();

    List getParameters();

    @XmlElement
    default long getStepsCount() {
        final List steps = isNull(getSteps()) ? emptyList() : getSteps();
        final long stepsCount = steps.size();
        return steps.stream()
                .map(Step::getStepsCount)
                .reduce(stepsCount, Long::sum);
    }

    @XmlElement
    default long getAttachmentsCount() {
        final List attachments = isNull(getAttachments()) ? emptyList() : getAttachments();
        final List steps = isNull(getSteps()) ? emptyList() : getSteps();
        final long attachmentsCount = isNull(attachments) ? 0 : attachments.size();
        return steps.stream()
                .map(Step::getAttachmentsCount)
                .reduce(attachmentsCount, Long::sum);
    }

    @XmlElement
    default boolean hasContent() {
        final List attachments = isNull(getAttachments()) ? emptyList() : getAttachments();
        final List steps = isNull(getSteps()) ? emptyList() : getSteps();
        final List parameters = isNull(getParameters()) ? emptyList() : getParameters();
        return steps.size() + attachments.size() + parameters.size() > 0;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy