diff --git a/runtime-components/non-repudiation-app/BUILD.bazel b/runtime-components/non-repudiation-app/BUILD.bazel index f1ba3667a0c6..bcdd7edbf06f 100644 --- a/runtime-components/non-repudiation-app/BUILD.bazel +++ b/runtime-components/non-repudiation-app/BUILD.bazel @@ -4,6 +4,7 @@ load( "//bazel_tools:scala.bzl", "da_scala_binary", + "da_scala_test", ) da_scala_binary( @@ -35,3 +36,14 @@ da_scala_binary( "@maven//:io_grpc_grpc_netty", ], ) + +da_scala_test( + name = "test", + srcs = glob(["src/test/scala/**/*.scala"]), + scala_deps = [ + "@maven//:com_github_scopt_scopt", + ], + deps = [ + ":non-repudiation-app", + ], +) diff --git a/runtime-components/non-repudiation-app/src/test/scala/com/daml/nonrepudiation/app/OptionParserSpec.scala b/runtime-components/non-repudiation-app/src/test/scala/com/daml/nonrepudiation/app/OptionParserSpec.scala new file mode 100644 index 000000000000..8b0361708937 --- /dev/null +++ b/runtime-components/non-repudiation-app/src/test/scala/com/daml/nonrepudiation/app/OptionParserSpec.scala @@ -0,0 +1,54 @@ +// Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 + +package com.daml.nonrepudiation.app + +import java.net.InetSocketAddress + +import org.scalatest.OptionValues +import org.scalatest.flatspec.AnyFlatSpec +import org.scalatest.matchers.should.Matchers + +final class OptionParserSpec extends AnyFlatSpec with Matchers with OptionValues { + + behavior of "OptionParser" + + it should "parse the expected options" in { + + val options = Array( + "--ledger-host", + "168.10.67.4", + "--ledger-port", + "7890", + "--proxy-host", + "168.10.67.5", + "--proxy-port", + "7891", + "--api-host", + "168.10.67.6", + "--api-port", + "7892", + "--jdbc", + "url=jdbc:postgresql:nr,user=psql,password=secret", + "--database-max-pool-size", + "30", + ) + + val expectedConfiguration = + Configuration( + participantAddress = new InetSocketAddress("168.10.67.4", 7890), + proxyAddress = new InetSocketAddress("168.10.67.5", 7891), + apiAddress = new InetSocketAddress("168.10.67.6", 7892), + apiShutdownTimeout = Configuration.Default.apiShutdownTimeout, + databaseJdbcUrl = "jdbc:postgresql:nr", + databaseJdbcUsername = "psql", + databaseJdbcPassword = "secret", + databaseMaxPoolSize = 30, + metricsReportingPeriod = Configuration.Default.metricsReportingPeriod, + ) + + OptionParser.parse(options, Configuration.Default).value shouldBe expectedConfiguration + + } + +}