From b12fc5e4d2fa793b3c5714f2504c1a89246fa5a8 Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Sun, 9 Jul 2023 13:17:58 +0200 Subject: [PATCH] Move EdgeComponent test constructor to NetworkDSL --- .../org/pgpainless/wot/network/EdgeComponent.kt | 16 ---------------- .../pgpainless/wot/network/EdgeComponentTest.kt | 3 ++- .../org/pgpainless/wot/network/EdgeTest.kt | 3 ++- .../kotlin/org/pgpainless/wot/dsl/NetworkDSL.kt | 14 ++++++++++++++ 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/wot-dijkstra/src/main/kotlin/org/pgpainless/wot/network/EdgeComponent.kt b/wot-dijkstra/src/main/kotlin/org/pgpainless/wot/network/EdgeComponent.kt index 2d33bca6..9727e8da 100644 --- a/wot-dijkstra/src/main/kotlin/org/pgpainless/wot/network/EdgeComponent.kt +++ b/wot-dijkstra/src/main/kotlin/org/pgpainless/wot/network/EdgeComponent.kt @@ -32,22 +32,6 @@ data class EdgeComponent( val regexes: RegexSet ) { - /** - * Construct a [EdgeComponent] with default values. The result is non-expiring, will be exportable and has a - * trust amount of 120, a depth of 0 and a wildcard regex. - * - * @param issuer synopsis of the certificate that issued the [EdgeComponent] - * @param target synopsis of the certificate that is target of this [EdgeComponent] - * @param targetUserId optional user-id. If this is null, the [EdgeComponent] is made over the primary key of the target. - * @param creationTime creation time of the [EdgeComponent] - */ - constructor( - issuer: Node, - target: Node, - targetUserId: String? = null, - creationTime: Date) : - this(issuer, target, targetUserId, creationTime, null, true, 120, Depth.limited(0), RegexSet.wildcard()) - override fun toString(): String { return if (trustDepth.limit == 0) "${issuer.fingerprint} certifies binding: $userId <-> ${target.fingerprint} [$trustAmount]" diff --git a/wot-dijkstra/src/test/kotlin/org/pgpainless/wot/network/EdgeComponentTest.kt b/wot-dijkstra/src/test/kotlin/org/pgpainless/wot/network/EdgeComponentTest.kt index e008dfc6..1230d195 100644 --- a/wot-dijkstra/src/test/kotlin/org/pgpainless/wot/network/EdgeComponentTest.kt +++ b/wot-dijkstra/src/test/kotlin/org/pgpainless/wot/network/EdgeComponentTest.kt @@ -1,6 +1,7 @@ package org.pgpainless.wot.network import org.junit.jupiter.api.Test +import org.pgpainless.wot.dsl.NetworkDSL import org.pgpainless.wot.network.Node import org.pgpainless.wot.network.EdgeComponent import org.pgpainless.wot.network.Fingerprint @@ -8,7 +9,7 @@ import org.pgpainless.wot.network.RevocationState import java.util.* import kotlin.test.assertEquals -class EdgeComponentTest { +class EdgeComponentTest: NetworkDSL { private val alice = Node( Fingerprint("A"), diff --git a/wot-dijkstra/src/test/kotlin/org/pgpainless/wot/network/EdgeTest.kt b/wot-dijkstra/src/test/kotlin/org/pgpainless/wot/network/EdgeTest.kt index 42199c12..53a0657b 100644 --- a/wot-dijkstra/src/test/kotlin/org/pgpainless/wot/network/EdgeTest.kt +++ b/wot-dijkstra/src/test/kotlin/org/pgpainless/wot/network/EdgeTest.kt @@ -6,11 +6,12 @@ package org.pgpainless.wot.network import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows +import org.pgpainless.wot.dsl.NetworkDSL import java.util.* import kotlin.test.assertEquals import kotlin.test.assertTrue -class EdgeTest { +class EdgeTest: NetworkDSL { private val alice = Node(Fingerprint("A"), null, RevocationState.notRevoked(), mapOf()) private val bob = Node(Fingerprint("B"), null, RevocationState.notRevoked(), mapOf()) diff --git a/wot-dijkstra/src/testFixtures/kotlin/org/pgpainless/wot/dsl/NetworkDSL.kt b/wot-dijkstra/src/testFixtures/kotlin/org/pgpainless/wot/dsl/NetworkDSL.kt index 3d6b2ad3..4dfb7ee2 100644 --- a/wot-dijkstra/src/testFixtures/kotlin/org/pgpainless/wot/dsl/NetworkDSL.kt +++ b/wot-dijkstra/src/testFixtures/kotlin/org/pgpainless/wot/dsl/NetworkDSL.kt @@ -43,6 +43,20 @@ interface NetworkDSL { fun EdgeComponent(issuer: Node, target: Node, amount: Int, depth: Depth): EdgeComponent = EdgeComponent(issuer, target, null, Date(), null, true, amount, depth, RegexSet.wildcard()) + + /** + * Construct a [EdgeComponent] with default values. The result is non-expiring, will be exportable and has a + * trust amount of 120, a depth of 0 and a wildcard regex. + * + * @param issuer synopsis of the certificate that issued the [EdgeComponent] + * @param target synopsis of the certificate that is target of this [EdgeComponent] + * @param targetUserId optional user-id. If this is null, the [EdgeComponent] is made over the primary key of the target. + * @param creationTime creation time of the [EdgeComponent] + */ + fun EdgeComponent(issuer: Node, target: Node, targetUserId: String? = null, creationTime: Date): EdgeComponent = + EdgeComponent(issuer, target, targetUserId, creationTime, null, true, 120, Depth.limited(0), RegexSet.wildcard()) + + /** * Add a single [Node] built from a [String] fingerprint to the builder. */