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

hyperledger / identus-cloud-agent / 11571116967

29 Oct 2024 09:37AM UTC coverage: 48.438% (-0.3%) from 48.741%
11571116967

Pull #1417

web-flow
Merge branch 'main' into chore/tapir-upgrade
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

0.0
/shared/core/src/main/scala/org/hyperledger/identus/shared/messaging/Serde.scala
1
package org.hyperledger.identus.shared.messaging
2

3
import org.hyperledger.identus.shared.models.WalletId
4

5
import java.nio.charset.StandardCharsets
6
import java.nio.ByteBuffer
7
import java.util.UUID
8

9
case class ByteArrayWrapper(ba: Array[Byte])
10

11
trait Serde[T] {
12
  def serialize(t: T): Array[Byte]
13
  def deserialize(ba: Array[Byte]): T
UNCOV
14
}
×
UNCOV
15

×
UNCOV
16
object Serde {
×
17
  given byteArraySerde: Serde[ByteArrayWrapper] = new Serde[ByteArrayWrapper] {
UNCOV
18
    override def serialize(t: ByteArrayWrapper): Array[Byte] = t.ba
×
UNCOV
19
    override def deserialize(ba: Array[Byte]): ByteArrayWrapper = ByteArrayWrapper(ba)
×
20
  }
21

22
  given stringSerde: Serde[String] = new Serde[String] {
UNCOV
23
    override def serialize(t: String): Array[Byte] = t.getBytes()
×
UNCOV
24
    override def deserialize(ba: Array[Byte]): String = new String(ba, StandardCharsets.UTF_8)
×
25
  }
26

27
  given intSerde: Serde[Int] = new Serde[Int] {
UNCOV
28
    override def serialize(t: Int): Array[Byte] = {
×
UNCOV
29
      val buffer = java.nio.ByteBuffer.allocate(4)
×
UNCOV
30
      buffer.putInt(t)
×
UNCOV
31
      buffer.array()
×
32
    }
UNCOV
33
    override def deserialize(ba: Array[Byte]): Int = ByteBuffer.wrap(ba).getInt()
×
34
  }
35

36
  given uuidSerde: Serde[UUID] = new Serde[UUID] {
UNCOV
37
    override def serialize(t: UUID): Array[Byte] = {
×
UNCOV
38
      val buffer = java.nio.ByteBuffer.allocate(16)
×
UNCOV
39
      buffer.putLong(t.getMostSignificantBits)
×
UNCOV
40
      buffer.putLong(t.getLeastSignificantBits)
×
UNCOV
41
      buffer.array()
×
42
    }
UNCOV
43
    override def deserialize(ba: Array[Byte]): UUID = {
×
UNCOV
44
      val byteBuffer = ByteBuffer.wrap(ba)
×
UNCOV
45
      val high = byteBuffer.getLong
×
UNCOV
46
      val low = byteBuffer.getLong
×
UNCOV
47
      new UUID(high, low)
×
48
    }
49
  }
50

51
  given walletIdSerde(using uuidSerde: Serde[UUID]): Serde[WalletId] = new Serde[WalletId] {
×
UNCOV
52
    override def serialize(w: WalletId): Array[Byte] = uuidSerde.serialize(w.toUUID)
×
UNCOV
53
    override def deserialize(ba: Array[Byte]): WalletId = WalletId.fromUUID(uuidSerde.deserialize(ba))
×
54
  }
55
}
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