• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pulibrary / bibdata / 3165b919-56f4-4faa-baf4-b5a08621230c

18 Sep 2025 03:08PM UTC coverage: 90.866% (+0.2%) from 90.675%
3165b919-56f4-4faa-baf4-b5a08621230c

Pull #2927

circleci

Ryan Laddusaw
Add QA DSpace config
Pull Request #2927: Index theses from dspace 7+

1411 of 1519 new or added lines in 16 files covered. (92.89%)

41 existing lines in 7 files now uncovered.

8874 of 9766 relevant lines covered (90.87%)

338.18 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

92.22
/lib/bibdata_rs/src/theses/legacy_dataspace/document/builder.rs
1
// This module provides a convenient way to create a DataspaceDocument using the builder pattern
2

3
use super::DataspaceDocument;
4

5
#[derive(Debug, Default)]
6
pub struct DataspaceDocumentBuilder {
7
    id: Option<String>,
8
    certificate: Option<Vec<String>>,
9
    contributor: Option<Vec<String>>,
10
    contributor_advisor: Option<Vec<String>>,
11
    contributor_author: Option<Vec<String>>,
12
    date_classyear: Option<Vec<String>>,
13
    description_abstract: Option<Vec<String>>,
14
    department: Option<Vec<String>>,
15
    embargo_lift: Option<Vec<String>>,
16
    embargo_terms: Option<Vec<String>>,
17
    format_extent: Option<Vec<String>>,
18
    identifier_other: Option<Vec<String>>,
19
    identifier_uri: Option<Vec<String>>,
20
    language_iso: Option<Vec<String>>,
21
    location: Option<Vec<String>>,
22
    mudd_walkin: Option<Vec<String>>,
23
    rights_access_rights: Option<Vec<String>>,
24
    title: Option<Vec<String>>,
25
}
26

27
impl DataspaceDocumentBuilder {
28
    pub fn with_id(mut self, id: impl Into<String>) -> Self {
15✔
29
        self.id = Some(id.into());
15✔
30
        self
15✔
31
    }
15✔
32

33
    pub fn with_certificate(mut self, certificate: impl Into<String>) -> Self {
7✔
34
        if let Some(ref mut vec) = self.certificate {
7✔
35
            vec.push(certificate.into())
2✔
36
        } else {
5✔
37
            self.certificate = Some(vec![certificate.into()]);
5✔
38
        };
5✔
39
        self
7✔
40
    }
7✔
41

42
    pub fn with_contributor(mut self, contributor: impl Into<String>) -> Self {
8✔
43
        if let Some(ref mut vec) = self.contributor {
8✔
44
            vec.push(contributor.into())
1✔
45
        } else {
7✔
46
            self.contributor = Some(vec![contributor.into()]);
7✔
47
        };
7✔
48
        self
8✔
49
    }
8✔
50

51
    pub fn with_contributor_advisor(mut self, contributor_advisor: impl Into<String>) -> Self {
7✔
52
        if let Some(ref mut vec) = self.contributor_advisor {
7✔
NEW
53
            vec.push(contributor_advisor.into())
×
54
        } else {
7✔
55
            self.contributor_advisor = Some(vec![contributor_advisor.into()]);
7✔
56
        };
7✔
57
        self
7✔
58
    }
7✔
59

60
    pub fn with_contributor_author(mut self, contributor_author: impl Into<String>) -> Self {
12✔
61
        if let Some(ref mut vec) = self.contributor_author {
12✔
62
            vec.push(contributor_author.into())
3✔
63
        } else {
9✔
64
            self.contributor_author = Some(vec![contributor_author.into()]);
9✔
65
        };
9✔
66
        self
12✔
67
    }
12✔
68

69
    pub fn with_date_classyear(mut self, date_classyear: impl Into<String>) -> Self {
18✔
70
        if let Some(ref mut vec) = self.date_classyear {
18✔
NEW
71
            vec.push(date_classyear.into())
×
72
        } else {
18✔
73
            self.date_classyear = Some(vec![date_classyear.into()]);
18✔
74
        };
18✔
75
        self
18✔
76
    }
18✔
77

78
    pub fn with_description_abstract(mut self, description_abstract: impl Into<String>) -> Self {
6✔
79
        if let Some(ref mut vec) = self.description_abstract {
6✔
NEW
80
            vec.push(description_abstract.into())
×
81
        } else {
6✔
82
            self.description_abstract = Some(vec![description_abstract.into()]);
6✔
83
        };
6✔
84
        self
6✔
85
    }
6✔
86

87
    pub fn with_department(mut self, department: impl Into<String>) -> Self {
20✔
88
        if let Some(ref mut vec) = self.department {
20✔
89
            vec.push(department.into())
8✔
90
        } else {
12✔
91
            self.department = Some(vec![department.into()]);
12✔
92
        };
12✔
93
        self
20✔
94
    }
20✔
95

96
    pub fn with_embargo_lift(mut self, embargo_lift: impl Into<String>) -> Self {
7✔
97
        if let Some(ref mut vec) = self.embargo_lift {
7✔
NEW
98
            vec.push(embargo_lift.into())
×
99
        } else {
7✔
100
            self.embargo_lift = Some(vec![embargo_lift.into()]);
7✔
101
        };
7✔
102
        self
7✔
103
    }
7✔
104

105
    pub fn with_embargo_terms(mut self, embargo_terms: impl Into<String>) -> Self {
3✔
106
        if let Some(ref mut vec) = self.embargo_terms {
3✔
NEW
107
            vec.push(embargo_terms.into())
×
108
        } else {
3✔
109
            self.embargo_terms = Some(vec![embargo_terms.into()]);
3✔
110
        };
3✔
111
        self
3✔
112
    }
3✔
113

114
    pub fn with_format_extent(mut self, format_extent: impl Into<String>) -> Self {
8✔
115
        if let Some(ref mut vec) = self.format_extent {
8✔
NEW
116
            vec.push(format_extent.into())
×
117
        } else {
8✔
118
            self.format_extent = Some(vec![format_extent.into()]);
8✔
119
        };
8✔
120
        self
8✔
121
    }
8✔
122

123
    pub fn with_identifier_other(mut self, identifier_other: impl Into<String>) -> Self {
1✔
124
        if let Some(ref mut vec) = self.identifier_other {
1✔
NEW
125
            vec.push(identifier_other.into())
×
126
        } else {
1✔
127
            self.identifier_other = Some(vec![identifier_other.into()]);
1✔
128
        };
1✔
129
        self
1✔
130
    }
1✔
131

132
    pub fn with_identifier_uri(mut self, identifier_uri: impl Into<String>) -> Self {
6✔
133
        if let Some(ref mut vec) = self.identifier_uri {
6✔
NEW
134
            vec.push(identifier_uri.into())
×
135
        } else {
6✔
136
            self.identifier_uri = Some(vec![identifier_uri.into()]);
6✔
137
        };
6✔
138
        self
6✔
139
    }
6✔
140

141
    pub fn with_language_iso(mut self, language_iso: impl Into<String>) -> Self {
8✔
142
        if let Some(ref mut vec) = self.language_iso {
8✔
NEW
143
            vec.push(language_iso.into())
×
144
        } else {
8✔
145
            self.language_iso = Some(vec![language_iso.into()]);
8✔
146
        };
8✔
147
        self
8✔
148
    }
8✔
149

150
    pub fn with_location(mut self, location: impl Into<String>) -> Self {
3✔
151
        if let Some(ref mut vec) = self.location {
3✔
NEW
152
            vec.push(location.into())
×
153
        } else {
3✔
154
            self.location = Some(vec![location.into()]);
3✔
155
        };
3✔
156
        self
3✔
157
    }
3✔
158

159
    pub fn with_mudd_walkin(mut self, mudd_walkin: impl Into<String>) -> Self {
5✔
160
        if let Some(ref mut vec) = self.mudd_walkin {
5✔
NEW
161
            vec.push(mudd_walkin.into())
×
162
        } else {
5✔
163
            self.mudd_walkin = Some(vec![mudd_walkin.into()]);
5✔
164
        };
5✔
165
        self
5✔
166
    }
5✔
167

168
    pub fn with_rights_access_rights(mut self, rights_access_rights: impl Into<String>) -> Self {
8✔
169
        if let Some(ref mut vec) = self.rights_access_rights {
8✔
NEW
170
            vec.push(rights_access_rights.into())
×
171
        } else {
8✔
172
            self.rights_access_rights = Some(vec![rights_access_rights.into()]);
8✔
173
        };
8✔
174
        self
8✔
175
    }
8✔
176

177
    pub fn with_title(mut self, title: impl Into<String>) -> Self {
8✔
178
        if let Some(ref mut vec) = self.title {
8✔
NEW
179
            vec.push(title.into())
×
180
        } else {
8✔
181
            self.title = Some(vec![title.into()]);
8✔
182
        };
8✔
183
        self
8✔
184
    }
8✔
185

186
    pub fn build(self) -> DataspaceDocument {
48✔
187
        DataspaceDocument {
48✔
188
            id: self.id,
48✔
189
            certificate: self.certificate,
48✔
190
            contributor: self.contributor,
48✔
191
            contributor_advisor: self.contributor_advisor,
48✔
192
            contributor_author: self.contributor_author,
48✔
193
            date_classyear: self.date_classyear,
48✔
194
            description_abstract: self.description_abstract,
48✔
195
            department: self.department,
48✔
196
            embargo_lift: self.embargo_lift,
48✔
197
            embargo_terms: self.embargo_terms,
48✔
198
            format_extent: self.format_extent,
48✔
199
            identifier_other: self.identifier_other,
48✔
200
            identifier_uri: self.identifier_uri,
48✔
201
            language_iso: self.language_iso,
48✔
202
            location: self.location,
48✔
203
            mudd_walkin: self.mudd_walkin,
48✔
204
            rights_access_rights: self.rights_access_rights,
48✔
205
            title: self.title,
48✔
206
        }
48✔
207
    }
48✔
208
}
209

210
#[cfg(test)]
211
mod tests {
212
    use super::*;
213

214
    #[test]
215
    fn it_can_create_a_dataspace_document() {
1✔
216
        let builder = DataspaceDocumentBuilder::default();
1✔
217
        let doc = builder.with_id("ABC123").build();
1✔
218
        assert_eq!(doc.id, Some("ABC123".to_owned()));
1✔
219
    }
1✔
220
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc