-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MAIN-T-84 Add solr indexing for Documents (#79)
- Loading branch information
1 parent
6196e11
commit cff3cc0
Showing
31 changed files
with
930 additions
and
252 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
name: tests | ||
|
||
on: | ||
# push: | ||
# branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
|
@@ -10,6 +12,21 @@ defaults: | |
|
||
jobs: | ||
|
||
qodana: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
args: --project-dir,server,--baseline,qodana.sarif.json | ||
- name: 'Qodana Scan' | ||
uses: JetBrains/[email protected] | ||
env: | ||
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }} | ||
|
||
unit: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[![tests](https://github.com/hanna-eismant/doky/actions/workflows/gradle.yml/badge.svg)](https://github.com/hanna-eismant/doky/actions/workflows/gradle.yml) | ||
|
||
Swagger documentation url: | ||
|
||
`http://{host}/swagger-ui/index.html` | ||
|
||
API docs as json: | ||
|
||
`http://{host}/api-docs` |
Large diffs are not rendered by default.
Oops, something went wrong.
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
File renamed without changes.
File renamed without changes.
69 changes: 0 additions & 69 deletions
69
server/src/apiTest/resources/META-INF/additional-spring-configuration-metadata.json
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
16 changes: 16 additions & 0 deletions
16
server/src/integrationTest/java/org/hkurh/doky/DokyIntegrationTest.kt
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,16 @@ | ||
package org.hkurh.doky | ||
|
||
import org.junit.jupiter.api.Tag | ||
import org.springframework.boot.test.context.SpringBootTest | ||
import org.springframework.test.context.ActiveProfiles | ||
import org.springframework.test.context.jdbc.Sql | ||
import org.springframework.test.context.jdbc.SqlMergeMode | ||
|
||
@ActiveProfiles("test") | ||
@Tag("integration") | ||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) | ||
@SqlMergeMode(SqlMergeMode.MergeMode.MERGE) | ||
@Sql(scripts = ["classpath:sql/create_base_test_data.sql"], executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD) | ||
@Sql(scripts = ["classpath:sql/cleanup_base_test_data.sql"], executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD) | ||
class DokyIntegrationTest { | ||
} |
34 changes: 34 additions & 0 deletions
34
server/src/integrationTest/java/org/hkurh/doky/SmtpServerExtension.kt
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,34 @@ | ||
package org.hkurh.doky | ||
|
||
import com.icegreen.greenmail.configuration.GreenMailConfiguration | ||
import com.icegreen.greenmail.util.GreenMail | ||
import com.icegreen.greenmail.util.ServerSetup | ||
import org.junit.jupiter.api.extension.AfterAllCallback | ||
import org.junit.jupiter.api.extension.BeforeAllCallback | ||
import org.junit.jupiter.api.extension.BeforeTestExecutionCallback | ||
import org.junit.jupiter.api.extension.ExtensionContext | ||
import org.junit.jupiter.api.extension.TestInstancePostProcessor | ||
|
||
class SmtpServerExtension : BeforeAllCallback, AfterAllCallback, BeforeTestExecutionCallback, | ||
TestInstancePostProcessor { | ||
private val greenMail = GreenMail(ServerSetup(2525, null, ServerSetup.PROTOCOL_SMTP)) | ||
|
||
override fun beforeAll(context: ExtensionContext?) { | ||
greenMail.apply { | ||
withConfiguration(GreenMailConfiguration.aConfig().withDisabledAuthentication()) | ||
start() | ||
} | ||
} | ||
|
||
override fun afterAll(context: ExtensionContext?) { | ||
greenMail.stop() | ||
} | ||
|
||
override fun beforeTestExecution(context: ExtensionContext?) { | ||
greenMail.purgeEmailFromAllMailboxes() | ||
} | ||
|
||
override fun postProcessTestInstance(testInstance: Any?, context: ExtensionContext?) { | ||
testInstance?.javaClass?.getMethod("setSmtpServer", GreenMail::class.java)?.invoke(testInstance, greenMail) | ||
} | ||
} |
6 changes: 0 additions & 6 deletions
6
server/src/integrationTest/java/org/hkurh/doky/SmtpServerRule.kt
This file was deleted.
Oops, something went wrong.
52 changes: 52 additions & 0 deletions
52
server/src/integrationTest/java/org/hkurh/doky/search/DocumentIndexServiceIntegrationTest.kt
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,52 @@ | ||
package org.hkurh.doky.search | ||
|
||
import org.apache.solr.client.solrj.SolrClient | ||
import org.apache.solr.common.params.CommonParams | ||
import org.apache.solr.common.params.ModifiableSolrParams | ||
import org.hkurh.doky.DokyIntegrationTest | ||
import org.junit.jupiter.api.Assertions.assertTrue | ||
import org.junit.jupiter.api.BeforeEach | ||
import org.junit.jupiter.api.DisplayName | ||
import org.junit.jupiter.api.Test | ||
import org.springframework.beans.factory.annotation.Autowired | ||
import org.springframework.beans.factory.annotation.Value | ||
import org.springframework.test.context.jdbc.Sql | ||
|
||
|
||
@DisplayName("DocumentIndexService integration test") | ||
class DocumentIndexServiceIntegrationTest : DokyIntegrationTest() { | ||
|
||
@Value("\${doky.search.solr.core.documents:documents-test}") | ||
lateinit var coreName: String | ||
|
||
@Autowired | ||
lateinit var documentIndexer: DocumentIndexService | ||
|
||
@Autowired | ||
lateinit var solrClient: SolrClient | ||
|
||
@BeforeEach | ||
fun setUp() { | ||
solrClient.deleteByQuery(coreName, "*:*") | ||
} | ||
|
||
@Test | ||
@Sql( | ||
scripts = ["classpath:sql/DocumentIndexServiceIntegrationTest/setup.sql"], | ||
executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD | ||
) | ||
@Sql( | ||
scripts = ["classpath:sql/DocumentIndexServiceIntegrationTest/cleanup.sql"], | ||
executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD | ||
) | ||
@DisplayName("Should add to index all documents") | ||
fun shouldAddToIndexAllDocuments() { | ||
// when | ||
documentIndexer.fullIndex() | ||
|
||
// then | ||
val solrParams = ModifiableSolrParams() | ||
solrParams.add(CommonParams.Q, "*:*") | ||
assertTrue(solrClient.query(coreName, solrParams).results.size == 4) | ||
} | ||
} |
Oops, something went wrong.