Source:
protected void beforeTest() { super.beforeTest(); String connectionString = interceptorManager.isPlaybackMode() ? "DefaultEndpointsProtocol=https;AccountName=dummyAccount;AccountKey=xyzDummy;EndpointSuffix=core.windows.net" : System.getenv("AZURE_TABLES_CONNECTION_STRING"); StorageConnectionString storageConnectionString = StorageConnectionString.create(connectionString, new ClientLogger(AzureTableImplTest.class)); StorageAuthenticationSettings authSettings = storageConnectionString.getStorageAuthSettings(); TablesSharedKeyCredential sharedKeyCredential = new TablesSharedKeyCredential(authSettings.getAccount().getName(), authSettings.getAccount().getAccessKey()); final List<HttpPipelinePolicy> policies = new ArrayList<>(); policies.add(new AddDatePolicy()); policies.add(new AddHeadersPolicy(new HttpHeaders().put("Accept", OdataMetadataFormat.APPLICATION_JSON_ODATA_MINIMALMETADATA.toString()))); policies.add(new TablesSharedKeyCredentialPolicy(sharedKeyCredential)); policies.add(new HttpLoggingPolicy(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BODY_AND_HEADERS))); final HttpClient httpClientToUse; if (interceptorManager.isPlaybackMode()) { httpClientToUse = interceptorManager.getPlaybackClient(); } else { httpClientToUse = HttpClient.createDefault(); policies.add(interceptorManager.getRecordPolicy()); policies.add(new RetryPolicy()); } final HttpPipeline pipeline = new HttpPipelineBuilder() .httpClient(httpClientToUse) .policies(policies.toArray(new HttpPipelinePolicy[0])) .build(); azureTable = new AzureTableImplBuilder() .pipeline(pipeline) .version("2019-02-02") .url(storageConnectionString.getTableEndpoint().getPrimaryUri()) .buildClient(); }

Target:
protected void beforeTest() { String connectionString = interceptorManager.isPlaybackMode() ? "DefaultEndpointsProtocol=https;AccountName=dummyAccount;AccountKey=xyzDummy;EndpointSuffix=core.windows.net" : System.getenv("AZURE_TABLES_CONNECTION_STRING"); StorageConnectionString storageConnectionString = StorageConnectionString.create(connectionString, new ClientLogger(AzureTableImplTest.class)); Assertions.assertNotNull(connectionString, "Cannot continue test if connectionString is not set."); StorageAuthenticationSettings authSettings = storageConnectionString.getStorageAuthSettings(); TablesSharedKeyCredential sharedKeyCredential = new TablesSharedKeyCredential(authSettings.getAccount().getName(), authSettings.getAccount().getAccessKey()); List<HttpPipelinePolicy> policies = new ArrayList<>(); policies.add(new AddDatePolicy()); policies.add(new AddHeadersPolicy(new HttpHeaders().put("Accept", OdataMetadataFormat.APPLICATION_JSON_ODATA_MINIMALMETADATA.toString()))); policies.add(new TablesSharedKeyCredentialPolicy(sharedKeyCredential)); policies.add(new HttpLoggingPolicy(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BODY_AND_HEADERS))); HttpClient httpClientToUse; if (interceptorManager.isPlaybackMode()) { httpClientToUse = interceptorManager.getPlaybackClient(); } else { httpClientToUse = HttpClient.createDefault(); policies.add(interceptorManager.getRecordPolicy()); policies.add(new RetryPolicy()); } HttpPipeline pipeline = new HttpPipelineBuilder() .httpClient(httpClientToUse) .policies(policies.toArray(new HttpPipelinePolicy[0])) .build(); azureTable = new AzureTableImplBuilder() .pipeline(pipeline) .version("2019-02-02") .url(storageConnectionString.getTableEndpoint().getPrimaryUri()) .buildClient(); }