test_class.declarator: IS_MULTITENANT = false
test_class.modifier: private static final
test_class.original_string: private static final boolean IS_MULTITENANT = false;
test_class.type: boolean
test_class.var_name: IS_MULTITENANT
test_class.declarator: multitenantStorage
test_class.modifier: private
test_class.original_string: private MultitenantStorage<TenantRecords<ProjectId>> multitenantStorage;
test_class.type: MultitenantStorage<TenantRecords<ProjectId>>
test_class.var_name: multitenantStorage
test_class.file: server/src/test/java/io/spine/server/storage/memory/MultitenantStorageTest.java
test_class.identifier: MultitenantStorageTest
test_case.body: @Test
      @DisplayName("return same slice within single tenant and multitenant environment")
      void returnSameSlice()
              throws InterruptedException, ExecutionException {
          int numberOfTasks = 1000;
          Collection<Callable<TenantRecords>> tasks = newArrayListWithExpectedSize(numberOfTasks);
  
          for (int i = 0; i < numberOfTasks; i++) {
              tasks.add(() -> {
                  TenantRecords<ProjectId> storage = multitenantStorage.currentSlice();
                  return storage;
              });
          }
  
          List<Future<TenantRecords>> futures = executeInMultithreadedEnvironment(tasks);
          Set<TenantRecords> tenantRecords = convertFuturesToSetOfCompletedResults(futures);
  
          int expected = 1;
          assertEquals(expected, tenantRecords.size());
      }
test_case.class_method_signature: MultitenantStorageTest.returnSameSlice()
test_case.full_signature: @Test @DisplayName("return same slice within single tenant and multitenant environment") void returnSameSlice()
test_case.identifier: returnSameSlice
test_case.invocations: newArrayListWithExpectedSize add currentSlice executeInMultithreadedEnvironment convertFuturesToSetOfCompletedResults assertEquals size
test_case.modifiers: @Test @DisplayName("return same slice within single tenant and multitenant environment")
test_case.parameters: ()
test_case.return: void
test_case.signature: void returnSameSlice()
focal_class.declarator: lock = new ReentrantLock()
focal_class.modifier: private final
focal_class.original_string: private final Lock lock = new ReentrantLock();
focal_class.type: Lock
focal_class.var_name: lock
focal_class.declarator: tenantSlices = newConcurrentMap()
focal_class.modifier: private final
focal_class.original_string: private final Map<TenantId, S> tenantSlices = newConcurrentMap();
focal_class.type: Map<TenantId, S>
focal_class.var_name: tenantSlices
focal_class.declarator: multitenant
focal_class.modifier: private final
focal_class.original_string: private final boolean multitenant;
focal_class.type: boolean
focal_class.var_name: multitenant
focal_class.file: server/src/main/java/io/spine/server/storage/memory/MultitenantStorage.java
focal_class.identifier: MultitenantStorage
focal_class.class_method_signature: MultitenantStorage.MultitenantStorage(boolean multitenant)
focal_class.full_signature:   MultitenantStorage(boolean multitenant)
focal_class.identifier: MultitenantStorage
focal_class.parameters: (boolean multitenant)
focal_class.signature:  MultitenantStorage(boolean multitenant)
focal_class.class_method_signature: MultitenantStorage.currentSlice()
focal_class.full_signature: final S currentSlice()
focal_class.identifier: currentSlice
focal_class.modifiers: final
focal_class.parameters: ()
focal_class.return: S
focal_class.signature: S currentSlice()
focal_class.class_method_signature: MultitenantStorage.createSlice()
focal_class.full_signature: abstract S createSlice()
focal_class.identifier: createSlice
focal_class.modifiers: abstract
focal_class.parameters: ()
focal_class.return: S
focal_class.signature: S createSlice()
focal_class.class_method_signature: MultitenantStorage.isMultitenant()
focal_class.full_signature: final boolean isMultitenant()
focal_class.identifier: isMultitenant
focal_class.modifiers: final
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean isMultitenant()
focal_method.body: final S currentSlice() {
          TenantFunction<S> func = new TenantFunction<S>(isMultitenant()) {
              @Override
              public @Nullable S apply(@Nullable TenantId tenantId) {
                  checkNotNull(tenantId);
                  lock.lock();
                  try {
                      return tenantSlices.computeIfAbsent(tenantId, id -> createSlice());
                  } finally {
                      lock.unlock();
                  }
              }
          };
          S result = func.execute();
          checkNotNull(result, "Current tenant slice is null.");
          return result;
      }
focal_method.class_method_signature: MultitenantStorage.currentSlice()
focal_method.full_signature: final S currentSlice()
focal_method.identifier: currentSlice
focal_method.invocations: isMultitenant checkNotNull lock computeIfAbsent createSlice unlock execute checkNotNull
focal_method.modifiers: final
focal_method.parameters: ()
focal_method.return: S
focal_method.signature: S currentSlice()