@Test public void download() throws IOException { this.applicationId .then(this::uploadApplication) .flatMap( applicationId -> this.cloudFoundryClient .applicationsV2() .download( DownloadApplicationRequest.builder().applicationId(applicationId).build())) .as(Stream::from) .reduce(new ByteArrayOutputStream(), ApplicationsTest::collectIntoByteArrayInputStream) .map(ByteArrayOutputStream::toByteArray) .map( bytes -> { try { File tempFile = File.createTempFile("downloadedFile", "zip"); new FileOutputStream(tempFile).write(bytes); return new ZipFile(tempFile).size(); } catch (IOException e) { throw new RuntimeException(e); } }) .subscribe( testSubscriber() .assertEquals( new ZipFile(new ClassPathResource("testApplication.zip").getFile()).size())); }
@Test public void upload() throws IOException { this.applicationId .then(this::uploadApplication) .flatMap( applicationId -> this.cloudFoundryClient .applicationsV2() .download( DownloadApplicationRequest.builder().applicationId(applicationId).build())) .after() .subscribe(testSubscriber()); }