33import java .nio .file .Path ;
44import org .slf4j .Logger ;
55
6+ import com .nordstrom .common .file .PathUtils ;
7+
68/**
79 * This interface defines the contract fulfilled by artifact capture providers. Instances of this interface supply the
810 * scenario-specific implementation for artifact capture through the {@link ArtifactCollector} listener.
1921 *
2022 * import com.nordstrom.automation.junit.ArtifactType;
2123 *
22- * public class MyArtifactType implements ArtifactType {
24+ * public class MyArtifactType extends ArtifactType {
2325 *
2426 * private static final String ARTIFACT_PATH = "artifacts";
2527 * private static final String EXTENSION = "txt";
3739 * }
3840 *
3941 * @Override
40- * public Page getArtifactPath(Object instance) {
41- * return ArtifactType. super.getArtifactPath(instance).resolve(ARTIFACT_PATH);
42+ * public Path getArtifactPath(Object instance) {
43+ * return super.getArtifactPath(instance).resolve(ARTIFACT_PATH);
4244 * }
4345 *
4446 * @Override
6668 * }
6769 * </code></pre>
6870 */
69- public interface ArtifactType {
71+ public abstract class ArtifactType {
7072
7173 /**
7274 * Get the SLF4J {@link Logger} for this artifact type.
7375 *
7476 * @return logger for this artifact (may be {@code null})
7577 */
76- Logger getLogger ();
78+ public Logger getLogger () {
79+ return null ;
80+ }
7781
7882 /**
7983 * Determine if artifact capture is available in the specified context.
8084 *
8185 * @param instance JUnit test class instance
8286 * @return 'true' if capture is available; otherwise 'false'
8387 */
84- boolean canGetArtifact (Object instance );
88+ public abstract boolean canGetArtifact (Object instance );
8589
8690 /**
8791 * Capture an artifact from the specified context.
@@ -90,23 +94,25 @@ public interface ArtifactType {
9094 * @param reason impetus for capture request; may be 'null'
9195 * @return byte array containing the captured artifact; if capture fails, an empty array is returned
9296 */
93- byte [] getArtifact (Object instance , Throwable reason );
97+ public abstract byte [] getArtifact (Object instance , Throwable reason );
9498
9599 /**
96100 * Get the path at which to store artifacts.
97101 * <p>
98102 * <b>NOTE</b>: The returned path can be either relative or absolute.
99103 *
100104 * @param instance JUnit test class instance
101- * @return artifact storage path; {@code null} to accept default path
105+ * @return artifact storage path
102106 */
103- Path getArtifactPath (Object instance );
107+ public Path getArtifactPath (Object instance ) {
108+ return PathUtils .ReportsDirectory .getPathForObject (instance );
109+ }
104110
105111 /**
106112 * Get the extension for artifact files of this type.
107113 *
108114 * @return artifact file extension
109115 */
110- String getArtifactExtension ();
116+ public abstract String getArtifactExtension ();
111117
112118}
0 commit comments