io.qameta.allure.core.LaunchResults Maven / Gradle / Ivy
/*
* Copyright 2019 Qameta Software OÜ
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.qameta.allure.core;
import io.qameta.allure.entity.Attachment;
import io.qameta.allure.entity.TestResult;
import java.nio.file.Path;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.function.Supplier;
import java.util.stream.Collectors;
/**
* Contains parsed results.
*
* @since 2.0
*/
public interface LaunchResults {
/**
* Returns not hidden test results.
*
* @return the results that are not hidden.
*/
default Set getResults() {
return getAllResults().stream()
.filter(result -> !result.isHidden())
.collect(Collectors.toSet());
}
/**
* Returns all test results, including hidden.
*
* @return all test results.
*/
Set getAllResults();
/**
* Returns all attachments.
*
* @return attachments.
*/
Map getAttachments();
/**
* Returns extra info by given name.
*
* @param name the name of extra block to return.
* @param the java type of extra block.
* @return the found block or empty if not present.
*/
Optional getExtra(String name);
/**
* Shortcut for {@link #getExtra(String)}. Returns default value instead of empty optional
* if block not present.
*
* @param name the name of extra block to return.
* @param defaultValue the supplier of default value.
* @param the java type of extra block.
* @return the found block or default value.
*/
default T getExtra(String name, Supplier defaultValue) {
final Optional extra = getExtra(name);
return extra.orElseGet(defaultValue);
}
}