Skip to content

Commit

Permalink
oehf#18: First throw of XDS repository and registry mock. Commiting a…
Browse files Browse the repository at this point in the history
… prelimenary result.
  • Loading branch information
bmehner committed Jul 17, 2012
1 parent 1c20cd9 commit 02612cd
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public QueryResponse registryStoredQuery(FindDocumentsQuery query) {
List<DocumentEntry> documentEntries = registry.get(patientId);
QueryResponse queryResponse = new QueryResponse();
queryResponse.setDocumentEntries(documentEntries);
queryResponse.setStatus(Status.SUCCESS);
return queryResponse;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,34 @@ public class XdsRouteBuilder extends SpringRouteBuilder {

@Override
public void configure() throws Exception {

from("xds-iti18:registryStoredQuery?audit=false")
.process(new Processor(){

@Override
public void process(Exchange exchange) throws Exception {
System.out.println(exchange);
}

})
.process(XdsCamelValidators.iti18RequestValidator())
.process(new Processor(){

@Override
public void process(Exchange exchange) throws Exception {
System.out.println(exchange);
}

})
.beanRef("registryRepositoryService", "registryStoredQuery")
.process(new Processor(){

@Override
public void process(Exchange exchange) throws Exception {
System.out.println(exchange);
}

})
// .process(new Processor() {
// @Override
// public void process(Exchange exchange) throws Exception {
Expand All @@ -39,6 +63,14 @@ public void configure() throws Exception {

from("xds-iti41:provideAndRegister?audit=false")
.process(XdsCamelValidators.iti41RequestValidator())
.process(new Processor(){

@Override
public void process(Exchange exchange) throws Exception {
System.out.println(exchange);
}

})
.beanRef("registryRepositoryService", "provideAndRegister")
.process(new Processor() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,25 @@
*******************************************************************************/
package org.openehealth.coala.mocks.xds;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.*;
import static org.openehealth.coala.mocks.xds.XdsTestUtils.createProvideAndRegisterDocumentSet;

import java.util.List;

import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.impl.DefaultExchange;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openehealth.coala.mocks.JettyStarter;
import org.openehealth.ipf.commons.ihe.xds.core.metadata.AssigningAuthority;
import org.openehealth.ipf.commons.ihe.xds.core.metadata.DocumentEntry;
import org.openehealth.ipf.commons.ihe.xds.core.metadata.Identifiable;
import org.openehealth.ipf.commons.ihe.xds.core.requests.ProvideAndRegisterDocumentSet;
import org.openehealth.ipf.commons.ihe.xds.core.requests.QueryRegistry;
import org.openehealth.ipf.commons.ihe.xds.core.requests.query.FindDocumentsQuery;
import org.openehealth.ipf.commons.ihe.xds.core.responses.QueryResponse;
import org.openehealth.ipf.commons.ihe.xds.core.responses.Response;
import org.openehealth.ipf.commons.ihe.xds.core.responses.Status;
import org.openehealth.ipf.platform.camel.core.util.Exchanges;
Expand All @@ -35,8 +43,10 @@
public class XdsRouteBuilderTest {

private static final int PORT = 8766;
private static final String URI = "xds-iti41://localhost:" + PORT + "/provideAndRegister?audit=false";
private static final String URI_PROVIDE_AND_REGISTER = "xds-iti41://localhost:" + PORT + "/provideAndRegister?audit=false";
private static final String URI_QUERY_REGISTRY = "xds-iti18://localhost:" + PORT + "/registryStoredQuery?audit=false";


static ApplicationContext appContext;
static ProducerTemplate template;
static CamelContext context;
Expand All @@ -49,16 +59,50 @@ public static void startServer() {
}

@Test
public void testRouteSetup() throws Exception {
public void testProvideAndRegisterIti41() throws Exception {
Exchange exchange = new DefaultExchange(context);

ProvideAndRegisterDocumentSet request = createProvideAndRegisterDocumentSet();
exchange.getIn().setBody(request);
Exchange result = template.send(URI, exchange);
Exchange result = template.send(URI_PROVIDE_AND_REGISTER, exchange);
Response response = Exchanges.resultMessage(result).getBody(Response.class);
assertEquals(Status.SUCCESS, response.getStatus());
}

@Test
public void testQueryRegistryIti18() throws Exception {
Exchange exchange = new DefaultExchange(context);

ProvideAndRegisterDocumentSet request = createProvideAndRegisterDocumentSet();
Identifiable patientId = request.getDocuments().get(0).getDocumentEntry().getPatientId();
String testId = "42";
patientId.setId(testId);
exchange.getIn().setBody(request);
Exchange result = template.send(URI_PROVIDE_AND_REGISTER, exchange);
Response response = Exchanges.resultMessage(result).getBody(Response.class);
assertEquals(Status.SUCCESS, response.getStatus());

Exchange requestExchange = new DefaultExchange(context);

FindDocumentsQuery query = new FindDocumentsQuery();
query.setPatientId(patientId);

// setting status of documents as given by parameter (method caller)
//query.setStatus(availabilityStati);

// Prepare request
QueryRegistry queryRegistry = new QueryRegistry(query);
queryRegistry.setReturnLeafObjects(true);
requestExchange.getIn().setBody(queryRegistry);

Exchange result2 = template.send(URI_QUERY_REGISTRY, requestExchange);
QueryResponse queryResponse = Exchanges.resultMessage(result2).getBody(QueryResponse.class);
assertNotNull("Query Response is null, but should not be so.", queryResponse);
assertEquals(Status.SUCCESS, queryResponse.getStatus());
List<DocumentEntry> documentEntries = queryResponse.getDocumentEntries();
assertEquals(1, documentEntries.size());

}



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,16 +158,13 @@ private void checkAndSetXDSConfiguration(XDSConfigurationImpl configuration)
public List<DocumentEntry> getConsentDocumentList(String pid,
List<AvailabilityStatus> availabilityStati)
throws XDSRequestFailedException {
// check parameters

checkParametersGetConsentList(pid, availabilityStati);
// prepare request
Exchange requestExchange = prepareConsentListRequest(pid,
availabilityStati);
// send request
Exchange responseExchange = producerTemplate.send(xdsIti18endpoint,
requestExchange);

// process response
if (responseExchange != null && responseExchange.getOut() != null
&& responseExchange.getOut().getBody() != null) {
QueryResponse resp = responseExchange.getOut().getBody(
Expand Down

0 comments on commit 02612cd

Please sign in to comment.