-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from advancedtelematic/feat/pro-2615/emit-tree…
…hub-commit [PRO-2615] send treehub commit event instead of dependency to core
- Loading branch information
Showing
9 changed files
with
85 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/main/scala/com/advancedtelematic/treehub/client/CoreBusClient.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* Copyright: Copyright (C) 2016, ATS Advanced Telematic Systems GmbH | ||
* License: MPL-2.0 | ||
*/ | ||
package com.advancedtelematic.treehub.client | ||
|
||
import scala.concurrent.ExecutionContext | ||
import akka.http.scaladsl.model.Uri | ||
import org.genivi.sota.messaging.MessageBusPublisher | ||
import scala.concurrent.{ExecutionContext, Future} | ||
import com.advancedtelematic.data.DataType.{Commit, Ref, RefName} | ||
import org.genivi.sota.messaging.Messages.TreehubCommit | ||
|
||
|
||
class CoreBusClient(messageBusPublisher: MessageBusPublisher, treeHubUri: Uri) extends Core { | ||
|
||
private def mkTreehubCommit(ref: Ref, description: String): TreehubCommit = { | ||
//TODO: PRO-1802 pass the refname as the description until we can parse the real description out of the commit | ||
val formattedRefName = ref.name.get.replaceFirst("^heads/", "").replace("/", "-") | ||
val size = -1 // TODO | ||
TreehubCommit(ref.namespace, ref.value.get, formattedRefName, description, size, treeHubUri.toString) | ||
} | ||
|
||
def publishRef(ref: Ref, description: String) | ||
(implicit ec: ExecutionContext): Future[Unit] = | ||
messageBusPublisher | ||
.publishSafe(mkTreehubCommit(ref, description)) | ||
.map(_ => ()) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/test/scala/com/advancedtelematic/treehub/client/FakeBusCore.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* Copyright: Copyright (C) 2016, ATS Advanced Telematic Systems GmbH | ||
* License: MPL-2.0 | ||
*/ | ||
package com.advancedtelematic.treehub.client | ||
|
||
import akka.actor.ActorSystem | ||
import com.advancedtelematic.data.DataType.{Commit, Ref} | ||
import org.genivi.sota.messaging.LocalMessageBus | ||
import scala.concurrent.{ExecutionContext, Future} | ||
|
||
class FakeBusCore() | ||
(implicit val system: ActorSystem) extends Core { | ||
|
||
val fakeMsgPublisher = LocalMessageBus.publisher(system) | ||
|
||
override def publishRef(ref: Ref, description: String) | ||
(implicit ec: ExecutionContext): Future[Unit] = Future.successful(()) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
be79e08
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TeamCity OTA+ :: treehub :: treehub ci Build 232 is now running
be79e08
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TeamCity OTA+ :: treehub :: treehub ci Build 232 outcome was SUCCESS
Summary: Tests passed: 19 Build time: 00:01:40