use of com.b2international.commons.json.Json in project snow-owl by b2ihealthcare.
the class SnomedConcreteValueApiTest method createConcreteValueInvalidValue.
@Test
public void createConcreteValueInvalidValue() {
Json requestBody = createConcreteValueRequestBody(Concepts.ROOT_CONCEPT, Concepts.PART_OF, new RelationshipValue(20)).with("value", "2021-06-05").with("commitComment", "Created new concrete value with invalid value");
createComponent(branchPath, SnomedComponentType.RELATIONSHIP, requestBody).statusCode(400);
}
use of com.b2international.commons.json.Json in project snow-owl by b2ihealthcare.
the class SnomedConcreteValueApiTest method createDuplicateConcreteValue.
@Test
public void createDuplicateConcreteValue() {
String relationshipId = createNewConcreteValue(branchPath);
Json requestBody = createConcreteValueRequestBody(Concepts.ROOT_CONCEPT, Concepts.PART_OF, new RelationshipValue("string value")).with("id", relationshipId).with("commitComment", "Created new concrete value with duplicate identifier");
createComponent(branchPath, SnomedComponentType.RELATIONSHIP, requestBody).statusCode(409);
}
use of com.b2international.commons.json.Json in project snow-owl by b2ihealthcare.
the class SnomedModuleDependencyRefsetTest method updateExistingModuleDependencyMembers.
@Test
public void updateExistingModuleDependencyMembers() {
Json conceptRequestBody = createConceptRequestBody(// it must belong to the core module
Concepts.MODULE_ROOT, // it must belong to the core module
Concepts.MODULE_SCT_CORE, SnomedApiTestConstants.UK_PREFERRED_MAP).with("commitComment", "Created concept with INT core module");
String conceptId = createConcept(SnomedContentRule.SNOMEDCT, conceptRequestBody);
assertThat(getConcept(SnomedContentRule.SNOMEDCT, conceptId).getEffectiveTime()).isNull();
// version branch
final LocalDate versionEffectiveTime = getNextAvailableEffectiveDate(SnomedContentRule.SNOMEDCT_ID);
final String versionId = "updateExistingModuleDependencyMembers";
createVersion(SnomedContentRule.SNOMEDCT_ID, versionId, versionEffectiveTime).statusCode(201);
assertGetVersion(SnomedContentRule.SNOMEDCT_ID, versionId).statusCode(200);
assertThat(getConcept(SnomedContentRule.SNOMEDCT, conceptId).getEffectiveTime()).isEqualTo(versionEffectiveTime);
SnomedReferenceSetMembers coreModuleDependencyMembersAfterVersioning = SnomedRequests.prepareSearchMember().all().filterByActive(true).filterByModule(// filter for members where the module id is the SCT core module
Concepts.MODULE_SCT_CORE).filterByRefSet(Concepts.REFSET_MODULE_DEPENDENCY_TYPE).build(SnomedContentRule.SNOMEDCT).execute(getBus()).getSync();
for (SnomedReferenceSetMember member : coreModuleDependencyMembersAfterVersioning) {
assertEquals(versionEffectiveTime, member.getEffectiveTime());
}
}
use of com.b2international.commons.json.Json in project snow-owl by b2ihealthcare.
the class SnomedModuleDependencyRefsetTest method updateRelevantModDepMembersForExtensionVersions.
@Test
public void updateRelevantModDepMembersForExtensionVersions() {
final String shortName = "SNOMEDCT-MODULEDEPENDENCY";
createCodeSystem(branchPath, shortName).statusCode(201);
Set<String> INT_MODULE_IDS = Set.of(Concepts.MODULE_SCT_MODEL_COMPONENT, Concepts.MODULE_SCT_CORE, ICD_10_MAPPING_MODULE);
Map<Pair<String, String>, LocalDate> moduleToReferencedComponentAndEffectiveDateMap = Maps.newHashMap();
SnomedReferenceSetMembers intModuleDependencyMembers = SnomedRequests.prepareSearchMember().all().filterByActive(true).filterByRefSet(Concepts.REFSET_MODULE_DEPENDENCY_TYPE).filterByModules(INT_MODULE_IDS).filterByReferencedComponent(INT_MODULE_IDS).build(branchPath.getPath()).execute(getBus()).getSync();
intModuleDependencyMembers.forEach(member -> {
Pair<String, String> pair = Tuples.pair(member.getModuleId(), member.getReferencedComponent().getId());
moduleToReferencedComponentAndEffectiveDateMap.put(pair, member.getEffectiveTime());
});
// create Norwegian module
Json norwegianModuleRequestBody = createConceptRequestBody(Concepts.MODULE_ROOT, NORWEGIAN_MODULE_CONCEPT_ID, SnomedApiTestConstants.UK_PREFERRED_MAP).with("id", NORWEGIAN_MODULE_CONCEPT_ID).with("commitComment", "Created norwegian module concept");
createComponent(branchPath, SnomedComponentType.CONCEPT, norwegianModuleRequestBody).statusCode(201);
// create both inferred and stated relationships
Json inferredRelationshipRequestBody = SnomedRestFixtures.createRelationshipRequestBody(NORWEGIAN_MODULE_CONCEPT_ID, Concepts.IS_A, Concepts.MODULE_ROOT, NORWEGIAN_MODULE_CONCEPT_ID, Concepts.INFERRED_RELATIONSHIP, 0).with("commitComment", "Created inferred is_a from the norwegian module concept to SCT_MODULE_CORE");
Json statedRelationshipRequestBody = SnomedRestFixtures.createRelationshipRequestBody(NORWEGIAN_MODULE_CONCEPT_ID, Concepts.IS_A, Concepts.MODULE_ROOT, NORWEGIAN_MODULE_CONCEPT_ID, Concepts.STATED_RELATIONSHIP, 0).with("commitComment", "Created state is_a from the norwegian module concept to SCT_MODULE_CORE");
createComponent(branchPath, SnomedComponentType.RELATIONSHIP, inferredRelationshipRequestBody).statusCode(201);
createComponent(branchPath, SnomedComponentType.RELATIONSHIP, statedRelationshipRequestBody).statusCode(201);
// check for the newly created module concept to have effective set to null
SnomedRequests.prepareSearchConcept().filterById(NORWEGIAN_MODULE_CONCEPT_ID).build(branchPath.getPath()).execute(getBus()).getSync().forEach(c -> assertEquals("Effective time must still be null", null, c.getEffectiveTime()));
// version branch
final LocalDate effectiveTime = getNextAvailableEffectiveDate(shortName);
final String versionId = "testForModuleDependencyMembers";
createVersion(shortName, versionId, effectiveTime).statusCode(201);
assertGetVersion(shortName, versionId).statusCode(200);
// check for the newly created module concept after versioning to have effectiveTime set to the correct date
SnomedConcept norwegianModule = SnomedRequests.prepareGetConcept(NORWEGIAN_MODULE_CONCEPT_ID).build(branchPath.getPath()).execute(getBus()).getSync();
assertEquals("Effective time should have been set to the date of versioning", effectiveTime, norwegianModule.getEffectiveTime());
SnomedReferenceSetMembers moduleDependencyMembersAfterVersioning = SnomedRequests.prepareSearchMember().all().filterByActive(true).filterByRefSet(Concepts.REFSET_MODULE_DEPENDENCY_TYPE).build(branchPath.getPath()).execute(getBus()).getSync();
moduleDependencyMembersAfterVersioning.forEach(member -> {
final Pair<String, String> pair = Tuples.pair(member.getModuleId(), member.getReferencedComponent().getId());
final LocalDate originalMemberEffectiveTime = moduleToReferencedComponentAndEffectiveDateMap.get(pair);
if (originalMemberEffectiveTime != null) {
assertEquals(String.format("Effective dates on unaffected existing module dependency members shouldn't be updated after versioning. ModuleID: %s", member.getReferencedComponentId()), originalMemberEffectiveTime, member.getEffectiveTime());
} else {
assertEquals("The new members effective time should match the versionDate", effectiveTime, member.getEffectiveTime());
}
});
}
use of com.b2international.commons.json.Json in project snow-owl by b2ihealthcare.
the class SnomedDescriptionApiTest method updateUnreleasedDescriptionLanguageCode.
@Test
public void updateUnreleasedDescriptionLanguageCode() throws Exception {
String descriptionId = createNewDescription(branchPath);
Json update = Json.object(SnomedRf2Headers.FIELD_LANGUAGE_CODE, "hu", "commitComment", "Update unreleased description languageCode");
updateComponent(branchPath, SnomedComponentType.DESCRIPTION, descriptionId, update).statusCode(204);
getComponent(branchPath, SnomedComponentType.DESCRIPTION, descriptionId).statusCode(200).body(SnomedRf2Headers.FIELD_LANGUAGE_CODE, equalTo("hu"));
}
Aggregations