3

We're using the Destinations service to configure connections to different kinds of systems. As part of this, we are using the "Additional Properties" section to add non-standard properties, such as my.custom.property=123.

We have successfully used the SAP Cloud SDK's MockUtil to write Spring integration tests that use the files systems.yml and credentials.yml as source for test systems.

However, we couldn't find a way to create an entry there that would provide a test system with a custom property like my.custom.property=123.

The erp section accepts only the properties known for ERP systems, such as sapClient. The general systems section accepts only the absolute basic properties name, type, uri, and proxy. Adding an unknown property in either section results in a runtime error because the mock utils are unable to parse the unknown property into the data classes with fixed structure.

Is there another way to mock a Destination that would allow us to include non-standard properties?

For example, the DestinationAccessorMocker looks promising, as it seems to enable setting up custom implementations of the Destination interface, but we couldn't figure out how to employ it.

Florian
  • 4,821
  • 2
  • 19
  • 44

1 Answers1

6

Found an option that works.

MockUtil mockUtil = new MockUtil();
MockDestination destination = MockDestination
  .builder("my-service", URI.create("http://localhost:1234/"))
  .property("my.custom.property", "123")
  .build();
mockUtil.mockDestination(destination);

Maybe somebody can confirm that this is an intended way to do this?

Florian
  • 4,821
  • 2
  • 19
  • 44
  • 2
    Yes you are exactly right, this is also the approach I would have recommended. So I think you can mark your answer as correct :) – MatKuhr May 14 '20 at 11:20