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.

SearchTemplatesDataTest.java 2.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2019 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.permission.ws.template;
  21. import com.google.common.collect.HashBasedTable;
  22. import org.junit.Rule;
  23. import org.junit.Test;
  24. import org.junit.rules.ExpectedException;
  25. import static java.util.Collections.singletonList;
  26. import static org.sonar.db.permission.template.PermissionTemplateTesting.newPermissionTemplateDto;
  27. public class SearchTemplatesDataTest {
  28. @Rule
  29. public ExpectedException expectedException = ExpectedException.none();
  30. SearchTemplatesData.Builder underTest = SearchTemplatesData.builder()
  31. .defaultTemplates(new DefaultTemplatesResolverImpl.ResolvedDefaultTemplates("template_uuid", null, null))
  32. .templates(singletonList(newPermissionTemplateDto()))
  33. .userCountByTemplateIdAndPermission(HashBasedTable.create())
  34. .groupCountByTemplateIdAndPermission(HashBasedTable.create())
  35. .withProjectCreatorByTemplateIdAndPermission(HashBasedTable.create());
  36. @Test
  37. public void fail_if_templates_is_null() {
  38. expectedException.expect(IllegalStateException.class);
  39. underTest.templates(null);
  40. underTest.build();
  41. }
  42. @Test
  43. public void fail_if_default_templates_are_null() {
  44. expectedException.expect(IllegalStateException.class);
  45. underTest.defaultTemplates(null);
  46. underTest.build();
  47. }
  48. @Test
  49. public void fail_if_user_count_is_null() {
  50. expectedException.expect(IllegalStateException.class);
  51. underTest.userCountByTemplateIdAndPermission(null);
  52. underTest.build();
  53. }
  54. @Test
  55. public void fail_if_group_count_is_null() {
  56. expectedException.expect(IllegalStateException.class);
  57. underTest.groupCountByTemplateIdAndPermission(null);
  58. underTest.build();
  59. }
  60. @Test
  61. public void fail_if_with_project_creators_is_null() {
  62. expectedException.expect(IllegalStateException.class);
  63. underTest.withProjectCreatorByTemplateIdAndPermission(null);
  64. underTest.build();
  65. }
  66. }