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
Lib
cloud
azure
OS Core Lib Azure
Commits
87aed2f4
Commit
87aed2f4
authored
Mar 03, 2021
by
Rostislav Vatolin [SLB]
☕
Browse files
update PartitionServiceEventGridClient
parent
2fde7344
Pipeline
#29892
passed with stages
in 9 minutes and 54 seconds
Changes
2
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/opengroup/osdu/azure/partition/PartitionServiceEventGridClient.java
View file @
87aed2f4
...
@@ -193,8 +193,9 @@ public class PartitionServiceEventGridClient {
...
@@ -193,8 +193,9 @@ public class PartitionServiceEventGridClient {
* @return PartitionServiceClient
* @return PartitionServiceClient
*/
*/
private
IPartitionProvider
getServiceClient
()
{
private
IPartitionProvider
getServiceClient
()
{
this
.
headers
.
put
(
DpsHeaders
.
AUTHORIZATION
,
"Bearer "
+
this
.
tokenService
.
getAuthorizationToken
());
DpsHeaders
newHeaders
=
DpsHeaders
.
createFromMap
(
headers
.
getHeaders
());
return
this
.
partitionFactory
.
create
(
headers
);
newHeaders
.
put
(
DpsHeaders
.
AUTHORIZATION
,
"Bearer "
+
tokenService
.
getAuthorizationToken
());
return
partitionFactory
.
create
(
newHeaders
);
}
}
}
}
src/test/java/org/opengroup/osdu/azure/partition/PartitionServiceEventGridClientTest.java
View file @
87aed2f4
...
@@ -25,6 +25,7 @@ import org.opengroup.osdu.azure.util.AzureServicePrincipleTokenService;
...
@@ -25,6 +25,7 @@ import org.opengroup.osdu.azure.util.AzureServicePrincipleTokenService;
import
org.opengroup.osdu.core.common.model.http.AppException
;
import
org.opengroup.osdu.core.common.model.http.AppException
;
import
org.opengroup.osdu.core.common.model.http.DpsHeaders
;
import
org.opengroup.osdu.core.common.model.http.DpsHeaders
;
import
org.opengroup.osdu.core.common.partition.IPartitionFactory
;
import
org.opengroup.osdu.core.common.partition.IPartitionFactory
;
import
org.opengroup.osdu.core.common.partition.IPartitionProvider
;
import
org.opengroup.osdu.core.common.partition.PartitionException
;
import
org.opengroup.osdu.core.common.partition.PartitionException
;
import
org.opengroup.osdu.core.common.partition.PartitionInfo
;
import
org.opengroup.osdu.core.common.partition.PartitionInfo
;
import
org.opengroup.osdu.core.common.partition.Property
;
import
org.opengroup.osdu.core.common.partition.Property
;
...
@@ -32,9 +33,16 @@ import org.opengroup.osdu.core.common.partition.Property;
...
@@ -32,9 +33,16 @@ import org.opengroup.osdu.core.common.partition.Property;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.*;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertEquals
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertThrows
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertTrue
;
import
static
org
.
mockito
.
ArgumentMatchers
.
any
;
import
static
org
.
mockito
.
ArgumentMatchers
.
anyString
;
import
static
org
.
mockito
.
ArgumentMatchers
.
anyString
;
import
static
org
.
mockito
.
Mockito
.
doReturn
;
import
static
org
.
mockito
.
Mockito
.
doReturn
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
never
;
import
static
org
.
mockito
.
Mockito
.
verify
;
import
static
org
.
mockito
.
Mockito
.
when
;
@ExtendWith
(
MockitoExtension
.
class
)
@ExtendWith
(
MockitoExtension
.
class
)
public
class
PartitionServiceEventGridClientTest
{
public
class
PartitionServiceEventGridClientTest
{
...
@@ -118,4 +126,14 @@ public class PartitionServiceEventGridClientTest {
...
@@ -118,4 +126,14 @@ public class PartitionServiceEventGridClientTest {
AppException
exception
=
assertThrows
(
AppException
.
class
,
()
->
partitionServiceClientSpy
.
getEventGridTopicInPartition
(
"tenant1"
,
"recordschangedtopic"
));
AppException
exception
=
assertThrows
(
AppException
.
class
,
()
->
partitionServiceClientSpy
.
getEventGridTopicInPartition
(
"tenant1"
,
"recordschangedtopic"
));
assertEquals
(
500
,
exception
.
getError
().
getCode
());
assertEquals
(
500
,
exception
.
getError
().
getCode
());
}
}
@Test
public
void
shouldNotModifyDpsHeaders
()
throws
PartitionException
{
when
(
tokenService
.
getAuthorizationToken
()).
thenReturn
(
"token"
);
when
(
partitionFactory
.
create
(
any
(
DpsHeaders
.
class
))).
thenReturn
(
mock
(
IPartitionProvider
.
class
));
sut
.
getPartitionInfo
(
"test"
);
verify
(
headers
,
never
()).
put
(
DpsHeaders
.
AUTHORIZATION
,
"Bearer token"
);
}
}
}
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