/** * @return a sample query response using leaf class return type. */ public static QueryResponse createQueryResponseWithLeafClass(Status status, Identifiable... patientIDs) { QueryResponse response = new QueryResponse(); for (Identifiable patientID : patientIDs) { SubmissionSet submissionSet = createSubmissionSet(patientID); DocumentEntry docEntry = createDocumentEntry(patientID); Folder folder = createFolder(patientID); Association docAssociation = createAssociationDocEntryToSubmissionSet(); Association folderAssociation = createAssociationFolderToSubmissionSet(); Association docFolderAssociation = createAssociationDocEntryToFolder(); response.getSubmissionSets().add(submissionSet); response.getDocumentEntries().add(docEntry); response.getFolders().add(folder); response.getAssociations().add(docAssociation); response.getAssociations().add(folderAssociation); response.getAssociations().add(docFolderAssociation); } response.setStatus(status); return response; }
protected AdhocQueryResponse processRequest(AdhocQueryRequest body) { Exchange result = process(body); Exception exception = Exchanges.extractException(result); if (exception != null) { log.debug(getClass().getSimpleName() + " service failed", exception); QueryResponse errorResponse = new QueryResponse( exception, ErrorCode.REGISTRY_METADATA_ERROR, ErrorCode.REGISTRY_ERROR, homeCommunityId); errorResponse.getErrors().get(0).setLocation(homeCommunityId); return EbXML30Converters.convert(errorResponse); } return Exchanges.resultMessage(result).getBody(AdhocQueryResponse.class); } }
/** * @return a sample query response using object reference return type. */ public static QueryResponse createQueryResponseWithObjRef() { ObjectReference ref1 = new ObjectReference("ref1"); ObjectReference ref2 = new ObjectReference("ref2"); QueryResponse response = new QueryResponse(); response.setStatus(Status.SUCCESS); response.getReferences().add(ref1); response.getReferences().add(ref2); return response; }
@Test public void testFromEbXMLEmpty() { EbXMLQueryResponse ebXML = transformer.toEbXML(new QueryResponse()); assertEquals(new QueryResponse(), transformer.fromEbXML(ebXML)); } }
@Before public void setUp() { validator = new QueryResponseValidator(); EbXMLFactory factory = new EbXMLFactory30(); response = SampleData.createQueryResponseWithLeafClass(); transformer = new QueryResponseTransformer(factory); docEntry = response.getDocumentEntries().get(0); }
@Test public void testQueryResponseDoesNotHaveSubmissionSetLimitations() { response.getSubmissionSets().clear(); validator.validate(transformer.toEbXML(response), ITI_18); }
@Test public void testValidateDelegatesToRegistryResponseValidator() { // Try a failure that is produced by the RegistryResponseValidator response.setStatus(null); expectFailure(INVALID_STATUS_IN_RESPONSE); }
@Test public void testMissingObjRef() { response.getReferences().add(new ObjectReference()); expectFailure(MISSING_OBJ_REF); }
@Test public void testQueryResponseMultiplePatientIdsDueToFolder() { Identifiable otherId = new Identifiable("idbla", new AssigningAuthority("1.6")); Folder folderOtherPatientId = SampleData.createFolder(otherId); response.getFolders().add(folderOtherPatientId); expectFailure(RESULT_NOT_SINGLE_PATIENT); }
@Test public void testToEbXMLEmpty() { EbXMLQueryResponse result = transformer.toEbXML(new QueryResponse()); assertNotNull(result); assertEquals(0, result.getAssociations().size()); assertEquals(0, result.getExtrinsicObjects().size()); assertEquals(0, result.getRegistryPackages().size()); }
@Test public void testQueryResponseMultiplePatientIdsDueToDocEntry() { Identifiable otherId = new Identifiable("idbla", new AssigningAuthority("1.6")); DocumentEntry docEntryOtherPatientId = SampleData.createDocumentEntry(otherId); response.getDocumentEntries().add(docEntryOtherPatientId); expectFailure(RESULT_NOT_SINGLE_PATIENT); }
@Test public void testQueryResponseMultiplePatientIdsDueToSubmissionSet() { Identifiable otherId = new Identifiable("idbla", new AssigningAuthority("1.6")); SubmissionSet submissionSetOtherPatientId = SampleData.createSubmissionSet(otherId); response.getSubmissionSets().add(submissionSetOtherPatientId); expectFailure(RESULT_NOT_SINGLE_PATIENT); }