Skip to content

Commit b01a107

Browse files
committed
Remove destination mocking from docs
1 parent f583a5d commit b01a107

File tree

1 file changed

+3
-25
lines changed

1 file changed

+3
-25
lines changed

docs-java/features/connectivity/destinations.mdx

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -152,31 +152,7 @@ The SAP Cloud SDK offers convenient ways to create a destination at runtime and
152152
This is especially useful when working in a local environment.
153153
Destinations configured in the destination service are not available in a local setting and have to be mocked.
154154

155-
### Mocking Destinations for Testing
156-
157-
The SAP Cloud SDK offers a `MockUtil` class that is capable of injecting destinations into the `DestinationAccessor`:
158-
159-
```java
160-
final MockUtil mockUtil = new MockUtil();
161-
162-
MockDestination destination = MockDestination
163-
.builder("my-destination", URI.create("http://localhost:8080"))
164-
.build();
165-
166-
mockUtil.mockDestination(destination);
167-
168-
// This will now return the mocked destination
169-
DestinationAccessor.getDestination("my-destination").asHttp();
170-
```
171-
172-
This helps with keeping production and test code nicely separated.
173-
There are more overloads of the mocking on the [`MockUtil` class](https://help.sap.com/doc/b579bf8578954412aea2b458e8452201/1.0/en-US/com/sap/cloud/sdk/testutil/MockUtil.html) that you can use.
174-
Refer to [these tutorial steps](https://developers.sap.com/tutorials/s4sdk-odata-service-cloud-foundry.html#b77d53b0-2d8b-449c-9a9a-9df80ee09a4e) on how to mock destinations for local development and testing.
175-
176-
### Using Custom Destination Loaders
177-
178-
The above is useful for testing but not suited for productive code.
179-
If you want to register custom destinations in your productive code you can use the following API:
155+
You can create a destination manually and prepare a loader for it as follows:
180156

181157
```java
182158
customHttpDestination = DefaultHttpDestination.builder("http://url")
@@ -198,7 +174,9 @@ These are e.g. a loader to get destinations from the destination service and a l
198174
The above `appendDestinationLoader()` will add the provided loader at the end of such a chain.
199175
That means the new loader can operate as a fallback.
200176
Use `prependDestinationLoader()` to add it at the beginning if you would like it to take precedence.
177+
201178
Lastly use `setLoader()` to replace all existing loaders.
179+
This is useful if you want to supply a single destination to a piece of test code.
202180

203181
## Provide Headers for Destinations
204182

0 commit comments

Comments
 (0)