Skip to content

Commit

Permalink
refactor: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Dec 8, 2023
1 parent af04896 commit 2fc0ce3
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,45 +19,45 @@ class BadsmellAnalyserTest {
internal fun shouldIdentifyJavaEmptyTest() {
val path = getAbsolutePath("bs/LazyClass.java")
val data = JavaAnalyser().analysis(File(path).readText(), "LazyClass.java").DataStructures
val results = BadsmellAnalyser(data).analysis()
val results = BadsmellAnalyser().analysis(data)

assertEquals(1, results.size)
assertEquals("LazyClass.java", results[0].file)
assertEquals(SmellType.SMELL_LAZY_ELEMENT, results[0].bs)
assertEquals("LazyClass.java", results[0].fullName)
assertEquals("SMELL_LAZY_ELEMENT", results[0].name)
}

@Test
fun shouldIdentifyLongParameters() {
val path = getAbsolutePath("bs/LongParameter.java")
val data = JavaAnalyser().analysis(File(path).readText(), "LongParameter.java").DataStructures
val results = BadsmellAnalyser(data).analysis()
val results = BadsmellAnalyser().analysis(data)

assertEquals(1, results.size)
assertEquals("LongParameter.java", results[0].file)
assertEquals(SmellType.SMELL_LONG_PARAMETER_LIST, results[0].bs)
assertEquals("LongParameter.java", results[0].fullName)
assertEquals("SMELL_LONG_PARAMETER_LIST", results[0].name)
}

@Test
@Disabled
fun shouldIdentifyMultipleIf() {
val path = getAbsolutePath("bs/MultipleIf.java")
val data = JavaAnalyser().analysis(File(path).readText(), "MultipleIf.java").DataStructures
val results = BadsmellAnalyser(data).analysis()
val results = BadsmellAnalyser().analysis(data)

assertEquals(1, results.size)
assertEquals("MultipleIf.java", results[0].file)
assertEquals(SmellType.SMELL_COMPLEX_CONDITION, results[0].bs)
assertEquals("MultipleIf.java", results[0].fullName)
assertEquals("SMELL_COMPLEX_CONDITION", results[0].name)
}

@Test
fun shouldIdentifyLargeClass() {
val path = getAbsolutePath("bs/LargeClass.java")
val data = JavaAnalyser().analysis(File(path).readText(), "LargeClass.java").DataStructures
val results = BadsmellAnalyser(data).analysis()
val results = BadsmellAnalyser().analysis(data)

assertEquals(1, results.size)
assertEquals("LargeClass.java", results[0].file)
assertEquals(SmellType.SMELL_LARGE_CLASS, results[0].bs)
assertEquals("LargeClass.java", results[0].fullName)
assertEquals("SMELL_LARGE_CLASS", results[0].name)
}

@Test
Expand All @@ -74,11 +74,11 @@ class BadsmellAnalyserTest {
}
}.flatten().toList()

val results = BadsmellAnalyser(data).analysis()
val results = BadsmellAnalyser().analysis(data)

assertEquals(1, results.size)
assertEquals("GraphCallA.java", results[0].file)
assertEquals("", results[0].description)
assertEquals(SmellType.SMELL_GARPH_CONNECTED_CALL, results[0].bs)
assertEquals("GraphCallA.java", results[0].fullName)
assertEquals("", results[0].detail)
assertEquals("SMELL_GARPH_CONNECTED_CALL", results[0].name)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class EstimateAnalyserTest {
val file = File("sample.txt").canonicalPath

// when
val summary = EstimateAnalyser.getInstance().analysisByContent(content, file, "Go")!!
val summary = EstimateAnalyser().analysisByContent(content, file, "Go")!!

// then
assertEquals("Go", summary.name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,80 +17,80 @@ class TestBadsmellAnalyserTest {
internal fun shouldIdentifyJavaEmptyTest() {
val path = getAbsolutePath("tbs/EmptyTest.java")
val data = JavaAnalyser().analysis(File(path).readText(), "EmptyTest.java").DataStructures
val results = TestBadsmellAnalyser(data).analysis()
val results = TestBadsmellAnalyser().analysis(data)

assertEquals(results[0].fileName, "EmptyTest.java")
assertEquals(results[0].line, 8)
assertEquals(results[0].type, "EmptyTest")
assertEquals(results[0].fullName, "EmptyTest.java")
assertEquals(results[0].source, "8")
assertEquals(results[0].name, "EmptyTest")
}

@Test
internal fun shouldIdentifyJavaIgnoreTest() {
val path = getAbsolutePath("tbs/IgnoreTest.java")
val data = JavaAnalyser().analysis(File(path).readText(), path).DataStructures
val results = TestBadsmellAnalyser(data).analysis()
val results = TestBadsmellAnalyser().analysis(data)

assertEquals(results[0].line, 7)
assertEquals(results[0].type, "IgnoreTest")
assertEquals(results[0].source, "7")
assertEquals(results[0].name, "IgnoreTest")
}

@Test
internal fun shouldIdentifyJavaRedundantPrintTest() {
val path = getAbsolutePath("tbs/RedundantPrintTest.java")
val data = JavaAnalyser().analysis(File(path).readText(), path).DataStructures
val results = TestBadsmellAnalyser(data).analysis()
val results = TestBadsmellAnalyser().analysis(data)

assertEquals(results[0].line, 9)
assertEquals(results[0].type, "RedundantPrintTest")
assertEquals(results[0].source, "9")
assertEquals(results[0].name, "RedundantPrintTest")
}

@Test
internal fun shouldIdentifyJavaSleepyTest() {
val path = getAbsolutePath("tbs/SleepyTest.java")
val data = JavaAnalyser().analysis(File(path).readText(), path).DataStructures
val results = TestBadsmellAnalyser(data).analysis()
val results = TestBadsmellAnalyser().analysis(data)

assertEquals(results[0].line, 8)
assertEquals(results[0].type, "SleepyTest")
assertEquals(results[0].source, "8")
assertEquals(results[0].name, "SleepyTest")
}

@Test
internal fun shouldIdentifyRedundantAssertionTest() {
val path = getAbsolutePath("tbs/RedundantAssertionTest.java")
val data = JavaAnalyser().analysis(File(path).readText(), path).DataStructures
val results = TestBadsmellAnalyser(data).analysis()
val results = TestBadsmellAnalyser().analysis(data)

assertEquals(results[0].line, 14)
assertEquals(results[0].type, "RedundantAssertionTest")
assertEquals(results[0].source, "14")
assertEquals(results[0].name, "RedundantAssertionTest")
}

@Test
internal fun shouldIdentifyUnknownTest() {
val path = getAbsolutePath("tbs/UnknownTest.java")
val data = JavaAnalyser().analysis(File(path).readText(), path).DataStructures
val results = TestBadsmellAnalyser(data).analysis()
val results = TestBadsmellAnalyser().analysis(data)

assertEquals(results[0].line, 7)
assertEquals(results[0].type, "EmptyTest")
assertEquals(results[1].line, 7)
assertEquals(results[1].type, "UnknownTest")
assertEquals(results[0].source, "7")
assertEquals(results[0].name, "EmptyTest")
assertEquals(results[1].source, "7")
assertEquals(results[1].name, "UnknownTest")
}

@Test
internal fun shouldIdentifyDuplicateAssertTest() {
val path = getAbsolutePath("tbs/DuplicateAssertTest.java")
val data = JavaAnalyser().analysis(File(path).readText(), path).DataStructures
val results = TestBadsmellAnalyser(data).analysis()
val results = TestBadsmellAnalyser().analysis(data)

assertEquals(results[0].line, 9)
assertEquals(results[0].type, "DuplicateAssertTest")
assertEquals(results[0].source, "9")
assertEquals(results[0].name, "DuplicateAssertTest")
}

@Test
internal fun shouldReturnEmptyWhenIsCreator() {
val path = getAbsolutePath("tbs/regression/CreatorNotUnknownTest.java")
val data = JavaAnalyser().analysis(File(path).readText(), path).DataStructures
val results = TestBadsmellAnalyser(data).analysis()
val results = TestBadsmellAnalyser().analysis(data)

assertEquals(results.size, 0)
}
Expand All @@ -99,7 +99,7 @@ class TestBadsmellAnalyserTest {
internal fun shouldReturnEmptyWhenCallAssertInClassTests() {
val path = getAbsolutePath("tbs/regression/CallAssertInClassTests.java")
val data = JavaAnalyser().analysis(File(path).readText(), path).DataStructures
val results = TestBadsmellAnalyser(data).analysis()
val results = TestBadsmellAnalyser().analysis(data)

assertEquals(results.size, 0)
}
Expand All @@ -108,7 +108,7 @@ class TestBadsmellAnalyserTest {
internal fun shouldReturnEmptyWhenCall() {
val path = getAbsolutePath("tbs/regression/EnvironmentSystemIntegrationTests.java")
val data = JavaAnalyser().analysis(File(path).readText(), path).DataStructures
val results = TestBadsmellAnalyser(data).analysis()
val results = TestBadsmellAnalyser().analysis(data)

assertEquals(results.size, 0)
}
Expand All @@ -117,7 +117,7 @@ class TestBadsmellAnalyserTest {
internal fun shouldReturnMultipleResults() {
val path = getAbsolutePath("tbs/regression/I18NTest.java")
val data = JavaAnalyser().analysis(File(path).readText(), path).DataStructures
val results = TestBadsmellAnalyser(data).analysis()
val results = TestBadsmellAnalyser().analysis(data)

assertEquals(results.size, 4)
}
Expand Down

0 comments on commit 2fc0ce3

Please sign in to comment.