diff --git a/gsrs-module-substance-example/src/test/java/example/substance/validation/SaltValidatorTest.java b/gsrs-module-substance-example/src/test/java/example/substance/validation/SaltValidatorTest.java index 43d56164b..3f17e4cde 100644 --- a/gsrs-module-substance-example/src/test/java/example/substance/validation/SaltValidatorTest.java +++ b/gsrs-module-substance-example/src/test/java/example/substance/validation/SaltValidatorTest.java @@ -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; @@ -114,6 +116,8 @@ public void testFindLayer1DefHashDuplicates() { log.trace("testFindLayer1DefHashDuplicates"); String approvalID = "660YQ98I10"; ChemicalSubstance chemical = getChemicalFromFile(approvalID); + chemical.uuid=UUID.randomUUID(); + List duplicates = ValidationUtils.findDefinitionaLayer1lDuplicateCandidates(chemical, new DefHashCalcRequirements(definitionalElementFactory, searchService, transactionManager) ); log.trace("duplicate list size: " + duplicates.size() + "; items: "); @@ -133,6 +137,8 @@ public void testFindFullDefHashDuplicates() { log.trace("TestFindFullDefHashDuplicates"); String approvalID = "660YQ98I10"; ChemicalSubstance chemical = getChemicalFromFile(approvalID); + chemical.uuid=UUID.randomUUID(); + List duplicates = ValidationUtils.findFullDefinitionalDuplicateCandidates(chemical, new DefHashCalcRequirements( definitionalElementFactory, searchService, transactionManager)); assertEquals(1, duplicates.size()); diff --git a/gsrs-module-substance-example/src/test/java/example/substance/validation/SubstanceUniquenessValidatorTest.java b/gsrs-module-substance-example/src/test/java/example/substance/validation/SubstanceUniquenessValidatorTest.java index 26c5dca77..e905a04cd 100644 --- a/gsrs-module-substance-example/src/test/java/example/substance/validation/SubstanceUniquenessValidatorTest.java +++ b/gsrs-module-substance-example/src/test/java/example/substance/validation/SubstanceUniquenessValidatorTest.java @@ -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; @@ -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); @@ -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); @@ -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() {