Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Open Subsurface Data Universe Software
Platform
System
Schema
Commits
094228e2
Commit
094228e2
authored
Jun 25, 2021
by
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
Changes
2
Pipelines
6
Hide whitespace changes
Inline
Side-by-side
provider/schema-azure/src/main/java/org/opengroup/osdu/schema/azure/impl/schemainfostore/AzureSchemaInfoStore.java
View file @
094228e2
...
...
@@ -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
.
get
PartitionId
()
+
":"
+
flattenedSchemaInfo
.
getSupersededBy
();
String
id
=
data
PartitionId
+
":"
+
flattenedSchemaInfo
.
getSupersededBy
();
SchemaIdentity
schemaIdentity
=
schemaKindToSchemaIdentity
(
flattenedSchemaInfo
.
getSupersededBy
());
String
partitionKey
=
createSchemaInfoPartitionKey
(
schemaIdentity
);
SchemaInfoDoc
doc
=
cosmosStore
.
findItem
(
headers
.
get
PartitionId
()
,
cosmosDBName
,
schemaInfoContainer
,
id
,
partitionKey
,
SchemaInfoDoc
.
class
).
get
();
SchemaInfoDoc
doc
=
cosmosStore
.
findItem
(
data
PartitionId
,
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
())
{
...
...
provider/schema-azure/src/test/java/org/opengroup/osdu/schema/provider/azure/impl/schemainfostore/AzureSchemaInfoStoreTest.java
View file @
094228e2
...
...
@@ -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
()
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment