Skip to content

Commit

Permalink
chore: small clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
MikAoJk committed Nov 14, 2024
1 parent c32988e commit beb039d
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 46 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ This project is currently maintained by the organisation [@navikt](https://githu

If you need to raise an issue or question about this library, please create an issue here and tag it with the appropriate label.

For contact requests within the [@navikt](https://github.com/navikt) org, you can use the slack channel #pdfgen
For contact requests within the [@navikt](https://github.com/navikt) org, you can use the Slack channel #pdfgen

If you need to contact anyone directly, please see contributors.

Expand Down
12 changes: 6 additions & 6 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ val jacksonVersion = "2.18.1"
val jaxbVersion = "4.0.5"
val jaxbApiVersion = "2.3.1"
val jsoupVersion = "1.18.1"
val kluentVersion = "1.72"
val logbackVersion = "1.5.12"
val logstashEncoderVersion = "8.0"
val openHtmlToPdfVersion = "1.1.22"
Expand All @@ -18,7 +17,7 @@ val junitJupiterVersion = "5.11.3"
val verapdfVersion = "1.26.1"
val ktfmtVersion = "0.44"
val kotlinloggerVersion = "7.0.0"
val kotestVersion = "5.9.1"
val commonsIoVersion = "2.17.0"
val javaVersion = JvmTarget.JVM_21


Expand Down Expand Up @@ -68,6 +67,11 @@ dependencies {
implementation("io.github.openhtmltopdf:openhtmltopdf-pdfbox:$openHtmlToPdfVersion")
implementation("io.github.openhtmltopdf:openhtmltopdf-slf4j:$openHtmlToPdfVersion")
implementation("io.github.openhtmltopdf:openhtmltopdf-svg-support:$openHtmlToPdfVersion")
constraints {
implementation("commons-io:commons-io:$commonsIoVersion") {
because("Due to vulnerabilities in io.github.openhtmltopdf:openhtmltopdf-svg-support")
}
}

implementation("org.jsoup:jsoup:$jsoupVersion")
implementation("com.fasterxml.jackson.core:jackson-core:$jacksonVersion")
Expand All @@ -89,10 +93,6 @@ dependencies {
testImplementation("org.junit.jupiter:junit-jupiter-params:$junitJupiterVersion")
testImplementation("org.junit.jupiter:junit-jupiter-engine:$junitJupiterVersion")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
testImplementation("io.kotest:kotest-assertions-core:$kotestVersion")
testImplementation("io.kotest:kotest-property:$kotestVersion")


}

java {
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
7 changes: 5 additions & 2 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down Expand Up @@ -84,7 +86,8 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down
22 changes: 12 additions & 10 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem

@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
Expand Down Expand Up @@ -43,11 +45,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand All @@ -57,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand Down
52 changes: 31 additions & 21 deletions src/test/kotlin/no/nav/pdfgen/HelperTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ import com.github.jknack.handlebars.Handlebars
import com.github.jknack.handlebars.JsonNodeValueResolver
import com.github.jknack.handlebars.context.MapValueResolver
import com.github.jknack.handlebars.io.ClassPathTemplateLoader
import io.kotest.matchers.shouldBe
import io.kotest.matchers.string.shouldInclude
import io.kotest.matchers.string.shouldNotInclude
import no.nav.pdfgen.core.Environment
import no.nav.pdfgen.core.PDFGenCore
import no.nav.pdfgen.core.objectMapper
Expand Down Expand Up @@ -159,13 +156,13 @@ internal class HelperTest {
{{barn.navn}}
{{/filter}}
"""
.trimIndent()
.trimIndent(),
)

val result = template.apply(jsonContext(jsonString.toJson()))
result shouldInclude "Barn1 Etternavn"
result shouldInclude "Barn2 Etternavn"
result shouldNotInclude "Mor Etternavn"
assertEquals(true, result.contains("Barn1 Etternavn"))
assertEquals(true, result.contains("Barn2 Etternavn"))
assertEquals(false, result.contains("Mor Etternavn"))
}

@Test
Expand All @@ -187,11 +184,12 @@ internal class HelperTest {
"""
{{json_to_period periode}}
"""
.trimIndent()
.trimIndent(),
)

val result = template.apply(jsonContext(jsonString.toJson()))
result shouldBe "20.03.2020 - 23.09.2021"

assertEquals(result, "20.03.2020 - 23.09.2021")
}

@Test
Expand All @@ -213,11 +211,11 @@ internal class HelperTest {
"""
{{json_to_period periode}}
"""
.trimIndent()
.trimIndent(),
)

val result = template.apply(jsonContext(jsonString.toJson()))
result shouldBe "20.03.2020 - 23.09.2021"
assertEquals(result, "20.03.2020 - 23.09.2021")
}

@Test
Expand All @@ -236,11 +234,11 @@ internal class HelperTest {
"""
{{json_to_period periode}}
"""
.trimIndent()
.trimIndent(),
)

val result = template.apply(jsonContext(jsonString.toJson()))
result shouldBe "09.08.2019 - 10.08.2019"
assertEquals(result, "09.08.2019 - 10.08.2019")
}

@Test
Expand All @@ -261,11 +259,11 @@ internal class HelperTest {
"""
{{json_to_period periode}}
"""
.trimIndent()
.trimIndent(),
)

val result = template.apply(jsonContext(jsonString.toJson()))
result shouldBe "20.03.2020 - "
assertEquals(result, "20.03.2020 - ")
}

@Test
Expand Down Expand Up @@ -399,9 +397,14 @@ internal class HelperTest {
},
)

handlebars.compileInline("{{ iso_to_nor_date date }}").apply(context) shouldBe "03.03.2020"
handlebars.compileInline("{{ iso_to_nor_date dateWithoutDay }}").apply(context) shouldBe
"01.03.2020"
assertEquals(
handlebars.compileInline("{{ iso_to_nor_date date }}").apply(context),
"03.03.2020"
)
assertEquals(
handlebars.compileInline("{{ iso_to_nor_date dateWithoutDay }}").apply(context),
"01.03.2020",
)
}

@Test
Expand All @@ -414,9 +417,14 @@ internal class HelperTest {
},
)

handlebars.compileInline("{{ iso_to_year_month date }}").apply(context) shouldBe "03.2020"
handlebars.compileInline("{{ iso_to_year_month dateWithDay }}").apply(context) shouldBe
assertEquals(
handlebars.compileInline("{{ iso_to_year_month date }}").apply(context),
"03.2020"
)
assertEquals(
handlebars.compileInline("{{ iso_to_year_month dateWithDay }}").apply(context),
"03.2020",
)
}

@Test
Expand Down Expand Up @@ -1597,7 +1605,9 @@ internal class HelperTest {
},
)

handlebars.compileInline("{{concat value1 value2 value3 }}").apply(context) shouldBe
assertEquals(
handlebars.compileInline("{{concat value1 value2 value3 }}").apply(context),
"Value1 123123 value3"
)
}
}
5 changes: 0 additions & 5 deletions src/test/kotlin/no/nav/pdfgen/TestUtils.kt

This file was deleted.

0 comments on commit beb039d

Please sign in to comment.