Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SimpleType (and others?) equals isn't comprehensive #266

Open
er1c opened this issue Nov 3, 2017 · 0 comments
Open

SimpleType (and others?) equals isn't comprehensive #266

er1c opened this issue Nov 3, 2017 · 0 comments

Comments

@er1c
Copy link

er1c commented Nov 3, 2017

I'm still trying to understand if it's defined this way for a reason:

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant