use of com.google.api.services.dataplex.v1.model.GoogleCloudDataplexV1Entity in project DataflowTemplates by GoogleCloudPlatform.
the class DefaultDataplexClientTest method testGetGetCloudStorageEntitiesByAssetName.
@Test
public void testGetGetCloudStorageEntitiesByAssetName() throws IOException {
CloudDataplex cloudDataplexClient = mock(CloudDataplex.class, Answers.RETURNS_DEEP_STUBS);
Entities.List entitiesListRequest = mock(Entities.List.class, Answers.RETURNS_DEEP_STUBS);
when(cloudDataplexClient.projects().locations().lakes().zones().entities().list(ZONE_NAME)).thenReturn(entitiesListRequest);
GoogleCloudDataplexV1Entity entity1 = new GoogleCloudDataplexV1Entity().setName("entity1").setAsset(ASSET_NAME1).setSystem(StorageSystem.CLOUD_STORAGE.name());
GoogleCloudDataplexV1Entity entity2 = new GoogleCloudDataplexV1Entity().setName("entity2").setAsset(ASSET_NAME1).setSystem(// storage mismatch
"BIGQUERY");
GoogleCloudDataplexV1Entity entity3 = new GoogleCloudDataplexV1Entity().setName("entity3").setAsset(ASSET_NAME1).setSystem(StorageSystem.CLOUD_STORAGE.name());
GoogleCloudDataplexV1Entity entity4 = new GoogleCloudDataplexV1Entity().setName("entity4").setAsset(ASSET_NAME2).setSystem(// asset mismatch
StorageSystem.CLOUD_STORAGE.name());
// an entity with a short asset name
GoogleCloudDataplexV1Entity entity5 = new GoogleCloudDataplexV1Entity().setName("entity5").setAsset(SHORT_ASSET_NAME1).setSystem(StorageSystem.CLOUD_STORAGE.name());
GoogleCloudDataplexV1ListEntitiesResponse response1 = new GoogleCloudDataplexV1ListEntitiesResponse();
response1.setEntities(ImmutableList.of(entity1, entity2, entity3));
response1.setNextPageToken(PAGE_TOKEN);
GoogleCloudDataplexV1ListEntitiesResponse response2 = new GoogleCloudDataplexV1ListEntitiesResponse();
response2.setEntities(ImmutableList.of(entity4, entity5));
when(entitiesListRequest.setPageToken(any())).thenReturn(entitiesListRequest);
when(entitiesListRequest.execute()).thenReturn(response1, response2);
when(cloudDataplexClient.projects().locations().lakes().zones().entities().get("entity1").setView(GetEntityRequestEntityView.FULL.name()).execute()).thenReturn(entity1);
when(cloudDataplexClient.projects().locations().lakes().zones().entities().get("entity3").setView(GetEntityRequestEntityView.FULL.name()).execute()).thenReturn(entity3);
when(cloudDataplexClient.projects().locations().lakes().zones().entities().get("entity5").setView(GetEntityRequestEntityView.FULL.name()).execute()).thenReturn(entity5);
assertEquals(ImmutableList.of(entity1, entity3, entity5), DefaultDataplexClient.withClient(cloudDataplexClient).getCloudStorageEntities(ASSET_NAME1));
}
use of com.google.api.services.dataplex.v1.model.GoogleCloudDataplexV1Entity in project DataflowTemplates by GoogleCloudPlatform.
the class DefaultDataplexClientTest method testGetEntitiesByEntityNames.
@Test
public void testGetEntitiesByEntityNames() throws IOException {
CloudDataplex cloudDataplexClient = mock(CloudDataplex.class, Answers.RETURNS_DEEP_STUBS);
GoogleCloudDataplexV1Entity entity1 = new GoogleCloudDataplexV1Entity().setName("entity1").setAsset(ASSET_NAME1).setSystem(StorageSystem.CLOUD_STORAGE.name());
GoogleCloudDataplexV1Entity entity2 = new GoogleCloudDataplexV1Entity().setName("entity2").setAsset(ASSET_NAME1).setSystem(StorageSystem.CLOUD_STORAGE.name());
GoogleCloudDataplexV1Entity entity3 = new GoogleCloudDataplexV1Entity().setName("entity3").setAsset(ASSET_NAME1).setSystem(StorageSystem.CLOUD_STORAGE.name());
when(cloudDataplexClient.projects().locations().lakes().zones().entities().get("entity1").setView(GetEntityRequestEntityView.FULL.name()).execute()).thenReturn(entity1);
when(cloudDataplexClient.projects().locations().lakes().zones().entities().get("entity2").setView(GetEntityRequestEntityView.FULL.name()).execute()).thenReturn(entity2);
when(cloudDataplexClient.projects().locations().lakes().zones().entities().get("entity3").setView(GetEntityRequestEntityView.FULL.name()).execute()).thenReturn(entity3);
assertEquals(ImmutableList.of(entity1, entity2, entity3), DefaultDataplexClient.withClient(cloudDataplexClient).getEntities(ImmutableList.of("entity1", "entity2", "entity3")));
}
Aggregations