Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SONAR-8701 Lines measures are computed using lines from CE Component
- Loading branch information
1 parent
27c1900
commit 6840dc5
Showing
9 changed files
with
282 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
.../java/org/sonar/server/computation/task/projectanalysis/component/FileAttributesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
* SonarQube | ||
* Copyright (C) 2009-2016 SonarSource SA | ||
* mailto:contact AT sonarsource DOT com | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
package org.sonar.server.computation.task.projectanalysis.component; | ||
|
||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.rules.ExpectedException; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public class FileAttributesTest { | ||
|
||
@Rule | ||
public ExpectedException expectedException = ExpectedException.none(); | ||
|
||
@Test | ||
public void create_production_file() throws Exception { | ||
FileAttributes underTest = new FileAttributes(true, "java", 10); | ||
|
||
assertThat(underTest.isUnitTest()).isTrue(); | ||
assertThat(underTest.getLanguageKey()).isEqualTo("java"); | ||
assertThat(underTest.getLines()).isEqualTo(10); | ||
} | ||
|
||
@Test | ||
public void create_unit_test() throws Exception { | ||
FileAttributes underTest = new FileAttributes(true, "java", 10); | ||
|
||
assertThat(underTest.isUnitTest()).isTrue(); | ||
assertThat(underTest.getLanguageKey()).isEqualTo("java"); | ||
assertThat(underTest.getLines()).isEqualTo(10); | ||
} | ||
|
||
@Test | ||
public void create_without_language() throws Exception { | ||
FileAttributes underTest = new FileAttributes(true, null, 10); | ||
|
||
assertThat(underTest.isUnitTest()).isTrue(); | ||
assertThat(underTest.getLanguageKey()).isNull(); | ||
assertThat(underTest.getLines()).isEqualTo(10); | ||
} | ||
|
||
@Test | ||
public void fail_with_IAE_when_lines_is_0() throws Exception { | ||
expectedException.expect(IllegalArgumentException.class); | ||
expectedException.expectMessage("Number of lines must be greater than zero"); | ||
new FileAttributes(true, "java", 0); | ||
} | ||
|
||
@Test | ||
public void fail_with_IAE_when_lines_is_less_than_0() throws Exception { | ||
expectedException.expect(IllegalArgumentException.class); | ||
expectedException.expectMessage("Number of lines must be greater than zero"); | ||
new FileAttributes(true, "java", -10); | ||
} | ||
|
||
@Test | ||
public void test_toString() throws Exception { | ||
assertThat(new FileAttributes(true, "java", 10).toString()).isEqualTo("FileAttributes{languageKey='java', unitTest=true, lines=10}"); | ||
assertThat(new FileAttributes(false, null, 1).toString()).isEqualTo("FileAttributes{languageKey='null', unitTest=false, lines=1}"); | ||
} | ||
} |
Oops, something went wrong.