Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
603d361
build: fix kotlin version and update executions tag usage
ericksgmes Jun 3, 2025
33ae882
build: enable actions file
matheusspacifico Jun 3, 2025
97e2c8e
test: use fixed data instead of faker generation
matheusspacifico Jun 3, 2025
3799557
build: git rãbi action
ericksgmes Jun 3, 2025
b2231c9
commit joão txt
ericksgmes Jun 3, 2025
4e05114
build: test gitattributes
ericksgmes Jun 3, 2025
dfe9458
test: remove unused internal keyword from class
matheusspacifico Jun 4, 2025
9257c7c
test: add tags to tests that were missing
matheusspacifico Jun 4, 2025
06800f1
build: update spring-boot-starter-parent version
ericksgmes Jun 13, 2025
10ad125
Merge remote-tracking branch 'origin/fix-pom' into fix-pom
ericksgmes Jun 13, 2025
4873744
chore: add config to ignore tex files
ericksgmes Jun 13, 2025
bc7e6c3
feat: add find criteria by study endpoint
ericksgmes Jun 14, 2025
b868df2
feat: find criteria by study endpoint presenter
ericksgmes Jun 14, 2025
46e0f28
feat: find criteria by study endpoint service
ericksgmes Jun 14, 2025
73b7a68
feat: find criteria by study endpoint impl
ericksgmes Jun 14, 2025
c9c5835
feat: find criteria by study endpoint link factory
ericksgmes Jun 14, 2025
787d7e8
feat: find criteria by study endpoint bean
ericksgmes Jun 14, 2025
b0c7be4
test: find criteria by study endpoint happy path test
ericksgmes Jun 14, 2025
bfdfd07
test: create function to generate criteria
ericksgmes Jun 14, 2025
e6dabd9
test: remove unused imports and make variable private
ericksgmes Jun 14, 2025
9074109
feat: restful implementation of presenter
ericksgmes Jun 14, 2025
da75ba2
refactor: studyReviewId value
ericksgmes Jun 14, 2025
0c8ae63
build: add sonarqube to github actions
matheusspacifico Jun 17, 2025
889a365
chore(jpa): remove explicit Hibernate dialect configuration
ericksgmes Jun 21, 2025
a2b0078
chore(deps): bump springdoc-openapi-starter-webmvc-ui to 2.8.9 and sw…
ericksgmes Jun 21, 2025
21e6960
Merge remote-tracking branch 'origin/fix-pom' into fix-pom
ericksgmes Jun 21, 2025
34be856
chore: delete bogus unused file
ericksgmes Jun 22, 2025
bc13df2
feat: add links to each search source
ericksgmes Jun 22, 2025
e19dcb7
feat: add link to RemoveCriteriaService
ericksgmes Jun 22, 2025
b82d735
feat: create remove criteria presenter
ericksgmes Jun 22, 2025
b7b2b53
feat: create remove criteria request
ericksgmes Jun 22, 2025
267d561
feat: create remove criteria service
ericksgmes Jun 22, 2025
8f39a3e
feat: create remove criteria service impl
ericksgmes Jun 22, 2025
e15aea4
feat: create remove criteria restful presenter
ericksgmes Jun 22, 2025
6f7dd6a
feat: create remove criteria request mapping
ericksgmes Jun 22, 2025
bcad4b2
feat: add remove criteria service config
ericksgmes Jun 22, 2025
59646a3
chore: remove junit dependency - let spring solve it automatically
ericksgmes Jun 23, 2025
de668b9
Merge remote-tracking branch 'origin/main' into fix-pom
matheusspacifico Jun 23, 2025
8c6b440
build: normalise scas kotlin version
matheusspacifico Jun 23, 2025
974506d
chore: change text to be grammatically accurate.
ericksgmes Jun 24, 2025
9bb90fc
Merge remote-tracking branch 'origin/fix-pom' into fix-pom
ericksgmes Jun 24, 2025
a95e755
feat(batchAnswer): add new patch batch request model
matheusspacifico Jun 25, 2025
5e1d297
feat(batchAnswer): add new patch batch service and presenter interfaces
matheusspacifico Jun 25, 2025
492e3b2
feat(batchAnswer): add new patch batch service implementation
matheusspacifico Jun 25, 2025
ab43577
refactor(batchAnswer): add properly exceptions to sad paths
matheusspacifico Jun 25, 2025
29ecba1
fix(batchAnswer): change convert answer wrong passing param
matheusspacifico Jun 25, 2025
2407d84
refactor(batchAnswer): change bloat count variable
matheusspacifico Jun 25, 2025
13fba24
fix(batchAnswer): make service implementation transactional
matheusspacifico Jun 25, 2025
2f35b2c
feat(batchAnswer): add restful batch answer question presenter
matheusspacifico Jun 25, 2025
0fd1b31
feat(batchAnswer): implement two new endpoints for batch answering qu…
matheusspacifico Jun 25, 2025
de1285d
refactor(email): revamp email validation logic
matheusspacifico Jun 26, 2025
878e84f
test(email): modify tests with false premises
matheusspacifico Jun 26, 2025
e6d6915
test(email): remove hardcoded email
matheusspacifico Jun 26, 2025
4f6b43d
test(studyController): add number and label question generations in d…
matheusspacifico Jun 26, 2025
e4ce13e
test(studyController): add new tests for both batch endpoints
matheusspacifico Jun 26, 2025
976408b
test(batchAnswer): WIP add service test setup
matheusspacifico Jun 26, 2025
5b09b43
test(batchAnswer): add request model generation in data factory
matheusspacifico Jun 28, 2025
3a0ad40
test(batchAnswer): add tests for batch answer service impl
matheusspacifico Jun 28, 2025
719da3d
chore: add picoc word to the dictionary
matheusspacifico Jun 30, 2025
c671e08
feat(protocolStage): add protocol stage presenter
matheusspacifico Jun 30, 2025
2fcc5d9
feat(protocolStage): add protocol stage service
matheusspacifico Jun 30, 2025
cb7a7bd
feat(protocolStage): add protocol stage restful presenter
matheusspacifico Jun 30, 2025
93e537a
feat(protocolStage): add protocol stage endpoint to protocol controller
matheusspacifico Jun 30, 2025
df81378
docs(protocolStage): fix swagger response model for protocol stage en…
matheusspacifico Jun 30, 2025
0eb6c20
test(protocolStage): add test setup and first test
matheusspacifico Jul 1, 2025
4eded51
fix(protocolStage): change protocol part iii condition to properly ca…
matheusspacifico Jul 2, 2025
5880f10
test(protocolStage): add all missing happy path tests
matheusspacifico Jul 2, 2025
fe3edb3
fix(protocolStage): change picoc validation
matheusspacifico Jul 2, 2025
a5cf5e2
fix(protocolStage): invert protocol part iii condition check
matheusspacifico Jul 2, 2025
49995d3
fix(protocolStage): separate protocol part iii condition into two dif…
matheusspacifico Jul 2, 2025
10f1a3f
refactor(protocolStage): separate protocol part iii into two differen…
matheusspacifico Jul 2, 2025
b355f68
refactor(protocolStage): change protocol part iii conditional logic
matheusspacifico Jul 3, 2025
2b8e6b6
test(protocolStage): add controller tests for the stage endpoint
matheusspacifico Jul 3, 2025
c1ac097
build: change actions to main branch
matheusspacifico Jul 4, 2025
99b801c
fix: identification bug and add configuration
ericksgmes Jul 4, 2025
355c46a
Merge remote-tracking branch 'origin/fix-pom' into fix-pom
ericksgmes Jul 4, 2025
454ed5f
refactor(protocolStage): extract functions from condition for readabi…
matheusspacifico Jul 4, 2025
a627b95
test(protocolStage): fix broken tests after refactoring
matheusspacifico Jul 4, 2025
eb3cdcb
feat(batchAnswer): add controller configuration for batch endpoint
matheusspacifico Jul 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.tex linguist-detectable=false
*.bib linguist-detectable=false
*.bibtex linguist-detectable=false
File renamed without changes.
36 changes: 36 additions & 0 deletions .github/workflows/sonarqube.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: SonarQube
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
jobs:
build:
name: Build and analyze
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'zulu' # Alternative distribution options are available.
- name: Cache SonarQube packages
uses: actions/cache@v4
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Maven packages
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Build and analyze
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=pet-ads_systematic
7 changes: 7 additions & 0 deletions .idea/dictionaries/project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 2 additions & 16 deletions account/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,7 @@
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
<extensions>true</extensions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
Expand All @@ -72,6 +57,7 @@
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.7.2</version>
</dependency>
</dependencies>
</project>
59 changes: 34 additions & 25 deletions account/src/main/kotlin/br/all/domain/user/Email.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,51 +7,60 @@ data class Email(val value: String) : ValueObject() {

init {
val notification = validate()
require(notification.hasNoErrors()) {notification.message()}
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 (!isValidEmailAddress(email)) return false
if (!hasLengthBelowMaximum(email)) return false
if (hasRepeatedSubdomains(email)) return false
if (email.contains("..")) return false
if (email.contains("@.")) return false
if (email.contains(".@")) return false
return true
}

private fun isValidEmailAddress(email: String): Boolean {
val regex = Regex("^[A-Za-z0-9+_.-]+@[a-z.]+$")
return regex.matches(email)
}
if (email.contains("..") || email.contains(".@") || email.contains("@.")) return false
if (email.startsWith(".") || email.endsWith(".")) return false
if (email.startsWith("@") || email.endsWith("@")) return false

fun hasRepeatedSubdomains(email: String): Boolean {
val parts = email.split("@")
if (parts.size != 2) return false

if (parts.size == 2) {
val subdomains = parts[1].split(".")
val verifyedSubdomains = HashSet<String>()
val localPart = parts[0]
val domainPart = parts[1]

for (subdomain in subdomains){
if (!verifyedSubdomains.add(subdomain)) return true
}
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 false

return localRegex.matches(localPart) && domainRegex.matches(domainPart)
}

fun hasLengthBelowMaximum(email: String): Boolean {
val parts = email.split("@")
return !(parts[0].length > 64 || parts[1].length > 255)
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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class RegisterUserAccountServiceImplTest {
inner class WhenSuccessfullyRegisteringUser {
@Test
fun `should register a new user`() {
val request = factory.registerRequest().copy(email = "user@example.com")
val request = factory.registerRequest()

every { userAccountRepository.existsByEmail(request.email) } returns false
every { userAccountRepository.existsByUsername(request.username) } returns false
Expand All @@ -53,7 +53,7 @@ class RegisterUserAccountServiceImplTest {
inner class WhenFailingToRegisterUser {
@Test
fun `should not register user with existing email`() {
val request = factory.registerRequest().copy(email = "user@example.com")
val request = factory.registerRequest()

every { userAccountRepository.existsByEmail(request.email) } returns true
every { userAccountRepository.existsByUsername(request.username) } returns false
Expand All @@ -68,7 +68,7 @@ class RegisterUserAccountServiceImplTest {

@Test
fun `should not register user with existing username`() {
val request = factory.registerRequest().copy(email = "user@example.com")
val request = factory.registerRequest()

every { userAccountRepository.existsByEmail(request.email) } returns false
every { userAccountRepository.existsByUsername(request.username) } returns true
Expand Down
2 changes: 2 additions & 0 deletions account/src/test/kotlin/br/all/domain/user/UserAccountTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ package br.all.domain.user

import io.github.serpro69.kfaker.Faker
import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.Tag
import java.time.LocalDateTime
import java.util.UUID
import kotlin.test.Test
import kotlin.test.assertFailsWith

@Tag("UnitTest")
class UserAccountTest{

private val faker = Faker()
Expand Down
39 changes: 18 additions & 21 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,17 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.1.2</version>
<version>3.4.4</version>
<relativePath/>
</parent>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<kotlin.code.style>official</kotlin.code.style>
<kotlin.compiler.jvmTarget>1.8</kotlin.compiler.jvmTarget>
<kotlin.version>1.9.0</kotlin.version>
<sonar.organization>pet-ads</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
</properties>

<repositories>
Expand All @@ -47,31 +50,26 @@
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-reflect</artifactId>
<version>${kotlin.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>1.9.0</version>
<version>${kotlin.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test-junit5</artifactId>
<version>1.9.0</version>
<version>${kotlin.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.github.serpro69</groupId>
<artifactId>kotlin-faker</artifactId>
<version>1.15.0</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.tngtech.archunit</groupId>
<artifactId>archunit-junit5</artifactId>
Expand All @@ -81,7 +79,7 @@
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test-junit</artifactId>
<version>1.9.0</version>
<version>${kotlin.version}</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -109,24 +107,20 @@
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>1.9.0</version>
<version>${kotlin.version}</version>
<dependencies>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>1.4.2.Final</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-allopen</artifactId>
<version>2.0.0-RC1</version>
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-noarg</artifactId>
<version>2.0.0-RC1</version>
<version>${kotlin.version}</version>
</dependency>
</dependencies>
<!--
<executions>
<execution>
<id>compile</id>
Expand Down Expand Up @@ -161,13 +155,16 @@
</configuration>
</execution>
</executions>

This was the old executions configuration; it has been removed because, as indicated by the Kotlin docs, from version 1.8.2 onward you can replace all of it with:
<extensions>true</extensions>
This executions block is faulty and is included here only for eventual future reference.
-->
<extensions>true</extensions>
<configuration>
<compilerPlugins>
<plugin>spring</plugin>
<plugin>jpa</plugin>
<compilerPlugins>
<plugin>spring</plugin>
</compilerPlugins>
</compilerPlugins>
</configuration>
</plugin>
Expand Down
5 changes: 2 additions & 3 deletions review/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
<version>3.1.2</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
Expand All @@ -33,11 +32,11 @@
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/io.swagger.core.v3/swagger-annotations-jakarta -->
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-annotations-jakarta</artifactId>
<version>2.2.19</version>
<scope>compile</scope>
<version>2.2.31</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package br.all.application.protocol.find

import br.all.application.shared.presenter.GenericPresenter
import br.all.application.protocol.find.GetProtocolStageService.ResponseModel

interface GetProtocolStagePresenter : GenericPresenter<ResponseModel>
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package br.all.application.protocol.find

import io.swagger.v3.oas.annotations.media.Schema
import java.util.UUID

interface GetProtocolStageService {
fun getStage(presenter: GetProtocolStagePresenter, request: RequestModel)

data class RequestModel(
val userId: UUID,
val systematicStudyId: UUID
)

@Schema(name = "GetProtocolStageServiceResponseModel", description = "Response model for Get Protocol Stage Service")
data class ResponseModel(
val userId: UUID,
val systematicStudyId: UUID,
val currentStage: ProtocolStage
)

enum class ProtocolStage {
PROTOCOL_PART_I,
PICOC,
PROTOCOL_PART_II,
PROTOCOL_PART_III,
IDENTIFICATION,
SELECTION,
EXTRACTION,
GRAPHICS,
FINALIZATION
}
}
Loading
Loading