-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* introduce JacocoCoverageRule * add JacocoCoverageRuleTest * support all nested objects * improve test coverage * add more tests
- Loading branch information
Showing
76 changed files
with
2,454 additions
and
296 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
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 |
---|---|---|
|
@@ -17,3 +17,5 @@ allprojects { | |
jcenter() | ||
} | ||
} | ||
|
||
apply { from("jacoco/jacocoFullReport.gradle") } |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package io.github.tarek360.core | ||
|
||
|
||
inline fun <T, R> Iterable<T>.filterThenMapIfNotNull(transform: (T) -> R?): List<R> { | ||
val size = if (this is Collection<*>) this.size else 10 | ||
val list = ArrayList<R>(size) | ||
for (element in this) { | ||
val mapped = transform(element) | ||
if (mapped != null) { | ||
list.add(mapped) | ||
} | ||
} | ||
return list | ||
} | ||
|
||
inline fun <T, R> Iterable<T>.filterThenMap(predicate: (T) -> Boolean, transform: (T) -> R): List<R> { | ||
val size = if (this is Collection<*>) this.size else 10 | ||
val list = ArrayList<R>(size) | ||
for (element in this) { | ||
if (predicate(element)) { | ||
val mapped = transform(element) | ||
list.add(mapped) | ||
} | ||
} | ||
return list | ||
} | ||
|
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 |
---|---|---|
@@ -1,6 +1,15 @@ | ||
package io.github.tarek360.core | ||
|
||
import org.junit.Assert.assertEquals | ||
import org.hamcrest.CoreMatchers.instanceOf | ||
import org.junit.Assert.* | ||
|
||
infix fun Any.mustEqual(expected: Any) = assertEquals(expected, this) | ||
infix fun Any.mustInstanceOf(expected: Class<*>) = assertThat(this, instanceOf(expected)) | ||
|
||
infix fun Any?.mustEqualAndNotNull(expected: Any) { | ||
assertNotNull(this) | ||
assertEquals(expected, this) | ||
} | ||
|
||
infix fun Collection<Any>.mustHaveSize(expected: Int) = assertEquals("unexpected size", expected, this.size) | ||
|
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 |
---|---|---|
@@ -1,33 +1,35 @@ | ||
package io.github.tarek360.core | ||
|
||
const val DEBUGGABLE = false | ||
const val DEBUGGABLE = true | ||
|
||
val logger: Logger = Logger() | ||
|
||
class Logger { | ||
|
||
val ANSI_RED = "\u001B[31m" | ||
val ANSI_YELLOW = "\u001B[33m" | ||
val ANSI_WHITE = "\u001B[37m" | ||
val ANSI_GREEN = "\u001B[32m" | ||
val ANSI_RESET = "\u001B[0m" | ||
companion object { | ||
private const val ANSI_RED = "\u001B[31m" | ||
private const val ANSI_YELLOW = "\u001B[33m" | ||
private const val ANSI_WHITE = "\u001B[37m" | ||
private const val ANSI_GREEN = "\u001B[32m" | ||
private const val ANSI_RESET = "\u001B[0m" | ||
} | ||
|
||
fun d(msg: () -> String?) { | ||
if (DEBUGGABLE) { | ||
println("$ANSI_WHITE${msg()}$ANSI_RESET") | ||
fun d(msg: () -> String?) { | ||
if (DEBUGGABLE) { | ||
println("$ANSI_WHITE${msg()}$ANSI_RESET") | ||
} | ||
} | ||
} | ||
|
||
fun e(msg: () -> String?) { | ||
println("$ANSI_RED${msg()}$ANSI_RESET") | ||
} | ||
fun e(msg: () -> String?) { | ||
println("$ANSI_RED${msg()}$ANSI_RESET") | ||
} | ||
|
||
fun w(msg: () -> String?) { | ||
println("$ANSI_YELLOW${msg()}$ANSI_RESET") | ||
} | ||
fun w(msg: () -> String?) { | ||
println("$ANSI_YELLOW${msg()}$ANSI_RESET") | ||
} | ||
|
||
fun i(msg: () -> String?) { | ||
println("$ANSI_GREEN${msg()}$ANSI_RESET") | ||
} | ||
fun i(msg: () -> String?) { | ||
println("$ANSI_GREEN${msg()}$ANSI_RESET") | ||
} | ||
|
||
} |
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
9 changes: 0 additions & 9 deletions
9
gitdiff-parser/src/main/java/io/github/tarek360/gitdiff/GitDiff.kt
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
12 changes: 12 additions & 0 deletions
12
gitdiff-parser/src/main/java/io/github/tarek360/gitdiff/GitDiffProvider.kt
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,12 @@ | ||
package io.github.tarek360.gitdiff | ||
|
||
import io.github.tarek360.gitdiffprovider.GitCommanderProvider | ||
|
||
class GitDiffProvider { | ||
companion object { | ||
fun provide(baseSha: String, headSha: String): GitDiff { | ||
val gitCommander = GitCommanderProvider.provide(baseSha, headSha) | ||
return GitDiffImpl(gitCommander) | ||
} | ||
} | ||
} |
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
24 changes: 24 additions & 0 deletions
24
githost/src/main/java/io/github/tarek360/githost/UnknownGitHost.kt
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,24 @@ | ||
package io.github.tarek360.githost | ||
|
||
import io.github.tarek360.core.logger | ||
|
||
class UnknownGitHost : GitHost { | ||
|
||
override fun post(comment: Comment): String? { | ||
logger.w { "Unknown GitHost: Koshry can't post the report" } | ||
return null | ||
} | ||
|
||
override fun post(status: Status) { | ||
logger.w { "Unknown GitHost: Koshry can't post the status" } | ||
} | ||
|
||
override fun pushFile(filePath: String, branchName: String, commitMsg: String) { | ||
logger.w { "Unknown GitHost: Koshry can't push files" } | ||
} | ||
|
||
override fun getPullRequestInfo(): PullRequest? { | ||
logger.w { "Unknown GitHost: Koshry can't get the Pull Request Info" } | ||
return null | ||
} | ||
} |
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
23 changes: 23 additions & 0 deletions
23
githost/src/test/kotlin/io/github/tarek360/githost/github/GitHubTest.kt
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,23 @@ | ||
package io.github.tarek360.githost.github | ||
|
||
import io.github.tarek360.githost.Comment | ||
import io.github.tarek360.githost.GitHostInfo | ||
import io.github.tarek360.githost.Status | ||
import org.junit.Test | ||
|
||
class GitHubTest { | ||
|
||
@Test | ||
fun postComment() { | ||
val gitHostInfo = GitHostInfo("tarek360/RichPath", 1, "abcd1234") | ||
val gitHub = GitHub(gitHostInfo) | ||
gitHub.post(Comment("Hi", false)) | ||
} | ||
|
||
@Test | ||
fun postStatus() { | ||
val gitHostInfo = GitHostInfo("tarek360/RichPath", 1, "abcd1234") | ||
val gitHub = GitHub(gitHostInfo) | ||
gitHub.post(Status("", Status.Type.SUCCESS, "abcef98765", "Status description", null)) | ||
} | ||
} |
Oops, something went wrong.