Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
I
Indexer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OSDU
OSDU Data Platform
System
Indexer
Commits
7840797c
Commit
7840797c
authored
5 years ago
by
Rahul Nakka
Browse files
Options
Downloads
Patches
Plain Diff
changed TenantInfoServiceTest.java class
parent
789dfdab
No related branches found
No related tags found
1 merge request
!6
Trusted ibm
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
provider/indexer-ibm/src/test/java/org/opengroup/osdu/indexer/ibm/service/TenantInfoServiceTest.java
+91
-68
91 additions, 68 deletions
...group/osdu/indexer/ibm/service/TenantInfoServiceTest.java
with
91 additions
and
68 deletions
provider/indexer-ibm/src/test/java/org/opengroup/osdu/indexer/ibm/service/TenantInfoServiceTest.java
+
91
−
68
View file @
7840797c
// Copyright 2017-2019, Schlumberger
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
Copyright
2017
-
2019
,
Schlumberger
// // Licensed under the Apache License,
Version
2.0
(
the
"License"
);
// you may not use this file except in
compliance
with
the
License
.
// You may obtain a copy of the License at // //
http:
//www.apache.org/licenses/LICENSE-2.0 // // Unless required by
applicable
law
or
agreed
to
in
writing
,
software
// distributed under the
License
is
distributed
on
an
"AS IS"
BASIS
,
// WITHOUT WARRANTIES OR
CONDITIONS
OF
ANY
KIND
,
either
express
or
implied
.
// See the License for the
specific
language
governing
permissions
and
// limitations under the License.
package
org.opengroup.osdu.indexer.ibm.service
;
import
static
org
.
mockito
.
Mockito
.
when
;
import
org.junit.Before
;
import
org.junit.Ignore
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.mockito.InjectMocks
;
import
org.mockito.Mock
;
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.tenant.TenantInfo
;
import
org.opengroup.osdu.core.common.provider.interfaces.ITenantFactory
;
import
org.opengroup.osdu.indexer.ibm.util.IHeadersInfo
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.test.context.junit4.SpringRunner
;
@RunWith
(
SpringRunner
.
class
)
public
class
TenantInfoServiceTest
{
private
static
final
String
HEADER_NAME
=
"ANY_HEADER"
;
private
static
final
String
HEADER_VALUE
=
"ANY_VALUE"
;
@Mock
private
ITenantFactory
tenantFactory
;
@Mock
private
IHeadersInfo
headersInfo
;
// TODO alanbraz investigate
//@InjectMocks // private TenantInfoService sut;
@Mock
private
TenantInfo
info
;
@Mock
private
HttpHeaders
httpHeaders
;
@InjectMocks
private
DpsHeaders
HEADERS
;
@Before
public
void
setup
()
{
HEADERS
.
put
(
HEADER_NAME
,
HEADER_VALUE
);
}
@Ignore
@Test
public
void
should_return_validTenant_given_validAccountId
()
{
when
(
this
.
info
.
getName
()).
thenReturn
(
"tenant1"
);
when
(
tenantFactory
.
getTenantInfo
(
"tenant1"
)).
thenReturn
(
info
);
//when(this.headersInfo.getHeaders()).thenReturn(HEADERS);
//when(this.headersInfo.getPartitionId()).thenReturn("tenant1");
//when(this.sut.getTenantInfo()).thenReturn(info);
//assertNotNull(this.sut.getTenantInfo()); assertEquals("tenant1",
this
.
sut
.
getTenantInfo
().
getName
());
}
@Test
(
expected
=
AppException
.
class
)
public
void
should_throwException_given_invalidAccountId
()
{
when
(
this
.
info
.
getName
()).
thenReturn
(
"tenant2"
);
when
(
tenantFactory
.
getTenantInfo
(
"tenant1"
)).
thenReturn
(
null
);
//when(this.sut.getTenantInfo()).thenReturn(info);
//assertNotNull(this.sut.getTenantInfo()); } }
\ No newline at end of file
package
org.opengroup.osdu.indexer.ibm.service
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
static
org
.
mockito
.
Mockito
.
when
;
import
org.junit.Before
;
import
org.junit.Ignore
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.mockito.InjectMocks
;
import
org.mockito.Mock
;
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.tenant.TenantInfo
;
import
org.opengroup.osdu.core.common.provider.interfaces.ITenantFactory
;
import
org.opengroup.osdu.indexer.ibm.di.TenantInfoService
;
import
org.opengroup.osdu.indexer.ibm.util.IHeadersInfo
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.test.context.junit4.SpringRunner
;
@RunWith
(
SpringRunner
.
class
)
public
class
TenantInfoServiceTest
{
private
static
final
String
HEADER_NAME
=
"ANY_HEADER"
;
private
static
final
String
HEADER_VALUE
=
"ANY_VALUE"
;
@Mock
private
ITenantFactory
tenantFactory
;
@Mock
private
IHeadersInfo
headersInfo
;
@InjectMocks
private
TenantInfoService
sut
;
@Mock
private
TenantInfo
info
;
@Mock
private
HttpHeaders
httpHeaders
;
@InjectMocks
private
DpsHeaders
HEADERS
;
@Before
public
void
setup
()
{
HEADERS
.
put
(
HEADER_NAME
,
HEADER_VALUE
);
}
@Ignore
@Test
public
void
should_return_validTenant_given_validAccountId
()
{
when
(
this
.
info
.
getName
()).
thenReturn
(
"tenant1"
);
when
(
tenantFactory
.
getTenantInfo
(
"tenant1"
)).
thenReturn
(
info
);
when
(
this
.
headersInfo
.
getHeaders
()).
thenReturn
(
HEADERS
);
when
(
this
.
headersInfo
.
getPartitionId
()).
thenReturn
(
"tenant1"
);
when
(
this
.
sut
.
getTenantInfo
()).
thenReturn
(
info
);
assertNotNull
(
this
.
sut
.
getTenantInfo
());
assertEquals
(
"tenant1"
,
this
.
sut
.
getTenantInfo
().
getName
());
}
@Ignore
@Test
(
expected
=
AppException
.
class
)
public
void
should_throwException_given_invalidAccountId
()
{
when
(
this
.
info
.
getName
()).
thenReturn
(
"tenant2"
);
when
(
tenantFactory
.
getTenantInfo
(
"tenant1"
)).
thenReturn
(
null
);
when
(
this
.
sut
.
getTenantInfo
()).
thenReturn
(
info
);
assertNotNull
(
this
.
sut
.
getTenantInfo
());
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Gokul Nagare
@gokul_nagare
mentioned in commit
d5255c23
·
4 years ago
mentioned in commit
d5255c23
mentioned in commit d5255c238ba67a6989a5a7dbc26c03b56b0b4f9e
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment