-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
- remove unused
Showing
42 changed files
with
460 additions
and
2,335 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 0 additions & 69 deletions
69
src/main/java/org/folio/search/client/InventoryViewClient.java
This file was deleted.
Oops, something went wrong.
41 changes: 0 additions & 41 deletions
41
.../java/org/folio/search/configuration/kafka/ConsortiumInstanceEventKafkaConfiguration.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 0 additions & 21 deletions
21
src/main/java/org/folio/search/model/event/ConsortiumInstanceEvent.java
This file was deleted.
Oops, something went wrong.
17 changes: 0 additions & 17 deletions
17
src/main/java/org/folio/search/model/event/ContributorResourceEvent.java
This file was deleted.
Oops, something went wrong.
17 changes: 0 additions & 17 deletions
17
src/main/java/org/folio/search/model/event/SubjectResourceEvent.java
This file was deleted.
Oops, something went wrong.
113 changes: 0 additions & 113 deletions
113
src/main/java/org/folio/search/repository/InstanceContributorsRepository.java
This file was deleted.
Oops, something went wrong.
114 changes: 0 additions & 114 deletions
114
src/main/java/org/folio/search/repository/InstanceSubjectRepository.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
src/test/java/org/folio/search/controller/IndexingAuthorityIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package org.folio.search.controller; | ||
|
||
import static org.folio.search.domain.dto.ResourceEventType.DELETE; | ||
import static org.folio.search.model.types.ResourceType.AUTHORITY; | ||
import static org.folio.search.support.base.ApiEndpoints.authoritySearchPath; | ||
import static org.folio.search.utils.TestConstants.TENANT_ID; | ||
import static org.folio.search.utils.TestConstants.inventoryAuthorityTopic; | ||
import static org.folio.search.utils.TestUtils.randomId; | ||
import static org.folio.search.utils.TestUtils.resourceEvent; | ||
import static org.folio.search.utils.TestUtils.toMap; | ||
|
||
import java.util.List; | ||
import org.folio.search.domain.dto.Authority; | ||
import org.folio.search.support.base.BaseIntegrationTest; | ||
import org.folio.spring.testing.type.IntegrationTest; | ||
import org.junit.jupiter.api.AfterAll; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
|
||
@IntegrationTest | ||
class IndexingAuthorityIT extends BaseIntegrationTest { | ||
|
||
@BeforeAll | ||
static void prepare() { | ||
setUpTenant(); | ||
} | ||
|
||
@AfterAll | ||
static void cleanUp() { | ||
removeTenant(); | ||
} | ||
|
||
@Test | ||
void shouldRemoveAuthority() { | ||
var authorityId = randomId(); | ||
var authority = new Authority().id(authorityId).personalName("personal name") | ||
.corporateName("corporate name").uniformTitle("uniform title"); | ||
var resourceEvent = resourceEvent(authorityId, AUTHORITY, toMap(authority)); | ||
kafkaTemplate.send(inventoryAuthorityTopic(TENANT_ID), resourceEvent); | ||
assertCountByIds(authoritySearchPath(), List.of(authorityId), 3); | ||
|
||
var deleteEvent = resourceEvent(authorityId, AUTHORITY, null).type(DELETE).old(toMap(authority)); | ||
kafkaTemplate.send(inventoryAuthorityTopic(TENANT_ID), deleteEvent); | ||
assertCountByIds(authoritySearchPath(), List.of(authorityId), 0); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
src/test/java/org/folio/search/controller/IndexingInstanceContributorIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package org.folio.search.controller; | ||
|
||
import static org.assertj.core.api.AssertionsForClassTypes.entry; | ||
import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat; | ||
import static org.folio.search.model.types.ResourceType.INSTANCE_CONTRIBUTOR; | ||
import static org.folio.search.support.base.ApiEndpoints.instanceSearchPath; | ||
import static org.folio.search.utils.TestConstants.TENANT_ID; | ||
import static org.folio.search.utils.TestUtils.randomId; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
import org.folio.search.domain.dto.Contributor; | ||
import org.folio.search.domain.dto.Instance; | ||
import org.folio.search.support.base.BaseIntegrationTest; | ||
import org.folio.spring.testing.type.IntegrationTest; | ||
import org.junit.jupiter.api.AfterAll; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
|
||
@IntegrationTest | ||
class IndexingInstanceContributorIT extends BaseIntegrationTest { | ||
|
||
@BeforeAll | ||
static void prepare() { | ||
setUpTenant(); | ||
} | ||
|
||
@AfterAll | ||
static void cleanUp() { | ||
removeTenant(); | ||
} | ||
|
||
@Test | ||
void shouldIndexInstanceContributor_createDocument() { | ||
var instanceId1 = randomId(); | ||
var instanceId2 = randomId(); | ||
var authorityId = "ce176ace-a53e-4b4d-aa89-725ed7b2edac"; | ||
var contributorTypeId = "13f6dc91-c2e5-4d18-a6c8-5015974454ef"; | ||
var contributorNameTypeId = "d2775d47-5e1f-4659-99ff-ccbaff84af85"; | ||
var name = "John Tolkien"; | ||
var contributor = new Contributor() | ||
.name(name) | ||
.contributorTypeId(contributorTypeId) | ||
.contributorNameTypeId(contributorNameTypeId) | ||
.authorityId(authorityId); | ||
var instance1 = new Instance().id(instanceId1).addContributorsItem(contributor); | ||
var instance2 = new Instance().id(instanceId2).addContributorsItem(contributor); | ||
inventoryApi.createInstance(TENANT_ID, instance1); | ||
inventoryApi.createInstance(TENANT_ID, instance2); | ||
assertCountByIds(instanceSearchPath(), List.of(instanceId1, instanceId2), 2); | ||
awaitAssertion(() -> assertThat(fetchAllDocuments(INSTANCE_CONTRIBUTOR, TENANT_ID)).hasSize(1)); | ||
|
||
var hits = fetchAllDocuments(INSTANCE_CONTRIBUTOR, TENANT_ID); | ||
var sourceAsMap = hits[0].getSourceAsMap(); | ||
assertThat(sourceAsMap) | ||
.contains( | ||
entry("name", name), | ||
entry("contributorNameTypeId", contributorNameTypeId), | ||
entry("authorityId", authorityId) | ||
); | ||
|
||
@SuppressWarnings("unchecked") | ||
var instances = (List<Map<String, Object>>) sourceAsMap.get("instances"); | ||
assertThat(instances) | ||
.allSatisfy(map -> assertThat(map).containsEntry("shared", false)) | ||
.allSatisfy(map -> assertThat(map).containsEntry("tenantId", TENANT_ID)) | ||
.allSatisfy(map -> assertThat(map).containsEntry("typeId", contributorTypeId)) | ||
.anySatisfy(map -> assertThat(map).containsEntry("instanceId", instanceId1)) | ||
.anySatisfy(map -> assertThat(map).containsEntry("instanceId", instanceId2)); | ||
} | ||
|
||
@Test | ||
void shouldIndexInstanceContributor_deleteDocument() { | ||
var instanceId = randomId(); | ||
var contributor = new Contributor().name("Frodo Begins").authorityId(null); | ||
var instance = new Instance().id(instanceId).addContributorsItem(contributor); | ||
inventoryApi.createInstance(TENANT_ID, instance); | ||
assertCountByIds(instanceSearchPath(), List.of(instanceId), 1); | ||
awaitAssertion(() -> assertThat(fetchAllDocuments(INSTANCE_CONTRIBUTOR, TENANT_ID)).hasSize(1)); | ||
inventoryApi.updateInstance(TENANT_ID, instance.contributors(null)); | ||
awaitAssertion(() -> assertThat(fetchAllDocuments(INSTANCE_CONTRIBUTOR, TENANT_ID)).isEmpty()); | ||
} | ||
} |
114 changes: 114 additions & 0 deletions
114
src/test/java/org/folio/search/controller/IndexingInstanceIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
package org.folio.search.controller; | ||
|
||
import static org.folio.search.support.base.ApiEndpoints.instanceSearchPath; | ||
import static org.folio.search.utils.TestConstants.TENANT_ID; | ||
import static org.folio.search.utils.TestUtils.randomId; | ||
|
||
import java.util.List; | ||
import java.util.stream.IntStream; | ||
import org.folio.search.domain.dto.Holding; | ||
import org.folio.search.domain.dto.Instance; | ||
import org.folio.search.domain.dto.Item; | ||
import org.folio.search.support.base.BaseIntegrationTest; | ||
import org.folio.spring.testing.type.IntegrationTest; | ||
import org.junit.jupiter.api.AfterAll; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
|
||
@IntegrationTest | ||
class IndexingInstanceIT extends BaseIntegrationTest { | ||
|
||
private static final List<String> INSTANCE_IDS = getRandomIds(3); | ||
private static final List<String> ITEM_IDS = getRandomIds(2); | ||
private static final List<String> HOLDING_IDS = getRandomIds(4); | ||
|
||
@BeforeAll | ||
static void prepare() { | ||
setUpTenant(); | ||
} | ||
|
||
@AfterAll | ||
static void cleanUp() { | ||
removeTenant(); | ||
} | ||
|
||
@Test | ||
void shouldRemoveItem() { | ||
createInstances(); | ||
var itemIdToDelete = ITEM_IDS.get(1); | ||
inventoryApi.deleteItem(TENANT_ID, itemIdToDelete); | ||
assertCountByQuery(instanceSearchPath(), "items.id=={value}", itemIdToDelete, 0); | ||
assertCountByQuery(instanceSearchPath(), "items.id=={value}", ITEM_IDS.get(0), 1); | ||
} | ||
|
||
@Test | ||
void shouldUpdateAndDeleteInstance() { | ||
var instanceId = randomId(); | ||
var instance = new Instance().id(instanceId).title("test-resource"); | ||
|
||
inventoryApi.createInstance(TENANT_ID, instance); | ||
assertCountByQuery(instanceSearchPath(), "title=={value}", "test-resource", 1); | ||
|
||
var instanceToUpdate = new Instance().id(instanceId).title("test-resource-updated"); | ||
inventoryApi.updateInstance(TENANT_ID, instanceToUpdate); | ||
assertCountByQuery(instanceSearchPath(), "title=={value}", "test-resource-updated", 1); | ||
|
||
inventoryApi.deleteInstance(TENANT_ID, instanceId); | ||
assertCountByQuery(instanceSearchPath(), "id=={value}", instanceId, 0); | ||
} | ||
|
||
@Test | ||
void shouldRemoveHolding() { | ||
createInstances(); | ||
inventoryApi.deleteHolding(TENANT_ID, HOLDING_IDS.get(0)); | ||
assertCountByIds(instanceSearchPath(), List.of(HOLDING_IDS.get(0)), 0); | ||
HOLDING_IDS.subList(1, 4).forEach(id -> assertCountByIds(instanceSearchPath(), List.of(id), 1)); | ||
} | ||
|
||
@Test | ||
void shouldRemoveInstance() { | ||
createInstances(); | ||
var instanceIdToDelete = INSTANCE_IDS.get(0); | ||
|
||
assertCountByIds(instanceSearchPath(), INSTANCE_IDS, INSTANCE_IDS.size()); | ||
|
||
inventoryApi.deleteInstance(TENANT_ID, instanceIdToDelete); | ||
assertCountByIds(instanceSearchPath(), List.of(instanceIdToDelete), 0); | ||
List<String> ids = INSTANCE_IDS.subList(1, 3); | ||
assertCountByIds(instanceSearchPath(), ids, 2); | ||
} | ||
|
||
private static Item item(int i) { | ||
return new Item().id(ITEM_IDS.get(i)).holdingsRecordId(HOLDING_IDS.get(i)); | ||
} | ||
|
||
private static Holding holdingsRecord(int i) { | ||
return new Holding().id(HOLDING_IDS.get(i)); | ||
} | ||
|
||
private static List<String> getRandomIds(int count) { | ||
return IntStream.range(0, count).mapToObj(index -> randomId()).toList(); | ||
} | ||
|
||
private void createInstances() { | ||
var instances = INSTANCE_IDS.stream() | ||
.map(id -> new Instance().id(id).title("title-" + id)) | ||
.toList(); | ||
|
||
instances.get(0) | ||
.holdings(List.of(holdingsRecord(0), holdingsRecord(1))) | ||
.items(List.of(item(0), item(1))); | ||
|
||
instances.get(1).holdings(List.of(holdingsRecord(2), holdingsRecord(3))); | ||
|
||
instances.forEach(instance -> inventoryApi.createInstance(TENANT_ID, instance)); | ||
assertCountByIds(instanceSearchPath(), INSTANCE_IDS, 3); | ||
for (String itemId : ITEM_IDS) { | ||
assertCountByQuery(instanceSearchPath(), "items.id=={value}", itemId, 1); | ||
} | ||
for (String holdingId : HOLDING_IDS) { | ||
assertCountByQuery(instanceSearchPath(), "holdings.id=={value}", holdingId, 1); | ||
} | ||
} | ||
|
||
} |
75 changes: 75 additions & 0 deletions
75
src/test/java/org/folio/search/controller/IndexingInstanceSubjectIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package org.folio.search.controller; | ||
|
||
import static org.assertj.core.api.AssertionsForClassTypes.entry; | ||
import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat; | ||
import static org.folio.search.model.types.ResourceType.INSTANCE_SUBJECT; | ||
import static org.folio.search.support.base.ApiEndpoints.instanceSearchPath; | ||
import static org.folio.search.utils.TestConstants.TENANT_ID; | ||
import static org.folio.search.utils.TestUtils.randomId; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
import org.folio.search.domain.dto.Instance; | ||
import org.folio.search.domain.dto.Subject; | ||
import org.folio.search.support.base.BaseIntegrationTest; | ||
import org.folio.spring.testing.type.IntegrationTest; | ||
import org.junit.jupiter.api.AfterAll; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
|
||
@IntegrationTest | ||
class IndexingInstanceSubjectIT extends BaseIntegrationTest { | ||
|
||
@BeforeAll | ||
static void prepare() { | ||
setUpTenant(); | ||
} | ||
|
||
@AfterAll | ||
static void cleanUp() { | ||
removeTenant(); | ||
} | ||
|
||
@Test | ||
void shouldIndexInstanceSubject_createDocument() { | ||
var instanceId1 = randomId(); | ||
var instanceId2 = randomId(); | ||
var authorityId = "ce176ace-a53e-4b4d-aa89-725ed7b2edac"; | ||
var value = "Fantasy"; | ||
var subject = new Subject().value(value).authorityId(authorityId); | ||
var instance1 = new Instance().id(instanceId1).addSubjectsItem(subject); | ||
var instance2 = new Instance().id(instanceId2).addSubjectsItem(subject); | ||
inventoryApi.createInstance(TENANT_ID, instance1); | ||
inventoryApi.createInstance(TENANT_ID, instance2); | ||
assertCountByIds(instanceSearchPath(), List.of(instanceId1, instanceId2), 2); | ||
awaitAssertion(() -> assertThat(fetchAllDocuments(INSTANCE_SUBJECT, TENANT_ID)).hasSize(1)); | ||
|
||
var hits = fetchAllDocuments(INSTANCE_SUBJECT, TENANT_ID); | ||
var sourceAsMap = hits[0].getSourceAsMap(); | ||
assertThat(sourceAsMap) | ||
.contains( | ||
entry("value", value), | ||
entry("authorityId", authorityId) | ||
); | ||
|
||
@SuppressWarnings("unchecked") | ||
var instances = (List<Map<String, Object>>) sourceAsMap.get("instances"); | ||
assertThat(instances) | ||
.allSatisfy(map -> assertThat(map).containsEntry("shared", false)) | ||
.allSatisfy(map -> assertThat(map).containsEntry("tenantId", TENANT_ID)) | ||
.anySatisfy(map -> assertThat(map).containsEntry("instanceId", instanceId1)) | ||
.anySatisfy(map -> assertThat(map).containsEntry("instanceId", instanceId2)); | ||
} | ||
|
||
@Test | ||
void shouldIndexInstanceSubject_deleteDocument() { | ||
var instanceId = randomId(); | ||
var subject = new Subject().value("Sci-Fi").authorityId(null); | ||
var instance = new Instance().id(instanceId).addSubjectsItem(subject); | ||
inventoryApi.createInstance(TENANT_ID, instance); | ||
assertCountByIds(instanceSearchPath(), List.of(instanceId), 1); | ||
awaitAssertion(() -> assertThat(fetchAllDocuments(INSTANCE_SUBJECT, TENANT_ID)).hasSize(1)); | ||
inventoryApi.updateInstance(TENANT_ID, instance.subjects(null)); | ||
awaitAssertion(() -> assertThat(fetchAllDocuments(INSTANCE_SUBJECT, TENANT_ID)).isEmpty()); | ||
} | ||
} |
241 changes: 0 additions & 241 deletions
241
src/test/java/org/folio/search/controller/RecordsIndexingIT.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
175 changes: 0 additions & 175 deletions
175
src/test/java/org/folio/search/repository/InstanceContributorsRepositoryTest.java
This file was deleted.
Oops, something went wrong.
207 changes: 0 additions & 207 deletions
207
src/test/java/org/folio/search/repository/InstanceSubjectRepositoryTest.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.