Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 2015-2017 the original author or authors.
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
* accompanies this distribution and is available at
*
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.junit.jupiter.api.extension;
import static org.junit.platform.commons.meta.API.Usage.Experimental;
import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.function.Function;
import org.junit.platform.commons.meta.API;
import org.junit.platform.commons.util.PreconditionViolationException;
import org.junit.platform.commons.util.Preconditions;
/**
* {@code ExtensionContext} encapsulates the context in which the
* current test or container is being executed.
*
*
{@link Extension Extensions} are provided an instance of
* {@code ExtensionContext} to perform their work.
*
* @since 5.0
* @see Store
* @see Namespace
*/
@API(Experimental)
public interface ExtensionContext {
/**
* Get the parent extension context, if available.
*
* @return an {@code Optional} containing the parent; never {@code null} but
* potentially empty
* @see #getRoot()
*/
Optional getParent();
/**
* Get the root {@code ExtensionContext}.
*
* @return the root extension context; never {@code null} but potentially
* this {@code ExtensionContext}
* @see #getParent()
*/
ExtensionContext getRoot();
/**
* Get the unique ID of the current test or container.
*
* @return the unique ID of the test or container; never {@code null} or blank
*/
String getUniqueId();
/**
* Get the display name for the current test or container.
*
*
The display name is either a default name or a custom name configured
* via {@link org.junit.jupiter.api.DisplayName @DisplayName}.
*
*
For details on default display names consult the Javadoc for
* {@link org.junit.jupiter.api.TestInfo#getDisplayName()}.
*
*
Note that display names are typically used for test reporting in IDEs
* and build tools and may contain spaces, special characters, and even emoji.
*
* @return the display name of the test or container; never {@code null} or blank
*/
String getDisplayName();
/**
* Get the set of all tags for the current test or container.
*
*
Tags may be declared directly on the test element or inherited
* from an outer context.
*
* @return the set of tags for the test or container; never {@code null} but
* potentially empty
*/
Set getTags();
/**
* Get the {@link AnnotatedElement} corresponding to the current extension
* context, if available.
*
*
For example, if the current extension context encapsulates a test
* class, test method, test factory method, or test template method, the
* annotated element will be the corresponding {@link Class} or {@link Method}
* reference.
*
*
Favor this method over more specific methods whenever the
* {@code AnnotatedElement} API suits the task at hand — for example,
* when looking up annotations regardless of concrete element type.
*
* @return an {@code Optional} containing the {@code AnnotatedElement};
* never {@code null} but potentially empty
* @see #getTestClass()
* @see #getTestMethod()
*/
Optional getElement();
/**
* Get the {@link Class} associated with the current test or container,
* if available.
*
* @return an {@code Optional} containing the class; never {@code null} but
* potentially empty
* @see #getRequiredTestClass()
*/
Optional> getTestClass();
/**
* Get the required {@link Class} associated with the current test
* or container.
*
*
Use this method as an alternative to {@link #getTestClass()} for use
* cases in which the test class is required to be present.
*
* @return the test class; never {@code null}
* @throws PreconditionViolationException if the test class is not present
* in this {@code ExtensionContext}
*/
default Class> getRequiredTestClass() {
return Preconditions.notNull(getTestClass().orElse(null),
"Illegal state: required test class is not present in the current ExtensionContext");
}
/**
* Get the test instance associated with the current test or container,
* if available.
*
* @return an {@code Optional} containing the test instance; never
* {@code null} but potentially empty
* @see #getRequiredTestInstance()
*/
Optional