question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using Wiremock 2.x from Scala

See original GitHub issue

I am trying to use Wiremock 2.1.6 from Scala. However, something has changed in the types of the mapping builders, so that scalac cannot typecheck it anymore.

The first stubbing example in the documentation:

stubFor(get(urlEqualTo("/some/thing"))
        .willReturn(aResponse()
            .withHeader("Content-Type", "text/plain")
            .withBody("Hello world!")));

results in this error when compiling:

type mismatch;
    found   : ?0(in value <local TestSpec>) where type ?0(in value <local TestSpec>) <: AnyRef
    required: com.github.tomakehurst.wiremock.client.RemoteMappingBuilder[_ <: AnyRef, _ <: com.github.tomakehurst.wiremock.client.ScenarioMappingBuilder]
    get(urlEqualTo("some/thing")).willReturn(

The method willReturn is defined in the RemoteMappingBuilder interface

public interface RemoteMappingBuilder<M extends RemoteMappingBuilder, S extends ScenarioMappingBuilder> {
    ...
    M willReturn(ResponseDefinitionBuilder responseDefBuilder);
}

It seems to me that Scala is not happy about the generic interface RemoteMappingBuilder being used without type parameters in M extends RemoteMappingBuilder.

Any suggestions on how to work around this?

(I also posted this on SO: http://stackoverflow.com/questions/38301631/wiremock-2-x-in-scala)

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
tomakehurstcommented, Aug 16, 2016

We’re working on a fix but it’s taking a while. Maintaining some semblance of backwards compatibility is going to be hard.

Breaking Scala certainly wasn’t intentional. I’m not a Scala expert and hadn’t appreciated that its generics system will reject code that javac had no problem with.

0reactions
mriehlcommented, Aug 16, 2016

Cool, thanks. That’s also the first time I come across something like this 😕

Read more comments on GitHub >

github_iconTop Results From Across the Web

Wiremock 2.x in Scala - Stack Overflow
I am trying to use Wiremock 2.1.6 from Scala. However, something has changed in the types of the mapping builders, so that scalac...
Read more >
Using Wiremock 2.x from Scala · Issue #457 - GitHub
I am trying to use Wiremock 2.1.6 from Scala. However, something has changed in the types of the mapping builders, so that scalac...
Read more >
[Solved]-Wiremock 2.x in Scala-scala - appsloveworld
Coding example for the question Wiremock 2.x in Scala-scala.
Read more >
Getting Started - WireMock
WireMock is distributed via Maven Central and can be included in your project using common build tools' dependency management. Get started with WireMock....
Read more >
How to Download and Install WireMock
WireMock is distributed in two flavours - a standard JAR containing just WireMock, and a standalone fat JAR containing WireMock plus all its...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found