• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

hyperledger / identus-cloud-agent / 11517833922

25 Oct 2024 12:03PM UTC coverage: 48.438% (-0.3%) from 48.741%
11517833922

Pull #1417

bvoiturier
chore: run scalafmt

Signed-off-by: Benjamin Voiturier <benjamin.voiturier@iohk.io>
Pull Request #1417: chore: upgrade to latest Tapir version

1 of 1 new or added line in 1 file covered. (100.0%)

243 existing lines in 57 files now uncovered.

8018 of 16553 relevant lines covered (48.44%)

0.48 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

5.88
/cloud-agent/service/server/src/main/scala/org/hyperledger/identus/api/http/codec/OrderCodec.scala
1
package org.hyperledger.identus.api.http.codec
2

3
import org.hyperledger.identus.api.http.model.Order
4
import org.hyperledger.identus.api.http.model.Order.Direction
5
import sttp.tapir.{Codec, DecodeResult}
6
import sttp.tapir.Codec.PlainCodec
7

8
import java.util.Base64
9

10
object OrderCodec {
11
  implicit def orderCodec: PlainCodec[Order] = {
1✔
12
    def decode(s: String): DecodeResult[Order] =
×
13
      try {
×
14
        val s2 = new String(Base64.getDecoder.decode(s))
×
15
        val order = s2.split(".", 2) match {
×
16
          case Array()          => Order.empty
×
17
          case Array(field)     => Order(field)
×
18
          case Array(field, "") => Order(field)
×
19
          case Array(field, direction) =>
×
20
            Order(field, Some(Direction.valueOf(direction)))
21
          case _ => sys.error("impossible")
×
22
        }
23
        DecodeResult.Value(order)
24
      } catch {
25
        case e: Exception => DecodeResult.Error(s, e)
×
26
      }
27

28
    def encode(order: Order): String =
×
29
      Base64.getEncoder
×
30
        .encodeToString(
×
31
          s"${order.field}.${order.direction.getOrElse(Order.DefaultDirection).toString}"
×
32
            .getBytes("UTF-8")
×
33
        )
34

UNCOV
35
    Codec.string.mapDecode(decode)(encode)
×
36
  }
37
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc