Add tests

This commit is contained in:
James Agnew 2015-08-09 17:28:29 -04:00
parent 24634880db
commit 28d35fe1fe
2 changed files with 20 additions and 5 deletions

View File

@ -133,6 +133,9 @@ import ca.uhn.fhir.util.ObjectUtil;
@Transactional(propagation = Propagation.REQUIRED)
public abstract class BaseHapiFhirResourceDao<T extends IResource> extends BaseHapiFhirDao implements IFhirResourceDao<T> {
static final String OO_SEVERITY_INFO = "information";
static final String OO_SEVERITY_ERROR = "error";
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BaseHapiFhirResourceDao.class);
@PersistenceContext(type = PersistenceContextType.TRANSACTION)
@ -962,11 +965,11 @@ public abstract class BaseHapiFhirResourceDao<T extends IResource> extends BaseH
}
protected IBaseOperationOutcome createErrorOperationOutcome(String theMessage) {
return createOperationOutcome(IssueSeverityEnum.ERROR.getCode(), theMessage);
return createOperationOutcome(OO_SEVERITY_ERROR, theMessage);
}
protected IBaseOperationOutcome createInfoOperationOutcome(String theMessage) {
return createOperationOutcome(IssueSeverityEnum.INFORMATION.getCode(), theMessage);
return createOperationOutcome(OO_SEVERITY_INFO, theMessage);
}
protected abstract IBaseOperationOutcome createOperationOutcome(String theSeverity, String theMessage);

View File

@ -36,9 +36,6 @@ import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.jmx.access.InvalidInvocationException;
import com.ctc.wstx.util.StringUtil;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamString;
@ -115,6 +112,21 @@ public class FhirResourceDaoDstu2Test extends BaseJpaTest {
private static IFhirResourceDao<Questionnaire> ourQuestionnaireDao;
private static IFhirSystemDao<Bundle> ourSystemDao;
@Test
public void testCreateOperationOutcome() {
/*
* If any of this ever fails, it means that one of the OperationOutcome
* issue severity codes has changed code value across versions. We store
* the string as a constant, so something will need to be fixed.
*/
assertEquals(org.hl7.fhir.instance.model.OperationOutcome.IssueSeverity.ERROR.toCode(), BaseHapiFhirResourceDao.OO_SEVERITY_ERROR);
assertEquals(ca.uhn.fhir.model.dstu.valueset.IssueSeverityEnum.ERROR.getCode(), BaseHapiFhirResourceDao.OO_SEVERITY_ERROR);
assertEquals(ca.uhn.fhir.model.dstu2.valueset.IssueSeverityEnum.ERROR.getCode(), BaseHapiFhirResourceDao.OO_SEVERITY_ERROR);
assertEquals(org.hl7.fhir.instance.model.OperationOutcome.IssueSeverity.INFORMATION.toCode(), BaseHapiFhirResourceDao.OO_SEVERITY_INFO);
assertEquals(ca.uhn.fhir.model.dstu.valueset.IssueSeverityEnum.INFORMATION.getCode(), BaseHapiFhirResourceDao.OO_SEVERITY_INFO);
assertEquals(ca.uhn.fhir.model.dstu2.valueset.IssueSeverityEnum.INFORMATION.getCode(), BaseHapiFhirResourceDao.OO_SEVERITY_INFO);
}
@Test
public void testChoiceParamConcept() {
Observation o1 = new Observation();