diff --git a/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/skill/controller/SkillController.kt b/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/skill/controller/SkillController.kt index 6d68d8f..9582862 100644 --- a/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/skill/controller/SkillController.kt +++ b/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/skill/controller/SkillController.kt @@ -9,6 +9,7 @@ import com.aamdigital.aambackendservice.skill.domain.EscoSkill import com.aamdigital.aambackendservice.skill.domain.SkillUsage import com.aamdigital.aambackendservice.skill.domain.UserProfile import com.aamdigital.aambackendservice.skill.repository.SkillLabUserProfileRepository +import com.fasterxml.jackson.databind.ObjectMapper import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty import org.springframework.http.HttpStatus import org.springframework.http.ResponseEntity @@ -41,6 +42,7 @@ data class FetchUserProfilesDto( class SkillController( private val searchUserProfileUseCase: SearchUserProfileUseCase, private val userProfileRepository: SkillLabUserProfileRepository, + private val objectMapper: ObjectMapper, ) { companion object { @@ -131,7 +133,7 @@ class SkillController( email = entity.email, skills = entity.skills.map { EscoSkill( - usage = SkillUsage.valueOf(it.usage.uppercase()), + usage = objectMapper.convertValue(it.usage.uppercase(), SkillUsage::class.java), escoUri = it.escoUri ) }, diff --git a/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/skill/core/SqlSearchUserProfileUseCase.kt b/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/skill/core/SqlSearchUserProfileUseCase.kt index 7746d88..3c3568f 100644 --- a/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/skill/core/SqlSearchUserProfileUseCase.kt +++ b/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/skill/core/SqlSearchUserProfileUseCase.kt @@ -6,6 +6,7 @@ import com.aamdigital.aambackendservice.skill.domain.SkillUsage import com.aamdigital.aambackendservice.skill.domain.UserProfile import com.aamdigital.aambackendservice.skill.repository.SkillLabUserProfileEntity import com.aamdigital.aambackendservice.skill.repository.SkillLabUserProfileRepository +import com.fasterxml.jackson.databind.ObjectMapper import org.springframework.data.domain.Example import org.springframework.data.domain.ExampleMatcher import org.springframework.data.domain.Page @@ -24,6 +25,7 @@ import org.springframework.data.domain.Pageable */ class SqlSearchUserProfileUseCase( private val userProfileRepository: SkillLabUserProfileRepository, + private val objectMapper: ObjectMapper, ) : SearchUserProfileUseCase() { companion object { @@ -170,7 +172,7 @@ class SqlSearchUserProfileUseCase( phone = it.mobileNumber, skills = it.skills.map { skill -> EscoSkill( - usage = SkillUsage.valueOf(skill.usage.uppercase()), + usage = objectMapper.convertValue(skill.usage.uppercase(), SkillUsage::class.java), escoUri = skill.escoUri ) }, diff --git a/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/skill/di/SkillConfigurationSkillLab.kt b/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/skill/di/SkillConfigurationSkillLab.kt index 06d2661..6293e84 100644 --- a/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/skill/di/SkillConfigurationSkillLab.kt +++ b/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/skill/di/SkillConfigurationSkillLab.kt @@ -73,15 +73,19 @@ class SkillConfigurationSkillLab { fun skillLabSyncUserProfileUseCase( skillLabClient: SkillLabClient, skillLabUserProfileRepository: SkillLabUserProfileRepository, + objectMapper: ObjectMapper, ): SyncUserProfileUseCase = SkillLabSyncUserProfileUseCase( skillLabClient = skillLabClient, skillLabUserProfileRepository = skillLabUserProfileRepository, + objectMapper = objectMapper, ) @Bean fun sqlSearchUserProfileUseCase( skillLabUserProfileRepository: SkillLabUserProfileRepository, + objectMapper: ObjectMapper, ): SearchUserProfileUseCase = SqlSearchUserProfileUseCase( userProfileRepository = skillLabUserProfileRepository, + objectMapper = objectMapper, ) } diff --git a/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/skill/skilllab/SkillLabSyncUserProfileUseCase.kt b/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/skill/skilllab/SkillLabSyncUserProfileUseCase.kt index 985b2ad..2e8f0b5 100644 --- a/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/skill/skilllab/SkillLabSyncUserProfileUseCase.kt +++ b/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/skill/skilllab/SkillLabSyncUserProfileUseCase.kt @@ -11,6 +11,7 @@ import com.aamdigital.aambackendservice.skill.domain.UserProfile import com.aamdigital.aambackendservice.skill.repository.SkillLabUserProfileEntity import com.aamdigital.aambackendservice.skill.repository.SkillLabUserProfileRepository import com.aamdigital.aambackendservice.skill.repository.SkillReferenceEntity +import com.fasterxml.jackson.databind.ObjectMapper enum class SkillLabSyncUserProfileErrorCode : AamErrorCode { IO_ERROR @@ -22,6 +23,7 @@ enum class SkillLabSyncUserProfileErrorCode : AamErrorCode { class SkillLabSyncUserProfileUseCase( private val skillLabClient: SkillLabClient, private val skillLabUserProfileRepository: SkillLabUserProfileRepository, + private val objectMapper: ObjectMapper, ) : SyncUserProfileUseCase() { override fun apply(request: SyncUserProfileRequest): UseCaseOutcome { @@ -59,7 +61,7 @@ class SkillLabSyncUserProfileUseCase( email = userProfileEntity.email, skills = allSkillsEntities.map { skill -> EscoSkill( - usage = SkillUsage.valueOf(skill.usage.uppercase()), + usage = objectMapper.convertValue(skill.usage.uppercase(), SkillUsage::class.java), escoUri = skill.escoUri ) }, diff --git a/application/aam-backend-service/src/test/kotlin/com/aamdigital/aambackendservice/skill/core/SqlSearchUserProfileUseCaseTest.kt b/application/aam-backend-service/src/test/kotlin/com/aamdigital/aambackendservice/skill/core/SqlSearchUserProfileUseCaseTest.kt index f186e05..91550f9 100644 --- a/application/aam-backend-service/src/test/kotlin/com/aamdigital/aambackendservice/skill/core/SqlSearchUserProfileUseCaseTest.kt +++ b/application/aam-backend-service/src/test/kotlin/com/aamdigital/aambackendservice/skill/core/SqlSearchUserProfileUseCaseTest.kt @@ -24,6 +24,7 @@ import org.springframework.data.domain.Example import org.springframework.data.domain.Page import org.springframework.data.domain.PageImpl import org.springframework.data.domain.Pageable +import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder import kotlin.test.assertEquals @ExtendWith(MockitoExtension::class) @@ -36,7 +37,10 @@ class SqlSearchUserProfileUseCaseTest { @BeforeEach fun setup() { reset(userProfileRepository) - service = SqlSearchUserProfileUseCase(userProfileRepository = userProfileRepository) + service = SqlSearchUserProfileUseCase( + userProfileRepository = userProfileRepository, + objectMapper = Jackson2ObjectMapperBuilder().build() + ) } diff --git a/application/aam-backend-service/src/test/kotlin/com/aamdigital/aambackendservice/skill/skilllab/SkillLabSyncUserProfileUseCaseTest.kt b/application/aam-backend-service/src/test/kotlin/com/aamdigital/aambackendservice/skill/skilllab/SkillLabSyncUserProfileUseCaseTest.kt index 26de777..ed73941 100644 --- a/application/aam-backend-service/src/test/kotlin/com/aamdigital/aambackendservice/skill/skilllab/SkillLabSyncUserProfileUseCaseTest.kt +++ b/application/aam-backend-service/src/test/kotlin/com/aamdigital/aambackendservice/skill/skilllab/SkillLabSyncUserProfileUseCaseTest.kt @@ -19,6 +19,7 @@ import org.mockito.kotlin.reset import org.mockito.kotlin.times import org.mockito.kotlin.verify import org.mockito.kotlin.whenever +import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder import java.io.IOException import java.util.* @@ -39,7 +40,9 @@ class SkillLabSyncUserProfileUseCaseTest { skillLabUserProfileRepository, ) service = SkillLabSyncUserProfileUseCase( - skillLabClient = skillLabClient, skillLabUserProfileRepository = skillLabUserProfileRepository + skillLabClient = skillLabClient, + skillLabUserProfileRepository = skillLabUserProfileRepository, + objectMapper = Jackson2ObjectMapperBuilder().build(), ) }