adiwg-mdtranslator 0.12.0 → 0.12.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9/module_dictionaryInfo.rb +4 -0
- data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9/module_domain.rb +4 -0
- data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9/module_onlineResource.rb +35 -36
- data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9/module_responsibleParty.rb +5 -0
- data/lib/adiwg/mdtranslator/version.rb +2 -1
- data/lib/adiwg/mdtranslator.rb +4 -4
- data/test/readers/mdJson/v0_9/tc_reader_mdjson_additionalDocumentation.rb +1 -1
- data/test/readers/mdJson/v0_9/tc_reader_mdjson_address.rb +1 -1
- data/test/readers/mdJson/v0_9/tc_reader_mdjson_associatedResource.rb +1 -1
- data/test/readers/mdJson/v0_9/tc_reader_mdjson_browseGraphic.rb +21 -1
- data/test/readers/mdJson/v0_9/tc_reader_mdjson_citation.rb +1 -1
- data/test/readers/mdJson/v0_9/tc_reader_mdjson_contact.rb +1 -1
- data/test/readers/mdJson/v0_9/tc_reader_mdjson_dictionaryInfo.rb +95 -0
- data/test/readers/mdJson/v0_9/tc_reader_mdjson_domain.rb +99 -0
- data/test/readers/mdJson/v0_9/tc_reader_mdjson_onlineResource.rb +62 -17
- data/test/readers/mdJson/v0_9/tc_reader_mdjson_phone.rb +47 -65
- data/test/readers/mdJson/v0_9/tc_reader_mdjson_responsibleParty.rb +76 -0
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5778189b902252c9a7d2355f2d494da4e2938e55
|
4
|
+
data.tar.gz: cf516a023ba7c331f7874668246006e984191e4d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0f5b57040f1fc9f4a30a56492c979194e9fbaad168ee530a7639b58297e8d590fe91feab3443f1f8df0f1e4a23bb59dd841dbb22fce1c76c7f83f524b76a55e
|
7
|
+
data.tar.gz: 033b527532dd79b6811f082a82d56522f1514f3508483c4c1cfdc5c2844c32040bbf1c74ebb6a4a911639120a24b0dd53318aa0350a048c4c13ab7fede00ecc1
|
@@ -16,6 +16,10 @@ module ADIWG
|
|
16
16
|
|
17
17
|
def self.unpack(hDictInfo)
|
18
18
|
|
19
|
+
# return nil object if input is empty
|
20
|
+
intDictInfo = nil
|
21
|
+
return if hDictInfo.empty?
|
22
|
+
|
19
23
|
# instance classes needed in script
|
20
24
|
intMetadataClass = InternalMetadata.new
|
21
25
|
intDictInfo = intMetadataClass.newDictionaryInfo
|
@@ -16,6 +16,10 @@ module ADIWG
|
|
16
16
|
|
17
17
|
def self.unpack(hDomain)
|
18
18
|
|
19
|
+
# return nil object if input is empty
|
20
|
+
intDomain = nil
|
21
|
+
return if hDomain.empty?
|
22
|
+
|
19
23
|
# instance classes needed in script
|
20
24
|
intMetadataClass = InternalMetadata.new
|
21
25
|
intDomain = intMetadataClass.newDictionaryDomain
|
@@ -18,54 +18,53 @@ module ADIWG
|
|
18
18
|
|
19
19
|
def self.unpack(hOlResource)
|
20
20
|
|
21
|
-
#
|
22
|
-
intMetadataClass = InternalMetadata.new
|
21
|
+
# return nil object if input is empty
|
23
22
|
intOLRes = nil
|
23
|
+
return if hOlResource.empty?
|
24
24
|
|
25
|
-
|
26
|
-
|
25
|
+
# instance classes needed in script
|
26
|
+
intMetadataClass = InternalMetadata.new
|
27
|
+
intOLRes = intMetadataClass.newOnlineResource
|
27
28
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
end
|
29
|
+
# unpack the online resource
|
30
|
+
# resource - web link
|
31
|
+
if hOlResource.has_key?('uri')
|
32
|
+
s = hOlResource['uri']
|
33
|
+
if s != ''
|
34
|
+
intOLRes[:olResURI] = s
|
35
35
|
end
|
36
|
+
end
|
36
37
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
end
|
38
|
+
# resource - web link protocol
|
39
|
+
if hOlResource.has_key?('protocol')
|
40
|
+
s = hOlResource['protocol']
|
41
|
+
if s != ''
|
42
|
+
intOLRes[:olResProtocol] = s
|
43
43
|
end
|
44
|
+
end
|
44
45
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
end
|
46
|
+
# resource - web link name
|
47
|
+
if hOlResource.has_key?('name')
|
48
|
+
s = hOlResource['name']
|
49
|
+
if s != ''
|
50
|
+
intOLRes[:olResName] = s
|
51
51
|
end
|
52
|
+
end
|
52
53
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
end
|
54
|
+
# resource - web link description
|
55
|
+
if hOlResource.has_key?('description')
|
56
|
+
s = hOlResource['description']
|
57
|
+
if s != ''
|
58
|
+
intOLRes[:olResDesc] = s
|
59
59
|
end
|
60
|
+
end
|
60
61
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
end
|
62
|
+
# resource - web link function
|
63
|
+
if hOlResource.has_key?('function')
|
64
|
+
s = hOlResource['function']
|
65
|
+
if s != ''
|
66
|
+
intOLRes[:olResFunction] = s
|
67
67
|
end
|
68
|
-
|
69
68
|
end
|
70
69
|
|
71
70
|
return intOLRes
|
@@ -6,6 +6,7 @@
|
|
6
6
|
# Stan Smith 2014-05-28 modified to support JSON schema 0.5.0
|
7
7
|
# ... removed resource IDs associated with contact
|
8
8
|
# Stan Smith 2014-12-15 refactored to handle namespacing readers and writers
|
9
|
+
# Stan Smith 2015-01-18 added nil return if hRParty empty
|
9
10
|
|
10
11
|
module ADIWG
|
11
12
|
module Mdtranslator
|
@@ -16,6 +17,10 @@ module ADIWG
|
|
16
17
|
|
17
18
|
def self.unpack(hRParty)
|
18
19
|
|
20
|
+
# return nil object if input is empty
|
21
|
+
intResById = nil
|
22
|
+
return if hRParty.empty?
|
23
|
+
|
19
24
|
# instance classes needed in script
|
20
25
|
intMetadataClass = InternalMetadata.new
|
21
26
|
intResById = intMetadataClass.newRespParty
|
@@ -32,11 +32,12 @@
|
|
32
32
|
# 0.11.3 2015-01-14 change return type from false to $response when writer name is invalid
|
33
33
|
# 0.12.0 2015-01-16 changed translate entry point method to use keyword parameters
|
34
34
|
# ... must now be ruby version 2.0.0 or higher
|
35
|
+
# 0.12.1 2015-01-21 fixed problem with crash on writer = ''
|
35
36
|
|
36
37
|
module ADIWG
|
37
38
|
module Mdtranslator
|
38
39
|
# current mdtranslator version
|
39
|
-
VERSION = "0.12.
|
40
|
+
VERSION = "0.12.1"
|
40
41
|
end
|
41
42
|
end
|
42
43
|
|
data/lib/adiwg/mdtranslator.rb
CHANGED
@@ -79,12 +79,12 @@ module ADIWG
|
|
79
79
|
end
|
80
80
|
|
81
81
|
# handle writers
|
82
|
-
if writer
|
83
|
-
require File.join(File.dirname(__FILE__), 'mdtranslator/writers/mdWriters')
|
84
|
-
ADIWG::Mdtranslator::Writers.handleWriter(intObj)
|
85
|
-
else
|
82
|
+
if writer.nil? || writer == ''
|
86
83
|
$response[:writerPass] = false
|
87
84
|
$response[:writerMessages] << 'Writer name is missing.'
|
85
|
+
else
|
86
|
+
require File.join(File.dirname(__FILE__), 'mdtranslator/writers/mdWriters')
|
87
|
+
ADIWG::Mdtranslator::Writers.handleWriter(intObj)
|
88
88
|
end
|
89
89
|
return $response
|
90
90
|
|
@@ -36,6 +36,26 @@ class TestReaderMdJsonBrowseGraphic_v0_9 < MiniTest::Test
|
|
36
36
|
|
37
37
|
end
|
38
38
|
|
39
|
+
def test_missing_browseGraphic_elements
|
40
|
+
|
41
|
+
# except for fileName
|
42
|
+
|
43
|
+
hIn = @@hIn.clone
|
44
|
+
hIn.delete('fileDescription')
|
45
|
+
hIn.delete('fileType')
|
46
|
+
hIn.delete('fileUri')
|
47
|
+
|
48
|
+
intObj = {
|
49
|
+
bGName: 'fileName',
|
50
|
+
bGDescription: nil,
|
51
|
+
bGType: nil,
|
52
|
+
bGURI: nil
|
53
|
+
}
|
54
|
+
|
55
|
+
assert_equal intObj,@@NameSpace.unpack(hIn)
|
56
|
+
|
57
|
+
end
|
58
|
+
|
39
59
|
def test_empty_browseGraphic_elements
|
40
60
|
|
41
61
|
hIn = @@hIn.clone
|
@@ -57,7 +77,7 @@ class TestReaderMdJsonBrowseGraphic_v0_9 < MiniTest::Test
|
|
57
77
|
|
58
78
|
def test_empty_browseGraphic_object
|
59
79
|
|
60
|
-
hIn =
|
80
|
+
hIn = {}
|
61
81
|
|
62
82
|
assert_equal nil, @@NameSpace.unpack(hIn)
|
63
83
|
|
@@ -0,0 +1,95 @@
|
|
1
|
+
# MdTranslator - minitest of
|
2
|
+
# reader / mdJson / module_dictionaryInfo
|
3
|
+
|
4
|
+
# History:
|
5
|
+
# Stan Smith 2015-01-20 original script
|
6
|
+
|
7
|
+
#set globals used in testing
|
8
|
+
#set globals used by mdJson_reader.rb before requiring module
|
9
|
+
$response = {
|
10
|
+
readerVersionUsed: '0.9',
|
11
|
+
readerExecutionPas: true,
|
12
|
+
readerExecutionMessages: []
|
13
|
+
}
|
14
|
+
|
15
|
+
require 'minitest/autorun'
|
16
|
+
require 'json'
|
17
|
+
require 'adiwg/mdtranslator/internal/internal_metadata_obj'
|
18
|
+
require 'adiwg/mdtranslator/readers/mdJson/modules_0.9/module_dictionaryInfo'
|
19
|
+
|
20
|
+
class TestReaderMdJsonDictionaryInfo_v0_9 < MiniTest::Test
|
21
|
+
|
22
|
+
# get json test example
|
23
|
+
file = File.open('test/schemas/v0_9/examples/dataDictionary.json', 'r')
|
24
|
+
jsonFile = file.read
|
25
|
+
file.close
|
26
|
+
aIn = JSON.parse(jsonFile)
|
27
|
+
@@hIn = aIn[0]['dictionaryInfo']
|
28
|
+
|
29
|
+
# set namespace
|
30
|
+
@@NameSpace = ADIWG::Mdtranslator::Readers::MdJson::DictionaryInfo
|
31
|
+
|
32
|
+
def test_complete_dictionaryInfo_object
|
33
|
+
|
34
|
+
|
35
|
+
hIn = @@hIn.clone
|
36
|
+
hIn.delete('citation')
|
37
|
+
intObj = {
|
38
|
+
dictCitation: {},
|
39
|
+
dictDescription: 'description',
|
40
|
+
dictResourceType: 'resourceType',
|
41
|
+
dictLanguage: 'language'
|
42
|
+
}
|
43
|
+
|
44
|
+
assert_equal intObj, @@NameSpace.unpack(hIn)
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_empty_dictionaryInfo_elements
|
49
|
+
|
50
|
+
hIn = @@hIn.clone
|
51
|
+
hIn['citation'] = {}
|
52
|
+
hIn['description'] = ''
|
53
|
+
hIn['resourceType'] = ''
|
54
|
+
hIn['language'] = ''
|
55
|
+
|
56
|
+
intObj = {
|
57
|
+
dictCitation: {},
|
58
|
+
dictDescription: nil,
|
59
|
+
dictResourceType: nil,
|
60
|
+
dictLanguage: nil
|
61
|
+
}
|
62
|
+
|
63
|
+
assert_equal intObj, @@NameSpace.unpack(hIn)
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_missing_dictionaryInfo_elements
|
68
|
+
|
69
|
+
# except for citation
|
70
|
+
hIn = @@hIn.clone
|
71
|
+
hIn['citation'] = {}
|
72
|
+
hIn.delete('description')
|
73
|
+
hIn.delete('resourceType')
|
74
|
+
hIn.delete('language')
|
75
|
+
|
76
|
+
intObj = {
|
77
|
+
dictCitation: {},
|
78
|
+
dictDescription: nil,
|
79
|
+
dictResourceType: nil,
|
80
|
+
dictLanguage: nil
|
81
|
+
}
|
82
|
+
|
83
|
+
assert_equal intObj, @@NameSpace.unpack(hIn)
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_empty_dictionaryInfo_object
|
88
|
+
|
89
|
+
hIn = {}
|
90
|
+
|
91
|
+
assert_equal nil, @@NameSpace.unpack(hIn)
|
92
|
+
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
# MdTranslator - minitest of
|
2
|
+
# reader / mdJson / module_domain
|
3
|
+
|
4
|
+
# History:
|
5
|
+
# Stan Smith 2015-01-20 original script
|
6
|
+
|
7
|
+
#set globals used in testing
|
8
|
+
#set globals used by mdJson_reader.rb before requiring module
|
9
|
+
$response = {
|
10
|
+
readerVersionUsed: '0.9',
|
11
|
+
readerExecutionPas: true,
|
12
|
+
readerExecutionMessages: []
|
13
|
+
}
|
14
|
+
|
15
|
+
require 'minitest/autorun'
|
16
|
+
require 'json'
|
17
|
+
require 'adiwg/mdtranslator/internal/internal_metadata_obj'
|
18
|
+
require 'adiwg/mdtranslator/readers/mdJson/modules_0.9/module_domain'
|
19
|
+
|
20
|
+
class TestReaderMdJsonDomain_v0_9 < MiniTest::Test
|
21
|
+
|
22
|
+
# get json test example
|
23
|
+
file = File.open('test/schemas/v0_9/examples/dataDictionary.json', 'r')
|
24
|
+
jsonFile = file.read
|
25
|
+
file.close
|
26
|
+
aIn = JSON.parse(jsonFile)
|
27
|
+
@@hIn = aIn[0]['domain'][0]
|
28
|
+
|
29
|
+
# set namespace
|
30
|
+
@@NameSpace = ADIWG::Mdtranslator::Readers::MdJson::Domain
|
31
|
+
|
32
|
+
def test_complete_domain_object
|
33
|
+
|
34
|
+
|
35
|
+
hIn = @@hIn.clone
|
36
|
+
hIn.delete('member')
|
37
|
+
intObj = {
|
38
|
+
domainId: 'domainId1',
|
39
|
+
domainName: 'commonName1',
|
40
|
+
domainCode: 'codeName1',
|
41
|
+
domainDescription: 'description1',
|
42
|
+
domainItems: []
|
43
|
+
}
|
44
|
+
|
45
|
+
assert_equal intObj, @@NameSpace.unpack(hIn)
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_empty_domain_elements
|
50
|
+
|
51
|
+
hIn = @@hIn.clone
|
52
|
+
hIn['domainId'] = ''
|
53
|
+
hIn['commonName'] = ''
|
54
|
+
hIn['codeName'] = ''
|
55
|
+
hIn['description'] = ''
|
56
|
+
hIn['member'] = []
|
57
|
+
|
58
|
+
intObj = {
|
59
|
+
domainId: nil,
|
60
|
+
domainName: nil,
|
61
|
+
domainCode: nil,
|
62
|
+
domainDescription: nil,
|
63
|
+
domainItems: []
|
64
|
+
}
|
65
|
+
|
66
|
+
assert_equal intObj, @@NameSpace.unpack(hIn)
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_missing_domain_elements
|
71
|
+
|
72
|
+
# except for domainId
|
73
|
+
hIn = @@hIn.clone
|
74
|
+
hIn.delete('commonName')
|
75
|
+
hIn.delete('codeName')
|
76
|
+
hIn.delete('description')
|
77
|
+
hIn.delete('member')
|
78
|
+
|
79
|
+
intObj = {
|
80
|
+
domainId: 'domainId1',
|
81
|
+
domainName: nil,
|
82
|
+
domainCode: nil,
|
83
|
+
domainDescription: nil,
|
84
|
+
domainItems: []
|
85
|
+
}
|
86
|
+
|
87
|
+
assert_equal intObj, @@NameSpace.unpack(hIn)
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_empty_domain_object
|
92
|
+
|
93
|
+
hIn = {}
|
94
|
+
|
95
|
+
assert_equal nil, @@NameSpace.unpack(hIn)
|
96
|
+
|
97
|
+
end
|
98
|
+
|
99
|
+
end
|
@@ -12,35 +12,80 @@ require 'adiwg/mdtranslator/readers/mdJson/modules_0.9/module_onlineResource'
|
|
12
12
|
|
13
13
|
class TestReaderMdJsonOnlineResource_v0_9 < MiniTest::Test
|
14
14
|
|
15
|
-
|
15
|
+
# get json test example
|
16
|
+
file = File.open('test/schemas/v0_9/examples/onlineResource.json', 'r')
|
17
|
+
jsonFile = file.read
|
18
|
+
file.close
|
19
|
+
aIn = JSON.parse(jsonFile)
|
20
|
+
@@hIn = aIn[0]
|
16
21
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
'}'
|
24
|
-
hIn = JSON.parse(json_string)
|
22
|
+
# set namespace
|
23
|
+
@@NameSpace = ADIWG::Mdtranslator::Readers::MdJson::OnlineResource
|
24
|
+
|
25
|
+
def test_complete_onlineResource_object
|
26
|
+
|
27
|
+
hIn = @@hIn.clone
|
25
28
|
|
26
29
|
intObj = {
|
27
|
-
olResURI: 'http://
|
30
|
+
olResURI: 'http://thisisanexample.com',
|
28
31
|
olResProtocol: 'protocol',
|
29
|
-
olResName: '
|
30
|
-
olResDesc: '
|
32
|
+
olResName: 'name',
|
33
|
+
olResDesc: 'description',
|
31
34
|
olResFunction: 'function'
|
32
35
|
}
|
33
36
|
|
34
|
-
assert_equal intObj,
|
37
|
+
assert_equal intObj, @@NameSpace.unpack(hIn)
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_missing_onlineResource_elements
|
42
|
+
|
43
|
+
# except for uri
|
44
|
+
|
45
|
+
hIn = @@hIn.clone
|
46
|
+
hIn.delete('protocol')
|
47
|
+
hIn.delete('name')
|
48
|
+
hIn.delete('description')
|
49
|
+
hIn.delete('function')
|
50
|
+
|
51
|
+
intObj = {
|
52
|
+
olResURI: 'http://thisisanexample.com',
|
53
|
+
olResProtocol: nil,
|
54
|
+
olResName: nil,
|
55
|
+
olResDesc: nil,
|
56
|
+
olResFunction: nil
|
57
|
+
}
|
58
|
+
|
59
|
+
assert_equal intObj, @@NameSpace.unpack(hIn)
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_empty_onlineResource_elements
|
64
|
+
|
65
|
+
hIn = @@hIn.clone
|
66
|
+
hIn['uri'] = ''
|
67
|
+
hIn['protocol'] = ''
|
68
|
+
hIn['name'] = ''
|
69
|
+
hIn['description'] = ''
|
70
|
+
hIn['function'] = ''
|
71
|
+
|
72
|
+
intObj = {
|
73
|
+
olResURI: nil,
|
74
|
+
olResProtocol: nil,
|
75
|
+
olResName: nil,
|
76
|
+
olResDesc: nil,
|
77
|
+
olResFunction: nil
|
78
|
+
}
|
79
|
+
|
80
|
+
assert_equal intObj, @@NameSpace.unpack(hIn)
|
35
81
|
|
36
82
|
end
|
37
83
|
|
38
|
-
def
|
84
|
+
def test_empty_onlineResource_object
|
39
85
|
|
40
|
-
|
41
|
-
hIn = JSON.parse(json_string)
|
86
|
+
hIn = {}
|
42
87
|
|
43
|
-
assert_equal nil,
|
88
|
+
assert_equal nil, @@NameSpace.unpack(hIn)
|
44
89
|
|
45
90
|
end
|
46
91
|
|
@@ -10,118 +10,100 @@ require 'json'
|
|
10
10
|
require 'adiwg/mdtranslator/internal/internal_metadata_obj'
|
11
11
|
require 'adiwg/mdtranslator/readers/mdJson/modules_0.9/module_phone'
|
12
12
|
|
13
|
-
class
|
13
|
+
class TestReaderMdJsonPhone_v0_9 < MiniTest::Test
|
14
14
|
|
15
|
-
|
15
|
+
# get json test example
|
16
|
+
file = File.open('test/schemas/v0_9/examples/contact.json', 'r')
|
17
|
+
jsonFile = file.read
|
18
|
+
file.close
|
19
|
+
aIn = JSON.parse(jsonFile)
|
20
|
+
@@hIn = aIn[0]['phoneBook'][0]
|
16
21
|
|
17
|
-
|
18
|
-
|
19
|
-
'"phoneNumber": "(999)999-9999",' +
|
20
|
-
'"service": ["voice","fax","sms"]' +
|
21
|
-
'}'
|
22
|
-
hIn = JSON.parse(json_string)
|
22
|
+
# set namespace
|
23
|
+
@@NameSpace = ADIWG::Mdtranslator::Readers::MdJson::Phone
|
23
24
|
|
25
|
+
def test_complete_phone_object
|
26
|
+
|
27
|
+
|
28
|
+
hIn = @@hIn.clone
|
24
29
|
intObj = []
|
25
|
-
|
26
|
-
phoneServiceType: '
|
27
|
-
phoneName: '
|
28
|
-
phoneNumber: '
|
30
|
+
intObj << {
|
31
|
+
phoneServiceType: 'service11',
|
32
|
+
phoneName: 'phoneName1',
|
33
|
+
phoneNumber: '111-111-1111'
|
29
34
|
}
|
30
|
-
intObj <<
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
phoneNumber: '(999)999-9999'
|
35
|
+
intObj << {
|
36
|
+
phoneServiceType: 'service12',
|
37
|
+
phoneName: 'phoneName1',
|
38
|
+
phoneNumber: '111-111-1111'
|
35
39
|
}
|
36
|
-
intObj << intObjPart
|
37
|
-
intObjPart = {
|
38
|
-
phoneServiceType: 'sms',
|
39
|
-
phoneName: 'Name',
|
40
|
-
phoneNumber: '(999)999-9999'
|
41
|
-
}
|
42
|
-
intObj << intObjPart
|
43
40
|
|
44
|
-
assert_equal intObj,
|
41
|
+
assert_equal intObj, @@NameSpace.unpack(hIn)
|
45
42
|
|
46
43
|
end
|
47
44
|
|
48
45
|
def test_missing_phone_service
|
49
46
|
|
50
|
-
|
51
|
-
|
52
|
-
'"phoneNumber": "(999)999-9999"' +
|
53
|
-
'}'
|
54
|
-
hIn = JSON.parse(json_string)
|
47
|
+
hIn = @@hIn.clone
|
48
|
+
hIn.delete('service')
|
55
49
|
|
56
50
|
intObj = []
|
57
|
-
|
51
|
+
intObj << {
|
58
52
|
phoneServiceType: 'voice',
|
59
|
-
phoneName: '
|
60
|
-
phoneNumber: '
|
53
|
+
phoneName: 'phoneName1',
|
54
|
+
phoneNumber: '111-111-1111'
|
61
55
|
}
|
62
|
-
intObj << intObjPart
|
63
56
|
|
64
|
-
assert_equal intObj,
|
57
|
+
assert_equal intObj, @@NameSpace.unpack(hIn)
|
65
58
|
|
66
59
|
end
|
67
60
|
|
68
|
-
def
|
61
|
+
def test_empty_phone_service
|
69
62
|
|
70
|
-
|
71
|
-
|
72
|
-
'"phoneNumber": "(999)999-9999",' +
|
73
|
-
'"service": ""' +
|
74
|
-
'}'
|
75
|
-
hIn = JSON.parse(json_string)
|
63
|
+
hIn = @@hIn.clone
|
64
|
+
hIn['service'] = ''
|
76
65
|
|
77
66
|
intObj = []
|
78
|
-
|
67
|
+
intObj << {
|
79
68
|
phoneServiceType: 'voice',
|
80
|
-
phoneName: '
|
81
|
-
phoneNumber: '
|
69
|
+
phoneName: 'phoneName1',
|
70
|
+
phoneNumber: '111-111-1111'
|
82
71
|
}
|
83
|
-
intObj << intObjPart
|
84
72
|
|
85
|
-
assert_equal intObj,
|
73
|
+
assert_equal intObj, @@NameSpace.unpack(hIn)
|
86
74
|
|
87
75
|
end
|
88
76
|
|
89
77
|
def test_missing_phone_number
|
90
78
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
hIn = JSON.parse(json_string)
|
79
|
+
# missing phone number should return empty object
|
80
|
+
hIn = @@hIn.clone
|
81
|
+
hIn.delete('phoneNumber')
|
95
82
|
|
96
83
|
intObj = []
|
97
84
|
|
98
|
-
assert_equal intObj,
|
85
|
+
assert_equal intObj, @@NameSpace.unpack(hIn)
|
99
86
|
|
100
87
|
end
|
101
88
|
|
102
|
-
def
|
89
|
+
def test_empty_phone_number
|
103
90
|
|
104
|
-
#
|
105
|
-
|
106
|
-
|
107
|
-
'"phoneNumber": "",' +
|
108
|
-
'"service": ""' +
|
109
|
-
'}'
|
110
|
-
hIn = JSON.parse(json_string)
|
91
|
+
# empty phone number should return empty object
|
92
|
+
hIn = @@hIn.clone
|
93
|
+
hIn['phoneNumber'] = ''
|
111
94
|
|
112
95
|
intObj = []
|
113
96
|
|
114
|
-
assert_equal intObj,
|
97
|
+
assert_equal intObj, @@NameSpace.unpack(hIn)
|
115
98
|
|
116
99
|
end
|
117
100
|
|
118
|
-
def
|
101
|
+
def test_empty_phone_object
|
119
102
|
|
120
|
-
|
121
|
-
hIn = JSON.parse(json_string)
|
103
|
+
hIn = {}
|
122
104
|
intObj = []
|
123
105
|
|
124
|
-
assert_equal intObj,
|
106
|
+
assert_equal intObj, @@NameSpace.unpack(hIn)
|
125
107
|
|
126
108
|
end
|
127
109
|
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# MdTranslator - minitest of
|
2
|
+
# reader / mdJson / module_responsibleParty
|
3
|
+
|
4
|
+
# History:
|
5
|
+
# Stan Smith 2015-01-18 original script
|
6
|
+
|
7
|
+
require 'minitest/autorun'
|
8
|
+
require 'json'
|
9
|
+
require 'adiwg/mdtranslator/internal/internal_metadata_obj'
|
10
|
+
require 'adiwg/mdtranslator/readers/mdJson/modules_0.9/module_responsibleParty'
|
11
|
+
|
12
|
+
class TestReaderMdJsonResponsibleParty_v0_9 < MiniTest::Test
|
13
|
+
|
14
|
+
# get json test example
|
15
|
+
file = File.open('test/schemas/v0_9/examples/contactRef.json', 'r')
|
16
|
+
jsonFile = file.read
|
17
|
+
file.close
|
18
|
+
aIn = JSON.parse(jsonFile)
|
19
|
+
@@hIn = aIn[0]
|
20
|
+
|
21
|
+
# set namespace
|
22
|
+
@@NameSpace = ADIWG::Mdtranslator::Readers::MdJson::ResponsibleParty
|
23
|
+
|
24
|
+
def test_complete_responsibleParty_object
|
25
|
+
|
26
|
+
hIn = @@hIn.clone
|
27
|
+
|
28
|
+
intObj = {
|
29
|
+
contactId: 'contactId',
|
30
|
+
roleName: 'role'
|
31
|
+
}
|
32
|
+
|
33
|
+
assert_equal intObj, @@NameSpace.unpack(hIn)
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_missing_responsibleParty_elements
|
38
|
+
|
39
|
+
# except for contactId
|
40
|
+
|
41
|
+
hIn = @@hIn.clone
|
42
|
+
hIn.delete('role')
|
43
|
+
|
44
|
+
intObj = {
|
45
|
+
contactId: 'contactId',
|
46
|
+
roleName: nil
|
47
|
+
}
|
48
|
+
|
49
|
+
assert_equal intObj, @@NameSpace.unpack(hIn)
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_empty_responsibleParty_elements
|
54
|
+
|
55
|
+
hIn = @@hIn.clone
|
56
|
+
hIn['contactId'] = ''
|
57
|
+
hIn['role'] = ''
|
58
|
+
|
59
|
+
intObj = {
|
60
|
+
contactId: nil,
|
61
|
+
roleName: nil
|
62
|
+
}
|
63
|
+
|
64
|
+
assert_equal intObj, @@NameSpace.unpack(hIn)
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_empty_responsibleParty_object
|
69
|
+
|
70
|
+
hIn = {}
|
71
|
+
|
72
|
+
assert_equal nil, @@NameSpace.unpack(hIn)
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: adiwg-mdtranslator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.12.
|
4
|
+
version: 0.12.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stan Smith
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-01-
|
12
|
+
date: 2015-01-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -318,8 +318,11 @@ files:
|
|
318
318
|
- test/readers/mdJson/v0_9/tc_reader_mdjson_browseGraphic.rb
|
319
319
|
- test/readers/mdJson/v0_9/tc_reader_mdjson_citation.rb
|
320
320
|
- test/readers/mdJson/v0_9/tc_reader_mdjson_contact.rb
|
321
|
+
- test/readers/mdJson/v0_9/tc_reader_mdjson_dictionaryInfo.rb
|
322
|
+
- test/readers/mdJson/v0_9/tc_reader_mdjson_domain.rb
|
321
323
|
- test/readers/mdJson/v0_9/tc_reader_mdjson_onlineResource.rb
|
322
324
|
- test/readers/mdJson/v0_9/tc_reader_mdjson_phone.rb
|
325
|
+
- test/readers/mdJson/v0_9/tc_reader_mdjson_responsibleParty.rb
|
323
326
|
- test/readers/mdJson/v0_9/tc_translation.rb
|
324
327
|
- test/writers/iso19115_2/tc_writer_iso19115_2_address.rb
|
325
328
|
homepage: http://www.adiwg.org/mdTranslator
|
@@ -355,7 +358,10 @@ test_files:
|
|
355
358
|
- test/readers/mdJson/v0_9/tc_reader_mdjson_browseGraphic.rb
|
356
359
|
- test/readers/mdJson/v0_9/tc_reader_mdjson_citation.rb
|
357
360
|
- test/readers/mdJson/v0_9/tc_reader_mdjson_contact.rb
|
361
|
+
- test/readers/mdJson/v0_9/tc_reader_mdjson_dictionaryInfo.rb
|
362
|
+
- test/readers/mdJson/v0_9/tc_reader_mdjson_domain.rb
|
358
363
|
- test/readers/mdJson/v0_9/tc_reader_mdjson_onlineResource.rb
|
359
364
|
- test/readers/mdJson/v0_9/tc_reader_mdjson_phone.rb
|
365
|
+
- test/readers/mdJson/v0_9/tc_reader_mdjson_responsibleParty.rb
|
360
366
|
- test/readers/mdJson/v0_9/tc_translation.rb
|
361
367
|
- test/writers/iso19115_2/tc_writer_iso19115_2_address.rb
|