Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OTSWithFeign
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Siva Naga Someswara Jatla
OTSWithFeign
Commits
6cd14803
Commit
6cd14803
authored
Apr 14, 2020
by
Siva Naga Someswara Jatla
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
component test case added
parent
3128d7e4
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
151 additions
and
14 deletions
+151
-14
build.gradle
build.gradle
+7
-10
plugin.xml
libs/resources/META-INF/plugin.xml
+33
-0
OfferControllerComponentTest.java
...ctionservice/controller/OfferControllerComponentTest.java
+102
-0
OfferControllerTest.java
...fertransactionservice/controller/OfferControllerTest.java
+1
-2
OfferServiceTest.java
...sum/offertransactionservice/service/OfferServiceTest.java
+0
-1
application.properties
src/test/resources/application.properties
+8
-1
No files found.
build.gradle
View file @
6cd14803
...
...
@@ -9,7 +9,7 @@ apply plugin: 'net.ltgt.apt-idea'
group
=
'com.nisum'
version
=
'0.0.1-SNAPSHOT'
sourceCompatibility
=
'1.
8
'
sourceCompatibility
=
'1.
9
'
configurations
{
compileOnly
{
...
...
@@ -19,7 +19,7 @@ configurations {
repositories
{
flatDir
{
dirs
'
C:\\Users\\kpadhi\\.m2\\repository\\com\\nisum\\exceptionservice\\
0.0.1'
dirs
'
/Users/sivanagasomeswaragandhijatla/.m2/repository/com/nisum/exceptionservice/
0.0.1'
}
mavenCentral
()
}
...
...
@@ -44,22 +44,19 @@ dependencies {
compile
'org.mapstruct:mapstruct:1.3.0.Beta2'
testCompile
'com.squareup.okhttp3:mockwebserver:3.8.0'
implementation
group:
'junit'
,
name:
'junit'
,
version:
'4.12'
//
implementation group: 'junit', name: 'junit', version: '4.12'
testImplementation
(
'org.springframework.boot:spring-boot-starter-test'
)
testImplementation
group:
'org.springframework.boot'
,
name:
'spring-boot-starter-test'
,
version:
'2.0.3.RELEASE'
testImplementation
group:
'junit'
,
name:
'junit'
,
version:
'4.12'
//
testImplementation group: 'junit', name: 'junit', version: '4.12'
compile
group:
'org.apache.commons'
,
name:
'commons-lang3'
,
version:
'3.0'
testImplementation
'io.projectreactor:reactor-test'
testImplementation
'org.junit.jupiter:junit-jupiter-api:5.3.1'
testRuntimeOnly
'org.junit.jupiter:junit-jupiter-engine:5.3.1'
compile
'com.h2database:h2:1.3.156'
}
tasks
.
withType
(
Test
){
scanForTestClasses
=
false
include
"**/*Test.class"
}
test
{
useJUnitPlatform
()
}
libs/resources/META-INF/plugin.xml
0 → 100644
View file @
6cd14803
<idea-plugin>
<id>
com.your.company.unique.plugin.id
</id>
<name>
Plugin display name here
</name>
<version>
1.0
</version>
<vendor
email=
"support@yourcompany.com"
url=
"http://www.yourcompany.com"
>
YourCompany
</vendor>
<description>
<![CDATA[
Enter short description for your plugin here.<br>
<em>
most HTML tags may be used
</em>
]]>
</description>
<change-notes>
<![CDATA[
Add change notes here.<br>
<em>
most HTML tags may be used
</em>
]]>
</change-notes>
<!-- please see http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/build_number_ranges.html for description -->
<idea-version
since-build=
"173.0"
/>
<!-- please see http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/plugin_compatibility.html
on how to target different products -->
<depends>
com.intellij.modules.platform
</depends>
<extensions
defaultExtensionNs=
"com.intellij"
>
<!-- Add your extensions here -->
</extensions>
<actions>
<!-- Add your actions here -->
</actions>
</idea-plugin>
\ No newline at end of file
src/test/java/com/nisum/offertransactionservice/controller/OfferControllerComponentTest.java
0 → 100644
View file @
6cd14803
package
com
.
nisum
.
offertransactionservice
.
controller
;
import
com.nisum.offertransactionservice.client.ClientService
;
import
com.nisum.offertransactionservice.dao.OfferLookupRepo
;
import
com.nisum.offertransactionservice.model.*
;
import
com.nisum.offertransactionservice.service.OfferCallingPEService
;
import
org.junit.Assert
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.mockito.*
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.boot.test.mock.mockito.MockBean
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.stream.Collectors
;
import
static
org
.
mockito
.
Mockito
.
when
;
@RunWith
(
SpringRunner
.
class
)
@SpringBootTest
public
class
OfferControllerComponentTest
{
@Autowired
private
OfferTransactionController
offerTransactionController
;
@InjectMocks
private
OfferCallingPEService
offerCallingPEService
=
new
OfferCallingPEService
();
@MockBean
private
OfferLookupRepo
offerLookupRepo
;
@MockBean
private
ClientService
clientService
;
@Before
public
void
setUp
()
throws
Exception
{
MockitoAnnotations
.
initMocks
(
this
);
}
@Test
public
void
test
()
throws
InterruptedException
{
when
(
offerLookupRepo
.
findAll
()).
thenReturn
(
returnOffers
());
when
(
clientService
.
getPeResponseFlux
(
ArgumentMatchers
.
any
())).
thenReturn
(
getPeResponse
());
OfferTransactionResponse
offerTransactionResponse
=
offerTransactionController
.
getOfferTransactionResponse
(
getOfferTransactionRequest
());
Assert
.
assertEquals
(
Objects
.
nonNull
(
offerTransactionResponse
.
getTransactionId
()),
true
);
}
private
PERequest
getPEReq
()
{
PERequest
peRequest
=
new
PERequest
();
peRequest
.
setHhId
(
"123"
);
List
<
Item
>
itemList
=
new
ArrayList
<>();
Item
item1
=
new
Item
(
"Coke"
,
"12"
,
6.05
);
Item
item2
=
new
Item
(
"Thumpsup"
,
"11"
,
12.32
);
itemList
.
add
(
item1
);
itemList
.
add
(
item2
);
peRequest
.
setItemList
(
itemList
);
return
peRequest
;
}
private
PEResponse
getPeResponse
()
{
PEResponse
peResponse
=
new
PEResponse
();
peResponse
.
setHhid
(
"123"
);
List
<
Item
>
itemList
=
new
ArrayList
<>();
Item
item1
=
new
Item
(
"Coke"
,
"12"
,
6.05
);
Item
item2
=
new
Item
(
"Thumpsup"
,
"11"
,
12.32
);
itemList
.
add
(
item1
);
itemList
.
add
(
item2
);
peResponse
.
setDiscountedItemList
(
itemList
);
return
peResponse
;
}
public
List
<
OfferLookup
>
returnOffers
()
{
OfferLookup
offerLookup1
=
new
OfferLookup
(
"1"
,
"12"
,
"234"
,
"02"
,
"AND"
,
"BOGO"
);
OfferLookup
offerLookup2
=
new
OfferLookup
(
"2"
,
"13"
,
"234"
,
"02"
,
"OR"
,
"BXGY"
);
List
<
OfferLookup
>
offerLookups
=
new
ArrayList
<>();
offerLookups
.
add
(
offerLookup1
);
offerLookups
.
add
(
offerLookup2
);
return
offerLookups
.
stream
().
collect
(
Collectors
.
toList
());
}
private
OfferTransactionRequest
getOfferTransactionRequest
()
{
OfferTransactionRequest
offerTransactionRequest
=
new
OfferTransactionRequest
();
offerTransactionRequest
.
setHhId
(
"123"
);
List
<
Item
>
itemList
=
new
ArrayList
<>();
Item
item1
=
new
Item
(
"Coke"
,
"12"
,
13.05
);
Item
item2
=
new
Item
(
"Thumpsup"
,
"11"
,
14.05
);
itemList
.
add
(
item1
);
itemList
.
add
(
item2
);
offerTransactionRequest
.
setItemList
(
itemList
);
return
offerTransactionRequest
;
}
}
src/test/java/com/nisum/offertransactionservice/controller/OfferControllerTest.java
View file @
6cd14803
...
...
@@ -5,7 +5,7 @@ import com.nisum.offertransactionservice.service.EndOfSaleService;
import
com.nisum.offertransactionservice.service.EndOfTransactionService
;
import
com.nisum.offertransactionservice.service.OfferCallingPEService
;
import
org.junit.Assert
;
import
org.junit.Ignore
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.mockito.Mock
;
...
...
@@ -19,7 +19,6 @@ import java.util.UUID;
import
java.util.stream.Collectors
;
@RunWith
(
MockitoJUnitRunner
.
class
)
@Ignore
public
class
OfferControllerTest
{
@Mock
...
...
src/test/java/com/nisum/offertransactionservice/service/OfferServiceTest.java
View file @
6cd14803
...
...
@@ -25,7 +25,6 @@ import java.util.stream.Collectors;
@RunWith
(
MockitoJUnitRunner
.
class
)
@SpringBootTest
@DirtiesContext
@Ignore
public
class
OfferServiceTest
{
@Mock
private
OfferLookupRepo
offerLookupRepo
;
...
...
src/test/resources/application.properties
View file @
6cd14803
promotion.engine.calculate.discount.url
=
/promotionEngine/calculateDiscount
\ No newline at end of file
spring.datasource.url
=
jdbc:postgresql://127.0.0.1:5432/postgres
spring.datasource.username
=
user
spring.datasource.password
=
password123
endpoint.url.promotionEngineUrl
=
/promotionEngine/calculateDiscount
endpoint.url.peBaseUrl
=
http://localhost:8081
endpoint.url.storeConsumerUrl
=
/store/producer
endpoint.url.scBaseUrl
=
http://localhost:8081
server.port
=
8085
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