diff --git a/.idea/isgd-shorten.iml b/.idea/isgd-shorten.iml
deleted file mode 100644
index b01780e..0000000
--- a/.idea/isgd-shorten.iml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
index 5d3d4fc..4290988 100644
--- a/.idea/jarRepositories.xml
+++ b/.idea/jarRepositories.xml
@@ -36,5 +36,10 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
deleted file mode 100644
index df66d51..0000000
--- a/.idea/modules.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/LICENSE.txt b/LICENSE.txt
index 15551d4..695e358 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -1,4 +1,4 @@
-Copyright (c) 2020-2021, Erik C. Thauvin (erik@thauvin.net)
+Copyright (c) 2020-2022, Erik C. Thauvin (erik@thauvin.net)
All rights reserved.
Redistribution and use in source and binary forms, with or without
diff --git a/build.gradle.kts b/build.gradle.kts
index 668da7f..0eed035 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -3,18 +3,18 @@ import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
plugins {
- id("com.github.ben-manes.versions") version "0.39.0"
- id("io.gitlab.arturbosch.detekt") version "1.18.1"
- id("jacoco")
+ id("com.github.ben-manes.versions") version "0.40.0"
+ id("io.gitlab.arturbosch.detekt") version "1.19.0"
id("java")
id("java-library")
id("maven-publish")
id("net.thauvin.erik.gradle.semver") version "1.0.4"
- id("org.jetbrains.dokka") version "1.5.30"
+ id("org.jetbrains.dokka") version "1.6.10"
+ id("org.jetbrains.kotlinx.kover") version "0.4.4"
id("org.sonarqube") version "3.3"
id("signing")
- kotlin("jvm") version "1.5.31"
- kotlin("kapt") version "1.5.31"
+ kotlin("jvm") version "1.6.10"
+ kotlin("kapt") version "1.6.10"
}
group = "net.thauvin.erik"
@@ -56,6 +56,7 @@ sonarqube {
property("sonar.organization", "ethauvin-github")
property("sonar.host.url", "https://sonarcloud.io")
property("sonar.sourceEncoding", "UTF-8")
+ property("sonar.coverage.jacoco.xmlReportPaths", "${project.buildDir}/reports/kover/report.xml")
}
}
@@ -83,18 +84,6 @@ tasks {
destination = file("$projectDir/pom.xml")
}
- jacoco {
- toolVersion = "0.8.7"
- }
-
- jacocoTestReport {
- dependsOn(test)
- reports {
- xml.required.set(true)
- html.required.set(true)
- }
- }
-
assemble {
dependsOn(javadocJar)
}
@@ -144,7 +133,7 @@ tasks {
}
"sonarqube" {
- dependsOn(jacocoTestReport)
+ dependsOn(koverReport)
}
}
diff --git a/examples/build.gradle.kts b/examples/build.gradle.kts
index c0b8126..89cc257 100644
--- a/examples/build.gradle.kts
+++ b/examples/build.gradle.kts
@@ -2,8 +2,8 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("application")
- id("com.github.ben-manes.versions") version "0.39.0"
- kotlin("jvm") version "1.5.31"
+ id("com.github.ben-manes.versions") version "0.40.0"
+ kotlin("jvm") version "1.6.10"
}
// ./gradlew run --args='https://www.example.com https://is.gd/Pt2sET'
diff --git a/examples/gradle/wrapper/gradle-wrapper.properties b/examples/gradle/wrapper/gradle-wrapper.properties
index ffed3a2..2e6e589 100644
--- a/examples/gradle/wrapper/gradle-wrapper.properties
+++ b/examples/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index ffed3a2..2e6e589 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/src/main/kotlin/net/thauvin/erik/isgd/Isgd.kt b/src/main/kotlin/net/thauvin/erik/isgd/Isgd.kt
index b7e4268..161b259 100644
--- a/src/main/kotlin/net/thauvin/erik/isgd/Isgd.kt
+++ b/src/main/kotlin/net/thauvin/erik/isgd/Isgd.kt
@@ -1,7 +1,7 @@
/*
* Isgd.kt
*
- * Copyright (c) 2020-2021, Erik C. Thauvin (erik@thauvin.net)
+ * Copyright (c) 2022, Erik C. Thauvin (erik@thauvin.net)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/src/main/kotlin/net/thauvin/erik/isgd/IsgdException.kt b/src/main/kotlin/net/thauvin/erik/isgd/IsgdException.kt
index 2fabf3f..b6302f1 100644
--- a/src/main/kotlin/net/thauvin/erik/isgd/IsgdException.kt
+++ b/src/main/kotlin/net/thauvin/erik/isgd/IsgdException.kt
@@ -1,7 +1,7 @@
/*
* IsgdException.kt
*
- * Copyright (c) 2020-2021, Erik C. Thauvin (erik@thauvin.net)
+ * Copyright (c) 2022, Erik C. Thauvin (erik@thauvin.net)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/src/test/kotlin/net/thauvin/erik/isgd/IsgdTest.kt b/src/test/kotlin/net/thauvin/erik/isgd/IsgdTest.kt
index b3bd72e..c746e2c 100644
--- a/src/test/kotlin/net/thauvin/erik/isgd/IsgdTest.kt
+++ b/src/test/kotlin/net/thauvin/erik/isgd/IsgdTest.kt
@@ -1,7 +1,7 @@
/*
* IsgdTest.kt
*
- * Copyright (c) 2020-2021, Erik C. Thauvin (erik@thauvin.net)
+ * Copyright (c) 2022, Erik C. Thauvin (erik@thauvin.net)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -45,9 +45,9 @@ class IsgdTest {
@Test
fun testException() {
assertFailsWith(
- message = "URL is already shorten",
- exceptionClass = IsgdException::class,
- block = { Isgd.shorten(shortUrl) }
+ message = "URL is already shorten",
+ exceptionClass = IsgdException::class,
+ block = { Isgd.shorten(shortUrl) }
)
try {
@@ -58,6 +58,15 @@ class IsgdTest {
}
}
+ @Test
+ fun testLookup() {
+ assertFailsWith(
+ message = "empty url",
+ exceptionClass = IllegalArgumentException::class,
+ block = { Isgd.lookup("") }
+ )
+ }
+
@Test
fun testLookupDefault() {
assertEquals(url, Isgd.lookup(shortUrl))
@@ -68,17 +77,32 @@ class IsgdTest {
fun testLookupJson() {
assertEquals("{ \"url\": \"$url\" }", Isgd.lookup(shortUrl, format = Format.JSON))
assertEquals(
- "test({ \"url\": \"$url\" });",
- Isgd.lookup(shortUrl, callback = "test", format = Format.JSON),
- "with callback"
+ "test({ \"url\": \"$url\" });",
+ Isgd.lookup(shortUrl, callback = "test", format = Format.JSON),
+ "with callback"
)
}
@Test
fun testLookupXml() {
assertEquals(
- "",
- Isgd.lookup(shortUrl, format = Format.XML)
+ "",
+ Isgd.lookup(shortUrl, format = Format.XML)
+ )
+ }
+
+ @Test
+ fun testShorten() {
+ assertFailsWith(
+ message = "empty url",
+ exceptionClass = IllegalArgumentException::class,
+ block = { Isgd.shorten("") }
+ )
+
+ assertFailsWith(
+ message = "shorturl already take",
+ exceptionClass = IsgdException::class,
+ block = { Isgd.shorten(url, shorturl = "test") }
)
}
@@ -86,24 +110,25 @@ class IsgdTest {
fun testShortenDefault() {
assertEquals(shortUrl, Isgd.shorten(url))
assertEquals(shortVgdUrl, Isgd.shorten(url, isVgd = true), "v.gd")
+ assertTrue(Isgd.shorten(url, logstats = true).matches("https://is.gd/\\w{6}".toRegex()), "with logstats")
}
@Test
fun testShortenJson() {
assertEquals("{ \"shorturl\": \"$shortUrl\" }", Isgd.shorten(url, format = Format.JSON))
assertEquals(
- "test({ \"shorturl\": \"$shortUrl\" });",
- Isgd.shorten(url, callback = "test", format = Format.JSON),
- "with callback"
+ "test({ \"shorturl\": \"$shortUrl\" });",
+ Isgd.shorten(url, callback = "test", format = Format.JSON),
+ "with callback"
)
}
@Test
fun testShortenXml() {
assertEquals(
- "" +
- "",
- Isgd.shorten(url, format = Format.XML)
+ "" +
+ "",
+ Isgd.shorten(url, format = Format.XML)
)
}