-
Notifications
You must be signed in to change notification settings - Fork 73
Description
I'm still trying to understand if it's defined this way for a reason:
soa-model/core/src/main/groovy/com/predic8/schema/SimpleType.groovy
Lines 67 to 73 in 062ddf7
| public boolean equals(obj) { | |
| obj && ( this.is(obj) || | |
| getClass() == obj.getClass() && | |
| restriction == obj.restriction && | |
| union == obj.union && | |
| list == obj.list ) | |
| } |
But the equals method is ignoring the 'qname' which can cause bad evaluations...Ran into a nasty bug when trying to do a .distinct on the SimpleType collections and getting back different sizes each execution...
import com.predic8.{wsdl => w}
import scala.collection.JavaConverters._
// A good problematic API
val parsed = new w.WSDLParser().parse("http://wss.hpi.co.uk/TradeSoap/services/CoreEnquiryV1?wsdl")
val all = parsed.getSchemas.asScala.toIndexedSeq.map{ _.getAllSchemas.asScala }.head.toIndexedSeq.head.getSimpleTypes.asScala.toIndexedSeq
// Example bad equals
scala> all(0) == all(2)
res79: Boolean = true
scala> all(0)
res80: com.predic8.schema.SimpleType = SimpleType[qname={http://webservices.hpi.co.uk/CoreEnquiryV1}CustomerCodeType,restriction=Restriction[base={http://www.w3.org/2001/XMLSchema}string,facets=[com.predic8.schema.restriction.facet.MinLengthFacet@771c60a6]]]
scala> all(2)
res81: com.predic8.schema.SimpleType = SimpleType[qname={http://webservices.hpi.co.uk/CoreEnquiryV1}PasswordType,restriction=Restriction[base={http://www.w3.org/2001/XMLSchema}string,facets=[com.predic8.schema.restriction.facet.MinLengthFacet@5a9a021b]]]
I have a branch here to add (all?) of the other inherited members to the equals: er1c@099e129
I'm not really sure if I should be adding all of the attributes or just the qname...the ComplexType equals is seems to be pretty light too: https://github.com/membrane/soa-model/blob/master/core/src/main/groovy/com/predic8/schema/ComplexType.groovy#L132-L146 but it's equals logic seems significantly divergent from the SimpleType