|
1 | 1 | # frozen_string_literal: true
|
| 2 | +# typed: true |
| 3 | + |
| 4 | +require "sorbet-runtime" |
2 | 5 |
|
3 | 6 | class CertTestProcedure
|
| 7 | + extend T::Sig |
| 8 | + |
| 9 | + # @return [String] Unique ID of the test procedure |
| 10 | + sig { returns(String) } |
| 11 | + attr_reader :id |
| 12 | + |
| 13 | + # Description of test procedure (could be multiple lines). |
| 14 | + sig { returns(String) } |
| 15 | + attr_reader :description |
| 16 | + |
| 17 | + # What kind of database object is this? |
| 18 | + sig { returns(String) } |
| 19 | + attr_reader :kind |
| 20 | + |
| 21 | + # Name of test file that implements this test procedure. Could be nil. |
| 22 | + sig { returns(T.nilable(String)) } |
| 23 | + attr_reader :test_file_name |
| 24 | + |
4 | 25 | # @param data [Hash<String, Object>] Data from YAML file
|
5 | 26 | # @param db_obj [DatabaseObject] Database object that defines test procedure (Extension, Instruction, CSR, or CSR field)
|
| 27 | + sig {params(data: T::Hash[String, T.untyped], db_obj: T.any(Extension, Instruction, Csr, CsrField)).void } |
6 | 28 | def initialize(data, db_obj)
|
7 |
| - raise ArgumentError, "Need Hash but was passed a #{data.class}" unless data.is_a?(Hash) |
8 |
| - raise ArgumentError, "Need DatabaseObject but was passed a #{db_obj.class}" unless db_obj.is_a?(DatabaseObject) |
9 |
| - |
10 | 29 | @data = data
|
11 | 30 | @db_obj = db_obj
|
12 | 31 |
|
13 |
| - raise ArgumentError, "Missing certification test procedure ID for #{db_obj.name} of kind #{db_obj.kind}" if id.nil? |
14 |
| - warn "Warning: Missing test_file_name for certification test procedure description for #{db_obj.name} of kind #{db_obj.kind}" if test_file_name.nil? |
15 |
| - raise ArgumentError, "Missing certification test procedure description for #{db_obj.name} of kind #{db_obj.kind}" if description.nil? |
16 |
| - end |
17 |
| - |
18 |
| - # @return [String] Unique ID of the test procedure |
19 |
| - def id = @data["id"] |
| 32 | + @id = T.must_because(data["id"]) { pp data } |
| 33 | + @description = T.must_because(data["description"]) { pp data } |
| 34 | + @kind = T.must_because(db_obj.kind) { pp db_obj } |
| 35 | + @test_file_name = data["test_file_name"] |
20 | 36 |
|
21 |
| - # @return [String] Name of test file that implements this test procedure. Could be nil. |
22 |
| - def test_file_name = @data["test_file_name"] |
23 |
| - |
24 |
| - # @return [String] Description of test procedure (could be multiple lines) |
25 |
| - def description = @data["description"] |
| 37 | + if test_file_name.nil? |
| 38 | + warn "Warning: Missing test_file_name for certification test procedure description for ID #{id} of kind #{kind}" |
| 39 | + end |
| 40 | + end |
26 | 41 |
|
27 | 42 | # @return [Array<CertNormativeRule>]
|
28 | 43 | def cert_normative_rules
|
|
0 commit comments