Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

IssueListenerAdapterTest.java 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * SonarQube Runner - API
  3. * Copyright (C) 2011 SonarSource
  4. * sonarqube@googlegroups.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
  17. * License along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
  19. */
  20. package org.sonar.runner.api;
  21. import static org.assertj.core.api.Assertions.assertThat;
  22. import static org.mockito.Mockito.verify;
  23. import org.mockito.ArgumentCaptor;
  24. import org.junit.Before;
  25. import org.junit.Test;
  26. import static org.mockito.Mockito.mock;
  27. public class IssueListenerAdapterTest {
  28. private IssueListenerAdapter adapter;
  29. private IssueListener issueListener;
  30. @Before
  31. public void setUp() {
  32. issueListener = mock(IssueListener.class);
  33. adapter = new IssueListenerAdapter(issueListener);
  34. }
  35. @Test
  36. public void test() {
  37. org.sonar.runner.batch.IssueListener.Issue issue = new org.sonar.runner.batch.IssueListener.Issue();
  38. issue.setAssigneeName("dummy");
  39. issue.setStartLineOffset(2);
  40. adapter.handle(issue);
  41. ArgumentCaptor<Issue> argument = ArgumentCaptor.forClass(Issue.class);
  42. verify(issueListener).handle(argument.capture());
  43. Issue i = argument.getValue();
  44. assertThat(i.getAssigneeName()).isEqualTo("dummy");
  45. assertThat(i.getStartLineOffset()).isEqualTo(2);
  46. }
  47. }