@Test public void injectDatasetNameBasedOnId_alreadyHasADatasetName() { PersistentPreparation input = new PersistentPreparation(); String dataSetId = "1234"; input.setDataSetId(dataSetId); String datasetLabel = "dataset label"; input.setDataSetName(datasetLabel); PersistentPreparation result = dataSetNameInjection.injectDatasetNameBasedOnId(input); assertEquals(datasetLabel, result.getDataSetName()); verifyZeroInteractions(security); verifyZeroInteractions(securityProxy); verifyZeroInteractions(dataCatalogClient); verifyZeroInteractions(preparationRepository); }
public PersistentPreparation injectDatasetNameBasedOnId(PersistentPreparation preparation) { String dataSetName = preparation.getDataSetName(); if (dataSetName == null) { try { final String tenantId = security.getTenantId(); final Cache<String, String> tenantCache = cache.get(tenantId, this::createTenantCache); assert tenantCache != null; String dataSetId = preparation.getDataSetId(); dataSetName = tenantCache.get(dataSetId, this::getDatasetLabel); if (dataSetName != null) { preparation.setDataSetName(dataSetName); preparationRepository.add(preparation); } } catch (Exception e) { throw new TDPException(CommonErrorCodes.UNEXPECTED_EXCEPTION, e); } } return preparation; }
DataSetNameInjection { public PersistentPreparation injectDatasetNameBasedOnId(PersistentPreparation preparation) { String dataSetName = preparation.getDataSetName(); if (dataSetName == null) { try { final String tenantId = security.getTenantId(); final Cache<String, String> tenantCache = cache.get(tenantId, this::createTenantCache); assert tenantCache != null; String dataSetId = preparation.getDataSetId(); dataSetName = tenantCache.get(dataSetId, this::getDatasetLabel); if (dataSetName != null) { preparation.setDataSetName(dataSetName); preparationRepository.add(preparation); } } catch (Exception e) { throw new TDPException(CommonErrorCodes.UNEXPECTED_EXCEPTION, e); } } return preparation; } }
DataSetNameInjection { public PersistentPreparation injectDatasetNameBasedOnId(PersistentPreparation preparation) { String dataSetName = preparation.getDataSetName(); if (dataSetName == null) { try { final String tenantId = security.getTenantId(); final Cache<String, String> tenantCache = cache.get(tenantId, this::createTenantCache); assert tenantCache != null; String dataSetId = preparation.getDataSetId(); dataSetName = tenantCache.get(dataSetId, this::getDatasetLabel); if (dataSetName != null) { preparation.setDataSetName(dataSetName); preparationRepository.add(preparation); } } catch (Exception e) { throw new TDPException(CommonErrorCodes.UNEXPECTED_EXCEPTION, e); } } return preparation; }  }
DataSetNameInjection { public PersistentPreparation injectDatasetNameBasedOnId(PersistentPreparation preparation) { String dataSetName = preparation.getDataSetName(); if (dataSetName == null) { try { final String tenantId = security.getTenantId(); final Cache<String, String> tenantCache = cache.get(tenantId, this::createTenantCache); assert tenantCache != null; String dataSetId = preparation.getDataSetId(); dataSetName = tenantCache.get(dataSetId, this::getDatasetLabel); if (dataSetName != null) { preparation.setDataSetName(dataSetName); preparationRepository.add(preparation); } } catch (Exception e) { throw new TDPException(CommonErrorCodes.UNEXPECTED_EXCEPTION, e); } } return preparation; }  PersistentPreparation injectDatasetNameBasedOnId(PersistentPreparation preparation); }
DataSetNameInjection { public PersistentPreparation injectDatasetNameBasedOnId(PersistentPreparation preparation) { String dataSetName = preparation.getDataSetName(); if (dataSetName == null) { try { final String tenantId = security.getTenantId(); final Cache<String, String> tenantCache = cache.get(tenantId, this::createTenantCache); assert tenantCache != null; String dataSetId = preparation.getDataSetId(); dataSetName = tenantCache.get(dataSetId, this::getDatasetLabel); if (dataSetName != null) { preparation.setDataSetName(dataSetName); preparationRepository.add(preparation); } } catch (Exception e) { throw new TDPException(CommonErrorCodes.UNEXPECTED_EXCEPTION, e); } } return preparation; }  PersistentPreparation injectDatasetNameBasedOnId(PersistentPreparation preparation);  }