wttech / aem-stubs

Tool for providing sample data for AEM applications in a simple and flexible way. Stubbing server on AEM, no separate needed.
Apache License 2.0
41 stars 4 forks source link

PDF download not supported #53

Closed szymon-owczarzak closed 4 months ago

szymon-owczarzak commented 3 years ago

I'm unable to create a stub that returns PDF file.

Templating: PEEBLE

Stub:

{
  "mappings": [
    {
      "request": {
        "method": "GET",
        "url": "/my-document-pdf",
        "headers": {
          "Content-Type": "application/pdf"
        }
      },
      "response": {
        "status": 200,
        "bodyFileName": "documents/my.pdf"
      }
    }
  ]
}

Error:

29.03.2021 21:11:25.383 *ERROR* [sling-oak-observation-6] com.cognifide.aem.stubs.core.ConfigurableStubManager Cannot load AEM Stubs mapping at path '/conf/stubs/wiremock/fcam/api-document-download.stub.json'!
com.cognifide.aem.stubs.core.StubsException: Cannot load AEM Stubs mapping from resource at path '/conf/stubs/wiremock/fcam/api-document-download.stub.json'!
    at com.cognifide.aem.stubs.wiremock.MappingsLoader.lambda$null$2(MappingsLoader.java:43) [com.cognifide.aem.stubs.wiremock:2.0.1]
    at com.github.tomakehurst.wiremock.core.WireMockApp.loadMappingsUsing(WireMockApp.java:200) [com.cognifide.aem.stubs.wiremock:2.0.1]
    at com.cognifide.aem.stubs.wiremock.WireMockApp.mappingFrom(WireMockApp.java:19) [com.cognifide.aem.stubs.wiremock:2.0.1]
    at com.cognifide.aem.stubs.wiremock.MappingsLoader.lambda$loadMapping$3(MappingsLoader.java:32) [com.cognifide.aem.stubs.wiremock:2.0.1]
    at java.util.Optional.ifPresent(Optional.java:159)
    at com.cognifide.aem.stubs.wiremock.MappingsLoader.loadMapping(MappingsLoader.java:31) [com.cognifide.aem.stubs.wiremock:2.0.1]
    at com.cognifide.aem.stubs.wiremock.WireMockStubs.loadMapping(WireMockStubs.java:66) [com.cognifide.aem.stubs.wiremock:2.0.1]
    at com.cognifide.aem.stubs.core.ConfigurableStubManager$2.visit(ConfigurableStubManager.java:127) [com.cognifide.aem.stubs.core:2.0.1]
    at org.apache.sling.api.resource.AbstractResourceVisitor.accept(AbstractResourceVisitor.java:43) [org.apache.sling.api:2.20.0]
    at org.apache.sling.api.resource.AbstractResourceVisitor.traverseChildren(AbstractResourceVisitor.java:56) [org.apache.sling.api:2.20.0]
    at org.apache.sling.api.resource.AbstractResourceVisitor.accept(AbstractResourceVisitor.java:44) [org.apache.sling.api:2.20.0]
    at org.apache.sling.api.resource.AbstractResourceVisitor.traverseChildren(AbstractResourceVisitor.java:56) [org.apache.sling.api:2.20.0]
    at org.apache.sling.api.resource.AbstractResourceVisitor.accept(AbstractResourceVisitor.java:44) [org.apache.sling.api:2.20.0]
    at com.cognifide.aem.stubs.core.ConfigurableStubManager.lambda$mapAll$2(ConfigurableStubManager.java:135) [com.cognifide.aem.stubs.core:2.0.1]
    at com.cognifide.aem.stubs.core.util.ResolverAccessor.lambda$consume$0(ResolverAccessor.java:39) [com.cognifide.aem.stubs.core:2.0.1]
    at com.cognifide.aem.stubs.core.util.ResolverAccessor.resolve(ResolverAccessor.java:28) [com.cognifide.aem.stubs.core:2.0.1]
    at com.cognifide.aem.stubs.core.util.ResolverAccessor.consume(ResolverAccessor.java:38) [com.cognifide.aem.stubs.core:2.0.1]
    at com.cognifide.aem.stubs.core.ConfigurableStubManager.mapAll(ConfigurableStubManager.java:120) [com.cognifide.aem.stubs.core:2.0.1]
    at com.cognifide.aem.stubs.core.ConfigurableStubManager.reload(ConfigurableStubManager.java:56) [com.cognifide.aem.stubs.core:2.0.1]
    at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
    at java.util.stream.DistinctOps$1$2.accept(DistinctOps.java:175)
    at java.util.stream.Streams$StreamBuilderImpl.forEachRemaining(Streams.java:419)
    at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:647)
    at java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:272)
    at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
    at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
    at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
    at java.util.ArrayList$Itr.forEachRemaining(ArrayList.java:901)
    at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
    at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
    at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
    at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
    at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:485)
    at com.cognifide.aem.stubs.core.ConfigurableStubManager.onChange(ConfigurableStubManager.java:172) [com.cognifide.aem.stubs.core:2.0.1]
    at org.apache.sling.resourceresolver.impl.observation.BasicObservationReporter.reportChanges(BasicObservationReporter.java:211) [org.apache.sling.resourceresolver:1.6.8]
    at org.apache.sling.jcr.resource.internal.JcrResourceListener.onEvent(JcrResourceListener.java:155) [org.apache.sling.jcr.resource:3.0.16]
    at org.apache.jackrabbit.commons.observation.ListenerTracker$1.onEvent(ListenerTracker.java:190) [org.apache.jackrabbit.jackrabbit-jcr-commons:2.16.5]
    at org.apache.jackrabbit.oak.jcr.observation.ChangeProcessor.contentChanged(ChangeProcessor.java:508) [org.apache.jackrabbit.oak-jcr:1.8.20]
    at org.apache.jackrabbit.oak.plugins.observation.FilteringDispatcher.contentChanged(FilteringDispatcher.java:52) [org.apache.jackrabbit.oak-core:1.8.20]
    at org.apache.jackrabbit.oak.spi.commit.BackgroundObserver$1$1.call(BackgroundObserver.java:127) [org.apache.jackrabbit.oak-store-spi:1.8.20]
    at org.apache.jackrabbit.oak.spi.commit.BackgroundObserver$1$1.call(BackgroundObserver.java:121) [org.apache.jackrabbit.oak-store-spi:1.8.20]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: com.github.tomakehurst.wiremock.common.JsonException: {
  "errors" : [ {
    "code" : 10,
    "source" : {
      "pointer" : "/mappings/0/request/headers/Content-Type"
    },
    "title" : "Error parsing JSON",
    "detail" : "\"application/pdf\" is not a valid match operation"
  } ]
}
    at com.github.tomakehurst.wiremock.common.JsonException.fromJackson(JsonException.java:53) [com.cognifide.aem.stubs.wiremock:2.0.1]
    at com.github.tomakehurst.wiremock.common.Json.read(Json.java:55) [com.cognifide.aem.stubs.wiremock:2.0.1]
    at com.cognifide.aem.stubs.wiremock.MappingsLoader.lambda$null$2(MappingsLoader.java:35) [com.cognifide.aem.stubs.wiremock:2.0.1]
    ... 46 common frames omitted
pun-ky commented 3 years ago

@marcinkp maybe?:)

krystian-panek-vmltech commented 4 months ago

no longer valid for v4