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
Data Flow
Data Enrichment
wks
Commits
2ac124f3
Commit
2ac124f3
authored
Mar 02, 2021
by
ethiraj krishnamanaidu
Browse files
Merge branch 'mapping-info-fix-datatype' into 'master'
Fix mapping info datatype See merge request
!39
parents
a56a8e23
3557f585
Pipeline
#30701
failed with stages
in 33 minutes and 16 seconds
Changes
18
Pipelines
4
Hide whitespace changes
Inline
Side-by-side
deployments/mapping_info_records/opendes/1a3c1f16-25c7-44cf-9fbd-7d9cbc90805a.json
View file @
2ac124f3
{
"id"
:
"1a3c1f16-25c7-44cf-9fbd-7d9cbc90805a"
,
"version"
:
"
1606039291
"
,
"version"
:
1606039291
,
"authority"
:
"opendes"
,
"kind"
:
"opendes:mapping:mapping:1.0.0"
,
"mappingSchemaMajorVersion"
:
"1"
,
"mappingSchemaMinorVersion"
:
"0"
,
"mappingSchemaPatchVersion"
:
"0"
,
"mappingSchemaMajorVersion"
:
1
,
"mappingSchemaMinorVersion"
:
0
,
"mappingSchemaPatchVersion"
:
0
,
"sourceSchemaAuthority"
:
"opendes"
,
"sourceSchemaSource"
:
"oga"
,
"sourceEntityType"
:
"well"
,
"sourceSchemaMajorVersion"
:
"1"
,
"sourceSchemaMajorVersion"
:
1
,
"sourceSchemaKind"
:
"opendes:oga:well:1"
,
"targetSchemaAuthority"
:
"slb"
,
"targetSchemaSource"
:
"wks"
,
"targetEntityType"
:
"well"
,
"targetSchemaMajorVersion"
:
"4"
,
"targetSchemaMajorVersion"
:
4
,
"targetSchemaKind"
:
"slb:wks:well:4"
,
"createdBy"
:
"automation"
,
"fileName"
:
"1a3c1f16-25c7-44cf-9fbd-7d9cbc90805a.json"
,
...
...
deployments/mapping_info_records/opendes/4b312ef2-447d-4898-9d54-2a401975bd0b.json
View file @
2ac124f3
{
"id"
:
"4b312ef2-447d-4898-9d54-2a401975bd0b"
,
"version"
:
"
1606039291
"
,
"version"
:
1606039291
,
"authority"
:
"opendes"
,
"kind"
:
"opendes:mapping:mapping:1.0.0"
,
"mappingSchemaMajorVersion"
:
"1"
,
"mappingSchemaMinorVersion"
:
"0"
,
"mappingSchemaPatchVersion"
:
"0"
,
"mappingSchemaMajorVersion"
:
1
,
"mappingSchemaMinorVersion"
:
0
,
"mappingSchemaPatchVersion"
:
0
,
"sourceSchemaAuthority"
:
"opendes"
,
"sourceSchemaSource"
:
"ihs"
,
"sourceEntityType"
:
"log"
,
"sourceSchemaMajorVersion"
:
"1"
,
"sourceSchemaMajorVersion"
:
1
,
"sourceSchemaKind"
:
"opendes:ihs:log:1"
,
"targetSchemaAuthority"
:
"slb"
,
"targetSchemaSource"
:
"wks"
,
"targetEntityType"
:
"log"
,
"targetSchemaMajorVersion"
:
"2"
,
"targetSchemaMajorVersion"
:
2
,
"targetSchemaKind"
:
"slb:wks:log:2"
,
"createdBy"
:
"automation"
,
"fileName"
:
"4b312ef2-447d-4898-9d54-2a401975bd0b.json"
,
...
...
deployments/mapping_info_records/opendes/aa0ee7f6-2c0b-474a-962c-3e837a3b7de3.json
View file @
2ac124f3
{
"id"
:
"aa0ee7f6-2c0b-474a-962c-3e837a3b7de3"
,
"version"
:
"
1606039291
"
,
"version"
:
1606039291
,
"authority"
:
"opendes"
,
"kind"
:
"opendes:mapping:mapping:1.0.0"
,
"mappingSchemaMajorVersion"
:
"1"
,
"mappingSchemaMinorVersion"
:
"0"
,
"mappingSchemaPatchVersion"
:
"0"
,
"mappingSchemaMajorVersion"
:
1
,
"mappingSchemaMinorVersion"
:
0
,
"mappingSchemaPatchVersion"
:
0
,
"sourceSchemaAuthority"
:
"opendes"
,
"sourceSchemaSource"
:
"oga"
,
"sourceEntityType"
:
"well"
,
"sourceSchemaMajorVersion"
:
"1"
,
"sourceSchemaMajorVersion"
:
1
,
"sourceSchemaKind"
:
"opendes:oga:well:1"
,
"targetSchemaAuthority"
:
"abc"
,
"targetSchemaSource"
:
"wks"
,
"targetEntityType"
:
"well"
,
"targetSchemaMajorVersion"
:
"1"
,
"targetSchemaMajorVersion"
:
1
,
"targetSchemaKind"
:
"abc:wks:well:1"
,
"createdBy"
:
"automation"
,
"fileName"
:
"aa0ee7f6-2c0b-474a-962c-3e837a3b7de3.json"
,
...
...
deployments/mapping_info_records/opendes/d61a36bc-7b7b-4e7c-8a9c-33e7315bc076.json
View file @
2ac124f3
{
"id"
:
"d61a36bc-7b7b-4e7c-8a9c-33e7315bc076"
,
"version"
:
"
1606039291
"
,
"version"
:
1606039291
,
"authority"
:
"opendes"
,
"kind"
:
"opendes:mapping:mapping:1.0.0"
,
"mappingSchemaMinorVersion"
:
"0"
,
"mappingSchemaPatchVersion"
:
"0"
,
"mappingSchemaMajorVersion"
:
1
,
"mappingSchemaMinorVersion"
:
0
,
"mappingSchemaPatchVersion"
:
0
,
"sourceSchemaAuthority"
:
"opendes"
,
"sourceSchemaSource"
:
"ihs"
,
"sourceEntityType"
:
"log"
,
"sourceSchemaMajorVersion"
:
"1"
,
"sourceSchemaMajorVersion"
:
1
,
"sourceSchemaKind"
:
"opendes:ihs:log:1"
,
"targetSchemaAuthority"
:
"abc"
,
"targetSchemaSource"
:
"wks"
,
"targetEntityType"
:
"log"
,
"targetSchemaMajorVersion"
:
"3"
,
"targetSchemaMajorVersion"
:
3
,
"targetSchemaKind"
:
"abc:wks:log:3"
,
"createdBy"
:
"automation"
,
"fileName"
:
"d61a36bc-7b7b-4e7c-8a9c-33e7315bc076.json"
,
...
...
deployments/mapping_info_records/opendes/dda587cd-770b-4104-bae3-3f834c3a8aec.json
View file @
2ac124f3
{
"id"
:
"dda587cd-770b-4104-bae3-3f834c3a8aec"
,
"version"
:
"
1606039291
"
,
"version"
:
1606039291
,
"authority"
:
"opendes"
,
"kind"
:
"opendes:mapping:mapping:1.0.0"
,
"mappingSchemaMajorVersion"
:
"1"
,
"mappingSchemaMinorVersion"
:
"0"
,
"mappingSchemaPatchVersion"
:
"0"
,
"mappingSchemaMajorVersion"
:
1
,
"mappingSchemaMinorVersion"
:
0
,
"mappingSchemaPatchVersion"
:
0
,
"sourceSchemaAuthority"
:
"opendes"
,
"sourceSchemaSource"
:
"oga"
,
"sourceEntityType"
:
"well"
,
"sourceSchemaMajorVersion"
:
"1"
,
"sourceSchemaMajorVersion"
:
1
,
"sourceSchemaKind"
:
"opendes:oga:well:1"
,
"targetSchemaAuthority"
:
"slb"
,
"targetSchemaSource"
:
"wks"
,
"targetEntityType"
:
"well"
,
"targetSchemaMajorVersion"
:
"5"
,
"targetSchemaMajorVersion"
:
5
,
"targetSchemaKind"
:
"slb:wks:well:5"
,
"createdBy"
:
"automation"
,
"fileName"
:
"dda587cd-770b-4104-bae3-3f834c3a8aec.json"
,
...
...
deployments/mapping_info_records/opendes/e2678b5f-5917-4bb1-8b30-2006efcb720d.json
View file @
2ac124f3
{
"id"
:
"e2678b5f-5917-4bb1-8b30-2006efcb720d"
,
"version"
:
"
1606039291
"
,
"version"
:
1606039291
,
"authority"
:
"opendes"
,
"kind"
:
"opendes:mapping:mapping:1.0.0"
,
"mappingSchemaMajorVersion"
:
"1"
,
"mappingSchemaMinorVersion"
:
"0"
,
"mappingSchemaPatchVersion"
:
"0"
,
"mappingSchemaMajorVersion"
:
1
,
"mappingSchemaMinorVersion"
:
0
,
"mappingSchemaPatchVersion"
:
0
,
"sourceSchemaAuthority"
:
"opendes"
,
"sourceSchemaSource"
:
"at"
,
"sourceEntityType"
:
"wellbore"
,
"sourceSchemaMajorVersion"
:
"1"
,
"sourceSchemaMajorVersion"
:
1
,
"sourceSchemaKind"
:
"opendes:at:wellbore:1"
,
"targetSchemaAuthority"
:
"slb"
,
"targetSchemaSource"
:
"wks"
,
"targetEntityType"
:
"wellbore"
,
"targetSchemaMajorVersion"
:
"1"
,
"targetSchemaMajorVersion"
:
1
,
"targetSchemaKind"
:
"slb:wks:wellbore:1"
,
"createdBy"
:
"automation"
,
"fileName"
:
"e2678b5f-5917-4bb1-8b30-2006efcb720d.json"
,
...
...
provider/wks-azure/src/main/java/org/opengroup/osdu/wks/provider/azure/storage/MappingStoreImpl.java
View file @
2ac124f3
...
...
@@ -42,8 +42,8 @@ public class MappingStoreImpl implements MappingStore {
private
RequestIdentity
requestIdentity
;
@Override
public
List
<
MappingInfo
>
getMappingInfo
(
final
String
authority
,
final
String
entity
,
final
String
source
,
final
Str
in
g
majorVersion
)
{
String
schemaKind
=
String
.
join
(
Constants
.
COLON_SEPARATOR
,
authority
,
source
,
entity
,
majorVersion
);
public
List
<
MappingInfo
>
getMappingInfo
(
final
String
authority
,
final
String
entity
,
final
String
source
,
final
in
t
majorVersion
)
{
String
schemaKind
=
String
.
join
(
Constants
.
COLON_SEPARATOR
,
authority
,
source
,
entity
,
Integer
.
toString
(
majorVersion
)
)
;
SqlQuerySpec
query
=
new
SqlQuerySpec
(
"SELECT * FROM c where c.sourceSchemaAuthority = @authority AND c.sourceEntityType = @entity AND "
...
...
provider/wks-azure/src/test/java/org/opengroup/osdu/wks/provider/azure/storage/MappingStoreImplTest.java
View file @
2ac124f3
...
...
@@ -44,7 +44,7 @@ public class MappingStoreImplTest {
private
static
final
String
AUTHORITY_NAME
=
"opendes"
;
private
static
final
String
SOURCE
=
"wks"
;
private
static
final
String
ENTITY_TYPE
=
"wellbore"
;
private
static
final
Str
in
g
MAJOR_VERSION
=
"1"
;
private
static
final
in
t
MAJOR_VERSION
=
1
;
private
static
final
String
WKS_SCHEMA_KIND
=
"opendes:wks:wellbore:1"
;
@InjectMocks
...
...
provider/wks-gcp/src/main/java/org/opengroup/osdu/wks/storage/MappingStoreImpl.java
View file @
2ac124f3
...
...
@@ -41,7 +41,7 @@ public class MappingStoreImpl implements MappingStore {
*/
@Override
public
List
<
MappingInfo
>
getMappingInfo
(
String
authorityName
,
String
entityNamePrefix
,
String
sourceName
,
Str
in
g
majorVersion
)
{
public
List
<
MappingInfo
>
getMappingInfo
(
String
authorityName
,
String
entityNamePrefix
,
String
sourceName
,
in
t
majorVersion
)
{
return
new
ArrayList
<>();
}
...
...
wks-core/src/main/java/org/opengroup/osdu/wks/model/mapping/MappingInfo.java
View file @
2ac124f3
package
org.opengroup.osdu.wks.model.mapping
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
lombok.*
;
import
org.opengroup.osdu.wks.enums.MappingScope
;
import
java.sql.Timestamp
;
@Getter
@Setter
@AllArgsConstructor
...
...
@@ -15,16 +10,16 @@ import java.sql.Timestamp;
@Builder
public
class
MappingInfo
{
private
String
id
;
private
Stri
ng
version
;
private
lo
ng
version
;
private
String
authority
;
private
String
sourceSchemaAuthority
;
private
String
sourceSchemaSource
;
private
String
sourceEntityType
;
private
Str
in
g
sourceSchemaMajorVersion
;
private
in
t
sourceSchemaMajorVersion
;
private
String
sourceSchemaKind
;
private
String
targetSchemaAuthority
;
private
String
targetSchemaSource
;
private
Str
in
g
targetSchemaMajorVersion
;
private
in
t
targetSchemaMajorVersion
;
private
String
targetEntityType
;
private
String
targetSchemaKind
;
private
String
fileName
;
...
...
wks-core/src/main/java/org/opengroup/osdu/wks/provider/interfaces/MappingStore.java
View file @
2ac124f3
...
...
@@ -6,6 +6,6 @@ import org.opengroup.osdu.wks.model.mapping.MappingDefinition;
import
org.opengroup.osdu.wks.model.mapping.MappingInfo
;
public
interface
MappingStore
{
List
<
MappingInfo
>
getMappingInfo
(
String
authorityName
,
String
entityNamePrefix
,
String
sourceName
,
Str
in
g
majorVersion
);
List
<
MappingInfo
>
getMappingInfo
(
String
authorityName
,
String
entityNamePrefix
,
String
sourceName
,
in
t
majorVersion
);
MappingDefinition
getMappingDefinitionFromStorage
(
MappingInfo
mappingsInfo
);
}
wks-core/src/main/java/org/opengroup/osdu/wks/service/MappingService.java
View file @
2ac124f3
...
...
@@ -9,6 +9,6 @@ import org.opengroup.osdu.wks.model.mapping.MappingInfo;
public
interface
MappingService
{
List
<
MappingDefinition
>
getMapping
(
String
kind
)
throws
ApplicationException
;
List
<
MappingInfo
>
getMappingInfos
(
String
authority
,
String
entity
,
String
source
,
Str
in
g
majorVersion
);
List
<
MappingInfo
>
getMappingInfos
(
String
authority
,
String
entity
,
String
source
,
in
t
majorVersion
);
}
wks-core/src/main/java/org/opengroup/osdu/wks/service/MappingServiceImpl.java
View file @
2ac124f3
...
...
@@ -25,7 +25,7 @@ public class MappingServiceImpl implements MappingService {
String
authorityName
=
kindUtil
.
retrieveAuthorityName
(
kind
);
String
entityNamePrefix
=
kindUtil
.
retrieveEntityName
(
kind
);
String
sourceName
=
kindUtil
.
retrieveSourceName
(
kind
);
Str
in
g
majorVersion
=
kindUtil
.
retrieveMajorVersion
(
kind
);
in
t
majorVersion
=
kindUtil
.
retrieveMajorVersion
(
kind
);
List
<
MappingInfo
>
mappingInfos
=
mappingStore
.
getMappingInfo
(
authorityName
,
entityNamePrefix
,
sourceName
,
majorVersion
);
if
(
mappingInfos
.
isEmpty
())
{
return
Collections
.
emptyList
();
...
...
@@ -34,7 +34,7 @@ public class MappingServiceImpl implements MappingService {
}
@Override
public
List
<
MappingInfo
>
getMappingInfos
(
final
String
authority
,
final
String
entity
,
final
String
source
,
final
Str
in
g
majorVersion
)
{
public
List
<
MappingInfo
>
getMappingInfos
(
final
String
authority
,
final
String
entity
,
final
String
source
,
final
in
t
majorVersion
)
{
return
mappingStore
.
getMappingInfo
(
authority
,
entity
,
source
,
majorVersion
);
}
...
...
wks-core/src/main/java/org/opengroup/osdu/wks/util/KindUtil.java
View file @
2ac124f3
...
...
@@ -9,15 +9,6 @@ import java.util.stream.Stream;
@Component
public
class
KindUtil
{
public
Integer
getMajorVersionFromKind
(
String
kind
)
{
String
version
=
Stream
.
of
(
kind
.
split
(
Constants
.
COLON_SEPARATOR
)).
reduce
(
(
first
,
last
)
->
last
).
get
();
return
Integer
.
parseInt
(
version
.
split
(
"\\."
)[
0
]);
}
public
String
getVersionFromKind
(
String
kind
)
{
return
Stream
.
of
(
kind
.
split
(
Constants
.
COLON_SEPARATOR
)).
reduce
(
(
first
,
last
)
->
last
).
get
();
}
public
String
prepareKind
(
String
authority
,
String
source
,
String
entity
,
String
majorVersion
,
String
minorVersion
,
String
patchVersion
)
{
...
...
@@ -41,9 +32,9 @@ public class KindUtil {
return
idArr
[
SchemaConstants
.
SOURCE_INDEX
];
}
public
Str
in
g
retrieveMajorVersion
(
String
kind
)
{
public
in
t
retrieveMajorVersion
(
String
kind
)
{
String
[]
idArr
=
kind
.
split
(
Constants
.
COLON_SEPARATOR
);
String
version
=
idArr
[
SchemaConstants
.
VERSION_INDEX
];
return
version
.
split
(
"\\."
)[
0
];
return
Integer
.
parseInt
(
version
.
split
(
"\\."
)[
0
]
)
;
}
}
wks-core/src/main/java/org/opengroup/osdu/wks/util/RelationshipBlockHandler.java
View file @
2ac124f3
...
...
@@ -280,7 +280,7 @@ public class RelationshipBlockHandler {
private
List
<
WksInfo
>
getWKSRecordsCreatedByWKSService
(
String
rawId
,
List
<
WksInfo
>
wksInfos
,
Kind
rawKind
)
{
List
<
WksInfo
>
result
=
new
ArrayList
<>();
Str
in
g
majorVersion
=
rawKind
.
getVersion
().
split
(
"\\."
)[
0
]
;
in
t
majorVersion
=
kindUtil
.
retrieveMajorVersion
(
rawKind
.
getKindAsString
())
;
// TODO Look out for performance improvement through caching (FYI: Once mapping service comes
// online the entire logic of datastore look up will become obsolete)
List
<
MappingInfo
>
mappingInfos
=
mappingService
.
getMappingInfos
(
rawKind
.
getAuthority
(),
...
...
@@ -305,7 +305,7 @@ public class RelationshipBlockHandler {
return
result
;
}
private
String
generateKind
(
String
authority
,
String
source
,
String
entity
,
Str
in
g
majorVersion
)
{
private
String
generateKind
(
String
authority
,
String
source
,
String
entity
,
in
t
majorVersion
)
{
String
not
=
"0"
;
return
authority
+
Constants
.
COLON_SEPARATOR
+
source
+
Constants
.
COLON_SEPARATOR
+
entity
+
Constants
.
COLON_SEPARATOR
+
majorVersion
+
Constants
.
POINT
+
not
+
Constants
.
POINT
+
not
;
...
...
wks-core/src/main/java/org/opengroup/osdu/wks/util/WksIdGenerator.java
View file @
2ac124f3
...
...
@@ -19,7 +19,7 @@ public class WksIdGenerator {
.
toString
();
String
[]
idStrArr
=
rawId
.
split
(
Constants
.
COLON_SEPARATOR
);
Str
in
g
majorVersion
=
new
KindUtil
().
g
etMajorVersion
FromKind
(
targetSchemaKind
)
.
toString
()
;
in
t
majorVersion
=
new
KindUtil
().
r
et
rieve
MajorVersion
(
targetSchemaKind
);
String
targetSchemaKindInMapping
=
targetSchemaKind
.
substring
(
0
,
targetSchemaKind
.
lastIndexOf
(
Constants
.
COLON_SEPARATOR
))
+
Constants
.
COLON_SEPARATOR
+
majorVersion
;
//Replacing semicolons here with dots since Record Id should be of the format a:b:c
...
...
wks-core/src/test/java/org/opengroup/osdu/wks/service/MappingServiceImplTest.java
View file @
2ac124f3
...
...
@@ -35,9 +35,9 @@ public class MappingServiceImplTest {
when
(
kindUtil
.
retrieveAuthorityName
(
KIND
)).
thenReturn
(
"tenant1"
);
when
(
kindUtil
.
retrieveSourceName
(
KIND
)).
thenReturn
(
"source"
);
when
(
kindUtil
.
retrieveEntityName
(
KIND
)).
thenReturn
(
"entity"
);
when
(
kindUtil
.
retrieveMajorVersion
(
KIND
)).
thenReturn
(
"1"
);
when
(
kindUtil
.
retrieveMajorVersion
(
KIND
)).
thenReturn
(
1
);
MappingInfo
mappingInfo
=
new
MappingInfo
();
when
(
mappingStore
.
getMappingInfo
(
"tenant1"
,
"source"
,
"entity"
,
"1"
)).
thenReturn
(
Collections
.
singletonList
(
mappingInfo
));
when
(
mappingStore
.
getMappingInfo
(
"tenant1"
,
"source"
,
"entity"
,
1
)).
thenReturn
(
Collections
.
singletonList
(
mappingInfo
));
List
<
MappingDefinition
>
mappings
=
mappingService
.
getMapping
(
KIND
);
assertNotNull
(
mappings
);
}
...
...
wks-core/src/test/java/org/opengroup/osdu/wks/util/RelationshipBlockHandlerTest.java
View file @
2ac124f3
...
...
@@ -13,6 +13,7 @@ import java.util.List;
import
java.util.Map
;
import
java.util.Optional
;
import
org.junit.jupiter.api.BeforeEach
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.extension.ExtendWith
;
import
org.junit.runner.RunWith
;
...
...
@@ -48,7 +49,7 @@ class RelationshipBlockHandlerTest {
private
static
final
String
AUTHORITY
=
"part1"
;
private
static
final
String
SOURCE
=
"wks"
;
private
static
final
String
ENTITY
=
"wellbore"
;
private
static
final
Str
in
g
MAJOR_VERSION
=
"1"
;
private
static
final
in
t
MAJOR_VERSION
=
1
;
@Mock
private
StorageService
storageService
;
...
...
@@ -59,15 +60,16 @@ class RelationshipBlockHandlerTest {
@Mock
private
MappingService
mappingService
;
@Mock
private
KindUtil
kindUtil
;
@Mock
private
TargetSchemaUtil
targetSchemaUtil
;
@InjectMocks
private
RelationshipBlockHandler
relationshipBlockHandler
;
@BeforeEach
void
setUp
()
{
relationshipBlockHandler
=
new
RelationshipBlockHandler
(
storageService
,
searchService
,
mappingService
,
new
KindUtil
(),
targetSchemaUtil
);
}
@Test
public
void
testRelationshipForOneToOneRelationshipWhenWKSFound
()
throws
IOException
,
ApplicationException
,
NotFoundException
{
...
...
@@ -93,6 +95,9 @@ class RelationshipBlockHandlerTest {
assertTrue
(
response
.
getPendingEnitites
().
size
()
==
0
);
}
/*
When no WKS is found for related WKS, than WKS id is cooked for related raw record if mapping exist and added to relationship block
*/
@Test
public
void
testRelationshipForOneToManyRelationshipWhenNoRelatedWksIdFound
()
throws
IOException
,
ApplicationException
{
Tree
rawRecordWithRelationship
=
findJsonTree
(
"raw_record_valid_relationship_block_oneToMany.json"
);
...
...
@@ -115,7 +120,9 @@ class RelationshipBlockHandlerTest {
assertNotNull
(
response
);
assertNotNull
(
response
.
getRelationshipTree
());
assertTrue
(
response
.
getPendingEnitites
().
size
()
!=
0
);
assertEquals
(
"part1:wellbore:wks-5512187e645eda7f7b3b02ebbd0a5cbbe68770fb.part1.wks.wellbore.1"
,
response
.
getRelationshipTree
().
get
(
"wellbores.ids"
).
get
(
0
).
asString
());
assertEquals
(
"part1:wellbore:wks-e62beaebded27e04ea5b5c0c1c5b7345d75e6e01.part1.wks.wellbore.1"
,
response
.
getRelationshipTree
().
get
(
"wellbores.ids"
).
get
(
1
).
asString
());
assertEquals
(
0
,
response
.
getPendingEnitites
().
size
());
}
@SneakyThrows
...
...
@@ -133,10 +140,9 @@ class RelationshipBlockHandlerTest {
mappingInfoList
.
add
(
mappingInfo
);
when
(
kindUtil
.
retrieveAuthorityName
(
TARGET_SCHEMA_KIND
)).
thenReturn
(
AUTHORITY
);
when
(
storageService
.
getRecord
(
any
(
String
.
class
))).
thenReturn
(
Optional
.
of
(
wksRecordStr
));
when
(
searchService
.
query
(
any
(
String
.
class
))).
thenReturn
(
searchResults
);
when
(
mappingService
.
getMappingInfos
(
any
(),
any
(),
any
(),
any
(
))).
thenReturn
(
mappingInfoList
);
when
(
mappingService
.
getMappingInfos
(
eq
(
AUTHORITY
),
eq
(
ENTITY
),
eq
(
SOURCE
),
eq
(
MAJOR_VERSION
))).
thenReturn
(
mappingInfoList
);
UpdatedRelationshipBlock
response
=
relationshipBlockHandler
.
updateRelationshipBlockWithWksIds
(
rawRelationshipsBlockTree
,
TARGET_SCHEMA_KIND
);
...
...
@@ -160,10 +166,9 @@ class RelationshipBlockHandlerTest {
mappingInfoList
.
add
(
mappingInfo
);
when
(
kindUtil
.
retrieveAuthorityName
(
TARGET_SCHEMA_KIND
)).
thenReturn
(
AUTHORITY
);
when
(
storageService
.
getRecord
(
any
(
String
.
class
))).
thenReturn
(
Optional
.
of
(
wksRecordStr
));
when
(
searchService
.
query
(
any
(
String
.
class
))).
thenReturn
(
searchResults
);
when
(
mappingService
.
getMappingInfos
(
any
(),
any
(),
any
(),
any
(
))).
thenReturn
(
mappingInfoList
);
when
(
mappingService
.
getMappingInfos
(
eq
(
AUTHORITY
),
eq
(
ENTITY
),
eq
(
SOURCE
),
eq
(
MAJOR_VERSION
))).
thenReturn
(
mappingInfoList
);
UpdatedRelationshipBlock
response
=
relationshipBlockHandler
.
updateRelationshipBlockWithWksIds
(
rawRelationshipsBlockTree
,
TARGET_SCHEMA_KIND
);
...
...
@@ -171,7 +176,10 @@ class RelationshipBlockHandlerTest {
assertNotNull
(
response
.
getRelationshipTree
());
assertTrue
(
response
.
getPendingEnitites
().
size
()
==
0
);
}
/*
When no WKS is found for related WKS, than WKS id is cooked for related raw record if mapping exist and added to relationship block
*/
@Test
public
void
testRelationshipForOneToOneRelationshipWhenNoWKSRecordCreatedByService
()
throws
IOException
,
ApplicationException
{
Tree
rawRecordWithRelationship
=
findJsonTree
(
"raw_record_valid_relationship_block_oneToOne.json"
);
...
...
@@ -194,7 +202,9 @@ class RelationshipBlockHandlerTest {
assertNotNull
(
response
);
assertNotNull
(
response
.
getRelationshipTree
());
assertTrue
(
response
.
getPendingEnitites
().
size
()
!=
0
);
//Assert Cooked up wks id
assertEquals
(
"part1:wellbore:wks-5512187e645eda7f7b3b02ebbd0a5cbbe68770fb.part1.wks.wellbore.1"
,
response
.
getRelationshipTree
().
get
(
"wellbore.id"
).
asString
());
assertEquals
(
0
,
response
.
getPendingEnitites
().
size
());
}
@Test
...
...
@@ -221,7 +231,7 @@ class RelationshipBlockHandlerTest {
String
searchResults
=
findJsonTree
(
"search_results_multiple_wks_generated_within_same_universe.json"
).
toString
();
List
<
MappingInfo
>
mappingInfoList
=
new
ArrayList
<>();
MappingInfo
mappingInfo1
=
getMappingInfoObject
(
AUTHORITY
,
SOURCE
,
ENTITY
,
MAJOR_VERSION
);
MappingInfo
mappingInfo2
=
getMappingInfoObject
(
AUTHORITY
,
SOURCE
,
ENTITY
,
"3"
);
MappingInfo
mappingInfo2
=
getMappingInfoObject
(
AUTHORITY
,
SOURCE
,
ENTITY
,
3
);
mappingInfoList
.
add
(
mappingInfo1
);
mappingInfoList
.
add
(
mappingInfo2
);
...
...
@@ -250,8 +260,8 @@ class RelationshipBlockHandlerTest {
String
wksRecordStr
=
findJsonTree
(
"wks_record.json"
).
toString
();
String
searchResults
=
findJsonTree
(
"search_results_multiple_wks_generated_within_different_universe.json"
).
toString
();
List
<
MappingInfo
>
mappingInfoList
=
new
ArrayList
<>();
MappingInfo
mappingInfo1
=
getMappingInfoObject
(
"differentUniverse"
,
SOURCE
,
ENTITY
,
"5"
);
MappingInfo
mappingInfo2
=
getMappingInfoObject
(
AUTHORITY
,
SOURCE
,
ENTITY
,
"7"
);
MappingInfo
mappingInfo1
=
getMappingInfoObject
(
"differentUniverse"
,
SOURCE
,
ENTITY
,
5
);
MappingInfo
mappingInfo2
=
getMappingInfoObject
(
AUTHORITY
,
SOURCE
,
ENTITY
,
7
);
mappingInfoList
.
add
(
mappingInfo1
);
mappingInfoList
.
add
(
mappingInfo2
);
...
...
@@ -272,7 +282,7 @@ class RelationshipBlockHandlerTest {
assertTrue
(
response
.
getPendingEnitites
().
size
()
==
0
);
}
private
MappingInfo
getMappingInfoObject
(
String
authority
,
String
source
,
String
entity
,
Str
in
g
majorVersion
)
{
private
MappingInfo
getMappingInfoObject
(
String
authority
,
String
source
,
String
entity
,
in
t
majorVersion
)
{
MappingInfo
mappingInfo
=
new
MappingInfo
();
mappingInfo
.
setTargetSchemaAuthority
(
authority
);
mappingInfo
.
setTargetEntityType
(
entity
);
...
...
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