CockpitTestSuiteEntry.fromJson constructor

CockpitTestSuiteEntry.fromJson(
  1. Object? value, {
  2. required String path,
})

Decodes a CockpitTestSuiteEntry from a JSON object.

Implementation

factory CockpitTestSuiteEntry.fromJson(
  Object? value, {
  required String path,
}) {
  final json = CockpitTestValueReader.object(value, path);
  CockpitTestValueReader.keys(
    json,
    const <String>{
      'id',
      'source',
      'dependsOn',
      'fixtures',
      'matrixAxes',
      'targetIds',
      'inputs',
      'retry',
      'tags',
    },
    path,
    required: const <String>{'id', 'source'},
  );
  return CockpitTestSuiteEntry(
    id: CockpitTestValueReader.string(json['id'], '$path.id', id: true),
    source: CockpitTestSuiteCaseSource.fromJson(
      json['source'],
      path: '$path.source',
    ),
    dependsOn: _optionalIds(json['dependsOn'], '$path.dependsOn'),
    fixtures: _optionalIds(json['fixtures'], '$path.fixtures'),
    matrixAxes: _optionalIds(json['matrixAxes'], '$path.matrixAxes'),
    targetIds: _optionalIds(json['targetIds'], '$path.targetIds'),
    inputs: json['inputs'] == null
        ? const <String, Object?>{}
        : CockpitTestValueReader.object(
            CockpitTestValueReader.jsonValue(json['inputs'], '$path.inputs'),
            '$path.inputs',
          ),
    retry: json['retry'] == null
        ? null
        : CockpitTestSuiteRetryPolicy.fromJson(
            json['retry'],
            path: '$path.retry',
          ),
    tags: json['tags'] == null
        ? const <String>[]
        : CockpitTestValueReader.strings(
            json['tags'],
            '$path.tags',
            unique: true,
          ),
  );
}