Search in sources :

Example 1 with ValidationIssues

use of com.b2international.snowowl.core.validation.issue.ValidationIssues in project snow-owl by b2ihealthcare.

the class SnomedValidationIssueDetailTest method duplicateIssueWithSameComponentIdTest.

@Test
public void duplicateIssueWithSameComponentIdTest() throws Exception {
    final String conceptId = RandomSnomedIdentiferGenerator.generateConceptId();
    final ValidationIssue existingIssue = createIssue(conceptId, Collections.emptyMap());
    final ValidationIssue existingIssue2 = createIssue(conceptId, Collections.emptyMap());
    save(existingIssue);
    save(existingIssue2);
    ImmutableMap<String, Object> ruleQuery = ImmutableMap.<String, Object>builder().put("componentType", "concept").put("active", true).build();
    SnomedConceptDocument theConcept = concept(conceptId).active(true).build();
    indexRevision(MAIN, theConcept);
    createSnomedQueryRule(ruleQuery);
    final ValidationIssues issues = validate();
    assertThat(issues.getItems().size()).isEqualTo(1);
}
Also used : SnomedConceptDocument(com.b2international.snowowl.snomed.datastore.index.entry.SnomedConceptDocument) ValidationIssues(com.b2international.snowowl.core.validation.issue.ValidationIssues) ValidationIssue(com.b2international.snowowl.core.validation.issue.ValidationIssue) Test(org.junit.Test) BaseRevisionIndexTest(com.b2international.index.revision.BaseRevisionIndexTest)

Example 2 with ValidationIssues

use of com.b2international.snowowl.core.validation.issue.ValidationIssues in project snow-owl by b2ihealthcare.

the class SnomedQueryValidationRuleEvaluatorTest method descriptionRuleRegex.

@Test
public void descriptionRuleRegex() throws Exception {
    final String description1 = RandomSnomedIdentiferGenerator.generateDescriptionId();
    final String description2 = RandomSnomedIdentiferGenerator.generateDescriptionId();
    indexRevision(MAIN, description(description1, Concepts.SYNONYM, "Minor heart attack").conceptId(generateConceptId()).build(), description(description2, Concepts.SYNONYM, "Clinical finding").conceptId(generateConceptId()).build());
    final Map<String, Object> ruleQuery = ImmutableMap.<String, Object>builder().put("componentType", "description").put("term", "regex(.*heart.*)").build();
    final String ruleId = createSnomedQueryRule(ruleQuery);
    final ValidationIssues issues = validate(ruleId);
    assertThat(issues.getTotal()).isEqualTo(1);
    assertThat(issues.getItems().get(0).getAffectedComponent()).isEqualTo(ComponentIdentifier.of(SnomedDescription.TYPE, description1));
}
Also used : ValidationIssues(com.b2international.snowowl.core.validation.issue.ValidationIssues) BaseValidationTest(com.b2international.snowowl.test.commons.validation.BaseValidationTest) Test(org.junit.Test)

Example 3 with ValidationIssues

use of com.b2international.snowowl.core.validation.issue.ValidationIssues in project snow-owl by b2ihealthcare.

the class SnomedQueryValidationRuleEvaluatorTest method conceptRuleEclSingleConcept.

@Test
public void conceptRuleEclSingleConcept() throws Exception {
    final String concept1 = RandomSnomedIdentiferGenerator.generateConceptId();
    final String concept2 = RandomSnomedIdentiferGenerator.generateConceptId();
    indexRevision(MAIN, concept(concept1).build(), concept(concept2).build());
    final Map<String, Object> ruleQuery = ImmutableMap.<String, Object>builder().put("componentType", "concept").put("ecl", concept1).build();
    final String ruleId = createSnomedQueryRule(ruleQuery);
    final ValidationIssues issues = validate(ruleId);
    assertThat(issues.getTotal()).isEqualTo(1);
    assertThat(issues.getItems().get(0).getAffectedComponent()).isEqualTo(ComponentIdentifier.of(SnomedConcept.TYPE, concept1));
}
Also used : ValidationIssues(com.b2international.snowowl.core.validation.issue.ValidationIssues) BaseValidationTest(com.b2international.snowowl.test.commons.validation.BaseValidationTest) Test(org.junit.Test)

Example 4 with ValidationIssues

use of com.b2international.snowowl.core.validation.issue.ValidationIssues in project snow-owl by b2ihealthcare.

the class SnomedQueryValidationRuleEvaluatorTest method conceptRuleActiveAndModuleFilter.

@Test
public void conceptRuleActiveAndModuleFilter() throws Exception {
    final String concept1 = RandomSnomedIdentiferGenerator.generateConceptId();
    final String concept2 = RandomSnomedIdentiferGenerator.generateConceptId();
    final String concept3 = RandomSnomedIdentiferGenerator.generateConceptId();
    indexRevision(MAIN, concept(concept1).moduleId(Concepts.MODULE_B2I_EXTENSION).build(), concept(concept2).active(false).moduleId(Concepts.MODULE_B2I_EXTENSION).build(), concept(concept3).active(false).moduleId(Concepts.MODULE_SCT_CORE).build());
    final Map<String, Object> ruleQuery = ImmutableMap.<String, Object>builder().put("componentType", "concept").put("active", true).put("module", Concepts.MODULE_B2I_EXTENSION).build();
    final String ruleId = createSnomedQueryRule(ruleQuery);
    final ValidationIssues issues = validate(ruleId);
    assertThat(issues.getTotal()).isEqualTo(1);
    assertThat(issues.getItems().get(0).getAffectedComponent()).isEqualTo(ComponentIdentifier.of(SnomedConcept.TYPE, concept1));
}
Also used : ValidationIssues(com.b2international.snowowl.core.validation.issue.ValidationIssues) BaseValidationTest(com.b2international.snowowl.test.commons.validation.BaseValidationTest) Test(org.junit.Test)

Example 5 with ValidationIssues

use of com.b2international.snowowl.core.validation.issue.ValidationIssues in project snow-owl by b2ihealthcare.

the class SnomedQueryValidationRuleEvaluatorTest method descriptionAcceptableInAndPreferredIn.

@Test
public void descriptionAcceptableInAndPreferredIn() throws Exception {
    final String description1 = RandomSnomedIdentiferGenerator.generateDescriptionId();
    final String description2 = RandomSnomedIdentiferGenerator.generateDescriptionId();
    final String langRefSet1 = generateConceptId();
    final String langRefSet2 = RandomSnomedIdentiferGenerator.generateConceptId();
    indexRevision(MAIN, description(description1, Concepts.SYNONYM, "Minor heart attack").conceptId(generateConceptId()).acceptableIn(ImmutableSet.of(langRefSet1)).preferredIn(ImmutableSet.of(langRefSet2)).build(), description(description2, Concepts.SYNONYM, "Clinical finding (finding)").conceptId(generateConceptId()).acceptableIn(ImmutableSet.of(langRefSet1)).build());
    final Map<String, Object> ruleQuery = ImmutableMap.<String, Object>builder().put("componentType", "description").put("acceptableIn", ImmutableList.of(langRefSet1)).put("preferredIn", ImmutableList.of(langRefSet2)).build();
    final String ruleId = createSnomedQueryRule(ruleQuery);
    final ValidationIssues issues = validate(ruleId);
    assertThat(issues.getTotal()).isEqualTo(1);
    assertThat(issues.getItems().get(0).getAffectedComponent()).isEqualTo(ComponentIdentifier.of(SnomedDescription.TYPE, description1));
}
Also used : ValidationIssues(com.b2international.snowowl.core.validation.issue.ValidationIssues) BaseValidationTest(com.b2international.snowowl.test.commons.validation.BaseValidationTest) Test(org.junit.Test)

Aggregations

ValidationIssues (com.b2international.snowowl.core.validation.issue.ValidationIssues)44 Test (org.junit.Test)43 ValidationIssue (com.b2international.snowowl.core.validation.issue.ValidationIssue)9 BaseRevisionIndexTest (com.b2international.index.revision.BaseRevisionIndexTest)5 BaseValidationTest (com.b2international.snowowl.test.commons.validation.BaseValidationTest)5 ComponentURI (com.b2international.snowowl.core.uri.ComponentURI)1 SnomedConceptDocument (com.b2international.snowowl.snomed.datastore.index.entry.SnomedConceptDocument)1