CockpitTestCaseReport.fromJson constructor

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

Decodes a CockpitTestCaseReport from a JSON object.

Implementation

factory CockpitTestCaseReport.fromJson(
  Object? value, {
  required String path,
}) {
  final json = CockpitTestValueReader.object(value, path);
  CockpitTestValueReader.keys(
    json,
    const <String>{
      'entryId',
      'caseId',
      'definition',
      'sourceSha256',
      'outcome',
      'stability',
      'targetId',
      'matrix',
      'attempts',
    },
    path,
    required: const <String>{
      'entryId',
      'caseId',
      'definition',
      'sourceSha256',
      'outcome',
      'stability',
      'targetId',
      'attempts',
    },
  );
  final rawAttempts = CockpitTestValueReader.list(
    json['attempts'],
    '$path.attempts',
  );
  return CockpitTestCaseReport(
    entryId: CockpitTestValueReader.string(
      json['entryId'],
      '$path.entryId',
      id: true,
    ),
    caseId: CockpitTestValueReader.string(
      json['caseId'],
      '$path.caseId',
      id: true,
    ),
    definition: CockpitTestCase.fromJson(
      json['definition'],
      path: '$path.definition',
    ),
    sourceSha256: CockpitTestValueReader.string(
      json['sourceSha256'],
      '$path.sourceSha256',
    ),
    outcome: CockpitTestValueReader.enumeration(
      json['outcome'],
      CockpitRunOutcome.values,
      '$path.outcome',
    ),
    stability: CockpitTestValueReader.enumeration(
      json['stability'],
      CockpitRunStability.values,
      '$path.stability',
    ),
    targetId: CockpitTestValueReader.string(
      json['targetId'],
      '$path.targetId',
      id: true,
    ),
    matrix: json['matrix'] == null
        ? const <String, Object?>{}
        : CockpitTestValueReader.object(
            CockpitTestValueReader.jsonValue(json['matrix'], '$path.matrix'),
            '$path.matrix',
          ),
    attempts: <CockpitTestAttemptReport>[
      for (var index = 0; index < rawAttempts.length; index += 1)
        CockpitTestAttemptReport.fromJson(
          rawAttempts[index],
          path: '$path.attempts[$index]',
        ),
    ],
  );
}