Search in sources :

Example 1 with UploadFinishArgs

use of com.microsoft.applicationinsights.serviceprofilerapi.client.uploader.UploadFinishArgs in project ApplicationInsights-Java by microsoft.

the class ServiceProfilerUploaderTest method uploadFileGoodPathReturnsExpectedResponse.

@Test
void uploadFileGoodPathReturnsExpectedResponse() throws IOException {
    ServiceProfilerClientV2 serviceProfilerClient = stubServiceProfilerClient();
    File tmpFile = createFakeJfrFile();
    UUID appId = UUID.randomUUID();
    ServiceProfilerUploader serviceProfilerUploader = new ServiceProfilerUploader(serviceProfilerClient, "a-machine-name", "a-process-id", appId::toString, "a-role-name") {

        @Override
        protected Mono<UploadFinishArgs> performUpload(UploadContext uploadContext, BlobAccessPass uploadPass, File file) {
            return Mono.just(new UploadFinishArgs("a-stamp-id", "a-timestamp"));
        }
    };
    serviceProfilerUploader.uploadJfrFile("a-trigger", 321, tmpFile, 0.0, 0.0).subscribe(result -> {
        assertThat(result.getServiceProfilerIndex().getProperties().get(ServiceProfilerIndex.SERVICE_PROFILER_STAMPID_PROPERTY_NAME)).isEqualTo("a-stamp-id");
        assertThat(result.getServiceProfilerIndex().getProperties().get(ServiceProfilerIndex.SERVICE_PROFILER_MACHINENAME_PROPERTY_NAME)).isEqualTo("a-machine-name");
        assertThat(result.getServiceProfilerIndex().getProperties().get(ServiceProfilerIndex.SERVICE_PROFILER_ETLFILESESSIONID_PROPERTY_NAME)).isEqualTo("a-timestamp");
        assertThat(result.getServiceProfilerIndex().getProperties().get(ServiceProfilerIndex.SERVICE_PROFILER_DATACUBE_PROPERTY_NAME)).isEqualTo(appId.toString());
    });
}
Also used : ServiceProfilerClientV2(com.microsoft.applicationinsights.serviceprofilerapi.client.ServiceProfilerClientV2) BlobAccessPass(com.microsoft.applicationinsights.serviceprofilerapi.client.contract.BlobAccessPass) UUID(java.util.UUID) File(java.io.File) UploadContext(com.microsoft.applicationinsights.serviceprofilerapi.client.uploader.UploadContext) UploadFinishArgs(com.microsoft.applicationinsights.serviceprofilerapi.client.uploader.UploadFinishArgs) Test(org.junit.jupiter.api.Test)

Aggregations

ServiceProfilerClientV2 (com.microsoft.applicationinsights.serviceprofilerapi.client.ServiceProfilerClientV2)1 BlobAccessPass (com.microsoft.applicationinsights.serviceprofilerapi.client.contract.BlobAccessPass)1 UploadContext (com.microsoft.applicationinsights.serviceprofilerapi.client.uploader.UploadContext)1 UploadFinishArgs (com.microsoft.applicationinsights.serviceprofilerapi.client.uploader.UploadFinishArgs)1 File (java.io.File)1 UUID (java.util.UUID)1 Test (org.junit.jupiter.api.Test)1