test_class.declarator: dataSetNameInjection
test_class.modifier: @InjectMocks
      private
test_class.original_string: @InjectMocks
      private DataSetNameInjection dataSetNameInjection;
test_class.type: DataSetNameInjection
test_class.var_name: dataSetNameInjection
test_class.declarator: security
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private Security security;
test_class.type: Security
test_class.var_name: security
test_class.declarator: securityProxy
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private SecurityProxy securityProxy;
test_class.type: SecurityProxy
test_class.var_name: securityProxy
test_class.declarator: dataCatalogClient
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private DataCatalogClient dataCatalogClient;
test_class.type: DataCatalogClient
test_class.var_name: dataCatalogClient
test_class.declarator: preparationRepository
test_class.modifier: @Mock
      protected
test_class.original_string: @Mock
      protected PreparationRepository preparationRepository;
test_class.type: PreparationRepository
test_class.var_name: preparationRepository
test_class.file: dataprep-preparation/src/test/java/org/talend/dataprep/preparation/service/DataSetNameInjectionTest.java
test_class.identifier: DataSetNameInjectionTest
test_case.body: @Test
      public void injectDatasetNameBasedOnId_alreadyHasADatasetName() {
          // given
          PersistentPreparation input = new PersistentPreparation();
          String dataSetId = "1234";
          input.setDataSetId(dataSetId);
          String datasetLabel = "dataset label";
          input.setDataSetName(datasetLabel);
  
          // when
          PersistentPreparation result = dataSetNameInjection.injectDatasetNameBasedOnId(input);
  
          // then
          assertEquals(datasetLabel, result.getDataSetName());
          verifyZeroInteractions(security);
          verifyZeroInteractions(securityProxy);
          verifyZeroInteractions(dataCatalogClient);
          verifyZeroInteractions(preparationRepository);
      }
test_case.class_method_signature: DataSetNameInjectionTest.injectDatasetNameBasedOnId_alreadyHasADatasetName()
test_case.full_signature: @Test public void injectDatasetNameBasedOnId_alreadyHasADatasetName()
test_case.identifier: injectDatasetNameBasedOnId_alreadyHasADatasetName
test_case.invocations: setDataSetId setDataSetName injectDatasetNameBasedOnId assertEquals getDataSetName verifyZeroInteractions verifyZeroInteractions verifyZeroInteractions verifyZeroInteractions
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void injectDatasetNameBasedOnId_alreadyHasADatasetName()
focal_class.declarator: LOGGER = LoggerFactory.getLogger(DataSetNameInjection.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger LOGGER = LoggerFactory.getLogger(DataSetNameInjection.class);
focal_class.type: Logger
focal_class.var_name: LOGGER
focal_class.declarator: cache = Caffeine
              .newBuilder() //
              .maximumSize(10) //
              .expireAfterAccess(1, TimeUnit.MINUTES) //
              .build()
focal_class.modifier: private final
focal_class.original_string: private final Cache<String, Cache<String, String>> cache = Caffeine
              .newBuilder() //
              .maximumSize(10) //
              .expireAfterAccess(1, TimeUnit.MINUTES) //
              .build();
focal_class.type: Cache<String, Cache<String, String>>
focal_class.var_name: cache
focal_class.declarator: security
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private Security security;
focal_class.type: Security
focal_class.var_name: security
focal_class.declarator: securityProxy
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private SecurityProxy securityProxy;
focal_class.type: SecurityProxy
focal_class.var_name: securityProxy
focal_class.declarator: dataCatalogClient
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private DataCatalogClient dataCatalogClient;
focal_class.type: DataCatalogClient
focal_class.var_name: dataCatalogClient
focal_class.declarator: preparationRepository
focal_class.modifier: @Autowired
      protected
focal_class.original_string: @Autowired
      protected PreparationRepository preparationRepository;
focal_class.type: PreparationRepository
focal_class.var_name: preparationRepository
focal_class.file: dataprep-preparation/src/main/java/org/talend/dataprep/preparation/service/DataSetNameInjection.java
focal_class.identifier: DataSetNameInjection
focal_class.class_method_signature: DataSetNameInjection.injectDatasetNameBasedOnId(PersistentPreparation preparation)
focal_class.full_signature: public PersistentPreparation injectDatasetNameBasedOnId(PersistentPreparation preparation)
focal_class.identifier: injectDatasetNameBasedOnId
focal_class.modifiers: public
focal_class.parameters: (PersistentPreparation preparation)
focal_class.return: PersistentPreparation
focal_class.signature: PersistentPreparation injectDatasetNameBasedOnId(PersistentPreparation preparation)
focal_class.class_method_signature: DataSetNameInjection.createTenantCache(String tenantId)
focal_class.full_signature: @SuppressWarnings("unused") // needed to fit the cache get method private Cache<String, String> createTenantCache(String tenantId)
focal_class.identifier: createTenantCache
focal_class.modifiers: @SuppressWarnings("unused") // needed to fit the cache get method private
focal_class.parameters: (String tenantId)
focal_class.return: Cache<String, String>
focal_class.signature: Cache<String, String> createTenantCache(String tenantId)
focal_class.class_method_signature: DataSetNameInjection.getDatasetLabel(String dataSetId)
focal_class.full_signature: private String getDatasetLabel(String dataSetId)
focal_class.identifier: getDatasetLabel
focal_class.modifiers: private
focal_class.parameters: (String dataSetId)
focal_class.return: String
focal_class.signature: String getDatasetLabel(String dataSetId)
focal_method.body: 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; // initTenant() cannot return a null value
                  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;
      }
focal_method.class_method_signature: DataSetNameInjection.injectDatasetNameBasedOnId(PersistentPreparation preparation)
focal_method.full_signature: public PersistentPreparation injectDatasetNameBasedOnId(PersistentPreparation preparation)
focal_method.identifier: injectDatasetNameBasedOnId
focal_method.invocations: getDataSetName getTenantId get getDataSetId get setDataSetName add
focal_method.modifiers: public
focal_method.parameters: (PersistentPreparation preparation)
focal_method.return: PersistentPreparation
focal_method.signature: PersistentPreparation injectDatasetNameBasedOnId(PersistentPreparation preparation)