Skip to content

Commit

Permalink
Added ability to retrieve target name from link to comm registrar
Browse files Browse the repository at this point in the history
  • Loading branch information
chipsenkbeil committed Jul 12, 2015
1 parent f5a4aea commit 376921c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
11 changes: 11 additions & 0 deletions protocol/src/main/scala/com/ibm/spark/comm/CommRegistrar.scala
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,17 @@ class CommRegistrar(
def getLinks(targetName: String): Seq[v5.UUID] =
getLinksImpl(targetName)

/**
* Retrieves the target associated with the specified link.
*
* @param commId The Comm id whose target to look up
*
* @return Some target name if found, otherwise None
*/
def getTargetFromLink(commId: v5.UUID): Option[String] = {
commStorage.getTargetFromCommId(commId)
}

/**
* Retrieves the current links for the current target.
*
Expand Down
16 changes: 16 additions & 0 deletions protocol/src/test/scala/com/ibm/spark/comm/CommRegistrarSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,22 @@ class CommRegistrarSpec extends FunSpec with Matchers with MockitoSugar
}
}

describe("#getTargetFromLink") {
it("should return Some target name if found") {
val expected = TestTargetName

commRegistrar.register(expected).link(TestCommId)

val actual = commRegistrar.getTargetFromLink(TestCommId).get

actual should be (expected)
}

it("should return None if not found") {
commRegistrar.getTargetFromLink(TestCommId) should be (None)
}
}

describe("#getLinks") {
it("should return a collection of links for the target") {
commRegistrar.register(TestTargetName).link(TestCommId)
Expand Down

0 comments on commit 376921c

Please sign in to comment.