diff --git a/.idea/dictionaries/project.xml b/.idea/dictionaries/project.xml
index a7265e4c8..200eae3fa 100644
--- a/.idea/dictionaries/project.xml
+++ b/.idea/dictionaries/project.xml
@@ -2,6 +2,7 @@
picoc
+ scas
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
index 44efd8de8..a2ce51cff 100644
--- a/.idea/encodings.xml
+++ b/.idea/encodings.xml
@@ -8,6 +8,7 @@
+
diff --git a/account/pom.xml b/account/pom.xml
index 5ae3d627f..f89bc2c3f 100644
--- a/account/pom.xml
+++ b/account/pom.xml
@@ -59,5 +59,11 @@
postgresql
42.7.2
+
+ br.all
+ shared
+ 1.0-SNAPSHOT
+ compile
+
\ No newline at end of file
diff --git a/account/src/main/kotlin/br/all/application/user/create/RegisterUserAccountServiceImpl.kt b/account/src/main/kotlin/br/all/application/user/create/RegisterUserAccountServiceImpl.kt
index 9d2195cb0..2b72d2403 100644
--- a/account/src/main/kotlin/br/all/application/user/create/RegisterUserAccountServiceImpl.kt
+++ b/account/src/main/kotlin/br/all/application/user/create/RegisterUserAccountServiceImpl.kt
@@ -5,6 +5,7 @@ import br.all.application.user.create.RegisterUserAccountService.RequestModel
import br.all.application.user.create.RegisterUserAccountService.ResponseModel
import br.all.application.user.repository.UserAccountRepository
import br.all.application.user.repository.toDto
+import br.all.domain.shared.user.Email
import br.all.domain.user.*
class RegisterUserAccountServiceImpl(private val repository: UserAccountRepository) : RegisterUserAccountService {
diff --git a/account/src/main/kotlin/br/all/application/user/repository/UserAccountMapper.kt b/account/src/main/kotlin/br/all/application/user/repository/UserAccountMapper.kt
index 716c1ba41..dcc0754db 100644
--- a/account/src/main/kotlin/br/all/application/user/repository/UserAccountMapper.kt
+++ b/account/src/main/kotlin/br/all/application/user/repository/UserAccountMapper.kt
@@ -6,7 +6,7 @@ fun UserAccount.toDto() = UserAccountDto(
id.value(),
accountCredentials.username.value,
accountCredentials.password,
- email.value,
+ email.email,
country.value,
affiliation,
createdAt,
diff --git a/account/src/main/kotlin/br/all/domain/shared/ddd/ValueObject.kt b/account/src/main/kotlin/br/all/domain/shared/ddd/ValueObject.kt
deleted file mode 100644
index c22062ab7..000000000
--- a/account/src/main/kotlin/br/all/domain/shared/ddd/ValueObject.kt
+++ /dev/null
@@ -1,5 +0,0 @@
-package br.all.domain.shared.ddd
-
-abstract class ValueObject {
- protected abstract fun validate() : Notification
-}
diff --git a/account/src/main/kotlin/br/all/domain/user/Email.kt b/account/src/main/kotlin/br/all/domain/user/Email.kt
deleted file mode 100644
index 965415718..000000000
--- a/account/src/main/kotlin/br/all/domain/user/Email.kt
+++ /dev/null
@@ -1,66 +0,0 @@
-package br.all.domain.user
-
-import br.all.domain.shared.ddd.Notification
-import br.all.domain.shared.ddd.ValueObject
-
-data class Email(val value: String) : ValueObject() {
-
- init {
- val notification = validate()
- require(notification.hasNoErrors()) { notification.message() }
- }
-
- override fun validate(): Notification {
- val notification = Notification()
-
- if (value.isEmpty()) {
- notification.addError("Email must not be empty.")
- return notification
- }
-
- if (value.isBlank()) {
- notification.addError("Email must not be blank.")
- return notification
- }
-
- if (!isValidEmailFormat(value)) notification.addError("Wrong Email format.")
-
- return notification
- }
-
- private fun isValidEmailFormat(email: String): Boolean {
- if (email.contains("..") || email.contains(".@") || email.contains("@.")) return false
- if (email.startsWith(".") || email.endsWith(".")) return false
- if (email.startsWith("@") || email.endsWith("@")) return false
-
- val parts = email.split("@")
- if (parts.size != 2) return false
-
- val localPart = parts[0]
- val domainPart = parts[1]
-
- if (!hasValidLength(localPart, domainPart)) return false
- if (!isValidStructure(localPart, domainPart)) return false
-
- return true
- }
-
- private fun isValidStructure(localPart: String, domainPart: String): Boolean {
- val localRegex = Regex("^[A-Za-z0-9_!#$%&'*+/=?`{|}~^.-]+$")
- val domainRegex = Regex("^[A-Za-z0-9.-]+$")
-
- val domainLabels = domainPart.split(".")
- if (domainLabels.last().length < 2 || domainLabels.any { it.startsWith("-") || it.endsWith("-") }) {
- return false
- }
-
- return localRegex.matches(localPart) && domainRegex.matches(domainPart)
- }
-
- private fun hasValidLength(localPart: String, domainPart: String): Boolean {
- if (localPart.length > 64) return false
- if (domainPart.length > 255) return false
- if ((localPart.length + 1 + domainPart.length) > 254) return false
- return true
- }
-}
\ No newline at end of file
diff --git a/account/src/main/kotlin/br/all/domain/user/UserAccount.kt b/account/src/main/kotlin/br/all/domain/user/UserAccount.kt
index 673641552..61ca66dc2 100644
--- a/account/src/main/kotlin/br/all/domain/user/UserAccount.kt
+++ b/account/src/main/kotlin/br/all/domain/user/UserAccount.kt
@@ -1,6 +1,7 @@
package br.all.domain.user
import br.all.domain.shared.ddd.Entity
+import br.all.domain.shared.user.Email
import java.time.LocalDateTime
import java.util.UUID
diff --git a/account/src/main/kotlin/br/all/domain/user/Username.kt b/account/src/main/kotlin/br/all/domain/user/Username.kt
index 6c5f1704f..95c604a79 100644
--- a/account/src/main/kotlin/br/all/domain/user/Username.kt
+++ b/account/src/main/kotlin/br/all/domain/user/Username.kt
@@ -3,7 +3,7 @@ package br.all.domain.user
import br.all.domain.shared.ddd.Notification
import br.all.domain.shared.ddd.ValueObject
-data class Username(val value: String) : ValueObject (){
+data class Username(val value: String) : ValueObject(){
init {
val notification = validate()
@@ -16,6 +16,6 @@ data class Username(val value: String) : ValueObject (){
notification.addError("Username must not be blank!")
else if (!value.matches( Regex("[a-zA-Z0-9-_]*")))
notification.addError("Username must contain only letters and numbers, dashes and underscores!")
- return notification;
+ return notification
}
}
diff --git a/account/src/test/kotlin/br/all/domain/user/UserAccountTest.kt b/account/src/test/kotlin/br/all/domain/user/UserAccountTest.kt
index 25a1e4b8e..1483e8d4f 100644
--- a/account/src/test/kotlin/br/all/domain/user/UserAccountTest.kt
+++ b/account/src/test/kotlin/br/all/domain/user/UserAccountTest.kt
@@ -1,7 +1,8 @@
package br.all.domain.user
+import br.all.domain.shared.user.Email
import io.github.serpro69.kfaker.Faker
-import org.junit.jupiter.api.Assertions.*
+import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Tag
import java.time.LocalDateTime
import java.util.UUID
@@ -45,11 +46,11 @@ class UserAccountTest{
@Test
fun `should create account credentials with default values`(){
val user = createUser()
- assertEquals(user.accountCredentials.refreshToken, null)
- assertTrue(user.accountCredentials.isCredentialsNonExpired)
- assertTrue(user.accountCredentials.isAccountNonExpired)
- assertTrue(user.accountCredentials.isAccountNonLocked)
- assertTrue(user.accountCredentials.isEnabled)
+ Assertions.assertEquals(user.accountCredentials.refreshToken, null)
+ Assertions.assertTrue(user.accountCredentials.isCredentialsNonExpired)
+ Assertions.assertTrue(user.accountCredentials.isAccountNonExpired)
+ Assertions.assertTrue(user.accountCredentials.isAccountNonLocked)
+ Assertions.assertTrue(user.accountCredentials.isEnabled)
}
@Test
@@ -57,7 +58,7 @@ class UserAccountTest{
val user = createUser()
val username = Username("new_name")
user.changeUsername(username)
- assertEquals(user.accountCredentials.username, username)
+ Assertions.assertEquals(user.accountCredentials.username, username)
}
@Test
@@ -65,7 +66,7 @@ class UserAccountTest{
val user = createUser()
val password = "new_password"
user.changePassword(password)
- assertEquals(user.accountCredentials.password, password)
+ Assertions.assertEquals(user.accountCredentials.password, password)
}
private fun createUser(
@@ -79,6 +80,7 @@ class UserAccountTest{
authorities: Set = setOf(Authority.USER)
) = UserAccount(
UserAccountId(id),
- createdAt, email, country, affiliation, username, password, authorities)
+ createdAt, email, country, affiliation, username, password, authorities
+ )
}
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index da1865238..56653c651 100644
--- a/pom.xml
+++ b/pom.xml
@@ -16,6 +16,7 @@
web
account
scas
+ shared
diff --git a/review/pom.xml b/review/pom.xml
index 920d13193..9de66f259 100644
--- a/review/pom.xml
+++ b/review/pom.xml
@@ -32,6 +32,12 @@
1.0-SNAPSHOT
compile
+
+ br.all
+ shared
+ 1.0-SNAPSHOT
+ compile
+
io.swagger.core.v3
diff --git a/review/src/main/kotlin/br/all/domain/model/protocol/Criterion.kt b/review/src/main/kotlin/br/all/domain/model/protocol/Criterion.kt
index f88f64879..f5aaae05d 100644
--- a/review/src/main/kotlin/br/all/domain/model/protocol/Criterion.kt
+++ b/review/src/main/kotlin/br/all/domain/model/protocol/Criterion.kt
@@ -2,9 +2,8 @@ package br.all.domain.model.protocol
import br.all.domain.shared.ddd.Notification
import br.all.domain.shared.ddd.ValueObject
-import jakarta.persistence.Embeddable
-data class Criterion internal constructor(
+data class Criterion(
val description: String,
val type: CriterionType,
) : ValueObject() {
diff --git a/review/src/main/kotlin/br/all/domain/model/protocol/Protocol.kt b/review/src/main/kotlin/br/all/domain/model/protocol/Protocol.kt
index 430a97d9d..34f7afc52 100644
--- a/review/src/main/kotlin/br/all/domain/model/protocol/Protocol.kt
+++ b/review/src/main/kotlin/br/all/domain/model/protocol/Protocol.kt
@@ -1,8 +1,8 @@
package br.all.domain.model.protocol
+import br.all.domain.shared.ddd.Entity
import br.all.domain.model.question.QuestionId
import br.all.domain.model.review.SystematicStudyId
-import br.all.domain.shared.ddd.Entity
import br.all.domain.shared.utils.exists
import br.all.domain.shared.valueobject.Language
import java.util.*
diff --git a/review/src/main/kotlin/br/all/domain/model/question/PickList.kt b/review/src/main/kotlin/br/all/domain/model/question/PickList.kt
index 73fc705a7..8a04e5e3e 100644
--- a/review/src/main/kotlin/br/all/domain/model/question/PickList.kt
+++ b/review/src/main/kotlin/br/all/domain/model/question/PickList.kt
@@ -1,6 +1,5 @@
package br.all.domain.model.question
-import br.all.domain.model.protocol.ProtocolId
import br.all.domain.model.review.SystematicStudyId
import br.all.domain.model.study.Answer
import br.all.domain.shared.ddd.Notification
diff --git a/review/src/main/kotlin/br/all/domain/model/question/Question.kt b/review/src/main/kotlin/br/all/domain/model/question/Question.kt
index f5484018b..dcd216b10 100644
--- a/review/src/main/kotlin/br/all/domain/model/question/Question.kt
+++ b/review/src/main/kotlin/br/all/domain/model/question/Question.kt
@@ -1,9 +1,8 @@
package br.all.domain.model.question
-import br.all.domain.model.protocol.ProtocolId
+import br.all.domain.shared.ddd.Entity
import br.all.domain.model.review.SystematicStudyId
import br.all.domain.model.study.Answer
-import br.all.domain.shared.ddd.Entity
import br.all.domain.shared.ddd.Notification
import java.util.*
diff --git a/review/src/main/kotlin/br/all/domain/model/question/QuestionId.kt b/review/src/main/kotlin/br/all/domain/model/question/QuestionId.kt
index 339c6122a..5d232b4c0 100644
--- a/review/src/main/kotlin/br/all/domain/model/question/QuestionId.kt
+++ b/review/src/main/kotlin/br/all/domain/model/question/QuestionId.kt
@@ -2,11 +2,10 @@ package br.all.domain.model.question
import br.all.domain.shared.ddd.Identifier
import br.all.domain.shared.ddd.Notification
-import java.rmi.server.UID
import java.util.UUID
@JvmInline
-value class QuestionId(val value : UUID) : Identifier {
+value class QuestionId(val value : UUID) : Identifier {
override fun validate() = Notification()
override fun value(): UUID = value
override fun toString() = value.toString()
diff --git a/review/src/main/kotlin/br/all/domain/model/review/SystematicStudy.kt b/review/src/main/kotlin/br/all/domain/model/review/SystematicStudy.kt
index 6ff248e6e..50a0c71a3 100644
--- a/review/src/main/kotlin/br/all/domain/model/review/SystematicStudy.kt
+++ b/review/src/main/kotlin/br/all/domain/model/review/SystematicStudy.kt
@@ -1,7 +1,7 @@
package br.all.domain.model.review
-import br.all.domain.model.user.ResearcherId
import br.all.domain.shared.ddd.Entity
+import br.all.domain.model.user.ResearcherId
import br.all.domain.shared.ddd.Notification
import br.all.domain.shared.utils.exists
import java.util.*
diff --git a/review/src/main/kotlin/br/all/domain/model/search/SearchSession.kt b/review/src/main/kotlin/br/all/domain/model/search/SearchSession.kt
index 42eca6571..8e598a807 100644
--- a/review/src/main/kotlin/br/all/domain/model/search/SearchSession.kt
+++ b/review/src/main/kotlin/br/all/domain/model/search/SearchSession.kt
@@ -1,9 +1,9 @@
package br.all.domain.model.search
+import br.all.domain.shared.ddd.Entity
import br.all.domain.model.protocol.SearchSource
import br.all.domain.model.user.ResearcherId
import br.all.domain.model.review.SystematicStudyId
-import br.all.domain.shared.ddd.Entity
import br.all.domain.shared.ddd.Notification
import java.time.LocalDateTime
import java.util.*
diff --git a/review/src/main/kotlin/br/all/domain/model/search/SearchSessionID.kt b/review/src/main/kotlin/br/all/domain/model/search/SearchSessionID.kt
index 5a1c27d69..bdf029c24 100644
--- a/review/src/main/kotlin/br/all/domain/model/search/SearchSessionID.kt
+++ b/review/src/main/kotlin/br/all/domain/model/search/SearchSessionID.kt
@@ -5,7 +5,7 @@ import br.all.domain.shared.ddd.Notification
import java.util.*
@JvmInline
-value class SearchSessionID(val value: UUID) : Identifier {
+value class SearchSessionID(val value: UUID) : Identifier {
init {
val notification = validate()
diff --git a/review/src/main/kotlin/br/all/domain/model/study/StudyReview.kt b/review/src/main/kotlin/br/all/domain/model/study/StudyReview.kt
index 75e86a626..fec26fef2 100644
--- a/review/src/main/kotlin/br/all/domain/model/study/StudyReview.kt
+++ b/review/src/main/kotlin/br/all/domain/model/study/StudyReview.kt
@@ -1,7 +1,7 @@
package br.all.domain.model.study
-import br.all.domain.model.protocol.Criterion
import br.all.domain.shared.ddd.Entity
+import br.all.domain.model.protocol.Criterion
import br.all.domain.model.review.SystematicStudyId
import br.all.domain.model.search.SearchSessionID
diff --git a/review/src/main/kotlin/br/all/domain/model/study/StudyReviewId.kt b/review/src/main/kotlin/br/all/domain/model/study/StudyReviewId.kt
index e2e900969..4754210c2 100644
--- a/review/src/main/kotlin/br/all/domain/model/study/StudyReviewId.kt
+++ b/review/src/main/kotlin/br/all/domain/model/study/StudyReviewId.kt
@@ -2,11 +2,9 @@ package br.all.domain.model.study
import br.all.domain.shared.ddd.Identifier
import br.all.domain.shared.ddd.Notification
-import java.util.UUID
-import javax.swing.LookAndFeel
@JvmInline
-value class StudyReviewId(val value: Long) : Identifier {
+value class StudyReviewId(val value: Long) : Identifier {
init {
val notification = validate()
diff --git a/review/src/main/kotlin/br/all/domain/model/user/ResearcherId.kt b/review/src/main/kotlin/br/all/domain/model/user/ResearcherId.kt
index e9391c101..f4cd4ad04 100644
--- a/review/src/main/kotlin/br/all/domain/model/user/ResearcherId.kt
+++ b/review/src/main/kotlin/br/all/domain/model/user/ResearcherId.kt
@@ -5,7 +5,7 @@ import br.all.domain.shared.ddd.Notification
import java.util.*
@JvmInline
-value class ResearcherId(val value : UUID ) : Identifier {
+value class ResearcherId(val value : UUID ) : Identifier {
override fun validate() = Notification()
diff --git a/review/src/main/kotlin/br/all/domain/shared/ddd/Entity.kt b/review/src/main/kotlin/br/all/domain/shared/ddd/Entity.kt
deleted file mode 100644
index 417d8d3f4..000000000
--- a/review/src/main/kotlin/br/all/domain/shared/ddd/Entity.kt
+++ /dev/null
@@ -1,13 +0,0 @@
-package br.all.domain.shared.ddd
-
-abstract class Entity (val id: Identifier) {
-
- final override fun equals(other: Any?) = when {
- this === other -> true
- other !is Entity<*> -> false
- this::class != other::class -> false
- else -> id == other.id
- }
-
- final override fun hashCode() = id.hashCode()
-}
\ No newline at end of file
diff --git a/review/src/main/kotlin/br/all/domain/shared/ddd/Identifier.kt b/review/src/main/kotlin/br/all/domain/shared/ddd/Identifier.kt
deleted file mode 100644
index 6e5b54bbf..000000000
--- a/review/src/main/kotlin/br/all/domain/shared/ddd/Identifier.kt
+++ /dev/null
@@ -1,6 +0,0 @@
-package br.all.domain.shared.ddd
-
-interface Identifier {
- fun validate() : Notification
- fun value() : T
-}
\ No newline at end of file
diff --git a/review/src/main/kotlin/br/all/domain/shared/ddd/Notification.kt b/review/src/main/kotlin/br/all/domain/shared/ddd/Notification.kt
deleted file mode 100644
index 298fb9ac3..000000000
--- a/review/src/main/kotlin/br/all/domain/shared/ddd/Notification.kt
+++ /dev/null
@@ -1,13 +0,0 @@
-package br.all.domain.shared.ddd
-
-class Notification {
-
- private val errors: MutableList = mutableListOf()
- fun addError(message: String, cause: Exception? = null) = errors.add(Error(message, cause))
- fun hasNoErrors() = errors.isEmpty()
- fun message() = errors.joinToString(" | ") { it.message }
- data class Error(val message: String, val cause: Exception?)
-}
-
-
-
diff --git a/review/src/main/kotlin/br/all/domain/shared/utils/Phrase.kt b/review/src/main/kotlin/br/all/domain/shared/utils/Phrase.kt
index 4588df4b8..dea9f462f 100644
--- a/review/src/main/kotlin/br/all/domain/shared/utils/Phrase.kt
+++ b/review/src/main/kotlin/br/all/domain/shared/utils/Phrase.kt
@@ -2,6 +2,7 @@ package br.all.domain.shared.utils
import br.all.domain.shared.ddd.Notification
import br.all.domain.shared.ddd.ValueObject
+import kotlin.text.iterator
data class Phrase(private val text: String) : ValueObject() {
init {
diff --git a/scas/pom.xml b/scas/pom.xml
index b8ddb39a2..c05350760 100644
--- a/scas/pom.xml
+++ b/scas/pom.xml
@@ -26,7 +26,7 @@
src/main/kotlin
- src/test/kotlin
+
org.jetbrains.kotlin
@@ -78,11 +78,6 @@
5.10.0
test
-
- org.jetbrains.kotlin
- kotlin-stdlib
- 1.9.0
-
br.all
review
diff --git a/shared/pom.xml b/shared/pom.xml
new file mode 100644
index 000000000..c94b5f019
--- /dev/null
+++ b/shared/pom.xml
@@ -0,0 +1,38 @@
+
+
+ 4.0.0
+
+ br.all
+ systematic
+ 1.0-SNAPSHOT
+
+
+ shared
+
+
+ UTF-8
+ official
+ 1.8
+
+
+
+
+ mavenCentral
+ https://repo1.maven.org/maven2/
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-mongodb
+
+
+ org.springframework
+ spring-web
+
+
+
+
\ No newline at end of file
diff --git a/account/src/main/kotlin/br/all/domain/shared/ddd/Entity.kt b/shared/src/main/kotlin/br/all/domain/shared/ddd/Entity.kt
similarity index 99%
rename from account/src/main/kotlin/br/all/domain/shared/ddd/Entity.kt
rename to shared/src/main/kotlin/br/all/domain/shared/ddd/Entity.kt
index 417d8d3f4..f67a9a28e 100644
--- a/account/src/main/kotlin/br/all/domain/shared/ddd/Entity.kt
+++ b/shared/src/main/kotlin/br/all/domain/shared/ddd/Entity.kt
@@ -1,7 +1,6 @@
package br.all.domain.shared.ddd
abstract class Entity (val id: Identifier) {
-
final override fun equals(other: Any?) = when {
this === other -> true
other !is Entity<*> -> false
diff --git a/account/src/main/kotlin/br/all/domain/shared/ddd/Identifier.kt b/shared/src/main/kotlin/br/all/domain/shared/ddd/Identifier.kt
similarity index 100%
rename from account/src/main/kotlin/br/all/domain/shared/ddd/Identifier.kt
rename to shared/src/main/kotlin/br/all/domain/shared/ddd/Identifier.kt
diff --git a/account/src/main/kotlin/br/all/domain/shared/ddd/Notification.kt b/shared/src/main/kotlin/br/all/domain/shared/ddd/Notification.kt
similarity index 98%
rename from account/src/main/kotlin/br/all/domain/shared/ddd/Notification.kt
rename to shared/src/main/kotlin/br/all/domain/shared/ddd/Notification.kt
index 298fb9ac3..33c434bcd 100644
--- a/account/src/main/kotlin/br/all/domain/shared/ddd/Notification.kt
+++ b/shared/src/main/kotlin/br/all/domain/shared/ddd/Notification.kt
@@ -1,13 +1,9 @@
package br.all.domain.shared.ddd
class Notification {
-
private val errors: MutableList = mutableListOf()
fun addError(message: String, cause: Exception? = null) = errors.add(Error(message, cause))
fun hasNoErrors() = errors.isEmpty()
fun message() = errors.joinToString(" | ") { it.message }
data class Error(val message: String, val cause: Exception?)
}
-
-
-
diff --git a/review/src/main/kotlin/br/all/domain/shared/ddd/ValueObject.kt b/shared/src/main/kotlin/br/all/domain/shared/ddd/ValueObject.kt
similarity index 98%
rename from review/src/main/kotlin/br/all/domain/shared/ddd/ValueObject.kt
rename to shared/src/main/kotlin/br/all/domain/shared/ddd/ValueObject.kt
index c22062ab7..0b820a04b 100644
--- a/review/src/main/kotlin/br/all/domain/shared/ddd/ValueObject.kt
+++ b/shared/src/main/kotlin/br/all/domain/shared/ddd/ValueObject.kt
@@ -2,4 +2,4 @@ package br.all.domain.shared.ddd
abstract class ValueObject {
protected abstract fun validate() : Notification
-}
+}
\ No newline at end of file
diff --git a/review/src/main/kotlin/br/all/domain/shared/valueobject/Email.kt b/shared/src/main/kotlin/br/all/domain/shared/user/Email.kt
similarity index 98%
rename from review/src/main/kotlin/br/all/domain/shared/valueobject/Email.kt
rename to shared/src/main/kotlin/br/all/domain/shared/user/Email.kt
index aa332b362..903c10af5 100644
--- a/review/src/main/kotlin/br/all/domain/shared/valueobject/Email.kt
+++ b/shared/src/main/kotlin/br/all/domain/shared/user/Email.kt
@@ -1,4 +1,4 @@
-package br.all.domain.shared.valueobject
+package br.all.domain.shared.user
import br.all.domain.shared.ddd.Notification
import br.all.domain.shared.ddd.ValueObject
diff --git a/review/src/test/kotlin/br/all/domain/shared/ddd/EntityTest.kt b/shared/src/test/kotlin/br/all/domain/shared/ddd/EntityTest.kt
similarity index 58%
rename from review/src/test/kotlin/br/all/domain/shared/ddd/EntityTest.kt
rename to shared/src/test/kotlin/br/all/domain/shared/ddd/EntityTest.kt
index bbf2ae3b7..9f1aff62a 100644
--- a/review/src/test/kotlin/br/all/domain/shared/ddd/EntityTest.kt
+++ b/shared/src/test/kotlin/br/all/domain/shared/ddd/EntityTest.kt
@@ -1,59 +1,61 @@
package br.all.domain.shared.ddd
-import org.junit.jupiter.api.Assertions.*
+import org.junit.jupiter.api.Assertions.assertEquals
+import org.junit.jupiter.api.Assertions.assertFalse
+import org.junit.jupiter.api.Assertions.assertNotEquals
import org.junit.jupiter.api.Tag
-import org.junit.jupiter.api.Tags
import org.junit.jupiter.api.Test
@Tag("UnitTest")
-class EntityTest{
+class EntityTest {
@JvmInline
- private value class EntityId(val value: Long) : Identifier {
- override fun validate() = Notification ()
+ private value class EntityId(val value: Long) : Identifier {
+ override fun validate() = Notification()
override fun value() = value
}
- private class EntityA(id: EntityId) : Entity (id)
- private class EntityB(id: EntityId) : Entity (id)
+ private class EntityA(id: EntityId) : Entity(id)
+ private class EntityB(id: EntityId) : Entity(id)
@Test
- fun `Should two entities of same class and id be equal`(){
+ fun `Should two entities of same class and id be equal`() {
val entityA1 = EntityA(EntityId(10L))
val entityA2 = EntityA(EntityId(10L))
assertEquals(entityA1, entityA2)
}
@Test
- fun `Should two entities of same class and different ids be different`(){
+ fun `Should two entities of same class and different ids be different`() {
val entityA1 = EntityA(EntityId(10L))
val entityA2 = EntityA(EntityId(11L))
assertNotEquals(entityA1, entityA2)
}
@Test
- fun `Should an entity be different from a not entity`(){
+ fun `Should an entity be different from a not entity`() {
data class OtherClass(val id: Long)
- val otherObject = OtherClass(10L);
+
+ val otherObject = OtherClass(10L)
val entityA = EntityA(EntityId(10L))
assertNotEquals(otherObject, entityA)
}
@Test
- fun `Should two entities of different classes and same index be different`(){
+ fun `Should two entities of different classes and same index be different`() {
val entityA = EntityA(EntityId(10L))
val entityB = EntityB(EntityId(10L))
assertNotEquals(entityA, entityB)
}
@Test
- fun `Should entity be different from null`(){
+ fun `Should entity be different from null`() {
val entityA = EntityA(EntityId(10L))
- assertFalse(entityA.equals(null));
+ assertFalse(entityA.equals(null))
}
@Test
- fun `Should two variables of same object be equal`(){
+ fun `Should two variables of same object be equal`() {
val entityA = EntityA(EntityId(10L))
val entityB = entityA
assertEquals(entityA, entityB)
diff --git a/review/src/test/kotlin/br/all/domain/shared/ddd/NotificationTest.kt b/shared/src/test/kotlin/br/all/domain/shared/ddd/NotificationTest.kt
similarity index 100%
rename from review/src/test/kotlin/br/all/domain/shared/ddd/NotificationTest.kt
rename to shared/src/test/kotlin/br/all/domain/shared/ddd/NotificationTest.kt
diff --git a/review/src/test/kotlin/br/all/domain/shared/ddd/EmailTest.kt b/shared/src/test/kotlin/br/all/domain/shared/user/EmailTest.kt
similarity index 98%
rename from review/src/test/kotlin/br/all/domain/shared/ddd/EmailTest.kt
rename to shared/src/test/kotlin/br/all/domain/shared/user/EmailTest.kt
index 55959a529..b94e23685 100644
--- a/review/src/test/kotlin/br/all/domain/shared/ddd/EmailTest.kt
+++ b/shared/src/test/kotlin/br/all/domain/shared/user/EmailTest.kt
@@ -1,10 +1,9 @@
-package br.all.domain.shared.ddd
+package br.all.domain.shared.user
-import br.all.domain.shared.valueobject.Email
import org.junit.jupiter.api.Tag
import org.junit.jupiter.api.Test
-import org.junit.jupiter.api.assertDoesNotThrow
import org.junit.jupiter.api.assertThrows
+import org.junit.jupiter.api.assertDoesNotThrow
import kotlin.test.assertEquals
import kotlin.test.assertNotEquals
import kotlin.test.assertTrue
@@ -146,4 +145,4 @@ class EmailTest {
val exception = assertThrows { Email("user@domain@com") }
exception.message?.contains("Wrong Email format")?.let { assertTrue(it) }
}
-}
+}
\ No newline at end of file
diff --git a/web/src/main/kotlin/br/all/utils/example/RegisterUserExampleService.kt b/web/src/main/kotlin/br/all/utils/example/RegisterUserExampleService.kt
index 13cd68ab6..8c61d6b1c 100644
--- a/web/src/main/kotlin/br/all/utils/example/RegisterUserExampleService.kt
+++ b/web/src/main/kotlin/br/all/utils/example/RegisterUserExampleService.kt
@@ -2,6 +2,7 @@ package br.all.utils.example
import br.all.application.user.repository.UserAccountRepository
import br.all.application.user.repository.toDto
+import br.all.domain.shared.user.Email
import br.all.domain.user.*
import org.springframework.stereotype.Service
import java.util.*