Search in sources :

Example 6 with Json

use of com.b2international.commons.json.Json in project snow-owl by b2ihealthcare.

the class SnomedRefSetMemberApiTest method searchOWLAxiomRefsetMemberBySourceTypeDestination.

@Test
public void searchOWLAxiomRefsetMemberBySourceTypeDestination() {
    String conceptId = createNewConcept(branchPath);
    Json requestBody = createRefSetMemberRequestBody(Concepts.REFSET_OWL_AXIOM, conceptId).with(SnomedRf2Headers.FIELD_OWL_EXPRESSION, "SubClassOf(:" + conceptId + " :" + Concepts.NAMESPACE_ROOT + ")").with("commitComment", "Created new OWL Axiom reference set member");
    String memberId = assertCreated(createComponent(branchPath, SnomedComponentType.MEMBER, requestBody));
    SnomedReferenceSetMembers results = givenAuthenticatedRequest(SnomedApiTestConstants.SCT_API).queryParam("referencedComponentId", conceptId).queryParam("owlExpression.typeId", Concepts.IS_A).queryParam("owlExpression.destinationId", Concepts.NAMESPACE_ROOT).get("/{path}/members", branchPath.getPath()).then().extract().as(SnomedReferenceSetMembers.class);
    assertEquals(1, results.getItems().size());
    SnomedReferenceSetMember member = results.getItems().stream().findFirst().get();
    assertEquals(memberId, member.getId());
}
Also used : SnomedReferenceSetMember(com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMember) SnomedReferenceSetMembers(com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMembers) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Json(com.b2international.commons.json.Json) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 7 with Json

use of com.b2international.commons.json.Json in project snow-owl by b2ihealthcare.

the class SnomedRefSetMemberApiTest method createMRCMAttributeDomainMember.

@Test
public void createMRCMAttributeDomainMember() {
    String newIdentifierConceptId = createNewConcept(branchPath, SnomedRefSetUtil.getParentConceptId(SnomedRefSetType.MRCM_ATTRIBUTE_DOMAIN));
    createNewRefSet(branchPath, SnomedRefSetType.MRCM_ATTRIBUTE_DOMAIN, newIdentifierConceptId);
    Json requestBody = createRefSetMemberRequestBody(newIdentifierConceptId, Concepts.ROOT_CONCEPT).with(Json.object(SnomedRf2Headers.FIELD_MRCM_DOMAIN_ID, Concepts.ROOT_CONCEPT, SnomedRf2Headers.FIELD_MRCM_GROUPED, Boolean.TRUE, SnomedRf2Headers.FIELD_MRCM_ATTRIBUTE_CARDINALITY, "attributeCardinality", SnomedRf2Headers.FIELD_MRCM_ATTRIBUTE_IN_GROUP_CARDINALITY, "attributeInGroupCardinality", SnomedRf2Headers.FIELD_MRCM_RULE_STRENGTH_ID, Concepts.ROOT_CONCEPT, SnomedRf2Headers.FIELD_MRCM_CONTENT_TYPE_ID, Concepts.ROOT_CONCEPT, "commitComment", "Created new reference set member"));
    String memberId = assertCreated(createComponent(branchPath, SnomedComponentType.MEMBER, requestBody));
    getComponent(branchPath, SnomedComponentType.MEMBER, memberId).statusCode(200).body(SnomedRf2Headers.FIELD_MRCM_DOMAIN_ID, equalTo(Concepts.ROOT_CONCEPT)).body(SnomedRf2Headers.FIELD_MRCM_GROUPED, equalTo(Boolean.TRUE)).body(SnomedRf2Headers.FIELD_MRCM_ATTRIBUTE_CARDINALITY, equalTo("attributeCardinality")).body(SnomedRf2Headers.FIELD_MRCM_ATTRIBUTE_IN_GROUP_CARDINALITY, equalTo("attributeInGroupCardinality")).body(SnomedRf2Headers.FIELD_MRCM_RULE_STRENGTH_ID, equalTo(Concepts.ROOT_CONCEPT)).body(SnomedRf2Headers.FIELD_MRCM_CONTENT_TYPE_ID, equalTo(Concepts.ROOT_CONCEPT));
    Json requestBody2 = createRefSetMemberRequestBody(newIdentifierConceptId, Concepts.ROOT_CONCEPT).with(Json.object(// XXX batman should not be in the test dataset
    SnomedRf2Headers.FIELD_MRCM_DOMAIN_ID, // XXX batman should not be in the test dataset
    "159725002", SnomedRf2Headers.FIELD_MRCM_GROUPED, Boolean.TRUE, SnomedRf2Headers.FIELD_MRCM_ATTRIBUTE_CARDINALITY, "attributeCardinality", SnomedRf2Headers.FIELD_MRCM_ATTRIBUTE_IN_GROUP_CARDINALITY, "attributeInGroupCardinality", SnomedRf2Headers.FIELD_MRCM_RULE_STRENGTH_ID, Concepts.ROOT_CONCEPT, SnomedRf2Headers.FIELD_MRCM_CONTENT_TYPE_ID, Concepts.ROOT_CONCEPT, "commitComment", "Created new reference set member"));
    createComponent(branchPath, SnomedComponentType.MEMBER, requestBody2).statusCode(400);
    Json requestBody3 = createRefSetMemberRequestBody(newIdentifierConceptId, Concepts.ROOT_CONCEPT).with(Json.object(SnomedRf2Headers.FIELD_MRCM_DOMAIN_ID, Concepts.ROOT_CONCEPT, SnomedRf2Headers.FIELD_MRCM_GROUPED, Boolean.TRUE, SnomedRf2Headers.FIELD_MRCM_ATTRIBUTE_CARDINALITY, "attributeCardinality", SnomedRf2Headers.FIELD_MRCM_ATTRIBUTE_IN_GROUP_CARDINALITY, "attributeInGroupCardinality", // XXX batman should not be in the test dataset
    SnomedRf2Headers.FIELD_MRCM_RULE_STRENGTH_ID, // XXX batman should not be in the test dataset
    "159725002", SnomedRf2Headers.FIELD_MRCM_CONTENT_TYPE_ID, Concepts.ROOT_CONCEPT, "commitComment", "Created new reference set member"));
    createComponent(branchPath, SnomedComponentType.MEMBER, requestBody3).statusCode(400);
    Json requestBody4 = createRefSetMemberRequestBody(newIdentifierConceptId, Concepts.ROOT_CONCEPT).with(Json.object(SnomedRf2Headers.FIELD_MRCM_DOMAIN_ID, Concepts.ROOT_CONCEPT, SnomedRf2Headers.FIELD_MRCM_GROUPED, Boolean.TRUE, SnomedRf2Headers.FIELD_MRCM_ATTRIBUTE_CARDINALITY, "attributeCardinality", SnomedRf2Headers.FIELD_MRCM_ATTRIBUTE_IN_GROUP_CARDINALITY, "attributeInGroupCardinality", SnomedRf2Headers.FIELD_MRCM_RULE_STRENGTH_ID, Concepts.ROOT_CONCEPT, // XXX batman should not be in the test dataset
    SnomedRf2Headers.FIELD_MRCM_CONTENT_TYPE_ID, // XXX batman should not be in the test dataset
    "159725002", "commitComment", "Created new reference set member"));
    createComponent(branchPath, SnomedComponentType.MEMBER, requestBody4).statusCode(400);
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Json(com.b2international.commons.json.Json) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 8 with Json

use of com.b2international.commons.json.Json in project snow-owl by b2ihealthcare.

the class SnomedRefSetMemberApiTest method executeSyncAction.

private void executeSyncAction(final String memberId) {
    final Json syncActionRequest = Json.object("action", "sync", SnomedRf2Headers.FIELD_MODULE_ID, Concepts.MODULE_SCT_CORE, "commitComment", "Executed sync action on reference set member");
    executeMemberAction(branchPath, memberId, syncActionRequest).statusCode(200);
}
Also used : Json(com.b2international.commons.json.Json)

Example 9 with Json

use of com.b2international.commons.json.Json in project snow-owl by b2ihealthcare.

the class SnomedRefSetMemberApiTest method deleteReferringOwlAxiomRefsetMember.

@Test
public void deleteReferringOwlAxiomRefsetMember() {
    String newIdentifierConceptId = createNewConcept(branchPath, SnomedRefSetUtil.getParentConceptId(SnomedRefSetType.OWL_AXIOM));
    createNewRefSet(branchPath, SnomedRefSetType.OWL_AXIOM, newIdentifierConceptId);
    String conceptId = createNewConcept(branchPath);
    Json requestBody = createRefSetMemberRequestBody(newIdentifierConceptId, conceptId).with(SnomedRf2Headers.FIELD_OWL_EXPRESSION, SnomedApiTestConstants.owlAxiom1(conceptId)).with("commitComment", "Created new OWL Axiom reference set member");
    String memberId = assertCreated(createComponent(branchPath, SnomedComponentType.MEMBER, requestBody));
    getComponent(branchPath, SnomedComponentType.MEMBER, memberId).statusCode(200);
    deleteComponent(branchPath, SnomedComponentType.CONCEPT, conceptId, false).statusCode(204);
    getComponent(branchPath, SnomedComponentType.CONCEPT, conceptId).statusCode(404);
    getComponent(branchPath, SnomedComponentType.MEMBER, memberId).statusCode(404);
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Json(com.b2international.commons.json.Json) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 10 with Json

use of com.b2international.commons.json.Json in project snow-owl by b2ihealthcare.

the class SnomedRefSetMemberApiTest method createAndUpdateUnpublishedModuleDependencyMembers.

@Test
public void createAndUpdateUnpublishedModuleDependencyMembers() {
    Json requestBody = createRefSetMemberRequestBody(Concepts.REFSET_MODULE_DEPENDENCY_TYPE, Concepts.MODULE_SCT_MODEL_COMPONENT).with(SnomedRf2Headers.FIELD_SOURCE_EFFECTIVE_TIME, "").with(SnomedRf2Headers.FIELD_TARGET_EFFECTIVE_TIME, "").with("commitComment", "Created new module dependency reference set member");
    String memberId = assertCreated(createComponent(branchPath, SnomedComponentType.MEMBER, requestBody));
    SnomedReferenceSetMember member = getComponent(branchPath, SnomedComponentType.MEMBER, memberId).statusCode(200).extract().as(SnomedReferenceSetMember.class);
    assertNull(member.getProperties().get(SnomedRf2Headers.FIELD_SOURCE_EFFECTIVE_TIME));
    assertNull(member.getProperties().get(SnomedRf2Headers.FIELD_TARGET_EFFECTIVE_TIME));
    Json updateRequest = Json.object(SnomedRf2Headers.FIELD_SOURCE_EFFECTIVE_TIME, "20181002", SnomedRf2Headers.FIELD_TARGET_EFFECTIVE_TIME, "20181002", "commitComment", "Updated reference set member");
    updateRefSetComponent(branchPath, SnomedComponentType.MEMBER, memberId, updateRequest, false).statusCode(204);
    SnomedReferenceSetMember updatedMember = getComponent(branchPath, SnomedComponentType.MEMBER, memberId).statusCode(200).extract().as(SnomedReferenceSetMember.class);
    assertEquals(EffectiveTimes.parse("20181002", DateFormats.SHORT), updatedMember.getProperties().get(SnomedRf2Headers.FIELD_SOURCE_EFFECTIVE_TIME));
    assertEquals(EffectiveTimes.parse("20181002", DateFormats.SHORT), updatedMember.getProperties().get(SnomedRf2Headers.FIELD_TARGET_EFFECTIVE_TIME));
}
Also used : SnomedReferenceSetMember(com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMember) Json(com.b2international.commons.json.Json) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

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