Skip to content

Migrate from RestTemplate to WebClient#956

Merged
nictas merged 3 commits into
cloudfoundry:masterfrom
Boris-ILIEV:web-client
Sep 28, 2020
Merged

Migrate from RestTemplate to WebClient#956
nictas merged 3 commits into
cloudfoundry:masterfrom
Boris-ILIEV:web-client

Conversation

@Boris-ILIEV
Copy link
Copy Markdown
Contributor

ISSUE: LMCROSSITXSADEPLOY-1476

@Boris-ILIEV Boris-ILIEV changed the title Web client Migrate from RestTemplate to WebClient Sep 23, 2020
import reactor.core.publisher.Mono;

class TaggingRequestInterceptor implements ClientHttpRequestInterceptor {
class TaggingRequestFilter implements ExchangeFilterFunction {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably rename it to TaggingRequestFilterFunction to be suitable with the interface name

public void testInjectGenericValue() throws IOException {
TaggingRequestFilter testedFilter = new TaggingRequestFilter("1.58.0");
testedFilter.filter(clientRequest, nextFilter);
assertNotNull(clientRequest.headers());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can assign clientRequest.headers() to local field called "actualHeaders" and use it afterwads.

assertTrue(clientRequest.headers()
.containsKey(TaggingRequestFilter.TAG_HEADER_NAME));
String expectedValue = "MTA deploy-service v1.58.0";
Optional<String> foundValue = clientRequest.headers()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can simplify by using assertEquals(expectedValue, actualHeaders.getFirst(TaggingRequestFilter.TAG_HEADER_NAME))

}

@Test
public void testGetHeaderValue() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this unit test is not needed because it is already covered.

Comment thread pom.xml Outdated
<!-- C3P0 is only used if Quartz needs to create its own DataSource. Since we use Spring for that purpose,
it is not required. -->
<!-- C3P0 is only used if Quartz needs to create its
own DataSource. Since we use Spring for that purpose, it is not required. -->
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these formatting changes needed?

}

@Test
public void testInjectOrgAndSpaceValues() throws IOException {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why so many unit tests? I think that some of them tests the same thing.
You can prepare one larger unit tests that tests every tag, other option is to have 3 different unit tests for each tag


@Override
public void registerRestLogListener(RestLogCallback callBack) {
executeWithRetry(() -> delegate.registerRestLogListener(callBack));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was executed with retry... xD /facepalm

requires spring.security.jwt;
requires spring.web;
requires spring.webflux;
requires reactor.core;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Order these alphabetically for easier navigation.

@nictas nictas merged commit 2b3547e into cloudfoundry:master Sep 28, 2020
@IvanBorislavovDimitrov IvanBorislavovDimitrov mentioned this pull request May 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants