Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
IntegrationProducerApps
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
Raghunath Josula
IntegrationProducerApps
Commits
12c3e860
Commit
12c3e860
authored
Feb 21, 2020
by
rjosula
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated the test file with runtime input file as input to producer
application
parent
9e85d20c
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
14 deletions
+48
-14
VoterVerificationController.java
.../verification/controller/VoterVerificationController.java
+6
-2
application.properties
VoterProducerApi/src/main/resources/application.properties
+2
-1
voterproducer.json
VoterProducerApi/src/main/resources/voterproducer.json
+9
-0
VoterProducerApiApplicationTests.java
.../voter/verification/VoterProducerApiApplicationTests.java
+31
-11
No files found.
VoterProducerApi/src/main/java/com/voter/verification/controller/VoterVerificationController.java
View file @
12c3e860
...
...
@@ -3,6 +3,8 @@ package com.voter.verification.controller;
import
java.util.HashMap
;
import
java.util.Map
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.messaging.Message
;
import
org.springframework.messaging.MessageHeaders
;
...
...
@@ -28,6 +30,8 @@ public class VoterVerificationController {
@Autowired
private
VoterInformationGateway
voterInputGateway
;
Logger
logger
=
LogManager
.
getLogger
(
VoterVerificationController
.
class
);
/**
* Controller method recieves employee information json string which will be processed
* to verify whether the employee is eligible for voting or not.
...
...
@@ -35,12 +39,12 @@ public class VoterVerificationController {
*/
@RequestMapping
(
value
=
"/sendVoterInfo"
,
method
=
RequestMethod
.
POST
)
public
String
publishVoterInfo
(
@RequestBody
String
personString
)
{
logger
.
info
(
"Inside controller publishing the person string :: "
+
personString
);
Map
<
String
,
Object
>
headers
=
new
HashMap
<>();
headers
.
put
(
"content-type"
,
"application/json"
);
MessageHeaders
header
=
new
MessageHeaders
(
headers
);
Message
<
String
>
msg
=
MessageBuilder
.
createMessage
(
personString
,
header
);
logger
.
debug
(
"Sending the message to the Gateway"
);
voterInputGateway
.
sendToInputQ
(
msg
);
return
personString
;
}
...
...
VoterProducerApi/src/main/resources/application.properties
View file @
12c3e860
...
...
@@ -6,4 +6,5 @@ spring.data.mongodb.uri=mongodb://voter:admin@localhost:27017/admin
###Adding Logging information
logging.level.root
=
info
voter.producer.url
=
http://localhost:8080/voter/verificationapp/sendVoterInfo
voterInputFilePath
=
voterproducer.json
VoterProducerApi/src/main/resources/voterproducer.json
0 → 100644
View file @
12c3e860
{
"personId"
:
4
,
"personName"
:
"RK D"
,
"personAge"
:
35
,
"personAddress"
:
"DNo 7-6-69/204, Kousalya Colony, Bachupally-500090, Hyderabad"
,
"state"
:
"Telangana"
,
"emailId"
:
"raghunathbj13@gmail.com"
,
"referenceId"
:
"DGN31147076"
}
\ No newline at end of file
VoterProducerApi/src/test/java/com/voter/verification/VoterProducerApiApplicationTests.java
View file @
12c3e860
package
com
.
voter
.
verification
;
import
java.io.File
;
import
java.io.IOException
;
import
java.nio.file.Files
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.junit.jupiter.api.Test
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.
http.ResponseEntity
;
import
org.springframework.
core.io.ClassPathResource
;
import
org.springframework.web.client.RestTemplate
;
/**
* Voter producer application tests to test the voter information
* and to produce to a consumer.
* @author rjosula
*
*/
@SpringBootTest
class
VoterProducerApiApplicationTests
{
Logger
logger
=
LogManager
.
getLogger
(
VoterProducerApiApplicationTests
.
class
);
@Value
(
"${voterInputFilePath}"
)
String
voterJsonFile
;
/**
* Test for producing a voter string through a producer.
* @throws IOException
*/
@Test
void
voterProducer
()
{
String
voterInput
=
"{\n"
+
" \"personId\" : 4,\n"
+
" \"personName\":\"RK D\",\n"
+
" \"personAge\":35,\n"
+
" \"personAddress\":\"DNo 7-6-69/204, Kousalya Colony, Bachupally-500090, Hyderabad\",\n"
+
" \"state\":\"Telangana\",\n"
+
" \"emailId\":\"raghunathbj13@gmail.com\",\n"
+
" \"referenceId\":\"DGN31147076\"\n"
+
"}"
;
void
voterProducer
(){
logger
.
info
(
"voterJsonFile "
+
voterJsonFile
);
String
voterInput
=
""
;
try
{
File
resource
=
new
ClassPathResource
(
voterJsonFile
).
getFile
();
voterInput
=
new
String
(
Files
.
readAllBytes
(
resource
.
toPath
()));
}
catch
(
Exception
ex
)
{
}
if
(
voterInput
.
isEmpty
())
{
logger
.
throwing
(
new
Exception
(
"File Doesn't exists and test is failure."
));
}
RestTemplate
restCall
=
new
RestTemplate
();
String
url
=
"http://localhost:8080/voter/verificationapp/sendVoterInfo"
;
...
...
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