Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: wrapped id cc into Wrapper with companion objects
Browse files Browse the repository at this point in the history
Ioann Kurchin committed Feb 21, 2022
1 parent ac85bbc commit 447c854
Showing 44 changed files with 225 additions and 133 deletions.
Original file line number Diff line number Diff line change
@@ -6,9 +6,10 @@ import akka.http.scaladsl.server.{ ExceptionHandler, Route }
import cromwell.pipeline.controller.ProjectConfigurationController._
import cromwell.pipeline.controller.utils.FromStringUnmarshallers._
import cromwell.pipeline.controller.utils.FromUnitMarshaller._
import cromwell.pipeline.controller.utils.PathMatchers.{ Path, ProjectId }
import cromwell.pipeline.controller.utils.PathMatchers.{ Path, ProjectId => ProjectIdPM }
import cromwell.pipeline.datastorage.dto._
import cromwell.pipeline.datastorage.dto.auth.AccessTokenContent
import cromwell.pipeline.model.wrapper.ProjectId
import cromwell.pipeline.service.ProjectConfigurationService
import cromwell.pipeline.service.ProjectConfigurationService.Exceptions._
import de.heikoseeberger.akkahttpplayjson.PlayJsonSupport._
@@ -61,7 +62,7 @@ class ProjectConfigurationController(projectConfigurationService: ProjectConfigu

val route: AccessTokenContent => Route = implicit accessToken =>
handleExceptions(projectConfigurationServiceExceptionHandler) {
pathPrefix("projects" / ProjectId / "configurations") { projectId =>
pathPrefix("projects" / ProjectIdPM / "configurations") { projectId =>
buildConfiguration(projectId) ~
addConfiguration(projectId) ~
getConfiguration(projectId) ~
Original file line number Diff line number Diff line change
@@ -6,9 +6,10 @@ import akka.http.scaladsl.server.Route
import akka.stream.Materializer
import cromwell.pipeline.controller.utils.FieldUnmarshallers._
import cromwell.pipeline.controller.utils.FromStringUnmarshallers._
import cromwell.pipeline.controller.utils.PathMatchers.{ Path, ProjectId }
import cromwell.pipeline.controller.utils.PathMatchers.{ Path, ProjectId => ProjectIdPM }
import cromwell.pipeline.datastorage.dto._
import cromwell.pipeline.datastorage.dto.auth.AccessTokenContent
import cromwell.pipeline.model.wrapper.ProjectId
import cromwell.pipeline.service.ProjectFileService
import de.heikoseeberger.akkahttpplayjson.PlayJsonSupport._

@@ -99,10 +100,14 @@ class ProjectFileController(wdlService: ProjectFileService)(

val route: AccessTokenContent => Route = implicit accessToken =>
validateFile ~
pathPrefix("projects" / ProjectId / "files") { projectId =>
getFile(projectId) ~
getFiles(projectId) ~
uploadFile(projectId) ~
deleteFile(projectId)
pathPrefix("projects") {
path(ProjectIdPM / "files") { projectId =>
{
getFile(projectId) ~
getFiles(projectId) ~
uploadFile(projectId) ~
deleteFile(projectId)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -4,9 +4,10 @@ import akka.http.scaladsl.model.{ StatusCode, StatusCodes }
import akka.http.scaladsl.server.Directives.{ entity, _ }
import akka.http.scaladsl.server.{ ExceptionHandler, Route }
import cromwell.pipeline.controller.RunController.runServiceExceptionHandler
import cromwell.pipeline.controller.utils.PathMatchers.{ ProjectId, RunId }
import cromwell.pipeline.controller.utils.PathMatchers.{ RunId, ProjectId => ProjectIdPM }
import cromwell.pipeline.datastorage.dto._
import cromwell.pipeline.datastorage.dto.auth.AccessTokenContent
import cromwell.pipeline.model.wrapper.ProjectId
import cromwell.pipeline.service.RunService
import cromwell.pipeline.service.RunService.Exceptions.RunServiceException
import de.heikoseeberger.akkahttpplayjson.PlayJsonSupport._
@@ -46,12 +47,16 @@ class RunController(runService: RunService) {

val route: AccessTokenContent => Route = implicit accessToken =>
handleExceptions(runServiceExceptionHandler) {
pathPrefix("projects" / ProjectId / "runs") { projectId =>
getRun(projectId) ~
getRunsByProject(projectId) ~
deleteRun(projectId) ~
updateRun(projectId) ~
addRun(projectId)
pathPrefix("projects") {
path(ProjectIdPM / "runs") { projectId =>
{
getRun(projectId) ~
getRunsByProject(projectId) ~
deleteRun(projectId) ~
updateRun(projectId) ~
addRun(projectId)
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -2,8 +2,8 @@ package cromwell.pipeline.controller.utils

import akka.http.scaladsl.unmarshalling.Unmarshaller
import cats.data.Validated
import cromwell.pipeline.datastorage.dto.{ PipelineVersion, ProjectId }
import cromwell.pipeline.model.wrapper.RunId
import cromwell.pipeline.datastorage.dto.PipelineVersion
import cromwell.pipeline.model.wrapper.{ ProjectId, RunId }

import java.nio.file.{ Path, Paths }

@@ -17,7 +17,10 @@ object FromStringUnmarshallers {
}
implicit val stringToProjectId: Unmarshaller[String, ProjectId] = Unmarshaller.strict[String, ProjectId] {
projectId =>
ProjectId(projectId)
ProjectId.from(projectId) match {
case Validated.Valid(content) => content
case Validated.Invalid(errors) => throw new RuntimeException(errors.head)
}
}
implicit val stringToPath: Unmarshaller[String, Path] = Unmarshaller.strict[String, Path] { path =>
Paths.get(path)
Original file line number Diff line number Diff line change
@@ -2,13 +2,12 @@ package cromwell.pipeline.controller.utils

import akka.http.scaladsl.server.PathMatcher1
import akka.http.scaladsl.server.PathMatchers.Segment
import cromwell.pipeline.datastorage.dto
import cromwell.pipeline.model.wrapper

import java.nio.file.{ Path, Paths }

object PathMatchers {
val ProjectId: PathMatcher1[dto.ProjectId] = Segment.map(dto.ProjectId(_))
val ProjectId: PathMatcher1[wrapper.ProjectId] = Segment.flatMap(wrapper.ProjectId.from(_).toOption)
val Path: PathMatcher1[Path] = Segment.map(Paths.get(_))
val RunId: PathMatcher1[wrapper.RunId] = Segment.flatMap(wrapper.RunId.from(_).toOption)
val ProjectSearchFilterId: PathMatcher1[wrapper.ProjectSearchFilterId] =
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ import akka.http.scaladsl.testkit.ScalatestRouteTest
import cromwell.pipeline.datastorage.dao.utils.{ TestProjectUtils, TestUserUtils }
import cromwell.pipeline.datastorage.dto._
import cromwell.pipeline.datastorage.dto.auth.AccessTokenContent
import cromwell.pipeline.model.wrapper.ProjectConfigurationId
import cromwell.pipeline.service.ProjectConfigurationService.Exceptions.{ InternalError, NotFound, ValidationError }
import cromwell.pipeline.service.{ ProjectConfigurationService, VersioningException }
import cromwell.pipeline.utils.URLEncoderUtils
@@ -46,21 +47,19 @@ class ProjectConfigurationControllerTest extends AsyncWordSpec with Matchers wit

"return success for update configuration" in {
when(configurationService.addConfiguration(configuration, accessToken.userId)).thenReturn(Future.unit)
Put(s"/projects/${projectId.value}/configurations", configurationAdditionRequest) ~> configurationController
.route(
accessToken
) ~> check {
Put(s"/projects/$projectId/configurations", configurationAdditionRequest) ~> configurationController.route(
accessToken
) ~> check {
status shouldBe StatusCodes.NoContent
}
}

"return InternalServerError when failure update configuration" in {
val error = InternalError("Something went wrong")
when(configurationService.addConfiguration(configuration, accessToken.userId)).thenReturn(Future.failed(error))
Put(s"/projects/${projectId.value}/configurations", configurationAdditionRequest) ~> configurationController
.route(
accessToken
) ~> check {
Put(s"/projects/$projectId/configurations", configurationAdditionRequest) ~> configurationController.route(
accessToken
) ~> check {
status shouldBe StatusCodes.InternalServerError
entityAs[String] shouldBe "Something went wrong"
}
@@ -69,10 +68,9 @@ class ProjectConfigurationControllerTest extends AsyncWordSpec with Matchers wit
"return NotFound when failure find project to update configuration" in {
when(configurationService.addConfiguration(configuration, accessToken.userId))
.thenReturn(Future.failed(NotFound()))
Put(s"/projects/${projectId.value}/configurations", configurationAdditionRequest) ~> configurationController
.route(
accessToken
) ~> check {
Put(s"/projects/$projectId/configurations", configurationAdditionRequest) ~> configurationController.route(
accessToken
) ~> check {
status shouldBe StatusCodes.NotFound
}
}
@@ -82,7 +80,7 @@ class ProjectConfigurationControllerTest extends AsyncWordSpec with Matchers wit
"return configuration by existing project id" in {
when(configurationService.getLastByProjectId(projectId, accessToken.userId))
.thenReturn(Future.successful(configuration))
Get(s"/projects/${projectId.value}/configurations") ~> configurationController.route(accessToken) ~> check {
Get(s"/projects/$projectId/configurations") ~> configurationController.route(accessToken) ~> check {
status shouldBe StatusCodes.OK
entityAs[ProjectConfiguration] shouldBe configuration
}
@@ -91,7 +89,7 @@ class ProjectConfigurationControllerTest extends AsyncWordSpec with Matchers wit
"return Configuration not found message" in {
when(configurationService.getLastByProjectId(projectId, accessToken.userId))
.thenReturn(Future.failed(NotFound(s"There is no configuration with project_id: ${projectId.value}")))
Get(s"/projects/${projectId.value}/configurations") ~> configurationController.route(accessToken) ~> check {
Get(s"/projects/$projectId/configurations") ~> configurationController.route(accessToken) ~> check {
status shouldBe StatusCodes.NotFound
entityAs[String] shouldBe s"There is no configuration with project_id: ${projectId.value}"
}
@@ -103,15 +101,15 @@ class ProjectConfigurationControllerTest extends AsyncWordSpec with Matchers wit

"return success for deactivate configuration" in {
when(configurationService.deactivateLastByProjectId(projectId, accessToken.userId)).thenReturn(Future.unit)
Delete(s"/projects/${projectId.value}/configurations") ~> configurationController.route(accessToken) ~> check {
Delete(s"/projects/$projectId/configurations") ~> configurationController.route(accessToken) ~> check {
status shouldBe StatusCodes.NoContent
}
}

"return InternalServerError when failure deactivate configuration" in {
when(configurationService.deactivateLastByProjectId(projectId, accessToken.userId))
.thenReturn(Future.failed(error))
Delete(s"/projects/${projectId.value}/configurations") ~> configurationController.route(accessToken) ~> check {
Delete(s"/projects/$projectId/configurations") ~> configurationController.route(accessToken) ~> check {
status shouldBe StatusCodes.InternalServerError
entityAs[String] shouldBe "Something went wrong"
}
@@ -120,7 +118,7 @@ class ProjectConfigurationControllerTest extends AsyncWordSpec with Matchers wit
"return NotFound when failure find project to deactivate configuration" in {
when(configurationService.deactivateLastByProjectId(projectId, accessToken.userId))
.thenReturn(Future.failed(NotFound()))
Delete(s"/projects/${projectId.value}/configurations") ~> configurationController.route(accessToken) ~> check {
Delete(s"/projects/$projectId/configurations") ~> configurationController.route(accessToken) ~> check {
status shouldBe StatusCodes.NotFound
}
}
@@ -131,7 +129,7 @@ class ProjectConfigurationControllerTest extends AsyncWordSpec with Matchers wit
"return configuration for file" in {
when(configurationService.buildConfiguration(projectId, path, versionOption, accessToken.userId))
.thenReturn(Future.successful(configuration))
Get(s"/projects/${projectId.value}/configurations/files/$pathString?version=$versionString") ~>
Get(s"/projects/$projectId/configurations/files/$pathString?version=$versionString") ~>
configurationController.route(accessToken) ~> check {
status shouldBe StatusCodes.OK
entityAs[ProjectConfiguration] shouldBe configuration
@@ -141,7 +139,7 @@ class ProjectConfigurationControllerTest extends AsyncWordSpec with Matchers wit
"return failed for Bad request" in {
when(configurationService.buildConfiguration(projectId, path, versionOption, accessToken.userId))
.thenReturn(Future.failed(VersioningException.HttpException("Bad request")))
Get(s"/projects/${projectId.value}/configurations/files/$pathString?version=$versionString") ~>
Get(s"/projects/$projectId/configurations/files/$pathString?version=$versionString") ~>
configurationController.route(accessToken) ~> check {
status shouldBe StatusCodes.InternalServerError
entityAs[String] shouldBe "Bad request"
@@ -151,7 +149,7 @@ class ProjectConfigurationControllerTest extends AsyncWordSpec with Matchers wit
"return failed for invalid file" in {
when(configurationService.buildConfiguration(projectId, path, versionOption, accessToken.userId))
.thenReturn(Future.failed(ValidationError(List("invalid some field").mkString(","))))
Get(s"/projects/${projectId.value}/configurations/files/$pathString?version=$versionString") ~>
Get(s"/projects/$projectId/configurations/files/$pathString?version=$versionString") ~>
configurationController.route(accessToken) ~> check {
status shouldBe StatusCodes.UnprocessableEntity
entityAs[String] shouldBe "invalid some field"
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -55,7 +55,7 @@ services:
restart: always
environment:
GITLAB_OMNIBUS_CONFIG: |
# gitlab_rails['initial_root_password'] = 'initial_root_password'
# gitlab_rails['initial_root_password'] = 'initial_root_password'
external_url 'http://localhost:9080'
nginx['listen_port'] = 9080 # make nginx to listen on the same port as confgured in external_url
# Add any other gitlab.rb configuration here, each on its own line
Original file line number Diff line number Diff line change
@@ -20,6 +20,7 @@ trait Wrapped[T] extends Any {
override def hashCode: Int = this.getClass.hashCode + unwrap.hashCode()
override def toString: String = unwrap.toString
}

object Wrapped {
trait Companion {
type Type
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package cromwell.pipeline.model.wrapper

import cats.data.{ NonEmptyChain, Validated }
import cromwell.pipeline.model.validator.Wrapped
import slick.lifted.MappedTo

import java.util.UUID

final class ProjectConfigurationId private (override val unwrap: String)
extends AnyVal
with Wrapped[String]
with MappedTo[String] {
override def value: String = unwrap
}

object ProjectConfigurationId extends Wrapped.Companion {
override type Type = String
override type Wrapper = ProjectConfigurationId
override type Error = String

val pattern: String = "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"

def randomId: ProjectConfigurationId = new ProjectConfigurationId(UUID.randomUUID().toString)

override protected def create(value: String): ProjectConfigurationId = new ProjectConfigurationId(value)

override protected def validate(value: String): ValidationResult[String] = Validated.cond(
value.matches(pattern),
value,
NonEmptyChain.one("Invalid ProjectConfigurationId")
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package cromwell.pipeline.model.wrapper

import cats.data.{ NonEmptyChain, Validated }
import cromwell.pipeline.model.validator.Wrapped
import play.api.libs.json.Format
import slick.lifted.MappedTo

import java.util.UUID.randomUUID

final class ProjectId private (override val unwrap: String) extends AnyVal with Wrapped[String] with MappedTo[String] {
override def value: String = unwrap
}

object ProjectId extends Wrapped.Companion {
type Type = String
type Wrapper = ProjectId
type Error = String

implicit lazy val projectIdFormat: Format[ProjectId] = wrapperFormat

val pattern: String = "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"

override protected def create(value: String): ProjectId = new ProjectId(value)
override protected def validate(value: String): ValidationResult[String] = Validated.cond(
value.matches(pattern),
value,
NonEmptyChain.one("Invalid ProjectId")
)

def random: ProjectId = new ProjectId(randomUUID().toString)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package cromwell.pipeline.model.wrapper

import cats.data.{ NonEmptyChain, Validated }
import cromwell.pipeline.model.validator.Wrapped
import play.api.libs.json.Format
import slick.lifted.MappedTo

final case class RepositoryId(override val unwrap: Int) extends AnyVal with MappedTo[Int] with Wrapped[Int] {
override def value: Int = unwrap
}

object RepositoryId extends Wrapped.Companion {
type Type = Int
type Wrapper = RepositoryId
type Error = String

implicit lazy val repositoryIdFormat: Format[RepositoryId] = wrapperFormat

val pattern = "^[0-9]+$"

override protected def create(value: Int): RepositoryId = new RepositoryId(value)
override protected def validate(value: Int): ValidationResult[Int] = Validated.cond(
value >= 0,
value,
NonEmptyChain.one("Value should be not negative integer")
)
}
Original file line number Diff line number Diff line change
@@ -44,6 +44,12 @@ trait Profile {

implicit def uuidIso: Isomorphism[UserId, String] = iso[UserId, String](_.unwrap, UserId(_, Enable.Unsafe))
implicit def runidIso: Isomorphism[RunId, String] = iso[RunId, String](_.unwrap, RunId(_, Enable.Unsafe))
implicit def projectidIso: Isomorphism[ProjectId, String] =
iso[ProjectId, String](_.unwrap, ProjectId(_, Enable.Unsafe))
implicit def projectConfigurationIdIso: Isomorphism[ProjectConfigurationId, String] =
iso[ProjectConfigurationId, String](_.unwrap, ProjectConfigurationId(_, Enable.Unsafe))
implicit def repositoryId: Isomorphism[RepositoryId, Int] =
iso[RepositoryId, Int](_.unwrap, RepositoryId(_, Enable.Unsafe))
implicit def filteridIso: Isomorphism[ProjectSearchFilterId, String] =
iso[ProjectSearchFilterId, String](_.unwrap, ProjectSearchFilterId(_, Enable.Unsafe))
implicit def searchQueryIso: Isomorphism[ProjectSearchQuery, JsValue] =
Original file line number Diff line number Diff line change
@@ -2,8 +2,7 @@ package cromwell.pipeline.datastorage.dao.entry

import cromwell.pipeline.datastorage.Profile
import cromwell.pipeline.datastorage.dto._
import cromwell.pipeline.model.wrapper.UserId
import slick.lifted.MappedToBase.mappedToIsomorphism
import cromwell.pipeline.model.wrapper.{ ProjectId, RepositoryId, UserId }
import slick.lifted.{ ForeignKeyQuery, ProvenShape }

trait ProjectEntry { this: Profile with UserEntry with MyPostgresProfile with AliasesSupport =>
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package cromwell.pipeline.datastorage.dao.entry

import java.time.Instant

import cromwell.pipeline.datastorage.Profile
import cromwell.pipeline.datastorage.dto._
import cromwell.pipeline.model.wrapper.{ RunId, UserId }
import cromwell.pipeline.model.wrapper.{ ProjectId, RunId, UserId }
import slick.lifted.{ ForeignKeyQuery, ProvenShape }

import java.time.Instant

trait RunEntry { this: Profile with UserEntry with ProjectEntry with MyPostgresProfile with AliasesSupport =>
import Implicits._
import api._
Original file line number Diff line number Diff line change
@@ -2,7 +2,8 @@ package cromwell.pipeline.datastorage.dao.repository

import cromwell.pipeline.datastorage.dao.mongo.DocumentCodecInstances.projectConfigurationDocumentCodec
import cromwell.pipeline.datastorage.dao.mongo.DocumentRepository
import cromwell.pipeline.datastorage.dto.{ ProjectConfiguration, ProjectConfigurationId, ProjectId }
import cromwell.pipeline.datastorage.dto.ProjectConfiguration
import cromwell.pipeline.model.wrapper.{ ProjectConfigurationId, ProjectId }

import scala.concurrent.{ ExecutionContext, Future }

Original file line number Diff line number Diff line change
@@ -2,8 +2,8 @@ package cromwell.pipeline.datastorage.dao.repository

import cromwell.pipeline.database.PipelineDatabaseEngine
import cromwell.pipeline.datastorage.dao.entry.ProjectEntry
import cromwell.pipeline.datastorage.dto.{ Project, ProjectId }
import cromwell.pipeline.model.wrapper.UserId
import cromwell.pipeline.datastorage.dto.Project
import cromwell.pipeline.model.wrapper.{ ProjectId, UserId }

import scala.concurrent.Future

Original file line number Diff line number Diff line change
@@ -2,8 +2,8 @@ package cromwell.pipeline.datastorage.dao.repository

import cromwell.pipeline.database.PipelineDatabaseEngine
import cromwell.pipeline.datastorage.dao.entry.RunEntry
import cromwell.pipeline.datastorage.dto.{ ProjectId, Run }
import cromwell.pipeline.model.wrapper.{ RunId, UserId }
import cromwell.pipeline.datastorage.dto.Run
import cromwell.pipeline.model.wrapper.{ ProjectId, RunId, UserId }

import scala.concurrent.Future

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package cromwell.pipeline.datastorage.dto

import cromwell.pipeline.model.wrapper.UserId
import cromwell.pipeline.model.wrapper.{ ProjectId, UserId }

final case class CromwellInput(
projectId: ProjectId,
Original file line number Diff line number Diff line change
@@ -2,12 +2,12 @@ package cromwell.pipeline.datastorage.dto

import cats.data.Validated
import cats.implicits._
import cromwell.pipeline.model.wrapper.{ UserId, VersionValue }
import cromwell.pipeline.model.wrapper.{ ProjectId, RepositoryId, UserId, VersionValue }
import play.api.libs.functional.syntax._
import play.api.libs.json.JsonNaming.SnakeCase
import play.api.libs.json._

import java.nio.file.{ Path, Paths }
import slick.lifted.MappedTo
// scalastyle:off number.of.types
final case class Project(
projectId: ProjectId,
@@ -18,6 +18,7 @@ final case class Project(
version: PipelineVersion,
visibility: Visibility = Private
)

object Project {
implicit lazy val projectFormat: OFormat[Project] = Json.format[Project]
}
@@ -41,25 +42,12 @@ final case class LocalProject(
)
}

final case class PostProject(name: String)
final case class PostProject(name: ProjectId)

object PostProject {
implicit lazy val postProject: OFormat[PostProject] = Json.format[PostProject]
}

final case class ProjectId(value: String) extends MappedTo[String]

object ProjectId {
implicit lazy val projectIdFormat: Format[ProjectId] = implicitly[Format[String]].inmap(ProjectId.apply, _.value)
}

final case class RepositoryId(value: Int) extends MappedTo[Int]

object RepositoryId {
implicit lazy val repositoryIdFormat: Format[RepositoryId] =
implicitly[Format[Int]].inmap(RepositoryId.apply, _.value)
}

final case class ProjectAdditionRequest(name: String)

object ProjectAdditionRequest {
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package cromwell.pipeline.datastorage.dto

import cats.data.Validated
import cromwell.pipeline.model.wrapper.VersionValue
import cromwell.pipeline.model.wrapper.{ ProjectConfigurationId, ProjectId, VersionValue }
import ProjectFile.pathFormat
import play.api.libs.functional.syntax.toInvariantFunctorOps
import play.api.libs.json.{ Format, Json, OFormat }

import java.nio.file.Path
import java.util.UUID

case class WdlParams(path: Path, inputs: List[FileParameter])

@@ -54,14 +53,6 @@ object ProjectConfigurationVersion {
implicitly[Format[String]].inmap(ProjectConfigurationVersion.apply, _.name)
}

final case class ProjectConfigurationId(value: String)

object ProjectConfigurationId {
def randomId: ProjectConfigurationId = ProjectConfigurationId(UUID.randomUUID().toString)
implicit lazy val configurationIdFormat: Format[ProjectConfigurationId] =
implicitly[Format[String]].inmap(ProjectConfigurationId.apply, _.value)
}

final case class ProjectConfigurationAdditionRequest(
id: ProjectConfigurationId,
active: Boolean,
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package cromwell.pipeline.datastorage.dto

import cromwell.pipeline.model.wrapper.ProjectId
import play.api.libs.json.{ Json, OFormat }

final case class ProjectResponse(projectId: ProjectId, name: String, active: Boolean)
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package cromwell.pipeline.datastorage.dto

import cromwell.pipeline.model.wrapper.{ RunId, UserId }
import cromwell.pipeline.model.wrapper.{ ProjectId, RunId, UserId }
import play.api.libs.functional.syntax._
import play.api.libs.json._

Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package cromwell.pipeline.datastorage.dao.repository

import java.nio.file.Paths

import cromwell.pipeline.datastorage.dao.mongo.DocumentCodecInstances.projectConfigurationDocumentCodec
import cromwell.pipeline.datastorage.dao.mongo.DocumentRepository
import cromwell.pipeline.datastorage.dao.utils.TestProjectUtils
import cromwell.pipeline.datastorage.dto._
import cromwell.pipeline.model.wrapper.{ ProjectConfigurationId, ProjectId }
import org.mockito.Mockito.when
import org.scalatest.{ AsyncWordSpec, Matchers }
import org.scalatestplus.mockito.MockitoSugar
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package cromwell.pipeline.datastorage.dao.repository.impls

import cromwell.pipeline.datastorage.dao.repository.ProjectConfigurationRepository
import cromwell.pipeline.datastorage.dto.{ ProjectConfiguration, ProjectConfigurationId, ProjectId }
import cromwell.pipeline.datastorage.dto.ProjectConfiguration
import cromwell.pipeline.model.wrapper.{ ProjectConfigurationId, ProjectId }

import scala.collection.mutable
import scala.concurrent.Future
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package cromwell.pipeline.datastorage.dao.repository.impls

import cromwell.pipeline.datastorage.dao.repository.ProjectRepository
import cromwell.pipeline.datastorage.dto.{ Project, ProjectId }
import cromwell.pipeline.model.wrapper.UserId
import cromwell.pipeline.datastorage.dto.Project
import cromwell.pipeline.model.wrapper.{ ProjectId, UserId }

import scala.collection.mutable
import scala.concurrent.Future
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package cromwell.pipeline.datastorage.dao.repository.impls

import cromwell.pipeline.datastorage.dao.repository.RunRepository
import cromwell.pipeline.datastorage.dto.{ ProjectId, Run }
import cromwell.pipeline.model.wrapper.{ RunId, UserId }
import cromwell.pipeline.datastorage.dto.Run
import cromwell.pipeline.model.wrapper.{ ProjectId, RunId, UserId }

import scala.collection.mutable
import scala.concurrent.Future
Original file line number Diff line number Diff line change
@@ -20,10 +20,10 @@ object GeneratorUtils {
private def listOfN[T](gen: Gen[T], maxLength: Int = defaultListMaxLength): Gen[List[T]] =
Gen.chooseNum(0, maxLength).flatMap(length => Gen.listOfN(length, gen))

private lazy val projectIdGen: Gen[ProjectId] = Gen.uuid.map(id => ProjectId(id.toString))
private lazy val projectIdGen: Gen[ProjectId] = Gen.uuid.map(id => ProjectId(id.toString, Enable.Unsafe))

private lazy val projectConfigurationIdGen: Gen[ProjectConfigurationId] =
Gen.uuid.map(id => ProjectConfigurationId(id.toString))
Gen.uuid.map(id => ProjectConfigurationId(id.toString, Enable.Unsafe))

private lazy val emailGen: Gen[UserEmail] = for {
name <- stringGen()
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package cromwell.pipeline.datastorage.dao.utils

import cromwell.pipeline.datastorage.dto._
import cromwell.pipeline.model.wrapper.UserId
import cromwell.pipeline.model.validator.Enable
import cromwell.pipeline.model.wrapper.{ ProjectConfigurationId, ProjectId, RepositoryId, UserId }

import java.nio.file.Paths
import java.util.UUID
@@ -12,8 +13,8 @@ object TestProjectUtils {
private val defaultRange: Int = 100
private def randomInt(range: Int = defaultRange): Int = Random.nextInt(range)
private def randomUuidStr: String = UUID.randomUUID().toString
def getDummyProjectId: ProjectId = ProjectId(randomUuidStr)
def getDummyRepositoryId: RepositoryId = RepositoryId(randomInt())
def getDummyProjectId: ProjectId = ProjectId(randomUuidStr, Enable.Unsafe)
def getDummyRepositoryId: RepositoryId = RepositoryId(randomInt(), Enable.Unsafe)
def getDummyProject(
projectId: ProjectId = getDummyProjectId,
ownerId: UserId = TestUserUtils.getDummyUserId,
Original file line number Diff line number Diff line change
@@ -2,14 +2,13 @@ package cromwell.pipeline.datastorage.dao.utils

import java.time.Instant
import java.util.UUID

import cromwell.pipeline.datastorage.dto.{ Created, ProjectId, Run, Status }
import cromwell.pipeline.model.wrapper.{ RunId, UserId }
import cromwell.pipeline.datastorage.dto.{ Created, Run, Status }
import cromwell.pipeline.model.wrapper.{ ProjectId, RunId, UserId }

object TestRunUtils {

private def randomUuidStr: String = UUID.randomUUID().toString
def getDummyProjectId: ProjectId = ProjectId(randomUuidStr)
def getDummyProjectId: ProjectId = ProjectId.random
def getDummyRunId: RunId = RunId.random
def getDummyTimeStart: Instant = Instant.now()
def getDummyTimeEnd(isEmpty: Boolean): Option[Instant] =
Original file line number Diff line number Diff line change
@@ -3,7 +3,8 @@ package cromwell.pipeline.service
import cats.data.EitherT
import cats.implicits._
import cromwell.pipeline.datastorage.dto._
import cromwell.pipeline.model.wrapper.UserId
import cromwell.pipeline.model.wrapper.{ ProjectId, UserId }

import scala.concurrent.{ ExecutionContext, Future }

trait AggregationService {
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@ import cats.data.EitherT
import cats.implicits.toTraverseOps
import cromwell.pipeline.datastorage.dto.File.{ DeleteFileRequest, UpdateFileRequest }
import cromwell.pipeline.datastorage.dto._
import cromwell.pipeline.model.wrapper.RepositoryId
import cromwell.pipeline.service.VersioningException._
import cromwell.pipeline.utils.HttpStatusCodes.{ Accepted, NoContent, OK }
import cromwell.pipeline.utils.{ GitLabConfig, URLEncoderUtils }
@@ -19,7 +20,7 @@ class GitLabProjectVersioning(httpClient: HttpClient, config: GitLabConfig)(impl
Future.failed(RepositoryException("Could not create a repository for deleted project."))
} else {
val createRepoUrl: String = s"${config.url}projects"
val postProject = PostProject(name = localProject.projectId.value)
val postProject = PostProject(name = localProject.projectId)
httpClient
.post[GitLabRepositoryResponse, PostProject](url = createRepoUrl, headers = config.token, payload = postProject)
.map {
@@ -42,7 +43,7 @@ class GitLabProjectVersioning(httpClient: HttpClient, config: GitLabConfig)(impl
): AsyncResult[PipelineVersion] = {
val path = URLEncoderUtils.encode(projectFile.path.toString)
val repositoryId: RepositoryId = project.repositoryId
val fileUrl = s"${config.url}projects/${repositoryId.value}/repository/files/$path"
val fileUrl = s"${config.url}projects/${repositoryId}/repository/files/$path"

getUpdatedProjectVersion(project, version).flatMap {
case l @ Left(_) => Future.successful(l)
@@ -171,7 +172,7 @@ class GitLabProjectVersioning(httpClient: HttpClient, config: GitLabConfig)(impl
createTag(repositoryId, version).map(_.map(_ => version))

private def createTag(repositoryId: RepositoryId, version: PipelineVersion): AsyncResult[SuccessResponseMessage] = {
val tagUrl = s"${config.url}projects/${repositoryId.value}/repository/tags"
val tagUrl = s"${config.url}projects/${repositoryId}/repository/tags"
httpClient
.post[SuccessResponseMessage, EmptyPayload](
tagUrl,
@@ -193,7 +194,7 @@ class GitLabProjectVersioning(httpClient: HttpClient, config: GitLabConfig)(impl
case None => Map()
}
val filesTreeUrl: String =
s"${config.url}projects/${project.repositoryId.value}/repository/tree"
s"${config.url}projects/${project.repositoryId}/repository/tree"

httpClient
.get[List[FileTree]](url = filesTreeUrl, params = versionId, headers = config.token)
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ package cromwell.pipeline.service

import cromwell.pipeline.datastorage.dao.repository.ProjectConfigurationRepository
import cromwell.pipeline.datastorage.dto._
import cromwell.pipeline.model.wrapper.UserId
import cromwell.pipeline.model.wrapper.{ ProjectConfigurationId, ProjectId, UserId }
import cromwell.pipeline.service.ProjectConfigurationService.Exceptions.{
AccessDenied,
InternalError,
@@ -143,7 +143,7 @@ object ProjectConfigurationService {
Future.failed(InternalError(s"Failed to $action due to unexpected internal error"))

private def notFoundProjectError(projectId: ProjectId) =
Future.failed(NotFound(s"There is no configuration with project_id: ${projectId.value}"))
Future.failed(NotFound(s"There is no configuration with project_id: $projectId"))

private def serviceErrorMapper(exc: ProjectServiceException): Future[Nothing] =
exc match {
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cromwell.pipeline.service

import cromwell.pipeline.datastorage.dto._
import cromwell.pipeline.model.wrapper.UserId
import cromwell.pipeline.model.wrapper.{ ProjectId, UserId }
import cromwell.pipeline.womtool.WomToolAPI

import java.nio.file.Path
Original file line number Diff line number Diff line change
@@ -2,11 +2,10 @@ package cromwell.pipeline.service

import cromwell.pipeline.datastorage.dao.repository.ProjectRepository
import cromwell.pipeline.datastorage.dto._
import cromwell.pipeline.model.wrapper.UserId
import cromwell.pipeline.model.wrapper.{ ProjectId, UserId }
import cromwell.pipeline.service.ProjectService.Exceptions._
import cromwell.pipeline.service.exceptions.ServiceException

import java.util.UUID
import scala.concurrent.{ ExecutionContext, Future }

trait ProjectService {
@@ -74,7 +73,7 @@ object ProjectService {
def addProject(request: ProjectAdditionRequest, userId: UserId): Future[Project] = {
val localProject =
LocalProject(
projectId = ProjectId(UUID.randomUUID().toString),
projectId = ProjectId.random,
ownerId = userId,
name = request.name,
active = true
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ package cromwell.pipeline.service

import cromwell.pipeline.datastorage.dao.repository.RunRepository
import cromwell.pipeline.datastorage.dto._
import cromwell.pipeline.model.wrapper.{ RunId, UserId }
import cromwell.pipeline.model.wrapper.{ ProjectId, RunId, UserId }
import cromwell.pipeline.service.ProjectService.Exceptions.ProjectServiceException
import cromwell.pipeline.service.RunService.Exceptions._
import cromwell.pipeline.service.exceptions.ServiceException
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@ package cromwell.pipeline.service

import cromwell.pipeline.datastorage.dao.utils.{ TestProjectUtils, TestRunUtils, TestUserUtils }
import cromwell.pipeline.datastorage.dto._
import cromwell.pipeline.model.wrapper.ProjectConfigurationId
import cromwell.pipeline.service.ProjectService.Exceptions.NotFound
import cromwell.pipeline.service.impls.{
ProjectConfigurationServiceTestImpl,
@@ -75,12 +76,12 @@ class AggregationServiceTest extends AsyncWordSpec with Matchers {
"should return exception if configuration not found" taggedAs Service in {

val emptyProjectConfigurationService = ProjectConfigurationServiceTestImpl.withException(
NotFound(s"Configurations for projectId ${projectId.value} not found")
NotFound(s"Configurations for projectId $projectId not found")
)
val aggregatorService = createAggregationService(projectConfigurationService = emptyProjectConfigurationService)

aggregatorService.aggregate(run).failed.map {
_ should have.message(s"Configurations for projectId ${projectId.value} not found")
_ should have.message(s"Configurations for projectId $projectId not found")
}
}

Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@ class GitLabProjectVersioningTest extends AsyncWordSpec with Matchers with Mocki

def configureGetVersions(
versions: List[GitLabVersion],
tagUrl: String = s"${gitLabConfig.url}projects/${projectWithRepo.repositoryId.value}/repository/tags"
tagUrl: String = s"${gitLabConfig.url}projects/${projectWithRepo.repositoryId}/repository/tags"
): Unit =
when {
mockHttpClient.get[List[GitLabVersion]](
@@ -72,7 +72,7 @@ class GitLabProjectVersioningTest extends AsyncWordSpec with Matchers with Mocki
def configureCreateTag(
version: PipelineVersion,
response: SuccessResponseMessage,
tagUrl: String = s"${gitLabConfig.url}projects/${projectWithRepo.repositoryId.value}/repository/tags"
tagUrl: String = s"${gitLabConfig.url}projects/${projectWithRepo.repositoryId}/repository/tags"
): Unit =
when {
mockHttpClient.post[SuccessResponseMessage, EmptyPayload](
@@ -88,7 +88,7 @@ class GitLabProjectVersioningTest extends AsyncWordSpec with Matchers with Mocki
"deleteFile" should {

val path = URLEncoderUtils.encode(existFile.path.toString)
val url = s"${gitLabConfig.url}projects/${projectWithRepo.repositoryId.value}/repository/files/$path"
val url = s"${gitLabConfig.url}projects/${projectWithRepo.repositoryId}/repository/files/$path"
val gitlabVersion = TestProjectUtils.getDummyGitLabVersion(dummyPipelineVersion)
val payload = DeleteFileRequest(
s"Deleting file ${existFile.path} from repository: ${projectWithRepo.name}",
@@ -196,14 +196,14 @@ class GitLabProjectVersioningTest extends AsyncWordSpec with Matchers with Mocki

"updateFile" should {
val successCreateMessage = "File was created"
val tagUrl = s"${gitLabConfig.url}projects/${projectWithRepo.repositoryId.value}/repository/tags"
val tagUrl = s"${gitLabConfig.url}projects/${projectWithRepo.repositoryId}/repository/tags"
val gitlabVersion = TestProjectUtils.getDummyGitLabVersion(dummyPipelineVersion)
val gitlabVersionHigher = TestProjectUtils.getDummyGitLabVersion(dummyPipelineVersionHigher)

"succeed when file is new" taggedAs Service in {
val payload = UpdateFileRequest(newFile.content, dummyPipelineVersionHigher.name, gitLabConfig.defaultBranch)
val path = URLEncoderUtils.encode(newFile.path.toString)
val url = s"${gitLabConfig.url}projects/${projectWithRepo.repositoryId.value}/repository/files/$path"
val url = s"${gitLabConfig.url}projects/${projectWithRepo.repositoryId}/repository/files/$path"

val putResponse =
Response[UpdateFileResponse](
@@ -232,7 +232,7 @@ class GitLabProjectVersioningTest extends AsyncWordSpec with Matchers with Mocki
"succeed when file already exists" taggedAs Service in {
val payload = UpdateFileRequest(existFile.content, dummyPipelineVersionHigher.name, gitLabConfig.defaultBranch)
val path = URLEncoderUtils.encode(existFile.path.toString)
val url = s"${gitLabConfig.url}projects/${projectWithRepo.repositoryId.value}/repository/files/$path"
val url = s"${gitLabConfig.url}projects/${projectWithRepo.repositoryId}/repository/files/$path"

val putResponse = Response[UpdateFileResponse](
StatusCodes.OK.intValue,
@@ -253,7 +253,7 @@ class GitLabProjectVersioningTest extends AsyncWordSpec with Matchers with Mocki
val updatedVersion = dummyPipelineVersion.increaseRevision
val payload = UpdateFileRequest(existFile.content, updatedVersion.name, gitLabConfig.defaultBranch)
val path = URLEncoderUtils.encode(existFile.path.toString)
val url = s"${gitLabConfig.url}projects/${projectWithRepo.repositoryId.value}/repository/files/$path"
val url = s"${gitLabConfig.url}projects/${projectWithRepo.repositoryId}/repository/files/$path"

val putResponse = Response[UpdateFileResponse](
StatusCodes.OK.intValue,
@@ -304,7 +304,7 @@ class GitLabProjectVersioningTest extends AsyncWordSpec with Matchers with Mocki
val encodedPathStr = URLEncoderUtils.encode(path.toString)
when {
mockHttpClient.get[GitLabFileContent](
s"${gitLabConfig.url}projects/${activeProject.repositoryId.value}/repository/files/$encodedPathStr",
s"${gitLabConfig.url}projects/${activeProject.repositoryId}/repository/files/$encodedPathStr",
Map("ref" -> dummyPipelineVersion.name),
gitLabConfig.token
)
@@ -328,7 +328,7 @@ class GitLabProjectVersioningTest extends AsyncWordSpec with Matchers with Mocki
val encodedPathStr = URLEncoderUtils.encode(path.toString)
when {
mockHttpClient.get[GitLabFileContent](
s"${gitLabConfig.url}projects/${activeProject.repositoryId.value}/repository/files/$encodedPathStr",
s"${gitLabConfig.url}projects/${activeProject.repositoryId}/repository/files/$encodedPathStr",
Map("ref" -> dummyPipelineVersion.name),
gitLabConfig.token
)
@@ -356,7 +356,7 @@ class GitLabProjectVersioningTest extends AsyncWordSpec with Matchers with Mocki
case None => Map()
}
mockHttpClient.get[List[FileTree]](
url = exact(s"${gitLabConfig.url}projects/${project.repositoryId.value}/repository/tree"),
url = exact(s"${gitLabConfig.url}projects/${project.repositoryId}/repository/tree"),
params = exact(versionId),
headers = exact(gitLabConfig.token)
)(ec = any[ExecutionContext], f = any[Reads[List[FileTree]]])
@@ -368,14 +368,14 @@ class GitLabProjectVersioningTest extends AsyncWordSpec with Matchers with Mocki
version: Option[PipelineVersion]
): Future[Response[GitLabFileContent]] =
mockHttpClient.get[GitLabFileContent](
exact(s"${gitLabConfig.url}projects/${project.repositoryId.value}/repository/files/$filePath"),
exact(s"${gitLabConfig.url}projects/${project.repositoryId}/repository/files/$filePath"),
exact(Map("ref" -> version.map(_.name).getOrElse(project.version.name))),
exact(gitLabConfig.token)
)(ec = any[ExecutionContext], f = any[Reads[GitLabFileContent]])

def getGitLabProjectVersions(project: Project): Future[Response[List[GitLabVersion]]] =
mockHttpClient.get[List[GitLabVersion]](
exact(s"${gitLabConfig.url}projects/${project.repositoryId.value}/repository/tags"),
exact(s"${gitLabConfig.url}projects/${project.repositoryId}/repository/tags"),
any[Map[String, String]],
exact(gitLabConfig.token)
)(ec = any[ExecutionContext], f = any[Reads[List[GitLabVersion]]])
@@ -428,7 +428,7 @@ class GitLabProjectVersioningTest extends AsyncWordSpec with Matchers with Mocki
}
when {
mockHttpClient.get[GitLabFileContent](
s"${gitLabConfig.url}projects/${activeProject.repositoryId.value}/repository/files/$encodedPathStr",
s"${gitLabConfig.url}projects/${activeProject.repositoryId}/repository/files/$encodedPathStr",
Map("ref" -> dummyPipelineVersion.name),
gitLabConfig.token
)
@@ -447,7 +447,7 @@ class GitLabProjectVersioningTest extends AsyncWordSpec with Matchers with Mocki
"getProjectVersions" should {
def getProjectVersions(project: Project): Future[Response[Seq[GitLabVersion]]] =
mockHttpClient.get[Seq[GitLabVersion]](
url = exact(gitLabConfig.url + "projects/" + project.repositoryId.value + "/repository/tags"),
url = exact(gitLabConfig.url + "projects/" + project.repositoryId + "/repository/tags"),
headers = any[Map[String, String]],
params = any[Map[String, String]]
)(any[ExecutionContext], any[Reads[Seq[GitLabVersion]]])
@@ -493,7 +493,7 @@ class GitLabProjectVersioningTest extends AsyncWordSpec with Matchers with Mocki

def getFileVersions(project: Project): Future[Response[Seq[GLFileCommitInfo]]] =
mockHttpClient.get[Seq[GLFileCommitInfo]](
url = exact(s"${gitLabConfig.url}projects/${project.repositoryId.value}/repository/commits"),
url = exact(s"${gitLabConfig.url}projects/${project.repositoryId}/repository/commits"),
params = exact(Map("path" -> urlEncoder)),
headers = exact(gitLabConfig.token)
)(ec = any[ExecutionContext], f = any[Reads[Seq[GLFileCommitInfo]]])
@@ -539,7 +539,7 @@ class GitLabProjectVersioningTest extends AsyncWordSpec with Matchers with Mocki

def getFileCommits(project: Project): Future[Response[List[GLFileCommitInfo]]] =
mockHttpClient.get[List[GLFileCommitInfo]](
url = exact(s"${gitLabConfig.url}projects/${project.repositoryId.value}/repository/commits"),
url = exact(s"${gitLabConfig.url}projects/${project.repositoryId}/repository/commits"),
params = exact(Map("path" -> urlEncoder)),
headers = exact(gitLabConfig.token)
)(ec = any[ExecutionContext], f = any[Reads[List[GLFileCommitInfo]]])
@@ -631,7 +631,7 @@ class GitLabProjectVersioningTest extends AsyncWordSpec with Matchers with Mocki
lazy val inactiveProject: Project = activeProject.copy(active = false)
lazy val projectWithRepo: Project = activeLocalProject.toProject(gitLabRepositoryResponse.id, defaultVersion)

lazy val postProject: PostProject = PostProject(name = activeProject.projectId.value)
lazy val postProject: PostProject = PostProject(name = activeProject.projectId)

lazy val dummyPipelineVersion: PipelineVersion = TestProjectUtils.getDummyPipeLineVersion()
lazy val dummyPipelineVersionHigher: PipelineVersion = dummyPipelineVersion.increaseMinor
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ import cromwell.pipeline.datastorage.dao.repository.ProjectConfigurationReposito
import cromwell.pipeline.datastorage.dao.repository.impls.ProjectConfigurationRepositoryTestImpl
import cromwell.pipeline.datastorage.dao.utils.{ TestProjectUtils, TestUserUtils }
import cromwell.pipeline.datastorage.dto._
import cromwell.pipeline.model.wrapper.UserId
import cromwell.pipeline.model.wrapper.{ ProjectConfigurationId, ProjectId, UserId }
import cromwell.pipeline.service.ProjectConfigurationService.Exceptions._
import cromwell.pipeline.service.impls.{ ProjectServiceTestImpl, ProjectVersioningTestImpl, WomToolTestImpl }
import cromwell.pipeline.womtool.WomToolAPI
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ package cromwell.pipeline.service

import cromwell.pipeline.datastorage.dao.utils.TestProjectUtils
import cromwell.pipeline.datastorage.dto._
import cromwell.pipeline.model.wrapper.UserId
import cromwell.pipeline.model.wrapper.{ ProjectConfigurationId, ProjectId, UserId }
import cromwell.pipeline.service.ProjectSearchEngine.Exceptions.InternalError
import cromwell.pipeline.service.impls.{
ProjectConfigurationServiceTestImpl,
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ package cromwell.pipeline.service
import cromwell.pipeline.datastorage.dao.repository.impls.ProjectRepositoryTestImpl
import cromwell.pipeline.datastorage.dao.utils.TestProjectUtils
import cromwell.pipeline.datastorage.dto._
import cromwell.pipeline.model.wrapper.ProjectId
import cromwell.pipeline.service.ProjectService.Exceptions.{ AccessDenied, InternalError, NotFound }
import cromwell.pipeline.service.impls.ProjectVersioningTestImpl
import org.scalatest.{ AsyncWordSpec, Matchers }
@@ -106,7 +107,7 @@ class ProjectServiceTest extends AsyncWordSpec with Matchers with MockitoSugar {
}

"return none if project not found" taggedAs Service in {
val projectId = ProjectId("projectId")
val projectId = ProjectId.random

projectService.getUserProjectById(projectId, userId).failed.map { _ shouldBe NotFound() }
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cromwell.pipeline.service.impls

import cromwell.pipeline.datastorage.dto._
import cromwell.pipeline.model.wrapper.UserId
import cromwell.pipeline.model.wrapper.{ ProjectConfigurationId, ProjectId, UserId }
import cromwell.pipeline.service.ProjectConfigurationService

import java.nio.file.Path
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cromwell.pipeline.service.impls

import cromwell.pipeline.datastorage.dto._
import cromwell.pipeline.model.wrapper.UserId
import cromwell.pipeline.model.wrapper.{ ProjectId, UserId }
import cromwell.pipeline.service.{ ProjectFileService, VersioningException }

import java.nio.file.Path
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ package cromwell.pipeline.service.impls

import cromwell.pipeline.datastorage.dao.utils.TestProjectUtils
import cromwell.pipeline.datastorage.dto._
import cromwell.pipeline.model.wrapper.UserId
import cromwell.pipeline.model.wrapper.{ ProjectId, UserId }
import cromwell.pipeline.service.ProjectService

import scala.concurrent.Future
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cromwell.pipeline.service.impls

import cromwell.pipeline.datastorage.dto.{ ProjectId, Run, RunCreateRequest, RunUpdateRequest }
import cromwell.pipeline.model.wrapper.{ RunId, UserId }
import cromwell.pipeline.datastorage.dto.{ Run, RunCreateRequest, RunUpdateRequest }
import cromwell.pipeline.model.wrapper.{ ProjectId, RunId, UserId }
import cromwell.pipeline.service.RunService

import scala.concurrent.Future

0 comments on commit 447c854

Please sign in to comment.