Skip to content

Commit 78d06ab

Browse files
committed
feat: Sanitize the code
1 parent b39e647 commit 78d06ab

File tree

3 files changed

+36
-36
lines changed

3 files changed

+36
-36
lines changed

cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/logcache/v1/ReactorLogCacheEndpoints.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,6 @@ Mono<ReadResponse> read(ReadRequest request) {
5050
}
5151

5252
Mono<ReadResponse> recentLogs(ReadRequest request) {
53-
return get(request, ReadResponse.class, "read", request.getSourceId()).checkpoint();
53+
return read(request);
5454
}
5555
}

cloudfoundry-client/src/main/java/org/cloudfoundry/doppler/DopplerClient.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,16 @@ public interface DopplerClient {
3939
*/
4040
Flux<Envelope> firehose(FirehoseRequest request);
4141

42-
// TODO Adapt the message
4342
/**
4443
* Makes the <a href="https://github.com/cloudfoundry/loggregator/tree/develop/src/trafficcontroller#endpoints">Recent Logs</a> request
4544
*
46-
* @deprecated Do not use this type directly, it exists only for the <em>Jackson</em>-binding infrastructure
45+
* @deprecated Use {@link org.cloudfoundry.logcache.v1.LogCacheClient#recentLogs(org.cloudfoundry.logcache.v1.ReadRequest)} instead.
46+
* Only works with {@code Loggregator < 107.0}, shipped in {@code CFD < 24.3} and {@code TAS < 4.0}.
4747
* @param request the Recent Logs request
48-
* @return the events from the recent logs
48+
* @return a flux of events from the recent logs
49+
* @see <a href="https://github.com/cloudfoundry/loggregator">Loggregator</a>
50+
* @see <a href="https://github.com/cloudfoundry/log-cache">Log Cache</a>
51+
* @see org.cloudfoundry.logcache.v1.LogCacheClient#recentLogs(org.cloudfoundry.logcache.v1.ReadRequest)
4952
*/
5053
@Deprecated
5154
Flux<Envelope> recentLogs(RecentLogsRequest request);

cloudfoundry-operations/src/test/java/org/cloudfoundry/operations/applications/DefaultApplicationsTest.java

Lines changed: 29 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import static org.cloudfoundry.client.v3.LifecycleType.BUILDPACK;
2121
import static org.cloudfoundry.client.v3.LifecycleType.DOCKER;
2222
import static org.cloudfoundry.operations.TestObjects.fill;
23-
import static org.mockito.ArgumentMatchers.any;
2423
import static org.mockito.Mockito.RETURNS_SMART_NULLS;
2524
import static org.mockito.Mockito.mock;
2625
import static org.mockito.Mockito.when;
@@ -144,6 +143,7 @@
144143
import org.cloudfoundry.doppler.LogMessage;
145144
import org.cloudfoundry.doppler.RecentLogsRequest;
146145
import org.cloudfoundry.doppler.StreamRequest;
146+
import org.cloudfoundry.logcache.v1.Envelope;
147147
import org.cloudfoundry.logcache.v1.EnvelopeBatch;
148148
import org.cloudfoundry.logcache.v1.Log;
149149
import org.cloudfoundry.logcache.v1.LogCacheClient;
@@ -1315,7 +1315,7 @@ void listTasks() {
13151315

13161316
@SuppressWarnings("deprecation")
13171317
@Test
1318-
void logsRecent_doppler() {
1318+
void logsRecentDoppler() {
13191319
requestApplications(
13201320
this.cloudFoundryClient,
13211321
"test-application-name",
@@ -1332,7 +1332,7 @@ void logsRecent_doppler() {
13321332

13331333
@SuppressWarnings("deprecation")
13341334
@Test
1335-
void logsNoApp_doppler() {
1335+
void logsNoAppDoppler() {
13361336
requestApplicationsEmpty(this.cloudFoundryClient, "test-application-name", TEST_SPACE_ID);
13371337

13381338
this.applications
@@ -1349,7 +1349,7 @@ void logsNoApp_doppler() {
13491349

13501350
@SuppressWarnings("deprecation")
13511351
@Test
1352-
void logs_doppler() {
1352+
void logsDoppler() {
13531353
requestApplications(
13541354
this.cloudFoundryClient,
13551355
"test-application-name",
@@ -1365,15 +1365,15 @@ void logs_doppler() {
13651365
}
13661366

13671367
@Test
1368-
void logsRecent_LogCache() {
1368+
void logsRecentLogCache() {
13691369
requestApplications(
13701370
this.cloudFoundryClient,
13711371
"test-application-name",
13721372
TEST_SPACE_ID,
13731373
"test-metadata-id");
13741374
requestLogsRecentLogCache(this.logCacheClient, "test-metadata-id", "test-payload");
13751375
this.applications
1376-
.logsRecent(ReadRequest.builder().sourceId("test-application-name").build())
1376+
.logsRecent(ReadRequest.builder().sourceId("test-metadata-id").build())
13771377
.as(StepVerifier::create)
13781378
.expectNext(fill(Log.builder()).type(LogType.OUT).build())
13791379
.expectComplete()
@@ -1382,7 +1382,7 @@ void logsRecent_LogCache() {
13821382

13831383
@SuppressWarnings("deprecation")
13841384
@Test
1385-
void logsRecentNotSet_doppler() {
1385+
void logsRecentNotSetDoppler() {
13861386
requestApplications(
13871387
this.cloudFoundryClient,
13881388
"test-application-name",
@@ -5054,25 +5054,6 @@ private static void requestGetApplicationFailing(
50545054
.build()));
50555055
}
50565056

5057-
private static void requestGetApplicationTimeout(
5058-
CloudFoundryClient cloudFoundryClient, String applicationId) {
5059-
when(cloudFoundryClient
5060-
.applicationsV2()
5061-
.get(
5062-
org.cloudfoundry.client.v2.applications.GetApplicationRequest
5063-
.builder()
5064-
.applicationId(applicationId)
5065-
.build()))
5066-
.thenReturn(
5067-
Mono.just(
5068-
fill(GetApplicationResponse.builder())
5069-
.entity(
5070-
fill(ApplicationEntity.builder())
5071-
.packageState("STAGING")
5072-
.build())
5073-
.build()));
5074-
}
5075-
50765057
private static void requestInstancesApplicationFailing(
50775058
CloudFoundryClient cloudFoundryClient, String applicationId) {
50785059
when(cloudFoundryClient
@@ -5096,20 +5077,36 @@ private static void requestInstancesApplicationFailing(
50965077
.build()));
50975078
}
50985079

5080+
private static void requestGetApplicationTimeout(
5081+
CloudFoundryClient cloudFoundryClient, String applicationId) {
5082+
when(cloudFoundryClient
5083+
.applicationsV2()
5084+
.get(
5085+
org.cloudfoundry.client.v2.applications.GetApplicationRequest
5086+
.builder()
5087+
.applicationId(applicationId)
5088+
.build()))
5089+
.thenReturn(
5090+
Mono.just(
5091+
fill(GetApplicationResponse.builder())
5092+
.entity(
5093+
fill(ApplicationEntity.builder())
5094+
.packageState("STAGING")
5095+
.build())
5096+
.build()));
5097+
}
5098+
50995099
private static void requestLogsRecentLogCache(
5100-
LogCacheClient logCacheClient, String applicationName, String payload) {
5101-
when(logCacheClient.recentLogs(any()))
5100+
LogCacheClient logCacheClient, String sourceId, String payload) {
5101+
when(logCacheClient.recentLogs(ReadRequest.builder().sourceId(sourceId).build()))
51025102
.thenReturn(
51035103
Mono.just(
51045104
fill(ReadResponse.builder())
51055105
.envelopes(
51065106
fill(EnvelopeBatch.builder())
51075107
.batch(
51085108
Arrays.asList(
5109-
fill(org.cloudfoundry
5110-
.logcache.v1
5111-
.Envelope
5112-
.builder())
5109+
fill(Envelope.builder())
51135110
.log(
51145111
Log
51155112
.builder()

0 commit comments

Comments
 (0)