Skip to content

Commit

Permalink
fixed tests for uniqueness hash
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerperyea committed Oct 5, 2021
1 parent 9ac7924 commit c7f0f08
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.UUID;

import lombok.extern.slf4j.Slf4j;
import org.junit.After;
import org.junit.AfterClass;
Expand Down Expand Up @@ -114,6 +116,8 @@ public void testFindLayer1DefHashDuplicates() {
log.trace("testFindLayer1DefHashDuplicates");
String approvalID = "660YQ98I10";
ChemicalSubstance chemical = getChemicalFromFile(approvalID);
chemical.uuid=UUID.randomUUID();

List<Substance> duplicates = ValidationUtils.findDefinitionaLayer1lDuplicateCandidates(chemical,
new DefHashCalcRequirements(definitionalElementFactory, searchService, transactionManager) );
log.trace("duplicate list size: " + duplicates.size() + "; items: ");
Expand All @@ -133,6 +137,8 @@ public void testFindFullDefHashDuplicates() {
log.trace("TestFindFullDefHashDuplicates");
String approvalID = "660YQ98I10";
ChemicalSubstance chemical = getChemicalFromFile(approvalID);
chemical.uuid=UUID.randomUUID();

List<Substance> duplicates = ValidationUtils.findFullDefinitionalDuplicateCandidates(chemical,
new DefHashCalcRequirements( definitionalElementFactory, searchService, transactionManager));
assertEquals(1, duplicates.size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import ix.ginas.utils.validation.validators.SubstanceUniquenessValidator;
import java.io.File;
import java.io.IOException;
import java.util.UUID;

import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -75,6 +77,7 @@ public void testValidation() {
String name ="G6867RWN6N";
String completeDuplicateMessage= "appears to be a full duplicate";
ChemicalSubstance protein = getChemicalSubstanceFromFile(name);
protein.uuid= UUID.randomUUID();
SubstanceUniquenessValidator validator = new SubstanceUniquenessValidator();
AutowireHelper.getInstance().autowire(validator);
ValidationResponse response = validator.validate(protein, null);
Expand All @@ -87,6 +90,8 @@ public void testExactDuplicateStrDiv() {
String name ="N5WWR36MDJ";
String completeDuplicateMessage= "appears to be a full duplicate";
Substance substance = getSubstanceFromFile(name);
substance.uuid= UUID.randomUUID();

SubstanceUniquenessValidator validator = new SubstanceUniquenessValidator();
AutowireHelper.getInstance().autowire(validator);
ValidationResponse response = validator.validate(substance, null);
Expand All @@ -97,12 +102,27 @@ public void testValidationDiastereomer() {
log.trace("Starting in testValidation");
String name ="G6867RWN6N-diast";
String possibleDuplicateMessage= "is a possible duplicate";
ChemicalSubstance protein = getChemicalSubstanceFromFile(name);
ChemicalSubstance chem = getChemicalSubstanceFromFile(name);
chem.uuid=UUID.randomUUID();

SubstanceUniquenessValidator validator = new SubstanceUniquenessValidator();
AutowireHelper.getInstance().autowire(validator);
ValidationResponse response = validator.validate(protein, null);
ValidationResponse response = validator.validate(chem, null);
Assertions.assertTrue(response.getValidationMessages().stream().anyMatch(m-> ((GinasProcessingMessage) m).message.contains(possibleDuplicateMessage)));
}

@Test
public void testDuplicateDoesNotFindItself() {
log.trace("Starting in testValidation");
String name ="G6867RWN6N-diast";
String possibleDuplicateMessage= "is a possible duplicate";
ChemicalSubstance chem = getChemicalSubstanceFromFile(name);
SubstanceUniquenessValidator validator = new SubstanceUniquenessValidator();
AutowireHelper.getInstance().autowire(validator);
ValidationResponse response = validator.validate(chem, null);
//should not contain a duplicate message
Assertions.assertFalse(response.getValidationMessages().stream().anyMatch(m-> ((GinasProcessingMessage) m).message.contains(possibleDuplicateMessage)));
}

@Test
public void testValidationNoDuplicates() {
Expand Down

0 comments on commit c7f0f08

Please sign in to comment.