You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

GitlabProjectCreatorFactoryTest.java 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2024 SonarSource SA
  4. * mailto:info AT sonarsource DOT com
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 3 of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public License
  17. * along with this program; if not, write to the Free Software Foundation,
  18. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. */
  20. package org.sonar.server.almsettings.ws.gitlab;
  21. import java.util.Map;
  22. import org.assertj.core.api.AssertionsForClassTypes;
  23. import org.junit.jupiter.api.Test;
  24. import org.junit.jupiter.api.extension.ExtendWith;
  25. import org.mockito.InjectMocks;
  26. import org.mockito.Mockito;
  27. import org.mockito.junit.jupiter.MockitoExtension;
  28. import org.sonar.db.DbSession;
  29. import org.sonar.db.alm.setting.ALM;
  30. import org.sonar.db.alm.setting.AlmSettingDto;
  31. import org.sonar.server.almsettings.ws.DevOpsProjectDescriptor;
  32. import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
  33. import static org.mockito.Mockito.mock;
  34. import static org.mockito.Mockito.when;
  35. @ExtendWith(MockitoExtension.class)
  36. class GitlabProjectCreatorFactoryTest {
  37. @InjectMocks
  38. private GitlabProjectCreatorFactory underTest;
  39. @Test
  40. void getDevOpsProjectCreator_withCharacteristics_returnsEmpty() {
  41. assertThat(underTest.getDevOpsProjectCreator(mock(DbSession.class), Map.of())).isEmpty();
  42. }
  43. @Test
  44. void getDevOpsProjectCreator_whenDevOpsPlatformIsNotGitlab_returnsEmpty() {
  45. AlmSettingDto almSetting = mock();
  46. when(almSetting.getAlm()).thenReturn(ALM.AZURE_DEVOPS);
  47. AssertionsForClassTypes.assertThat(underTest.getDevOpsProjectCreator(almSetting, Mockito.mock(DevOpsProjectDescriptor.class))).isEmpty();
  48. }
  49. @Test
  50. void getDevOpsProjectCreator_whenDevOpsPlatformIsNotGitlab_returnsProjectCreator() {
  51. AlmSettingDto almSetting = mock();
  52. when(almSetting.getAlm()).thenReturn(ALM.GITLAB);
  53. assertThat(underTest.getDevOpsProjectCreator(almSetting, mock(DevOpsProjectDescriptor.class))).isNotEmpty();
  54. }
  55. }