-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from tls-attacker/summarizable-result
Implement Summarizable and Detailed Results
- Loading branch information
Showing
4 changed files
with
106 additions
and
2 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
src/main/java/de/rub/nds/scanner/core/probe/result/DetailedResult.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Scanner Core - A modular framework for probe definition, execution, and result analysis. | ||
* | ||
* Copyright 2017-2023 Ruhr University Bochum, Paderborn University, Technology Innovation Institute, and Hackmanit GmbH | ||
* | ||
* Licensed under Apache License, Version 2.0 | ||
* http://www.apache.org/licenses/LICENSE-2.0.txt | ||
*/ | ||
package de.rub.nds.scanner.core.probe.result; | ||
|
||
import java.io.Serializable; | ||
|
||
public class DetailedResult<T extends Serializable> implements SummarizableTestResult { | ||
|
||
public static <T extends Serializable> DetailedResult<T> TRUE() { | ||
return new DetailedResult<>(TestResults.TRUE); | ||
} | ||
|
||
public static <T extends Serializable> DetailedResult<T> TRUE(T details) { | ||
return new DetailedResult<>(TestResults.TRUE, details); | ||
} | ||
|
||
public static <T extends Serializable> DetailedResult<T> FALSE() { | ||
return new DetailedResult<>(TestResults.FALSE); | ||
} | ||
|
||
public static <T extends Serializable> DetailedResult<T> FALSE(T details) { | ||
return new DetailedResult<>(TestResults.FALSE, details); | ||
} | ||
|
||
private final T details; | ||
private final TestResults summary; | ||
|
||
public DetailedResult(TestResults summary, T details) { | ||
this.details = details; | ||
this.summary = summary; | ||
} | ||
|
||
public DetailedResult(TestResults summary) { | ||
this(summary, null); | ||
} | ||
|
||
public T getDetails() { | ||
return details; | ||
} | ||
|
||
@Override | ||
public TestResults getSummarizedResult() { | ||
return summary; | ||
} | ||
|
||
@Override | ||
public boolean isExplicitSummary() { | ||
return true; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/main/java/de/rub/nds/scanner/core/probe/result/SummarizableTestResult.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Scanner Core - A modular framework for probe definition, execution, and result analysis. | ||
* | ||
* Copyright 2017-2023 Ruhr University Bochum, Paderborn University, Technology Innovation Institute, and Hackmanit GmbH | ||
* | ||
* Licensed under Apache License, Version 2.0 | ||
* http://www.apache.org/licenses/LICENSE-2.0.txt | ||
*/ | ||
package de.rub.nds.scanner.core.probe.result; | ||
|
||
/** | ||
* A complex test result that can still be summarized into a single TestResults. This summary might | ||
* be generated on the fly (from the contained details), or set explicitly (e.g. in case of an | ||
* error) | ||
*/ | ||
public interface SummarizableTestResult extends TestResult { | ||
TestResults getSummarizedResult(); | ||
|
||
/** | ||
* @return Whether the summary was explicitly set instead of generated on the fly. | ||
*/ | ||
boolean isExplicitSummary(); | ||
|
||
@Override | ||
default boolean equalsExpectedResult(TestResult other) { | ||
if (other instanceof TestResults) { | ||
return getSummarizedResult().equals(other); | ||
} | ||
return this.equals(other); | ||
} | ||
|
||
@Override | ||
default String getName() { | ||
return getSummarizedResult().getName(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters