CockpitTestEvidenceIndexEntry constructor

CockpitTestEvidenceIndexEntry({
  1. required int stepResultIndex,
  2. required String stepExecutionId,
  3. required Iterable<String> artifactIds,
})

Implementation

CockpitTestEvidenceIndexEntry({
  required this.stepResultIndex,
  required this.stepExecutionId,
  required Iterable<String> artifactIds,
}) : artifactIds = List<String>.unmodifiable(artifactIds) {
  if (stepResultIndex < 0) {
    throw const FormatException(
      'Evidence index step result index must be non-negative.',
    );
  }
  CockpitTestValueReader.string(stepExecutionId, r'$.stepExecutionId');
  if (this.artifactIds.isEmpty) {
    throw const FormatException('Evidence index entry cannot be empty.');
  }
  final uniqueIds = <String>{};
  for (var index = 0; index < this.artifactIds.length; index += 1) {
    final artifactId = CockpitTestValueReader.string(
      this.artifactIds[index],
      '\$.artifactIds[$index]',
      id: true,
    );
    if (!uniqueIds.add(artifactId)) {
      throw const FormatException(
        'Evidence index contains a duplicate artifact id.',
      );
    }
  }
}