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
efa8ecbf
Commit
efa8ecbf
authored
Sep 02, 2020
by
Aman Verma
Committed by
Kishore Battula
Sep 02, 2020
Browse files
consuming new methods defined in BlobStore class
parent
9398f526
Changes
3
Hide whitespace changes
Inline
Side-by-side
provider/wks-azure/pom.xml
View file @
efa8ecbf
...
...
@@ -56,7 +56,7 @@
<dependency>
<groupId>
org.opengroup.osdu
</groupId>
<artifactId>
core-lib-azure
</artifactId>
<version>
0.0.
19
</version>
<version>
0.0.
23
</version>
</dependency>
<dependency>
<groupId>
org.projectlombok
</groupId>
...
...
provider/wks-azure/src/main/java/org/opengroup/osdu/wks/provider/azure/storage/MappingStoreImpl.java
View file @
efa8ecbf
...
...
@@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import
org.opengroup.osdu.azure.blobstorage.BlobStore
;
import
org.opengroup.osdu.core.common.model.http.DpsHeaders
;
import
org.opengroup.osdu.wks.model.MappingsModel
;
import
org.opengroup.osdu.wks.provider.azure.di.AzureBootstrapConfig
;
import
org.opengroup.osdu.wks.provider.interfaces.MappingStore
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -19,12 +20,18 @@ public class MappingStoreImpl implements MappingStore {
@Autowired
private
BlobStore
blobStore
;
@Autowired
private
AzureBootstrapConfig
config
;
@Override
public
MappingsModel
getMapping
(
final
String
fileName
)
{
MappingsModel
mappings
=
null
;
try
{
String
content
=
blobStore
.
readFromBlob
(
DpsHeaders
.
DATA_PARTITION_ID
,
fileName
+
JSON_EXTENSION
);
String
content
=
blobStore
.
readFromStorageContainer
(
DpsHeaders
.
DATA_PARTITION_ID
,
fileName
+
JSON_EXTENSION
,
config
.
containerName
());
ObjectMapper
mapper
=
new
ObjectMapper
();
mappings
=
mapper
.
readValue
(
content
,
MappingsModel
.
class
);
}
catch
(
Exception
e
)
{
...
...
provider/wks-azure/src/test/java/org/opengroup/osdu/wks/provider/azure/storage/MappingStoreImplTest.java
View file @
efa8ecbf
...
...
@@ -2,6 +2,7 @@ package org.opengroup.osdu.wks.provider.azure.storage;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
org.junit.jupiter.api.BeforeEach
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.extension.ExtendWith
;
import
org.mockito.InjectMocks
;
...
...
@@ -15,7 +16,10 @@ import org.opengroup.osdu.wks.provider.azure.di.AzureBootstrapConfig;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertEquals
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertNull
;
import
static
org
.
mockito
.
ArgumentMatchers
.
any
;
import
static
org
.
mockito
.
ArgumentMatchers
.
eq
;
import
static
org
.
mockito
.
Mockito
.
when
;
import
static
org
.
mockito
.
MockitoAnnotations
.
initMocks
;
@ExtendWith
(
MockitoExtension
.
class
)
public
class
MappingStoreImplTest
{
...
...
@@ -25,6 +29,7 @@ public class MappingStoreImplTest {
private
static
final
String
wksSchemaKind
=
"opendes;wks:wellbore:1.0.0"
;
private
static
final
String
rawAttribute
=
"well_id"
;
private
static
final
String
wksAttribute
=
"wks_id"
;
private
static
final
String
containerName
=
"opendes"
;
@InjectMocks
private
MappingStoreImpl
mappingStore
;
...
...
@@ -35,6 +40,12 @@ public class MappingStoreImplTest {
@Mock
private
AzureBootstrapConfig
azureBootstrapConfig
;
@BeforeEach
public
void
init
()
{
initMocks
(
this
);
when
(
azureBootstrapConfig
.
containerName
()).
thenReturn
(
containerName
);
}
@Test
public
void
shouldSuccessfullyReturnMappings
()
throws
JsonProcessingException
{
MappingsModel
mappingsModel
=
new
MappingsModel
();
...
...
@@ -46,8 +57,7 @@ public class MappingStoreImplTest {
ObjectMapper
mapper
=
new
ObjectMapper
();
String
content
=
mapper
.
writeValueAsString
(
mappingsModel
);
when
(
blobStore
.
readFromBlob
(
DpsHeaders
.
DATA_PARTITION_ID
,
fileName
+
JSON_EXTENSION
)).
thenReturn
(
content
);
when
(
blobStore
.
readFromStorageContainer
(
DpsHeaders
.
DATA_PARTITION_ID
,
fileName
+
JSON_EXTENSION
,
containerName
)).
thenReturn
(
content
);
MappingsModel
resultMappings
=
mappingStore
.
getMapping
(
fileName
);
assertEquals
(
mappingsModel
.
toString
(),
resultMappings
.
toString
());
...
...
@@ -56,7 +66,7 @@ public class MappingStoreImplTest {
@Test
public
void
shouldReturnNullWhenMappingIsInvalid
()
{
String
content
=
"{\n"
+
" \"name\": \"invalid_json\"\n"
+
"}"
;
when
(
blobStore
.
readFrom
Blob
(
DpsHeaders
.
DATA_PARTITION_ID
,
fileName
+
JSON_EXTENSION
)).
thenReturn
(
content
);
when
(
blobStore
.
readFrom
StorageContainer
(
DpsHeaders
.
DATA_PARTITION_ID
,
fileName
+
JSON_EXTENSION
,
containerName
)).
thenReturn
(
content
);
MappingsModel
mappings
=
mappingStore
.
getMapping
(
fileName
);
assertNull
(
mappings
);
...
...
Write
Preview
Markdown
is supported
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