Skip to content

Commit 21b4430

Browse files
committed
DefaultApplications: rename uses v3 api
1 parent 142ce60 commit 21b4430

File tree

2 files changed

+34
-11
lines changed

2 files changed

+34
-11
lines changed

cloudfoundry-operations/src/main/java/org/cloudfoundry/operations/applications/DefaultApplications.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -538,10 +538,12 @@ public Mono<Void> pushManifestV3(PushManifestV3Request request) {
538538

539539
@Override
540540
public Mono<Void> rename(RenameApplicationRequest request) {
541-
return getApplicationId(request.getName())
541+
return getApplicationIdV3(request.getName())
542542
.flatMap(
543543
applicationId ->
544-
requestUpdateApplicationName(applicationId, request.getNewName()))
544+
requestUpdateApplicationV3(
545+
applicationId,
546+
builder -> builder.name(request.getNewName())))
545547
.then()
546548
.transform(OperationsLogging.log("Rename Application"))
547549
.checkpoint();
@@ -2147,6 +2149,21 @@ private Mono<AbstractApplicationResource> requestUpdateApplication(
21472149
.cast(AbstractApplicationResource.class);
21482150
}
21492151

2152+
private Mono<Void> requestUpdateApplicationV3(
2153+
String applicationId,
2154+
UnaryOperator<org.cloudfoundry.client.v3.applications.UpdateApplicationRequest.Builder>
2155+
modifier) {
2156+
return this.cloudFoundryClient
2157+
.applicationsV3()
2158+
.update(
2159+
modifier.apply(
2160+
org.cloudfoundry.client.v3.applications
2161+
.UpdateApplicationRequest.builder()
2162+
.applicationId(applicationId))
2163+
.build())
2164+
.then();
2165+
}
2166+
21502167
private Mono<AbstractApplicationResource> requestUpdateApplicationEnvironment(
21512168
String applicationId, Map<String, Object> environment) {
21522169
return requestUpdateApplication(

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

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3236,7 +3236,7 @@ void pushUploadFails() throws IOException {
32363236

32373237
@Test
32383238
void rename() {
3239-
requestApplications(
3239+
requestApplicationsV3(
32403240
this.cloudFoundryClient, "test-app-name", TEST_SPACE_ID, "test-metadata-id");
32413241
requestUpdateApplicationRename(
32423242
this.cloudFoundryClient, "test-metadata-id", "test-new-app-name");
@@ -3254,7 +3254,7 @@ void rename() {
32543254

32553255
@Test
32563256
void renameNoApp() {
3257-
requestApplicationsEmpty(this.cloudFoundryClient, "test-app-name", TEST_SPACE_ID);
3257+
requestApplicationsEmptyV3(this.cloudFoundryClient, "test-app-name", TEST_SPACE_ID);
32583258

32593259
this.applications
32603260
.rename(
@@ -5931,19 +5931,25 @@ private static void requestUpdateApplicationHealthCheck(
59315931
private static void requestUpdateApplicationRename(
59325932
CloudFoundryClient cloudFoundryClient, String applicationId, String name) {
59335933
when(cloudFoundryClient
5934-
.applicationsV2()
5934+
.applicationsV3()
59355935
.update(
5936-
UpdateApplicationRequest.builder()
5936+
org.cloudfoundry.client.v3.applications.UpdateApplicationRequest
5937+
.builder()
59375938
.applicationId(applicationId)
59385939
.name(name)
59395940
.build()))
59405941
.thenReturn(
59415942
Mono.just(
5942-
fill(UpdateApplicationResponse.builder())
5943-
.entity(
5944-
fill(
5945-
ApplicationEntity.builder(),
5946-
"application-entity-")
5943+
org.cloudfoundry.client.v3.applications.UpdateApplicationResponse
5944+
.builder()
5945+
.id("test-application-id")
5946+
.createdAt("2016-02-08T15:45:59Z")
5947+
.state(ApplicationState.STARTED)
5948+
.name("test-application-name")
5949+
.lifecycle(
5950+
Lifecycle.builder()
5951+
.data(BuildpackData.builder().build())
5952+
.type(BUILDPACK)
59475953
.build())
59485954
.build()));
59495955
}

0 commit comments

Comments
 (0)