-
Notifications
You must be signed in to change notification settings - Fork 27
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
base: develop
Are you sure you want to change the base?
EPMLSTRCMW-311 Make All Id Types Wrapped #237
Conversation
ForeverRainmaN
commented
Feb 15, 2022
•
edited
Loading
edited
- Wrapped id's into a Wrapped trait
- Refactored test code according to new changes
60f393f
to
447c854
Compare
447c854
to
0396ecc
Compare
0396ecc
to
4d6399d
Compare
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.
Good job. But there are few moments to discuss
ProjectId.from(projectId) match { | ||
case Validated.Valid(content) => content | ||
case Validated.Invalid(errors) => throw new RuntimeException(errors.head) | ||
} |
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.
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) |
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.
We should think of generic way implementation to handle all wrappers to PathMatcher, but need to discuss with @myazinn
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.
I agree. It should relatively be easy to do.
override type Type = String | ||
override type Wrapper = ProjectConfigurationId | ||
override type Error = String |
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.
[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) |
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.
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]+$" |
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.
Redundant
import java.time.Instant | ||
|
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.
Why was this import moved?
4d6399d
to
d171b1a
Compare
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
2f628d2
to
55713d2
Compare
55713d2
to
c706125
Compare
0646ebf
to
c706125
Compare
@@ -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 |
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.
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) |
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.
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 |
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.
Is this change required for your MR?