Skip to content

Commit

Permalink
feat: entity handler test
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasBousselin committed Jan 8, 2025
1 parent 8b5fbf0 commit e6fdb2c
Show file tree
Hide file tree
Showing 6 changed files with 729 additions and 665 deletions.
1 change: 1 addition & 0 deletions search-service/config/detekt/baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<ID>ClassNaming:V0_29_JsonLd_migrationTests.kt$V0_29_JsonLd_migrationTests</ID>
<ID>ClassNaming:V0_29__JsonLd_migration.kt$V0_29__JsonLd_migration : BaseJavaMigration</ID>
<ID>ComplexCondition:EntitiesQueryUtils.kt$geoQuery == null &amp;&amp; q.isNullOrEmpty() &amp;&amp; typeSelection.isNullOrEmpty() &amp;&amp; attrs.isEmpty()</ID>
<ID>ComplexCondition:EntityQueryService.kt$EntityQueryService$it &amp;&amp; !inverse || !it &amp;&amp; inverse</ID>
<ID>Filename:V0_29__JsonLd_migration.kt$db.migration.V0_29__JsonLd_migration.kt</ID>
<ID>LongMethod:AttributeInstanceService.kt$AttributeInstanceService$@Transactional suspend fun create(attributeInstance: AttributeInstance): Either&lt;APIException, Unit&gt;</ID>
<ID>LongMethod:EnabledAuthorizationServiceTests.kt$EnabledAuthorizationServiceTests$@Test fun `it should return serialized access control entities with other rigths if user is owner`()</ID>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.egm.stellio.search.entity.sources
package com.egm.stellio.search.entity.compaction

import arrow.core.Either
import arrow.core.left
Expand Down Expand Up @@ -27,16 +27,13 @@ import org.springframework.stereotype.Service
import org.springframework.util.MultiValueMap
import java.net.URI

// todo find better package name and file name
@Service
class EntitySourceService(
class EntityCompactionService(
private val entityQueryService: EntityQueryService,
private val contextSourceRegistrationService: ContextSourceRegistrationService,
private val linkedEntityService: LinkedEntityService
) : BaseHandler() {
// todo could also return Pair<Either<APIException, EntitiesWithCount>, List<NGSILDWarning>>
// + more consistent with getEntity and let combined ApiException with warnings (no case for now)
// - can't use .bind() easilly

suspend fun getEntitiesFromSources(
sub: Sub?,
contexts: List<String>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import arrow.core.left
import arrow.core.raise.either
import arrow.core.right
import com.egm.stellio.search.csr.model.addWarnings
import com.egm.stellio.search.entity.compaction.EntityCompactionService
import com.egm.stellio.search.entity.service.EntityService
import com.egm.stellio.search.entity.sources.EntitySourceService
import com.egm.stellio.search.entity.util.composeEntitiesQueryFromGet
import com.egm.stellio.search.entity.util.validateMinimalQueryEntitiesParameters
import com.egm.stellio.shared.config.ApplicationProperties
Expand Down Expand Up @@ -63,7 +63,7 @@ import java.net.URI
class EntityHandler(
private val applicationProperties: ApplicationProperties,
private val entityService: EntityService,
private val entitySourceService: EntitySourceService
private val entityCompactionService: EntityCompactionService
) : BaseHandler() {

/**
Expand Down Expand Up @@ -199,7 +199,7 @@ class EntityHandler(
).bind()
.validateMinimalQueryEntitiesParameters().bind()

val (entities, count, warnings) = entitySourceService.getEntitiesFromSources(
val (entities, count, warnings) = entityCompactionService.getEntitiesFromSources(
sub = sub.getOrNull(),
contexts = contexts,
entitiesQuery = entitiesQuery,
Expand Down Expand Up @@ -248,7 +248,7 @@ class EntityHandler(
contexts
).bind()

val (entityOrException, warnings) = entitySourceService.getEntityFromSources(
val (entityOrException, warnings) = entityCompactionService.getEntityFromSources(
sub = sub.getOrNull(),
contexts = contexts,
entitiesQuery = entitiesQuery,
Expand Down
Loading

0 comments on commit e6fdb2c

Please sign in to comment.