8181
8282import java .io .ByteArrayInputStream ;
8383import java .io .IOException ;
84+ import java .nio .file .Path ;
8485import java .time .Duration ;
86+ import java .util .Arrays ;
8587import java .util .Collections ;
8688import java .util .HashSet ;
8789import java .util .Map ;
@@ -833,8 +835,9 @@ public void update() {
833835 .flatMap (applicationId -> this .cloudFoundryClient .applicationsV2 ()
834836 .update (UpdateApplicationRequest .builder ()
835837 .applicationId (applicationId )
836- .name (applicationName2 )
837838 .environmentJson ("test-var" , "test-value" )
839+ .name (applicationName2 )
840+ .ports (60606 , 60607 )
838841 .build ())
839842 .map (ResourceUtils ::getId ))
840843 .flatMap (applicationId -> Mono .zip (
@@ -855,6 +858,7 @@ public void update() {
855858 .as (StepVerifier ::create )
856859 .consumeNextWith (consumer ((entity1 , entity2 ) -> {
857860 assertThat (entity1 .getName ()).isEqualTo (applicationName2 );
861+ assertThat (entity1 .getPorts ().containsAll (Arrays .asList (60606 , 60607 )));
858862 assertThat (entity1 .getEnvironmentJsons ()).containsEntry ("test-var" , "test-value" );
859863 assertThat (entity2 .getEnvironmentJsons ()).isEmpty ();
860864 }))
@@ -897,48 +901,38 @@ public void uploadAndDownloadAsyncFalse() {
897901 }
898902
899903 @ Test
900- public void uploadDirectory () {
904+ public void uploadDirectory () throws IOException {
905+ Path application = new ClassPathResource ("test-application" ).getFile ().toPath ();
901906 String applicationName = this .nameFactory .getApplicationName ();
902907
903908 this .spaceId
904909 .flatMap (spaceId -> createApplicationId (this .cloudFoundryClient , spaceId , applicationName ))
905- .flatMap (applicationId -> {
906- try {
907- return this .cloudFoundryClient .applicationsV2 ()
908- .upload (UploadApplicationRequest .builder ()
909- .application (new ClassPathResource ("test-application" ).getFile ().toPath ())
910- .async (true )
911- .applicationId (applicationId )
912- .build ())
913- .flatMap (job -> JobUtils .waitForCompletion (this .cloudFoundryClient , Duration .ofMinutes (5 ), job ));
914- } catch (IOException e ) {
915- throw new RuntimeException (e );
916- }
917- })
910+ .flatMap (applicationId -> this .cloudFoundryClient .applicationsV2 ()
911+ .upload (UploadApplicationRequest .builder ()
912+ .application (application )
913+ .async (true )
914+ .applicationId (applicationId )
915+ .build ())
916+ .flatMap (job -> JobUtils .waitForCompletion (this .cloudFoundryClient , Duration .ofMinutes (5 ), job )))
918917 .as (StepVerifier ::create )
919918 .expectComplete ()
920919 .verify (Duration .ofMinutes (5 ));
921920 }
922921
923922 @ IfCloudFoundryVersion (greaterThanOrEqualTo = CloudFoundryVersion .PCF_1_9 )
924923 @ Test
925- public void uploadDroplet () {
924+ public void uploadDroplet () throws IOException {
925+ Path droplet = new ClassPathResource ("test-droplet.tgz" ).getFile ().toPath ();
926926 String applicationName = this .nameFactory .getApplicationName ();
927927
928928 this .spaceId
929929 .flatMap (spaceId -> createApplicationId (this .cloudFoundryClient , spaceId , applicationName ))
930- .flatMap (applicationId -> {
931- try {
932- return this .cloudFoundryClient .applicationsV2 ()
933- .uploadDroplet (UploadApplicationDropletRequest .builder ()
934- .applicationId (applicationId )
935- .droplet (new ClassPathResource ("test-droplet.tgz" ).getFile ().toPath ())
936- .build ())
937- .flatMap (job -> JobUtils .waitForCompletion (this .cloudFoundryClient , Duration .ofMinutes (5 ), job ));
938- } catch (IOException e ) {
939- throw new RuntimeException (e );
940- }
941- })
930+ .flatMap (applicationId -> this .cloudFoundryClient .applicationsV2 ()
931+ .uploadDroplet (UploadApplicationDropletRequest .builder ()
932+ .applicationId (applicationId )
933+ .droplet (droplet )
934+ .build ())
935+ .flatMap (job -> JobUtils .waitForCompletion (this .cloudFoundryClient , Duration .ofMinutes (5 ), job )))
942936 .as (StepVerifier ::create )
943937 .expectComplete ()
944938 .verify (Duration .ofMinutes (5 ));
0 commit comments