-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix missing enum, refactor test to follow correct naming
- Loading branch information
1 parent
e91cbe9
commit 1adf236
Showing
11 changed files
with
1,861 additions
and
16 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 |
---|---|---|
|
@@ -6,5 +6,5 @@ | |
public enum GeoNetworkField { | ||
creation, | ||
revision, | ||
; | ||
publication, | ||
} |
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
58 changes: 58 additions & 0 deletions
58
indexer/src/test/java/au/org/aodn/esindexer/service/IndexerServiceTest.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,58 @@ | ||
package au.org.aodn.esindexer.service; | ||
|
||
import co.elastic.clients.elasticsearch._types.ErrorCause; | ||
import co.elastic.clients.elasticsearch.core.BulkResponse; | ||
import co.elastic.clients.elasticsearch.core.bulk.BulkResponseItem; | ||
import co.elastic.clients.elasticsearch.core.bulk.OperationType; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.http.HttpStatus; | ||
|
||
/** | ||
* Unit test that do not require other dependent software running goes here | ||
*/ | ||
@Slf4j | ||
public class IndexerServiceTest { | ||
/** | ||
* Verify this function, it should only return error if items contains status no CREATED or OK | ||
*/ | ||
@Test | ||
public void verifyReduceResponse() { | ||
BulkResponse bulkResponse = BulkResponse.of(b -> | ||
b.items( | ||
BulkResponseItem.of(i -> i | ||
.status(HttpStatus.CREATED.value()) | ||
.operationType(OperationType.Create) | ||
.index("A") | ||
), | ||
BulkResponseItem.of(i -> i | ||
.status(HttpStatus.OK.value()) | ||
.operationType(OperationType.Update) | ||
.index("A") | ||
)) | ||
.errors(false).took(1) | ||
); | ||
|
||
bulkResponse = IndexerServiceImpl.reduceResponse(bulkResponse); | ||
Assertions.assertFalse(bulkResponse.errors(), "Should not contain error"); | ||
|
||
bulkResponse = BulkResponse.of(b -> | ||
b.items( | ||
BulkResponseItem.of(i -> i | ||
.status(HttpStatus.CREATED.value()) | ||
.operationType(OperationType.Create) | ||
.index("B") | ||
), | ||
BulkResponseItem.of(i -> i | ||
.status(HttpStatus.NOT_EXTENDED.value()) | ||
.operationType(OperationType.Index) | ||
.index("B") | ||
)) | ||
.errors(false).took(1) | ||
); | ||
|
||
bulkResponse = IndexerServiceImpl.reduceResponse(bulkResponse); | ||
Assertions.assertTrue(bulkResponse.errors(), "Should contain error"); | ||
} | ||
} |
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
Oops, something went wrong.