Commit 094228e2 authored by Paresh Behede's avatar Paresh Behede
Browse files

Merge branch 'superseded-defect-slb' into 'master'

Fixing supersededBy issue for SHARED partition

See merge request !113
parents c534d46c c98887e4
Pipeline #48742 failed with stages
in 82 minutes and 45 seconds
......@@ -102,7 +102,7 @@ public class AzureSchemaInfoStore implements ISchemaInfoStore {
SchemaInfoDoc schemaInfoDoc = cosmosStore.findItem(headers.getPartitionId(), cosmosDBName, schemaInfoContainer, id, partitioningKey, SchemaInfoDoc.class)
.orElseThrow(() -> new NotFoundException(SchemaConstants.SCHEMA_NOT_PRESENT));
return getSchemaInfoObject(schemaInfoDoc.getFlattenedSchemaInfo());
return getSchemaInfoObject(schemaInfoDoc.getFlattenedSchemaInfo(), headers.getPartitionId());
}
/**
......@@ -132,7 +132,7 @@ public class AzureSchemaInfoStore implements ISchemaInfoStore {
}
log.info(SchemaConstants.SCHEMA_INFO_CREATED);
return getSchemaInfoObject(flattenedSchemaInfo);
return getSchemaInfoObject(flattenedSchemaInfo, headers.getPartitionId());
}
/**
......@@ -157,7 +157,7 @@ public class AzureSchemaInfoStore implements ISchemaInfoStore {
}
log.info(SchemaConstants.SCHEMA_INFO_UPDATED);
return getSchemaInfoObject(flattenedSchemaInfo);
return getSchemaInfoObject(flattenedSchemaInfo, headers.getPartitionId());
}
/**
......@@ -268,13 +268,13 @@ public class AzureSchemaInfoStore implements ISchemaInfoStore {
.build();
}
private SchemaInfo getSchemaInfoObject(FlattenedSchemaInfo flattenedSchemaInfo) {
private SchemaInfo getSchemaInfoObject(FlattenedSchemaInfo flattenedSchemaInfo, String dataPartitionId) {
SchemaIdentity superSededBy = null;
if (!flattenedSchemaInfo.getSupersededBy().isEmpty()) {
String id = headers.getPartitionId() + ":" + flattenedSchemaInfo.getSupersededBy();
String id = dataPartitionId + ":" + flattenedSchemaInfo.getSupersededBy();
SchemaIdentity schemaIdentity = schemaKindToSchemaIdentity(flattenedSchemaInfo.getSupersededBy());
String partitionKey = createSchemaInfoPartitionKey(schemaIdentity);
SchemaInfoDoc doc = cosmosStore.findItem(headers.getPartitionId(), cosmosDBName, schemaInfoContainer, id, partitionKey, SchemaInfoDoc.class).get();
SchemaInfoDoc doc = cosmosStore.findItem(dataPartitionId, cosmosDBName, schemaInfoContainer, id, partitionKey, SchemaInfoDoc.class).get();
superSededBy = getSchemaIdentity(doc.getFlattenedSchemaInfo());
}
......@@ -357,7 +357,7 @@ public class AzureSchemaInfoStore implements ISchemaInfoStore {
List<SchemaInfo> schemaList = new LinkedList<>();
for (SchemaInfoDoc info: schemaInfoList)
{
schemaList.add(getSchemaInfoObject(info.getFlattenedSchemaInfo()));
schemaList.add(getSchemaInfoObject(info.getFlattenedSchemaInfo(), tenantId));
}
if (queryParams.getLatestVersion() != null && queryParams.getLatestVersion()) {
......
......@@ -35,6 +35,7 @@ import java.util.Collection;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Optional;
import org.junit.Before;
......@@ -466,6 +467,18 @@ public class AzureSchemaInfoStoreTest {
assertEquals(1,
schemaInfoStore.getSchemaInfoList(QueryParams.builder().limit(100).offset(0).build(), dataPartitionId).size());
}
@Test
public void testGetSchemaInfoList_Withoutqueryparam_FailedWhenSearchedIntoSharedPartition()
throws NotFoundException, ApplicationException, BadRequestException {
List<SchemaInfoDoc> schemaInfoDocsList = new LinkedList<>();
schemaInfoDocsList.add(getMockSchemaInfoDocWithSupersededBy());
doReturn(schemaInfoDocsList).when(cosmosStore).queryItems(eq(dataPartitionId), any(), any(), any(), any(), any());
doThrow(new NoSuchElementException()).when(cosmosStore).findItem(eq("common"), any(), any(), any(), any(), any());
doReturn(Optional.of(getMockSchemaInfoDoc())).when(cosmosStore).findItem(eq(dataPartitionId), any(), any(), any(), any(), any());
schemaInfoStore.getSchemaInfoList(QueryParams.builder().limit(100).offset(0).build(), dataPartitionId);
expectedException.none();
}
@Test
public void testGetSchemaInfoList_withqueryparam()
......@@ -531,6 +544,12 @@ public class AzureSchemaInfoStoreTest {
return new SchemaInfoDoc(id, headers.getPartitionId(), getFlattenedSchemaInfo());
}
private SchemaInfoDoc getMockSchemaInfoDocWithSupersededBy() {
String id = headers.getPartitionId() + ":" + schemaId;
return new SchemaInfoDoc(id, headers.getPartitionId(), getFlattenedSchemaInfo_SupersededBy());
}
private FlattenedSchemaInfo getFlattenedSchemaInfo() {
return FlattenedSchemaInfo.builder()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment