Skip to content

Error when using JodaTime in Pact given parameter #1861

@huehnerlady

Description

@huehnerlady

Hi,
I am currently trying to use an Object containing Jodatime as a parameter for the given part.

import au.com.dius.pact.consumer.dsl.PactBuilder
import au.com.dius.pact.consumer.junit5.PactConsumerTestExt
import au.com.dius.pact.core.model.annotations.Pact
import de.europace.privatkredit.kex.vorgaenge.web.HttpConfig
import org.joda.time.LocalDate

[...]

  @Pact(consumer = "CONSUMER", provider = "PROVIDER")
  fun jodaTime(builder: PactBuilder) = builder
      .given("joda time as parameter", "testClass", TestClass(LocalDate.now()))
      .expectsToReceiveHttpInteraction("test") { httpBuilder ->
        httpBuilder
            .withRequest { httpRequestBuilder ->
              httpRequestBuilder
                  .path("/test")
                  .method("GET")
                  .header(CONTENT_TYPE, "application/json")
            }
            .willRespondWith { httpResponseBuilder ->
              httpResponseBuilder
                  .status(200)
            }
      }
      .toPact()

unfortunately I then get the error:

java.lang.IllegalAccessException: class kotlin.reflect.jvm.internal.calls.CallerImpl$FieldGetter cannot access a member of class org.joda.time.LocalDate with modifiers "private final"
kotlin.reflect.full.IllegalCallableAccessException: java.lang.IllegalAccessException: class kotlin.reflect.jvm.internal.calls.CallerImpl$FieldGetter cannot access a member of class org.joda.time.LocalDate with modifiers "private final"
	at kotlin.reflect.jvm.internal.KCallableImpl.call

Can you please fix this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions