Search in sources :

Example 21 with Json

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

the class SnomedConcreteValueApiTest method createConcreteValueInferred.

@Test
public void createConcreteValueInferred() {
    Json requestBody = createConcreteValueRequestBody(Concepts.ROOT_CONCEPT, Concepts.PART_OF, new RelationshipValue(7), Concepts.INFERRED_RELATIONSHIP).with("commitComment", "Created new concrete value with inferred characteristic type");
    String relationshipId = assertCreated(createComponent(branchPath, SnomedComponentType.RELATIONSHIP, requestBody));
    getComponent(branchPath, SnomedComponentType.RELATIONSHIP, relationshipId).statusCode(200).body("characteristicTypeId", equalTo(Concepts.INFERRED_RELATIONSHIP));
}
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 22 with Json

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

the class SnomedConcreteValueApiTest method createConcreteValueInvalidModule.

@Test
public void createConcreteValueInvalidModule() {
    Json requestBody = createConcreteValueRequestBody(Concepts.ROOT_CONCEPT, Concepts.PART_OF, new RelationshipValue(5), Concepts.INFERRED_RELATIONSHIP, 0, "11110000").with("commitComment", "Created new concrete value with invalid moduleId");
    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 23 with Json

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

the class SnomedConcreteValueApiTest method createInactiveConcreteValue.

@Test
public void createInactiveConcreteValue() {
    Json requestBody = createConcreteValueRequestBody(Concepts.ROOT_CONCEPT, Concepts.PART_OF, new RelationshipValue(5)).with("active", false).with("commitComment", "Created inactive concrete value");
    String relationshipId = assertCreated(createComponent(branchPath, SnomedComponentType.RELATIONSHIP, requestBody));
    getComponent(branchPath, SnomedComponentType.RELATIONSHIP, relationshipId).statusCode(200).body("active", equalTo(false));
}
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 24 with Json

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

the class SnomedConcreteValueApiTest method restoreEffectiveTimeOnReleasedConcreteValue.

@Test
public void restoreEffectiveTimeOnReleasedConcreteValue() throws Exception {
    final String relationshipId = createNewConcreteValue(branchPath);
    // Create code system and version
    final LocalDate effectiveTime = LocalDate.parse("2017-03-01");
    createCodeSystemAndVersion(branchPath, "SNOMEDCT-CONCVAL-EFFTIME", "v1", effectiveTime);
    // After versioning, the concrete value should be released and have an effective time set on it
    getComponent(branchPath, SnomedComponentType.RELATIONSHIP, relationshipId).statusCode(200).body("active", equalTo(true)).body("released", equalTo(true)).body("effectiveTime", equalTo(effectiveTime.format(DateTimeFormatter.BASIC_ISO_DATE)));
    Json inactivationRequestBody = Json.object("active", false, "commitComment", "Inactivate concrete value");
    updateComponent(branchPath, SnomedComponentType.RELATIONSHIP, relationshipId, inactivationRequestBody).statusCode(204);
    // An inactivation should unset the effective time field
    getComponent(branchPath, SnomedComponentType.RELATIONSHIP, relationshipId).statusCode(200).body("active", equalTo(false)).body("released", equalTo(true)).body("effectiveTime", nullValue());
    Json reactivationRequestBody = Json.object("active", true, "commitComment", "Reactivate concrete value");
    updateComponent(branchPath, SnomedComponentType.RELATIONSHIP, relationshipId, reactivationRequestBody).statusCode(204);
    // Getting the concrete value back to its originally released state should restore its effective time
    getComponent(branchPath, SnomedComponentType.RELATIONSHIP, relationshipId).statusCode(200).body("active", equalTo(true)).body("released", equalTo(true)).body("effectiveTime", equalTo(effectiveTime.format(DateTimeFormatter.BASIC_ISO_DATE)));
}
Also used : Json(com.b2international.commons.json.Json) LocalDate(java.time.LocalDate) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 25 with Json

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

the class SnomedConcreteValueApiTest method updateUnreleasedConcreteValue.

@Test
public void updateUnreleasedConcreteValue() throws Exception {
    String relationshipId = createNewConcreteValue(branchPath);
    Json update = Json.object("value", Json.object("type", "INTEGER", "numericValue", "15"), "commitComment", "Updated value of unreleased concrete value");
    updateComponent(branchPath, SnomedComponentType.RELATIONSHIP, relationshipId, update).statusCode(204);
    getComponent(branchPath, SnomedComponentType.RELATIONSHIP, relationshipId).statusCode(200).body("value.type", equalTo("INTEGER")).body("value.numericValue", equalTo("15"));
}
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