public ImportedProject importProject(ImportProjectRequest request) {
    try (DbSession dbSession = dbClient.openSession(false)) {
      checkNewCodeDefinitionParam(request.newCodeDefinitionType(), request.newCodeDefinitionValue());
      AlmSettingDto almSetting = dbClient.almSettingDao().selectByUuid(dbSession, request.almSettingId()).orElseThrow(() -> new IllegalArgumentException("ALM setting not found"));
      DevOpsProjectDescriptor projectDescriptor = new DevOpsProjectDescriptor(almSetting.getAlm(), almSetting.getUrl(), request.repositoryIdentifier(),
        request.projectIdentifier());

      DevOpsProjectCreator projectCreator = devOpsProjectCreatorFactory.getDevOpsProjectCreator(almSetting, projectDescriptor)
        .orElseThrow(() -> new IllegalArgumentException(format("Platform %s not supported", almSetting.getAlm().name())));

      CreationMethod creationMethod = getCreationMethod(request.monorepo());
      ComponentCreationData componentCreationData = projectCreator.createProjectAndBindToDevOpsPlatform(
        dbSession,
        creationMethod,
        request.monorepo(),
        request.projectKey(),
        request.projectName());

      ProjectDto projectDto = Optional.ofNullable(componentCreationData.projectDto()).orElseThrow();
      BranchDto mainBranchDto = Optional.ofNullable(componentCreationData.mainBranchDto()).orElseThrow();

      if (request.newCodeDefinitionType() != null) {
        newCodeDefinitionResolver.createNewCodeDefinition(dbSession, projectDto.getUuid(), mainBranchDto.getUuid(),
          mainBranchDto.getKey(), request.newCodeDefinitionType(), request.newCodeDefinitionValue());
      }
      componentUpdater.commitAndIndex(dbSession, componentCreationData);
      ProjectAlmSettingDto projectAlmSettingDto = dbClient.projectAlmSettingDao().selectByProject(dbSession, projectDto)
        .orElseThrow(() -> new IllegalStateException("Project ALM setting was not created"));
      dbSession.commit();
      return new ImportedProject(projectDto, projectAlmSettingDto);
    }
  }
@Test
  void createImportedProject_whenAlmIsSupportedAndNoNewCodeDefinitionDefined_shouldCreateProject() {
    userSession.logIn().addPermission(PROVISION_PROJECTS);
    DbSession dbSession = mockDbSession();
    AlmSettingDto almSetting = mockAlmSetting(dbSession);

    DevOpsProjectCreator devOpsProjectCreator = mockDevOpsProjectCreator(almSetting);

    ComponentCreationData componentCreationData = mockProjectCreation(devOpsProjectCreator, ALM_IMPORT_MONOREPO_API, true, dbSession);

    ProjectDto projectDto = mockProjectDto(componentCreationData);
    when(componentCreationData.mainBranchDto()).thenReturn(mock(BranchDto.class));

    ProjectAlmSettingDto projectAlmSettingDto = mockProjectAlmSetting(dbSession, projectDto);

    ImportProjectRequest request = new ImportProjectRequest(PROJECT_KEY, PROJECT_NAME, ALM_SETTING_ID, DOP_REPOSITORY_ID, DOP_PROJECT_ID, null, null, true);

    ImportedProject importedProject = importProjectService.importProject(request);

    assertThat(importedProject.projectDto()).isEqualTo(projectDto);
    assertThat(importedProject.projectAlmSettingDto()).isEqualTo(projectAlmSettingDto);

    verify(componentUpdater).commitAndIndex(dbSession, componentCreationData);
  }