Skip to content
Snippets Groups Projects
Commit 207a6343 authored by Rustam Lotsmanenko (EPAM)'s avatar Rustam Lotsmanenko (EPAM)
Browse files

Merge branch 'fix-get-batch-for-dangling-records' into 'master'

Fix batch failure in Fetch Records API when versions are missing

See merge request !1009
parents 331fa62d e2f12c1e
No related branches found
No related tags found
1 merge request!1009Fix batch failure in Fetch Records API when versions are missing
Pipeline #314957 failed
......@@ -87,7 +87,7 @@ The following software have components provided under the terms of this license:
- Apache HttpCore (from http://hc.apache.org/httpcomponents-core-ga, http://hc.apache.org/httpcomponents-core-ga/, http://hc.apache.org/httpcomponents-core/)
- Apache Log4j API (from https://repo1.maven.org/maven2/org/apache/logging/log4j/log4j-api)
- Apache Log4j Core (from https://repo1.maven.org/maven2/org/apache/logging/log4j/log4j-core)
- Apache Log4j JUL Handler (from https://logging.apache.org/log4j/3.x/)
- Apache Log4j JUL Handler (from https://logging.apache.org/log4j/3.x/, https://repo1.maven.org/maven2/org/apache/logging/log4j/log4j-jul)
- Apache Log4j SLF4J 2.0 Binding (from https://repo1.maven.org/maven2/org/apache/logging/log4j/log4j-slf4j2-impl)
- Apache Log4j SLF4J Binding (from https://repo1.maven.org/maven2/org/apache/logging/log4j/log4j-slf4j-impl)
- Apache Log4j to SLF4J Adapter (from https://repo1.maven.org/maven2/org/apache/logging/log4j/log4j-to-slf4j)
......
......@@ -187,7 +187,7 @@ public abstract class BatchServiceImpl implements BatchService {
for (String recordId : recordIds) {
RecordMetadata recordMetadata = recordsMetadata.get(CollaborationContextUtil.composeIdWithNamespace(recordId, collaborationContext));
if (recordMetadata == null || !recordMetadata.getStatus().equals(RecordState.active)) {
if (recordMetadata == null || !recordMetadata.getStatus().equals(RecordState.active) || recordMetadata.getLatestVersion() == null) {
recordsNotFound.add(recordId);
continue;
}
......
......@@ -269,6 +269,30 @@ class BatchServiceImplTest {
assertTrue(multiRecordInfo.getRetryRecords().isEmpty());
}
@Test
void fetchMultipleRecords_returnsNotFoundRecords_whenRecordsWithoutVersionPaths() {
List<String> recordIds = Arrays.asList(TEST_ID_1, TEST_ID_2);
Map<String, RecordMetadata> recordMetadataMap = new HashMap<>();
RecordMetadata recordMetadataTestId1 = buildRecordMetadata(TEST_ID_1);
RecordMetadata recordMetadataTestId2 = buildRecordMetadata(TEST_ID_2);
recordMetadataTestId1.setGcsVersionPaths(new ArrayList<>());
recordMetadataTestId2.setGcsVersionPaths(new ArrayList<>());
recordMetadataMap.put(TEST_ID_1, recordMetadataTestId1);
recordMetadataMap.put(TEST_ID_2, recordMetadataTestId2);
MultiRecordRequest multiRecordRequest = new MultiRecordRequest();
multiRecordRequest.setRecords(recordIds);
when(recordRepository.get(recordIds, Optional.empty())).thenReturn(recordMetadataMap);
MultiRecordIds multiRecordIds = new MultiRecordIds();
multiRecordIds.setRecords(recordIds);
MultiRecordResponse multiRecordResponse = sut.fetchMultipleRecords(multiRecordRequest, Optional.empty());
assertTrue(multiRecordResponse.getRecords().isEmpty());
assertEquals(2, multiRecordResponse.getNotFound().size());
}
private static RecordMetadata buildRecordMetadata(String recordId) {
Acl acl = new Acl();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment