View Javadoc
1   /*
2    * Copyright 2009 the original author or authors.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *     
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.openehealth.ipf.commons.ihe.xds.core.validate.requests;
17  
18  import org.junit.Before;
19  import org.junit.Test;
20  import org.openehealth.ipf.commons.ihe.xds.core.SampleData;
21  import org.openehealth.ipf.commons.ihe.xds.core.ebxml.*;
22  import org.openehealth.ipf.commons.ihe.xds.core.ebxml.ebxml30.EbXMLFactory30;
23  import org.openehealth.ipf.commons.ihe.xds.core.ebxml.ebxml30.EbXMLSlot30;
24  import org.openehealth.ipf.commons.ihe.xds.core.metadata.*;
25  import org.openehealth.ipf.commons.ihe.xds.core.requests.ProvideAndRegisterDocumentSet;
26  import org.openehealth.ipf.commons.ihe.xds.core.transform.requests.ProvideAndRegisterDocumentSetTransformer;
27  import org.openehealth.ipf.commons.ihe.xds.core.validate.ValidationMessage;
28  import org.openehealth.ipf.commons.ihe.xds.core.validate.ValidationProfile;
29  import org.openehealth.ipf.commons.ihe.xds.core.validate.XDSMetaDataException;
30  
31  import java.util.Arrays;
32  
33  import static org.junit.Assert.*;
34  import static org.openehealth.ipf.commons.ihe.xds.XDS.Interactions.ITI_42;
35  import static org.openehealth.ipf.commons.ihe.xds.core.metadata.Vocabulary.SLOT_NAME_SUBMISSION_SET_STATUS;
36  import static org.openehealth.ipf.commons.ihe.xds.core.validate.ValidationMessage.*;
37  
38  /**
39   * Test for {@link SubmitObjectsRequestValidator}.
40   * @author Jens Riemschneider
41   */
42  public class SubmitObjectsRequestValidatorTest {
43  
44      private SubmitObjectsRequestValidator validator;    
45      private EbXMLFactory factory;
46      private ProvideAndRegisterDocumentSet request;
47      private ProvideAndRegisterDocumentSetTransformer transformer;
48  
49      private DocumentEntry docEntry;
50  
51      @Before
52      public void setUp() {
53          validator = new SubmitObjectsRequestValidator();
54          factory = new EbXMLFactory30();
55          
56          request = SampleData.createProvideAndRegisterDocumentSet();
57          transformer = new ProvideAndRegisterDocumentSetTransformer(factory);
58  
59          docEntry = request.getDocuments().get(0).getDocumentEntry();
60      }
61      
62      @Test
63      public void testValidateGoodCase() {
64          validator.validate(transformer.toEbXML(request), ITI_42);
65      }
66      
67      @Test
68      public void testValidateBadAuthorInstitution() {
69          docEntry.getAuthors().get(0).getAuthorInstitution().add(new Organization(null, "LOL", null));
70          expectFailure(ORGANIZATION_NAME_MISSING);            
71      }
72  
73      @Test
74      public void testValidateTooManyAuthorPersons() {
75          EbXMLProvideAndRegisterDocumentSetRequest ebXML = transformer.toEbXML(request);
76          ebXML.getExtrinsicObjects().get(0).getClassifications().get(0).getSlots().get(0).getValueList().add("bla");
77          expectFailure(WRONG_NUMBER_OF_SLOT_VALUES, ebXML);
78      }
79      
80      @Test
81      public void testValidateFolderHasInvalidAvailabilityStatus() {
82          request.getFolders().get(0).setAvailabilityStatus(AvailabilityStatus.DEPRECATED);
83          expectFailure(FOLDER_INVALID_AVAILABILITY_STATUS);
84      }
85  
86      @Test
87      public void testValidateSubmissionSetHasInvalidAvailabilityStatus() {
88          request.getSubmissionSet().setAvailabilityStatus(AvailabilityStatus.DEPRECATED);
89          expectFailure(SUBMISSION_SET_INVALID_AVAILABILITY_STATUS);
90      }
91  
92      @Test
93      public void testValidateExactlyOneSubmissionSetMustExist() {
94          EbXMLProvideAndRegisterDocumentSetRequest ebXML = transformer.toEbXML(request);
95          EbXMLRegistryPackage regPackage = factory.createRegistryPackage("lol", ebXML.getObjectLibrary());
96          ebXML.addRegistryPackage(regPackage);
97          EbXMLClassification classification = factory.createClassification(ebXML.getObjectLibrary());
98          classification.setClassifiedObject("lol");
99          classification.setClassificationNode(Vocabulary.SUBMISSION_SET_CLASS_NODE);
100         ebXML.addClassification(classification);
101         docEntry.setAvailabilityStatus(AvailabilityStatus.SUBMITTED);
102         expectFailure(EXACTLY_ONE_SUBMISSION_SET_MUST_EXIST, ebXML);
103     }
104     
105     @Test
106     public void testInvalidTitleEncoding() {
107         docEntry.setTitle(new LocalizedString("lol", "lol", "lol"));
108         expectFailure(INVALID_TITLE_ENCODING);
109     }
110 
111     @Test
112     public void testTitleTooLong() {
113         docEntry.setTitle(new LocalizedString("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"));
114         expectFailure(TITLE_TOO_LONG);
115     }
116 
117     @Test
118     public void testUniqueIdMissing() {
119         request.getFolders().get(0).setUniqueId(null);
120         expectFailure(UNIQUE_ID_MISSING);
121     }
122 
123     @Test
124     public void testUniqueIdTooLong() {
125         request.getFolders().get(0).setUniqueId("123456789012345678901234567890123456789012345678901234567890123451234567890123456789012345678901234567890123456789012345678901234");
126         expectFailure(UNIQUE_ID_TOO_LONG);
127     }
128 
129     @Test
130     public void testUUIDNotUnique() {
131         request.getFolders().get(0).setEntryUuid("id");
132         docEntry.setEntryUuid("id");
133         expectFailure(UUID_NOT_UNIQUE);
134     }
135 
136     @Test
137     public void testDocEntryPatientIdWrong() {
138         docEntry.setPatientId(new Identifiable("lol", new AssigningAuthority("1.3")));
139         expectFailure(DOC_ENTRY_PATIENT_ID_WRONG);
140     }
141     
142     @Test
143     public void testFolderPatientIdWrong() {
144         request.getFolders().get(0).setPatientId(new Identifiable("lol", new AssigningAuthority("1.3")));
145         expectFailure(FOLDER_PATIENT_ID_WRONG);
146     }
147     
148     @Test
149     public void testInvalidAssociationType() {
150         request.getAssociations().get(0).setAssociationType(null);
151         expectFailure(INVALID_ASSOCIATION_TYPE);
152     }
153 
154     @Test
155     public void testHasMemberShouldNotHaveDocCode() {
156         request.getAssociations().get(0).setDocCode(new Code("docCode1", new LocalizedString("docCode1"), "docScheme1"));
157         expectFailure(DOC_CODE_NOT_ALLOWED_ON_HAS_MEMBER);
158     }
159 
160     @Test
161     public void testTooManySubmissionSetStates() {
162         EbXMLProvideAndRegisterDocumentSetRequest ebXML = transformer.toEbXML(request);
163         ebXML.getAssociations().get(0).getSlots(SLOT_NAME_SUBMISSION_SET_STATUS).get(0).getValueList().add("lol");
164         expectFailure(TOO_MANY_SUBMISSION_SET_STATES, ebXML);
165     }
166 
167     @Test
168     public void testInvalidSubmissionSetStatus() {
169         EbXMLProvideAndRegisterDocumentSetRequest ebXML = transformer.toEbXML(request);
170         ebXML.getAssociations().get(0).getSlots(SLOT_NAME_SUBMISSION_SET_STATUS).get(0).getValueList().set(0, "lol");
171         expectFailure(INVALID_SUBMISSION_SET_STATUS, ebXML);
172     }
173 
174     @Test
175     public void testMandatorySubmissionSetStatus() {
176         request.getAssociations().get(0).setLabel(null);
177         expectFailure(SUBMISSION_SET_STATUS_MANDATORY);
178     }
179     
180     @Test
181     public void testMissingOriginal() {
182         request.getAssociations().get(0).setTargetUuid("lol");
183         expectFailure(MISSING_ORIGINAL);
184     }
185     
186     @Test
187     public void testSourceUUIDNotFound() {
188         Association association = new Association();
189         association.setTargetUuid("blabla");
190         association.setSourceUuid("lol");
191         association.setAssociationType(AssociationType.TRANSFORM);
192         request.getAssociations().add(association);       
193         expectFailure(SOURCE_UUID_NOT_FOUND);
194     }
195 
196     @Test
197     public void testSourceIsSnapshotAssociation() {
198         Association association = new Association();
199         association.setTargetUuid("urn:uuid:e0985823-dc50-45a5-a6c8-a11a829893bd");
200         association.setSourceUuid("blah");
201         association.setAssociationType(AssociationType.IS_SNAPSHOT_OF);
202         association.setEntryUuid("isSnapshotEntryId");
203         request.getAssociations().add(association);
204         expectFailure(MISSING_SNAPSHOT_ASSOCIATION);
205     }
206 
207     @Test
208     public void testSubmitAssociation() {
209         Association association = new Association();
210         association.setTargetUuid("urn:uuid:aa0da13b-51b0-4c2e-868c-cef8d7e1bc3d");
211         association.setSourceUuid("document01");
212         association.setAssociationType(AssociationType.APPEND);
213         association.setEntryUuid("apnd_assoc");
214         request.getAssociations().add(association);
215 
216         Association submitAssociation = new Association();
217         submitAssociation.setTargetUuid("apnd_assoc1");
218         submitAssociation.setSourceUuid("submissionSet01");
219         submitAssociation.setAssociationType(AssociationType.SUBMIT_ASSOCIATION);
220         submitAssociation.setEntryUuid("submitAssociation");
221         request.getAssociations().add(submitAssociation);
222         expectFailure(MISSING_ASSOCIATION);
223     }
224 
225     @Test    
226     public void testWrongNumberOfClassifications() {
227         docEntry.setFormatCode(null);
228         expectFailure(WRONG_NUMBER_OF_CLASSIFICATIONS);
229     }
230     
231     @Test    
232     public void testNoClassifiedObject() {
233         EbXMLProvideAndRegisterDocumentSetRequest ebXML = transformer.toEbXML(request);
234         ebXML.getExtrinsicObjects().get(0).getClassifications().get(0).setClassifiedObject(null);
235         expectFailure(NO_CLASSIFIED_OBJ, ebXML);
236     }
237     
238     @Test    
239     public void testWrongClassifiedObject() {
240         EbXMLProvideAndRegisterDocumentSetRequest ebXML = transformer.toEbXML(request);
241         ebXML.getExtrinsicObjects().get(0).getClassifications().get(0).setClassifiedObject("folder01");
242         expectFailure(WRONG_CLASSIFIED_OBJ, ebXML);
243     }
244 
245     private static boolean isAuthorClassification(EbXMLClassification classification) {
246         return classification.getClassificationScheme().equals(Vocabulary.DOC_ENTRY_AUTHOR_CLASS_SCHEME) ||
247                classification.getClassificationScheme().equals(Vocabulary.SUBMISSION_SET_AUTHOR_CLASS_SCHEME);
248     }
249 
250     @Test
251     public void testRequiredNodeRepresentationIsNull() {
252         EbXMLProvideAndRegisterDocumentSetRequest ebXML = transformer.toEbXML(request);
253         ebXML.getExtrinsicObjects().get(0).getClassifications().stream()
254                 .filter(x -> !isAuthorClassification(x))
255                 .findAny()
256                 .get()
257                 .setNodeRepresentation(null);
258         expectFailure(NODE_REPRESENTATION_MISSING, ebXML);
259     }
260 
261     @Test
262     public void testRequiredNodeRepresentationIsEmpty() {
263         EbXMLProvideAndRegisterDocumentSetRequest ebXML = transformer.toEbXML(request);
264         ebXML.getExtrinsicObjects().get(0).getClassifications().stream()
265                 .filter(x -> !isAuthorClassification(x))
266                 .findAny()
267                 .get()
268                 .setNodeRepresentation("");
269         expectFailure(NODE_REPRESENTATION_MISSING, ebXML);
270     }
271 
272     @Test
273     public void testProhibitedNodeRepresentationIsNotEmpty() {
274         EbXMLProvideAndRegisterDocumentSetRequest ebXML = transformer.toEbXML(request);
275         EbXMLClassification classification = ebXML.getExtrinsicObjects().get(0).getClassifications().stream()
276                 .filter(x -> isAuthorClassification(x))
277                 .findAny()
278                 .get();
279 
280         classification.setNodeRepresentation(null);
281         validator.validate(ebXML, ITI_42);
282 
283         classification.setNodeRepresentation("");
284         validator.validate(ebXML, ITI_42);
285 
286         classification.setNodeRepresentation("abcd");
287         expectFailure(NODE_REPRESENTATION_PROHIBITED, ebXML);
288     }
289 
290     @Test
291     public void testCXTooManyComponents() {
292         EbXMLProvideAndRegisterDocumentSetRequest ebXML = transformer.toEbXML(request);
293         ebXML.getExtrinsicObjects().get(0).getExternalIdentifiers().get(0).setValue("rotfl^^^^^^^^^lol");
294         expectFailure(CX_TOO_MANY_COMPONENTS, ebXML);
295     }
296     
297     @Test    
298     public void testCXNeedsId() {
299         EbXMLProvideAndRegisterDocumentSetRequest ebXML = transformer.toEbXML(request);
300         ebXML.getExtrinsicObjects().get(0).getExternalIdentifiers().get(0).setValue("");
301         expectFailure(CX_NEEDS_ID, ebXML);
302     }
303     
304     @Test    
305     public void testHDMUstNotHaveNamespaceId() {
306         EbXMLProvideAndRegisterDocumentSetRequest ebXML = transformer.toEbXML(request);
307         ebXML.getExtrinsicObjects().get(0).getExternalIdentifiers().get(0).setValue("12^^^lol&12.3&ISO");
308         expectFailure(HD_MUST_NOT_HAVE_NAMESPACE_ID, ebXML);
309     }
310     
311     @Test    
312     public void testUniversalIDMustBeISO() {
313         EbXMLProvideAndRegisterDocumentSetRequest ebXML = transformer.toEbXML(request);
314         ebXML.getExtrinsicObjects().get(0).getExternalIdentifiers().get(0).setValue("12^^^&12.3&LOL");
315         expectFailure(UNIVERSAL_ID_TYPE_MUST_BE_ISO, ebXML);
316     }
317     
318     @Test    
319     public void testUniversalIDToo() {
320         EbXMLProvideAndRegisterDocumentSetRequest ebXML = transformer.toEbXML(request);
321         ebXML.getExtrinsicObjects().get(0).getExternalIdentifiers().get(0).setValue("12");
322         expectFailure(UNIVERSAL_ID_TYPE_MUST_BE_ISO, ebXML);
323     }
324 
325     @Test
326     public void testHDNeedsUniversalID() {
327         EbXMLProvideAndRegisterDocumentSetRequest ebXML = transformer.toEbXML(request);
328         ebXML.getExtrinsicObjects().get(0).getExternalIdentifiers().get(0).setValue("12^^^&&ISO");
329         expectFailure(HD_NEEDS_UNIVERSAL_ID, ebXML);
330     }
331 
332     @Test    
333     public void testMissingExternalIdentifier() {
334         request.getSubmissionSet().setSourceId(null);
335         expectFailure(MISSING_EXTERNAL_IDENTIFIER);
336     }
337     
338     @Test    
339     public void testInvalidHashCode() {
340         docEntry.setHash("lol");
341         expectFailure(INVALID_HASH_CODE);
342     }
343     
344     @Test    
345     public void testInvalidLanguageCode() {
346         docEntry.setLanguageCode("123lol");
347         expectFailure(INVALID_LANGUAGE_CODE);
348     }
349     
350     @Test    
351     public void testOIDTooLong() {
352         request.getSubmissionSet().setSourceId("12345678901234567890123456789012345678901234567890123456789012345");
353         expectFailure(OID_TOO_LONG);
354     }
355     
356     @Test    
357     public void testInvalidOID() {
358         request.getSubmissionSet().setSourceId("lol");
359         expectFailure(INVALID_OID);
360     }
361         
362     @Test    
363     public void testInvalidPID() {
364         EbXMLProvideAndRegisterDocumentSetRequest ebXML = transformer.toEbXML(request);
365         ebXML.getExtrinsicObjects().get(0).getSlots(Vocabulary.SLOT_NAME_SOURCE_PATIENT_INFO).get(0).getValueList().add("PID-lol|lol");
366         expectFailure(INVALID_PID, ebXML);
367     }
368     
369     @Test    
370     public void testUnsupportedPID() {
371         EbXMLProvideAndRegisterDocumentSetRequest ebXML = transformer.toEbXML(request);
372         ebXML.getExtrinsicObjects().get(0).getSlots(Vocabulary.SLOT_NAME_SOURCE_PATIENT_INFO).get(0).getValueList().add("PID-2|lol");
373         expectFailure(UNSUPPORTED_PID, ebXML);
374     }
375     
376     @Test    
377     public void testInvalidNumberFormat() {
378         EbXMLProvideAndRegisterDocumentSetRequest ebXML = transformer.toEbXML(request);
379         ebXML.getExtrinsicObjects().get(0).getSlots(Vocabulary.SLOT_NAME_SIZE).get(0).getValueList().set(0, "lol");
380         expectFailure(INVALID_NUMBER_FORMAT, ebXML);
381     }
382     
383 //  This check is disabled for compatibility with older versions.
384 //    @Test    
385 //    public void testRecipientListEmpty() {
386 //        EbXMLProvideAndRegisterDocumentSetRequest ebXML = transformer.toEbXML(request);
387 //        ebXML.getRegistryPackages(Vocabulary.SUBMISSION_SET_CLASS_NODE).get(0).getSlots(Vocabulary.SLOT_NAME_INTENDED_RECIPIENT).get(0).getValueList().clear();
388 //        expectFailure(RECIPIENT_LIST_EMPTY, ebXML);
389 //    }
390     
391     @Test    
392     public void testRecipientEmpty() {
393         EbXMLProvideAndRegisterDocumentSetRequest ebXML = transformer.toEbXML(request);
394         ebXML.getRegistryPackages(Vocabulary.SUBMISSION_SET_CLASS_NODE).get(0).getSlots(Vocabulary.SLOT_NAME_INTENDED_RECIPIENT).get(0).getValueList().add("");
395         expectFailure(RECIPIENT_EMPTY, ebXML);
396     }
397     
398     @Test    
399     public void testInvalidRecipient() {
400         EbXMLProvideAndRegisterDocumentSetRequest ebXML = transformer.toEbXML(request);
401         ebXML.getRegistryPackages(Vocabulary.SUBMISSION_SET_CLASS_NODE).get(0).getSlots(Vocabulary.SLOT_NAME_INTENDED_RECIPIENT).get(0).getValueList().add("|||");
402         expectFailure(INVALID_RECIPIENT, ebXML);
403     }
404     
405     @Test    
406     public void testSlotValueTooLong() {
407         char[] chars = new char[EbXMLSlot30.MAX_SLOT_LENGTH + 1];
408         Arrays.fill(chars, 'x');
409         docEntry.setHash(String.valueOf(chars));
410         expectFailure(SLOT_VALUE_TOO_LONG);
411     }
412     
413     @Test    
414     public void testWrongNumberOfSlotValues() {
415         EbXMLProvideAndRegisterDocumentSetRequest ebXML = transformer.toEbXML(request);
416         ebXML.getExtrinsicObjects().get(0).getSlots(Vocabulary.SLOT_NAME_CREATION_TIME).get(0).getValueList().add("lol");
417         expectFailure(WRONG_NUMBER_OF_SLOT_VALUES, ebXML);
418     }
419     
420     @Test    
421     public void testEmptySlotValue() {
422         EbXMLProvideAndRegisterDocumentSetRequest ebXML = transformer.toEbXML(request);
423         ebXML.getExtrinsicObjects().get(0).getSlots(Vocabulary.SLOT_NAME_CREATION_TIME).get(0).getValueList().set(0, null);
424         expectFailure(EMPTY_SLOT_VALUE, ebXML);
425     }
426     
427     @Test(expected = XDSMetaDataException.class)
428     public void testInvalidTime() {
429         docEntry.setCreationTime("lol");
430     }
431 
432     @Test    
433     public void testMultipleUriValues() {
434         EbXMLProvideAndRegisterDocumentSetRequest ebXML = transformer.toEbXML(request);
435         ebXML.getExtrinsicObjects().get(0).getSlots(Vocabulary.SLOT_NAME_URI).get(0).getValueList().add("second value");
436         assertEquals(2, ebXML.getExtrinsicObjects().get(0).getSlots(Vocabulary.SLOT_NAME_URI).get(0).getValueList().size());
437         expectFailure(WRONG_NUMBER_OF_SLOT_VALUES, ebXML);
438     }
439     
440     @Test    
441     public void testEmptyUri() {
442         EbXMLProvideAndRegisterDocumentSetRequest ebXML = transformer.toEbXML(request);
443         ebXML.getExtrinsicObjects().get(0).getSlots(Vocabulary.SLOT_NAME_URI).get(0).getValueList().set(0, "");
444         expectFailure(EMPTY_URI, ebXML);
445     }
446     
447     @Test    
448     public void testInvalidUri() {
449         EbXMLProvideAndRegisterDocumentSetRequest ebXML = transformer.toEbXML(request);
450         ebXML.getExtrinsicObjects().get(0).getSlots(Vocabulary.SLOT_NAME_URI).get(0).getValueList().set(0, ":lol:");
451         expectFailure(INVALID_URI, ebXML);
452     }
453     
454     @Test    
455     public void testPersonMissingNameAndID() {
456         EbXMLProvideAndRegisterDocumentSetRequest ebXML = transformer.toEbXML(request);
457         ebXML.getExtrinsicObjects().get(0).getClassifications(Vocabulary.DOC_ENTRY_AUTHOR_CLASS_SCHEME).get(0).getSlots().get(0).getValueList().set(0, "^^^^^^^^&1.2.840.113619.6.197&ISO");
458         expectFailure(PERSON_MISSING_NAME_AND_ID, ebXML);
459     }
460     
461     @Test    
462     public void testPersonHDMissing() {
463         EbXMLProvideAndRegisterDocumentSetRequest ebXML = transformer.toEbXML(request);
464         ebXML.getExtrinsicObjects().get(0).getClassifications(Vocabulary.DOC_ENTRY_AUTHOR_CLASS_SCHEME).get(0).getSlots().get(0).getValueList().set(0, "lol");
465         // The spec allows this case: "If component 1 (ID Number) is specified, component 9 (Assigning Authority) shall be present if available"
466         validator.validate(transformer.toEbXML(request), ITI_42);
467     }
468         
469     @Test    
470     public void testOrganizationNameMissing() {
471         EbXMLProvideAndRegisterDocumentSetRequest ebXML = transformer.toEbXML(request);
472         ebXML.getExtrinsicObjects().get(0).getClassifications(Vocabulary.DOC_ENTRY_AUTHOR_CLASS_SCHEME).get(0).getSlots().get(1).getValueList().set(0, "^lol");
473         expectFailure(ORGANIZATION_NAME_MISSING, ebXML);
474     }
475     
476     @Test    
477     public void testOrganizationTooManyComponents() {
478         EbXMLProvideAndRegisterDocumentSetRequest ebXML = transformer.toEbXML(request);
479         ebXML.getExtrinsicObjects().get(0).getClassifications(Vocabulary.DOC_ENTRY_AUTHOR_CLASS_SCHEME).get(0).getSlots().get(1).getValueList().set(0, "Otto^lol");
480         expectFailure(ORGANIZATION_TOO_MANY_COMPONENTS, ebXML);
481     }
482 
483     @Test
484     public void testRepositoryUniqueIdIsNecessaryInXDSB() {
485         docEntry.setRepositoryUniqueId(null);
486         expectFailure(WRONG_NUMBER_OF_SLOT_VALUES);
487     }
488 
489     @Test
490     public void testFolderUpdateTimeLowPrecision() {
491         request.getFolders().get(0).setLastUpdateTime("20170207");
492         expectFailure(TIME_PRECISION_TOO_LOW);
493     }
494 
495     @Test
496     public void testAuthorValidation() {
497         request.getSubmissionSet().getAuthors().clear();
498         EbXMLProvideAndRegisterDocumentSetRequest ebXml = transformer.toEbXML(request);
499         new ObjectContainerValidator().validate(ebXml, ITI_42);
500 
501         Author author = new Author();
502         author.getAuthorRole().add(new Identifiable("clown", new AssigningAuthority("1.3.14.15", "ISO")));
503         request.getSubmissionSet().setAuthor(author);
504         ebXml = transformer.toEbXML(request);
505 
506         boolean failed = false;
507         try {
508             new ObjectContainerValidator().validate(ebXml, ITI_42);
509         } catch (XDSMetaDataException e) {
510             failed = true;
511         }
512 
513         assertTrue(failed);
514     }
515 
516 
517     private void expectFailure(ValidationMessage expectedMessage) {
518         expectFailure(expectedMessage, transformer.toEbXML(request));
519     }
520 
521     private void expectFailure(ValidationMessage expectedMessage, EbXMLSubmitObjectsRequest ebXML) {
522         expectFailure(expectedMessage, ebXML, ITI_42);
523     }
524 
525     private void expectFailure(ValidationMessage expectedMessage, EbXMLSubmitObjectsRequest ebXML, ValidationProfile profile) {
526         try {
527             validator.validate(ebXML, profile);
528             fail("Expected exception: " + XDSMetaDataException.class);
529         }
530         catch (XDSMetaDataException e) {
531             assertEquals(expectedMessage, e.getValidationMessage());
532         }
533     }
534 }