Search in sources :

Example 66 with Json

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

the class SnomedExportApiTest method exportConceptsAndRelationshipsOnly.

// until external classification service support is ready
@Ignore
@Test
public void exportConceptsAndRelationshipsOnly() throws Exception {
    final String codeSystemShortName = "SNOMEDCT-CONCEPTS-AND-RELATIONSHIPS-ONLY";
    createCodeSystem(branchPath, codeSystemShortName).statusCode(201);
    // create new concept
    final String conceptId = createNewConcept(branchPath);
    createNewDescription(branchPath, conceptId, Concepts.SYNONYM, UK_ACCEPTABLE_MAP, "en");
    String statedRelationshipId = createNewRelationship(branchPath, Concepts.ROOT_CONCEPT, Concepts.PART_OF, Concepts.NAMESPACE_ROOT, Concepts.STATED_RELATIONSHIP);
    String inferredRelationshipId = createNewRelationship(branchPath, Concepts.ROOT_CONCEPT, Concepts.PART_OF, Concepts.NAMESPACE_ROOT, Concepts.INFERRED_RELATIONSHIP);
    String additionalRelationshipId = createNewRelationship(branchPath, Concepts.ROOT_CONCEPT, Concepts.PART_OF, Concepts.NAMESPACE_ROOT, Concepts.ADDITIONAL_RELATIONSHIP);
    createNewRefSet(branchPath, SnomedRefSetType.OWL_AXIOM, Concepts.REFSET_OWL_AXIOM);
    String owlExpression = "";
    Json memberRequestBody = createRefSetMemberRequestBody(Concepts.REFSET_OWL_AXIOM, Concepts.ROOT_CONCEPT).with("owlExpression", owlExpression).with("commitComment", "Created new OWL axiom reference set member");
    String memberId = assertCreated(createComponent(branchPath, SnomedComponentType.MEMBER, memberRequestBody));
    // export delta rf2
    final Map<String, Object> config = ImmutableMap.<String, Object>builder().put("type", Rf2ReleaseType.DELTA.name()).put("conceptsAndRelationshipsOnly", true).put("includeUnpublished", true).build();
    final File exportArchive = doExport(branchPath, config);
    String conceptLine = TAB_JOINER.join(conceptId, "", "1", Concepts.MODULE_SCT_CORE, Concepts.PRIMITIVE);
    String statedLine = TAB_JOINER.join(statedRelationshipId, "", "1", Concepts.MODULE_SCT_CORE, Concepts.ROOT_CONCEPT, Concepts.NAMESPACE_ROOT, "0", Concepts.PART_OF, Concepts.STATED_RELATIONSHIP, Concepts.EXISTENTIAL_RESTRICTION_MODIFIER);
    String inferredLine = TAB_JOINER.join(inferredRelationshipId, "", "1", Concepts.MODULE_SCT_CORE, Concepts.ROOT_CONCEPT, Concepts.NAMESPACE_ROOT, "0", Concepts.PART_OF, Concepts.INFERRED_RELATIONSHIP, Concepts.EXISTENTIAL_RESTRICTION_MODIFIER);
    String additionalLine = TAB_JOINER.join(additionalRelationshipId, "", "1", Concepts.MODULE_SCT_CORE, Concepts.ROOT_CONCEPT, Concepts.NAMESPACE_ROOT, "0", Concepts.PART_OF, Concepts.ADDITIONAL_RELATIONSHIP, Concepts.EXISTENTIAL_RESTRICTION_MODIFIER);
    String owlMemberLine = TAB_JOINER.join(memberId, "", "1", Concepts.MODULE_SCT_CORE, Concepts.REFSET_OWL_AXIOM, Concepts.ROOT_CONCEPT, owlExpression);
    final Map<String, Boolean> files = ImmutableMap.<String, Boolean>builder().put("sct2_Concept", true).put("sct2_StatedRelationship", true).put("sct2_Relationship", true).put("sct2_Description", false).put("sct2_TextDefinition", false).put("der2_cRefset_LanguageDelta", false).put("der2_ssRefset_ModuleDependency", false).put("sct2_sRefset_OWLExpression", true).build();
    assertArchiveContainsFiles(exportArchive, files);
    final Multimap<String, Pair<Boolean, String>> fileToLinesMap = ArrayListMultimap.create();
    fileToLinesMap.put("sct2_Concept", Pair.of(true, conceptLine));
    fileToLinesMap.put("sct2_StatedRelationship", Pair.of(true, statedLine));
    fileToLinesMap.put("sct2_Relationship", Pair.of(true, inferredLine));
    fileToLinesMap.put("sct2_Relationship", Pair.of(false, additionalLine));
    fileToLinesMap.put("sct2_sRefset_OWLExpression", Pair.of(true, owlMemberLine));
    assertArchiveContainsLines(exportArchive, fileToLinesMap);
}
Also used : Json(com.b2international.commons.json.Json) File(java.io.File) Pair(com.b2international.commons.Pair) Ignore(org.junit.Ignore) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest) Test(org.junit.Test)

Example 67 with Json

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

the class SnomedExportApiTest method exportUnpublishedOWLExpressionRefsetMembers.

@Test
public void exportUnpublishedOWLExpressionRefsetMembers() throws Exception {
    Json owlOntologyRequestBody = createRefSetMemberRequestBody(Concepts.REFSET_OWL_ONTOLOGY, Concepts.ROOT_CONCEPT).with(SnomedRf2Headers.FIELD_OWL_EXPRESSION, SnomedApiTestConstants.OWL_ONTOLOGY_1).with("commitComment", "Created new OWL Ontology reference set member");
    String owlOntologyRefsetMemberId = assertCreated(createComponent(branchPath, SnomedComponentType.MEMBER, owlOntologyRequestBody));
    Json owlAxiomRequestBody = createRefSetMemberRequestBody(Concepts.REFSET_OWL_AXIOM, Concepts.ROOT_CONCEPT).with(SnomedRf2Headers.FIELD_OWL_EXPRESSION, SnomedApiTestConstants.owlAxiom1(Concepts.ROOT_CONCEPT)).with("commitComment", "Created new OWL Axiom reference set member");
    String owlAxiomRefsetMemberId = assertCreated(createComponent(branchPath, SnomedComponentType.MEMBER, owlAxiomRequestBody));
    File exportArchive = doExport(branchPath, Json.object("type", Rf2ReleaseType.DELTA.name()));
    String owlOntologyMemberLine = TAB_JOINER.join(owlOntologyRefsetMemberId, "", "1", Concepts.MODULE_SCT_CORE, Concepts.REFSET_OWL_ONTOLOGY, Concepts.ROOT_CONCEPT, SnomedApiTestConstants.OWL_ONTOLOGY_1);
    String owlAxiomMemberLine = TAB_JOINER.join(owlAxiomRefsetMemberId, "", "1", Concepts.MODULE_SCT_CORE, Concepts.REFSET_OWL_AXIOM, Concepts.ROOT_CONCEPT, SnomedApiTestConstants.owlAxiom1(Concepts.ROOT_CONCEPT));
    String expectedOwlExpressionDeltaFile = "sct2_sRefset_OWLExpressionDelta";
    final Map<String, Boolean> files = ImmutableMap.<String, Boolean>builder().put(expectedOwlExpressionDeltaFile, true).build();
    assertArchiveContainsFiles(exportArchive, files);
    Multimap<String, Pair<Boolean, String>> fileToLinesMap = ArrayListMultimap.<String, Pair<Boolean, String>>create();
    fileToLinesMap.put(expectedOwlExpressionDeltaFile, Pair.of(true, owlOntologyMemberLine));
    fileToLinesMap.put(expectedOwlExpressionDeltaFile, Pair.of(true, owlAxiomMemberLine));
    assertArchiveContainsLines(exportArchive, fileToLinesMap);
}
Also used : Json(com.b2international.commons.json.Json) File(java.io.File) Pair(com.b2international.commons.Pair) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest) Test(org.junit.Test)

Example 68 with Json

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

the class SnomedExportApiTest method exportUnpublishedMRCMReferenceSetMembers.

@Test
public void exportUnpublishedMRCMReferenceSetMembers() throws Exception {
    Json mrcmDomainRequestBody = createRefSetMemberRequestBody(Concepts.REFSET_MRCM_DOMAIN_INTERNATIONAL, Concepts.ROOT_CONCEPT).with(Json.object(SnomedRf2Headers.FIELD_MRCM_DOMAIN_CONSTRAINT, "domainConstraint", SnomedRf2Headers.FIELD_MRCM_PARENT_DOMAIN, "parentDomain", SnomedRf2Headers.FIELD_MRCM_PROXIMAL_PRIMITIVE_CONSTRAINT, "proximalPrimitiveConstraint", SnomedRf2Headers.FIELD_MRCM_PROXIMAL_PRIMITIVE_REFINEMENT, "proximalPrimitiveRefinement", SnomedRf2Headers.FIELD_MRCM_DOMAIN_TEMPLATE_FOR_PRECOORDINATION, "domainTemplateForPrecoordination", SnomedRf2Headers.FIELD_MRCM_DOMAIN_TEMPLATE_FOR_POSTCOORDINATION, "domainTemplateForPostcoordination", SnomedRf2Headers.FIELD_MRCM_GUIDEURL, "guideURL", "commitComment", "Created new MRCM domain reference set member"));
    String mrcmDomainRefsetMemberId = assertCreated(createComponent(branchPath, SnomedComponentType.MEMBER, mrcmDomainRequestBody));
    Map<?, ?> mrcmAttributeDomainRequestBody = createRefSetMemberRequestBody(Concepts.REFSET_MRCM_ATTRIBUTE_DOMAIN_INTERNATIONAL, 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 MRCM attribute domain reference set member"));
    String mrcmAttributeDomainRefsetMemberId = assertCreated(createComponent(branchPath, SnomedComponentType.MEMBER, mrcmAttributeDomainRequestBody));
    Map<?, ?> mrcmAttributeRangeRequestBody = createRefSetMemberRequestBody(Concepts.REFSET_MRCM_ATTRIBUTE_RANGE_INTERNATIONAL, Concepts.ROOT_CONCEPT).with(Json.object(SnomedRf2Headers.FIELD_MRCM_RANGE_CONSTRAINT, "rangeConstraint", SnomedRf2Headers.FIELD_MRCM_ATTRIBUTE_RULE, "attributeRule", SnomedRf2Headers.FIELD_MRCM_RULE_STRENGTH_ID, Concepts.ROOT_CONCEPT, SnomedRf2Headers.FIELD_MRCM_CONTENT_TYPE_ID, Concepts.ROOT_CONCEPT, "commitComment", "Created new MRCM attribute range reference set member"));
    String mrcmAttributeRangeRefsetMemberId = assertCreated(createComponent(branchPath, SnomedComponentType.MEMBER, mrcmAttributeRangeRequestBody));
    Json mrcmModuleScopeRequestBody = createRefSetMemberRequestBody(Concepts.REFSET_MRCM_MODULE_SCOPE, Concepts.ROOT_CONCEPT).with(SnomedRf2Headers.FIELD_MRCM_RULE_REFSET_ID, Concepts.ROOT_CONCEPT).with("commitComment", "Created new MRCM module scope reference set member");
    String mrcmModuleScopeRefsetMemberId = assertCreated(createComponent(branchPath, SnomedComponentType.MEMBER, mrcmModuleScopeRequestBody));
    Json config = Json.object("type", Rf2ReleaseType.DELTA.name());
    File exportArchive = doExport(branchPath, config);
    String mrcmDomainMemberLine = TAB_JOINER.join(mrcmDomainRefsetMemberId, "", "1", Concepts.MODULE_SCT_CORE, Concepts.REFSET_MRCM_DOMAIN_INTERNATIONAL, Concepts.ROOT_CONCEPT, "domainConstraint", "parentDomain", "proximalPrimitiveConstraint", "proximalPrimitiveRefinement", "domainTemplateForPrecoordination", "domainTemplateForPostcoordination", "guideURL");
    String mrcmAttributeDomainLine = TAB_JOINER.join(mrcmAttributeDomainRefsetMemberId, "", "1", Concepts.MODULE_SCT_CORE, Concepts.REFSET_MRCM_ATTRIBUTE_DOMAIN_INTERNATIONAL, Concepts.ROOT_CONCEPT, Concepts.ROOT_CONCEPT, "1", "attributeCardinality", "attributeInGroupCardinality", Concepts.ROOT_CONCEPT, Concepts.ROOT_CONCEPT);
    String mrcmAttributeRangeLine = TAB_JOINER.join(mrcmAttributeRangeRefsetMemberId, "", "1", Concepts.MODULE_SCT_CORE, Concepts.REFSET_MRCM_ATTRIBUTE_RANGE_INTERNATIONAL, Concepts.ROOT_CONCEPT, "rangeConstraint", "attributeRule", Concepts.ROOT_CONCEPT, Concepts.ROOT_CONCEPT);
    String mrcmModuleScopeLine = TAB_JOINER.join(mrcmModuleScopeRefsetMemberId, "", "1", Concepts.MODULE_SCT_CORE, Concepts.REFSET_MRCM_MODULE_SCOPE, Concepts.ROOT_CONCEPT, Concepts.ROOT_CONCEPT);
    final Map<String, Boolean> files = ImmutableMap.<String, Boolean>builder().put("der2_sssssssRefset_MRCMDomainDelta", true).put("der2_cissccRefset_MRCMAttributeDomainDelta", true).put("der2_ssccRefset_MRCMAttributeRangeDelta", true).put("der2_cRefset_MRCMModuleScopeDelta", true).build();
    assertArchiveContainsFiles(exportArchive, files);
    Multimap<String, Pair<Boolean, String>> fileToLinesMap = ArrayListMultimap.<String, Pair<Boolean, String>>create();
    fileToLinesMap.put("der2_sssssssRefset_MRCMDomainDelta", Pair.of(true, mrcmDomainMemberLine));
    fileToLinesMap.put("der2_cissccRefset_MRCMAttributeDomainDelta", Pair.of(true, mrcmAttributeDomainLine));
    fileToLinesMap.put("der2_ssccRefset_MRCMAttributeRangeDelta", Pair.of(true, mrcmAttributeRangeLine));
    fileToLinesMap.put("der2_cRefset_MRCMModuleScopeDelta", Pair.of(true, mrcmModuleScopeLine));
    assertArchiveContainsLines(exportArchive, fileToLinesMap);
}
Also used : Json(com.b2international.commons.json.Json) File(java.io.File) Pair(com.b2international.commons.Pair) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest) Test(org.junit.Test)

Example 69 with Json

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

the class SnomedRelationshipApiTest method createRelationshipInvalidDestination.

@Test
public void createRelationshipInvalidDestination() {
    Json requestBody = createRelationshipRequestBody(Concepts.ROOT_CONCEPT, Concepts.PART_OF, "11110000").with("commitComment", "Created new relationship with invalid destinationId");
    createComponent(branchPath, SnomedComponentType.RELATIONSHIP, requestBody).statusCode(400);
}
Also used : Json(com.b2international.commons.json.Json) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 70 with Json

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

the class SnomedRelationshipApiTest method createRelationshipInvalidType.

@Test
public void createRelationshipInvalidType() {
    Json requestBody = createRelationshipRequestBody(Concepts.ROOT_CONCEPT, "11110000", Concepts.NAMESPACE_ROOT).with("commitComment", "Created new relationship with invalid typeId");
    createComponent(branchPath, SnomedComponentType.RELATIONSHIP, requestBody).statusCode(400);
}
Also used : Json(com.b2international.commons.json.Json) 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