19
19
import ix .ginas .utils .validation .validators .SubstanceUniquenessValidator ;
20
20
import java .io .File ;
21
21
import java .io .IOException ;
22
+ import java .util .UUID ;
23
+
22
24
import lombok .extern .slf4j .Slf4j ;
23
25
import org .junit .jupiter .api .Assertions ;
24
26
import org .junit .jupiter .api .BeforeEach ;
@@ -75,6 +77,7 @@ public void testValidation() {
75
77
String name ="G6867RWN6N" ;
76
78
String completeDuplicateMessage = "appears to be a full duplicate" ;
77
79
ChemicalSubstance protein = getChemicalSubstanceFromFile (name );
80
+ protein .uuid = UUID .randomUUID ();
78
81
SubstanceUniquenessValidator validator = new SubstanceUniquenessValidator ();
79
82
AutowireHelper .getInstance ().autowire (validator );
80
83
ValidationResponse response = validator .validate (protein , null );
@@ -87,6 +90,8 @@ public void testExactDuplicateStrDiv() {
87
90
String name ="N5WWR36MDJ" ;
88
91
String completeDuplicateMessage = "appears to be a full duplicate" ;
89
92
Substance substance = getSubstanceFromFile (name );
93
+ substance .uuid = UUID .randomUUID ();
94
+
90
95
SubstanceUniquenessValidator validator = new SubstanceUniquenessValidator ();
91
96
AutowireHelper .getInstance ().autowire (validator );
92
97
ValidationResponse response = validator .validate (substance , null );
@@ -97,12 +102,27 @@ public void testValidationDiastereomer() {
97
102
log .trace ("Starting in testValidation" );
98
103
String name ="G6867RWN6N-diast" ;
99
104
String possibleDuplicateMessage = "is a possible duplicate" ;
100
- ChemicalSubstance protein = getChemicalSubstanceFromFile (name );
105
+ ChemicalSubstance chem = getChemicalSubstanceFromFile (name );
106
+ chem .uuid =UUID .randomUUID ();
107
+
101
108
SubstanceUniquenessValidator validator = new SubstanceUniquenessValidator ();
102
109
AutowireHelper .getInstance ().autowire (validator );
103
- ValidationResponse response = validator .validate (protein , null );
110
+ ValidationResponse response = validator .validate (chem , null );
104
111
Assertions .assertTrue (response .getValidationMessages ().stream ().anyMatch (m -> ((GinasProcessingMessage ) m ).message .contains (possibleDuplicateMessage )));
105
112
}
113
+
114
+ @ Test
115
+ public void testDuplicateDoesNotFindItself () {
116
+ log .trace ("Starting in testValidation" );
117
+ String name ="G6867RWN6N-diast" ;
118
+ String possibleDuplicateMessage = "is a possible duplicate" ;
119
+ ChemicalSubstance chem = getChemicalSubstanceFromFile (name );
120
+ SubstanceUniquenessValidator validator = new SubstanceUniquenessValidator ();
121
+ AutowireHelper .getInstance ().autowire (validator );
122
+ ValidationResponse response = validator .validate (chem , null );
123
+ //should not contain a duplicate message
124
+ Assertions .assertFalse (response .getValidationMessages ().stream ().anyMatch (m -> ((GinasProcessingMessage ) m ).message .contains (possibleDuplicateMessage )));
125
+ }
106
126
107
127
@ Test
108
128
public void testValidationNoDuplicates () {
0 commit comments