Fix broken ITs.
Add error message for non-snapshot upload with current version = false combination.
This commit is contained in:
parent
1ff1954cba
commit
45549d2bb9
|
@ -5,6 +5,7 @@ import ca.uhn.fhir.jpa.entity.TermCodeSystemVersion;
|
|||
import ca.uhn.fhir.jpa.entity.TermConcept;
|
||||
import ca.uhn.fhir.jpa.entity.TermConceptParentChildLink;
|
||||
import ca.uhn.fhir.jpa.entity.TermConceptProperty;
|
||||
import ca.uhn.fhir.jpa.model.util.JpaConstants;
|
||||
import ca.uhn.fhir.jpa.term.api.ITermCodeSystemStorageSvc;
|
||||
import ca.uhn.fhir.jpa.term.api.ITermDeferredStorageSvc;
|
||||
import ca.uhn.fhir.jpa.term.api.ITermLoaderSvc;
|
||||
|
@ -228,13 +229,15 @@ public class TermLoaderSvcImpl implements ITermLoaderSvc {
|
|||
|
||||
if (StringUtils.isBlank(codeSystemVersionId) && ! isMakeCurrentVersion) {
|
||||
throw new InvalidRequestException("'" + LOINC_CODESYSTEM_VERSION.getCode() +
|
||||
"' property is required when 'current-version' property is 'false'");
|
||||
"' property is required when '" + LOINC_CODESYSTEM_MAKE_CURRENT.getCode() + "' property is 'false'");
|
||||
}
|
||||
|
||||
//todo: is this the case?. Check with client
|
||||
// if (! isMakeCurrentVersion && mode != ModeEnum.SNAPSHOT) {
|
||||
// throw new ParseException("Delta operations must use (or default to) " + CURRENT_VERSION + "=true parameter");
|
||||
// }
|
||||
if (! isMakeCurrentVersion
|
||||
&& theRequestDetails.getOperation() != null
|
||||
&& ! theRequestDetails.getOperation().equals(JpaConstants.OPERATION_UPLOAD_EXTERNAL_CODE_SYSTEM)) {
|
||||
throw new InvalidRequestException("Delta operations require '" + LOINC_CODESYSTEM_MAKE_CURRENT.getCode() +
|
||||
"' parameter set (or defaulted to) 'true'");
|
||||
}
|
||||
|
||||
List<String> mandatoryFilenameFragments = Arrays.asList(
|
||||
uploadProperties.getProperty(LOINC_ANSWERLIST_FILE.getCode(), LOINC_ANSWERLIST_FILE_DEFAULT.getCode()),
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.hl7.fhir.r4.model.ValueSet;
|
|||
import org.hl7.fhir.r4.model.ValueSet.ConceptReferenceComponent;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Answers;
|
||||
|
@ -42,8 +43,10 @@ import org.springframework.transaction.PlatformTransactionManager;
|
|||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static ca.uhn.fhir.jpa.term.api.ITermCodeSystemStorageSvc.MAKE_LOADING_VERSION_CURRENT;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@RequiresDocker
|
||||
|
@ -83,6 +86,13 @@ public class FhirResourceDaoR4TerminologyElasticsearchIT extends BaseJpaTest {
|
|||
@Autowired
|
||||
private IBulkDataExportSvc myBulkDataExportSvc;
|
||||
|
||||
|
||||
@BeforeEach
|
||||
public void beforeEach() {
|
||||
when(mySrd.getUserData().getOrDefault(MAKE_LOADING_VERSION_CURRENT, Boolean.TRUE)).thenReturn(Boolean.TRUE);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testExpandWithIncludeContainingDashesInInclude() {
|
||||
CodeSystem codeSystem = new CodeSystem();
|
||||
|
|
|
@ -6,6 +6,7 @@ import ca.uhn.fhir.jpa.entity.TermCodeSystemVersion;
|
|||
import ca.uhn.fhir.jpa.entity.TermConcept;
|
||||
import ca.uhn.fhir.jpa.entity.TermConceptDesignation;
|
||||
import ca.uhn.fhir.jpa.entity.TermConceptProperty;
|
||||
import ca.uhn.fhir.jpa.model.util.JpaConstants;
|
||||
import ca.uhn.fhir.jpa.term.api.ITermCodeSystemStorageSvc;
|
||||
import ca.uhn.fhir.jpa.term.api.ITermDeferredStorageSvc;
|
||||
import ca.uhn.fhir.jpa.term.api.ITermLoaderSvc;
|
||||
|
@ -85,6 +86,7 @@ import static org.mockito.Mockito.reset;
|
|||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class TerminologyLoaderSvcLoincTest extends BaseLoaderTest {
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(TerminologyLoaderSvcLoincTest.class);
|
||||
|
@ -856,6 +858,7 @@ public class TerminologyLoaderSvcLoincTest extends BaseLoaderTest {
|
|||
void beforeEach() {
|
||||
testedSvc = spy(mySvc);
|
||||
doReturn(testProps).when(testedSvc).getProperties(any(), eq(LOINC_UPLOAD_PROPERTIES_FILE.getCode()));
|
||||
requestDetails.setOperation(JpaConstants.OPERATION_UPLOAD_EXTERNAL_CODE_SYSTEM);
|
||||
}
|
||||
|
||||
|
||||
|
@ -932,10 +935,25 @@ public class TerminologyLoaderSvcLoincTest extends BaseLoaderTest {
|
|||
InvalidRequestException thrown = Assertions.assertThrows(InvalidRequestException.class,
|
||||
() -> testedSvc.loadLoinc(mockFileDescriptorList, mySrd) );
|
||||
|
||||
assertEquals("'" + LOINC_CODESYSTEM_VERSION.getCode() +
|
||||
"' property is required when 'current-version' property is 'false'", thrown.getMessage());
|
||||
assertEquals("'" + LOINC_CODESYSTEM_VERSION.getCode() + "' property is required when '" +
|
||||
LOINC_CODESYSTEM_MAKE_CURRENT.getCode() + "' property is 'false'", thrown.getMessage());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testNoSnapshotAndNoMakeCurrentThrows() {
|
||||
testProps.put(LOINC_CODESYSTEM_MAKE_CURRENT.getCode(), "false");
|
||||
testProps.put(LOINC_CODESYSTEM_VERSION.getCode(), "27.0");
|
||||
when(mySrd.getOperation()).thenReturn(JpaConstants.OPERATION_APPLY_CODESYSTEM_DELTA_ADD);
|
||||
doReturn(mockFileDescriptors).when(testedSvc).getLoadedFileDescriptors(mockFileDescriptorList);
|
||||
|
||||
InvalidRequestException thrown = Assertions.assertThrows(InvalidRequestException.class,
|
||||
() -> testedSvc.loadLoinc(mockFileDescriptorList, mySrd) );
|
||||
|
||||
assertEquals("Delta operations require '" + LOINC_CODESYSTEM_MAKE_CURRENT.getCode() +
|
||||
"' parameter set (or defaulted to) 'true'", thrown.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ import org.hl7.fhir.r4.model.CodeableConcept;
|
|||
import org.hl7.fhir.r4.model.Coding;
|
||||
import org.hl7.fhir.r4.model.ValueSet;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Answers;
|
||||
|
@ -40,6 +41,7 @@ import org.springframework.test.context.ContextConfiguration;
|
|||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
|
||||
import static ca.uhn.fhir.jpa.term.api.ITermCodeSystemStorageSvc.MAKE_LOADING_VERSION_CURRENT;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import static org.mockito.ArgumentMatchers.anyCollection;
|
||||
|
@ -90,6 +92,13 @@ public class ValueSetExpansionR4ElasticsearchIT extends BaseJpaTest {
|
|||
@Mock
|
||||
private IValueSetConceptAccumulator myValueSetCodeAccumulator;
|
||||
|
||||
|
||||
@BeforeEach
|
||||
public void beforeEach() {
|
||||
when(mySrd.getUserData().getOrDefault(MAKE_LOADING_VERSION_CURRENT, Boolean.TRUE)).thenReturn(Boolean.TRUE);
|
||||
}
|
||||
|
||||
|
||||
@AfterEach
|
||||
public void after() {
|
||||
myDaoConfig.setMaximumExpansionSize(DaoConfig.DEFAULT_MAX_EXPANSION_SIZE);
|
||||
|
|
Loading…
Reference in New Issue