use of com.b2international.commons.json.Json in project snow-owl by b2ihealthcare.
the class SnomedRefSetMemberApiTest method issue_SO_2501_ioobe_during_member_deletion.
/**
* Removals are sent in a BulkRequest which includes individual DeleteRequests for each member to be deleted. The version of SnomedEditingContext prior to the fix, however, used
* a server-side query to determine the list index for each member, and the list index reported by the database become misaligned with the actual
* contents if the members were not removed in decreasing index order. This test verifies that order of delete requests inside a bulk request does not matter.
*/
@Test
public void issue_SO_2501_ioobe_during_member_deletion() throws Exception {
String simpleRefSetId = createNewRefSet(branchPath);
final Json memberRequest = Json.object(SnomedRf2Headers.FIELD_MODULE_ID, Concepts.MODULE_SCT_CORE, "refsetId", simpleRefSetId, SnomedRf2Headers.FIELD_REFERENCED_COMPONENT_ID, simpleRefSetId, "commitComment", "Created new simple reference set member");
final String member1Id = assertCreated(createComponent(branchPath, SnomedComponentType.MEMBER, memberRequest));
final String member2Id = assertCreated(createComponent(branchPath, SnomedComponentType.MEMBER, memberRequest));
final String member3Id = assertCreated(createComponent(branchPath, SnomedComponentType.MEMBER, memberRequest));
final BulkRequestBuilder<TransactionContext> bulk = BulkRequest.create();
bulk.add(SnomedRequests.prepareDeleteMember(member1Id));
bulk.add(SnomedRequests.prepareDeleteMember(member3Id));
SnomedRequests.prepareCommit().setBody(bulk).setCommitComment("Delete reference set members in ascending index order").setAuthor("test").build(branchPath.getPath()).execute(Services.bus()).getSync();
// Check that member 2 still exists
getComponent(branchPath, SnomedComponentType.MEMBER, member2Id).statusCode(200);
}
use of com.b2international.commons.json.Json in project snow-owl by b2ihealthcare.
the class SnomedRefSetMemberApiTest method executeInvalidAction.
@Test
public void executeInvalidAction() throws Exception {
String queryRefSetId = createNewRefSet(branchPath, SnomedRefSetType.QUERY);
String simpleRefSetId = createNewRefSet(branchPath);
final Json memberRequest = Json.object(SnomedRf2Headers.FIELD_MODULE_ID, Concepts.MODULE_SCT_CORE, "refsetId", queryRefSetId, SnomedRf2Headers.FIELD_REFERENCED_COMPONENT_ID, simpleRefSetId, SnomedRf2Headers.FIELD_QUERY, "<" + Concepts.REFSET_ROOT_CONCEPT, "commitComment", "Created new query reference set member");
final String memberId = assertCreated(createComponent(branchPath, SnomedComponentType.MEMBER, memberRequest));
getComponent(branchPath, SnomedComponentType.MEMBER, memberId).statusCode(200);
final Json invalidActionRequest = Json.object("action", "invalid", "commitComment", "Executed invalid action on reference set member");
executeMemberAction(branchPath, memberId, invalidActionRequest).statusCode(400).body("message", containsString("Invalid")).body("message", containsString("CREATE")).body("message", containsString("UPDATE")).body("message", containsString("DELETE")).body("message", containsString("SYNC"));
}
use of com.b2international.commons.json.Json in project snow-owl by b2ihealthcare.
the class SnomedRefSetMemberApiTest method createMRCMModuleScopeMember.
@Test
public void createMRCMModuleScopeMember() {
String newIdentifierConceptId = createNewConcept(branchPath, SnomedRefSetUtil.getParentConceptId(SnomedRefSetType.MRCM_MODULE_SCOPE));
createNewRefSet(branchPath, SnomedRefSetType.MRCM_MODULE_SCOPE, newIdentifierConceptId);
Json requestBody = createRefSetMemberRequestBody(newIdentifierConceptId, Concepts.ROOT_CONCEPT).with(SnomedRf2Headers.FIELD_MRCM_RULE_REFSET_ID, Concepts.ROOT_CONCEPT).with("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_RULE_REFSET_ID, equalTo(Concepts.ROOT_CONCEPT));
Json requestBody2 = createRefSetMemberRequestBody(newIdentifierConceptId, Concepts.ROOT_CONCEPT).with(SnomedRf2Headers.FIELD_MRCM_RULE_REFSET_ID, // XXX batman should not be in the test dataset
"159725002").with("commitComment", "Created new reference set member");
createComponent(branchPath, SnomedComponentType.MEMBER, requestBody2).statusCode(400);
}
use of com.b2international.commons.json.Json in project snow-owl by b2ihealthcare.
the class SnomedRefSetMemberParameterizedTest method rejectMismatchedComponentType.
@Test
public void rejectMismatchedComponentType() throws Exception {
String refSetId = getOrCreateRefSet(branchPath, refSetType);
String referencedComponentType = getFirstAllowedReferencedComponentType(refSetType);
for (String disallowedComponentType : REFERENCED_COMPONENT_TYPES) {
if (!referencedComponentType.equals(disallowedComponentType)) {
String referencedComponentId = getFirstMatchingReferencedComponent(branchPath, disallowedComponentType);
Json requestBody = createRefSetMemberRequestBody(refSetId, referencedComponentId).with(getValidProperties(refSetType, referencedComponentId)).with("commitComment", "Created new reference set member with mismatched referencedComponentId");
String expectedMessage = String.format("'%s' reference set can't reference '%s | %s' component. Only '%s' components are allowed.", refSetId, referencedComponentId, disallowedComponentType, referencedComponentType);
createComponent(branchPath, SnomedComponentType.MEMBER, requestBody).statusCode(400).body("message", equalTo(expectedMessage));
}
}
}
use of com.b2international.commons.json.Json in project snow-owl by b2ihealthcare.
the class SnomedRefSetMemberParameterizedTest method updateMemberEffectiveTime.
@Test
public void updateMemberEffectiveTime() throws Exception {
final Pair<String, String> member = createRefSetMember();
final String memberId = member.getA();
LocalDate effectiveTime = getNextAvailableEffectiveDate(SnomedContentRule.SNOMEDCT_ID);
Json updateRequest = Json.object("effectiveTime", EffectiveTimes.format(effectiveTime, DateFormats.SHORT), "commitComment", "Updated effective time on reference set member without force flag");
// The update does not go through anymore, rejected with an error
updateRefSetComponent(branchPath, SnomedComponentType.MEMBER, memberId, updateRequest, false).statusCode(400);
}
Aggregations