Search in sources :

Example 26 with Json

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);
}
Also used : Json(com.b2international.commons.json.Json) RelationshipValue(com.b2international.snowowl.snomed.core.domain.RelationshipValue) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 27 with Json

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);
}
Also used : Json(com.b2international.commons.json.Json) RelationshipValue(com.b2international.snowowl.snomed.core.domain.RelationshipValue) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 28 with Json

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());
    }
}
Also used : SnomedReferenceSetMember(com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMember) SnomedReferenceSetMembers(com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMembers) Json(com.b2international.commons.json.Json) LocalDate(java.time.LocalDate) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 29 with Json

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());
        }
    });
}
Also used : SnomedReferenceSetMembers(com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMembers) Json(com.b2international.commons.json.Json) SnomedConcept(com.b2international.snowowl.snomed.core.domain.SnomedConcept) LocalDate(java.time.LocalDate) Pair(org.eclipse.xtext.util.Pair) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 30 with Json

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"));
}
Also used : Json(com.b2international.commons.json.Json) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest) Test(org.junit.Test)

Aggregations

Json (com.b2international.commons.json.Json)139 Test (org.junit.Test)134 AbstractSnomedApiTest (com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)111 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)33 LocalDate (java.time.LocalDate)17 RelationshipValue (com.b2international.snowowl.snomed.core.domain.RelationshipValue)11 SnomedDescription (com.b2international.snowowl.snomed.core.domain.SnomedDescription)11 SnomedReferenceSetMember (com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMember)11 BaseResourceApiTest (com.b2international.snowowl.core.rest.BaseResourceApiTest)10 SnomedReferenceSetMembers (com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMembers)10 CodeSystem (com.b2international.snowowl.core.codesystem.CodeSystem)7 ISnomedIdentifierService (com.b2international.snowowl.snomed.cis.ISnomedIdentifierService)6 SnomedConcept (com.b2international.snowowl.snomed.core.domain.SnomedConcept)6 SctId (com.b2international.snowowl.snomed.cis.domain.SctId)4 Pair (com.b2international.commons.Pair)3 ValidatableResponse (io.restassured.response.ValidatableResponse)3 File (java.io.File)3 NotFoundException (com.b2international.commons.exceptions.NotFoundException)2 IBranchPath (com.b2international.snowowl.core.api.IBranchPath)2 TransactionContext (com.b2international.snowowl.core.domain.TransactionContext)2