I have this case class define:
class Protocol(protocol:String)
object Protocol {
def apply(protocol:String) :Protocol = {
protocol.toUpperCase match {
case "HTTP" => Http()
case "HTTPS" => Https()
case "Ftp" => Ftp()
case "Mail" =>Mail()
case other => new Protocol(other)
}
}
}
case class Http() extends Protocol("HTTP") {}
Which I then use in this case class:
case class Url(protocol: Protocol,
username: Option[String],
password: Option[String],
domainName: DomainName,
port: Option[Int],
path: Option[List[String]],
parameters: Option[List[Parameter]]) {
And then try to use here:
"An url class" should {
"represent http://localhost" in {
val url = Url(Http, None, None, localhost, None, None, None)
url.toString must beEqualTo("http://localhost")
}
For which I get the following baffling compiler error:
[error] C:\Users\Jim.Barrows\Desktop\workspaces\utils\src\test\scala\UrlSpec.scala:16: type mismatch;
[error] found : bizondemand.utils.models.internet.Http.type (with underlying type object bizondemand.utils.models.internet.Http)
[error] required: bizondemand.utils.models.internet.Protocol
[error] val url = Url(Http, None, None, localhost, None, None, None)
What am I doing wrong?