🚧 Add matcher for own identities
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 1 Nov 2019 17:37:45 +0000 (18:37 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 1 Nov 2019 17:37:45 +0000 (18:37 +0100)
src/test/kotlin/net/pterodactylus/sone/test/Matchers.kt

index d941c01..21d225c 100644 (file)
@@ -65,6 +65,15 @@ fun isIdentity(id: String, nickname: String, requestUri: String, contexts: Match
                                .addAttribute("contexts", Identity::getContexts, contexts)
                                .addAttribute("properties", Identity::getProperties, properties)
 
+fun isOwnIdentity(id: String, nickname: String, requestUri: String, insertUri: String, contexts: Matcher<Iterable<String>>, properties: Matcher<Map<out String, String>>) =
+               AttributeMatcher<OwnIdentity>("own identity")
+                               .addAttribute("id", id, OwnIdentity::getId)
+                               .addAttribute("nickname", nickname, OwnIdentity::getNickname)
+                               .addAttribute("request uri", requestUri, OwnIdentity::getRequestUri)
+                               .addAttribute("insert uri", insertUri, OwnIdentity::getInsertUri)
+                               .addAttribute("contexts", OwnIdentity::getContexts, contexts)
+                               .addAttribute("properties", OwnIdentity::getProperties, properties)
+
 /**
  * [TypeSafeDiagnosingMatcher] implementation that aims to cut down boilerplate on verifying the attributes
  * of typical container objects.