Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EPMLSTRCMW-311 Make All Id Types Wrapped #237

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

ForeverRainmaN
Copy link

@ForeverRainmaN ForeverRainmaN commented Feb 15, 2022

  • Wrapped id's into a Wrapped trait
  • Refactored test code according to new changes

@ForeverRainmaN ForeverRainmaN force-pushed the EPMLSTRCMW-311-Make-All-Id-Types-Wrapped branch from 60f393f to 447c854 Compare February 21, 2022 11:21
@ForeverRainmaN ForeverRainmaN changed the title refactor: wrapped id cc into Wrapper with companion objects EPMLSTRCMW-311 Make All Id Types Wrapped Feb 21, 2022
@ForeverRainmaN ForeverRainmaN changed the title EPMLSTRCMW-311 Make All Id Types Wrapped EPMLSTRCMW-311-Make All Id Types Wrapped Feb 21, 2022
@ForeverRainmaN ForeverRainmaN force-pushed the EPMLSTRCMW-311-Make-All-Id-Types-Wrapped branch from 447c854 to 0396ecc Compare February 21, 2022 11:28
@ForeverRainmaN ForeverRainmaN changed the title EPMLSTRCMW-311-Make All Id Types Wrapped EPMLSTRCMW-311 Make All Id Types Wrapped Feb 21, 2022
@ForeverRainmaN ForeverRainmaN force-pushed the EPMLSTRCMW-311-Make-All-Id-Types-Wrapped branch from 0396ecc to 4d6399d Compare February 21, 2022 11:43
Copy link

@GrigoriiBerezin GrigoriiBerezin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job. But there are few moments to discuss

Comment on lines 20 to 23
ProjectId.from(projectId) match {
case Validated.Valid(content) => content
case Validated.Invalid(errors) => throw new RuntimeException(errors.head)
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it has the same behavior as apply method, you can use ProjectId(projectId, Enable.Unsafe)

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)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should think of generic way implementation to handle all wrappers to PathMatcher, but need to discuss with @myazinn

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. It should relatively be easy to do.

Comment on lines 17 to 19
override type Type = String
override type Wrapper = ProjectConfigurationId
override type Error = String

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[OPT] It's not an override actually, key word override should be removed


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)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this method? I see that we using it only in one place for creating dummy instance


implicit lazy val repositoryIdFormat: Format[RepositoryId] = wrapperFormat

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant

Comment on lines 8 to 9
import java.time.Instant

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this import moved?

@ForeverRainmaN ForeverRainmaN force-pushed the EPMLSTRCMW-311-Make-All-Id-Types-Wrapped branch from 4d6399d to d171b1a Compare March 1, 2022 08:22
@codecov-commenter
Copy link

codecov-commenter commented Mar 1, 2022

Codecov Report

Merging #237 (c706125) into develop (ac85bbc) will decrease coverage by 0.20%.
The diff coverage is 78.57%.

@@             Coverage Diff             @@
##           develop     #237      +/-   ##
===========================================
- Coverage    89.95%   89.74%   -0.21%     
===========================================
  Files           54       54              
  Lines          876      878       +2     
  Branches         6        5       -1     
===========================================
  Hits           788      788              
- Misses          88       90       +2     
Impacted Files Coverage Δ
...ine/controller/utils/FromStringUnmarshallers.scala 66.66% <0.00%> (ø)
.../pipeline/datastorage/dao/entry/ProjectEntry.scala 95.00% <ø> (ø)
...well/pipeline/datastorage/dao/entry/RunEntry.scala 92.30% <ø> (ø)
...ao/repository/ProjectConfigurationRepository.scala 100.00% <ø> (ø)
...datastorage/dao/repository/ProjectRepository.scala 100.00% <ø> (ø)
...ine/datastorage/dao/repository/RunRepository.scala 100.00% <ø> (ø)
...la/cromwell/pipeline/datastorage/dto/Project.scala 77.77% <ø> (ø)
...ipeline/datastorage/dto/ProjectConfiguration.scala 63.63% <ø> (-3.04%) ⬇️
.../scala/cromwell/pipeline/datastorage/dto/Run.scala 50.00% <ø> (ø)
...cromwell/pipeline/service/AggregationService.scala 100.00% <ø> (ø)
... and 10 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ac85bbc...c706125. Read the comment docs.

@ForeverRainmaN ForeverRainmaN force-pushed the EPMLSTRCMW-311-Make-All-Id-Types-Wrapped branch 4 times, most recently from 2f628d2 to 55713d2 Compare March 1, 2022 11:37
@ForeverRainmaN ForeverRainmaN force-pushed the EPMLSTRCMW-311-Make-All-Id-Types-Wrapped branch from 55713d2 to c706125 Compare March 1, 2022 11:46
@ForeverRainmaN ForeverRainmaN force-pushed the EPMLSTRCMW-311-Make-All-Id-Types-Wrapped branch from 0646ebf to c706125 Compare March 16, 2022 09:38
@@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO it is a bit inconsistent that you are removing id = ProjectConfigurationId.randomId in ProjectConfigurationServiceTestImpl while adding it here. We should stick to either of this approach, but not change them back and forth (randomId looks better IMO)

@@ -41,25 +42,12 @@ final case class LocalProject(
)
}

final case class PostProject(name: String)
final case class PostProject(name: ProjectId)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an incorrect change. Project name is a human-friendly thing (such as "My pet project"), this is not a projectId that we control and must be unique.

@@ -12,7 +10,6 @@ object RunId extends Wrapped.Companion {
type Wrapper = RunId
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}$"
implicit lazy val runIdFormat: Format[RunId] = wrapperFormat
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change required for your MR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants