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
9e85d20c
Commit
9e85d20c
authored
Feb 20, 2020
by
rjosula
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added Junit Tests for producer components
parent
16ee4e93
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
11 deletions
+37
-11
pom.xml
VoterProducerApi/pom.xml
+8
-3
VoterVerificationController.java
.../verification/controller/VoterVerificationController.java
+3
-7
application.properties
VoterProducerApi/src/main/resources/application.properties
+2
-0
VoterProducerApiApplicationTests.java
.../voter/verification/VoterProducerApiApplicationTests.java
+24
-1
No files found.
VoterProducerApi/pom.xml
View file @
9e85d20c
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"
>
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<modelVersion>
4.0.0
</modelVersion>
<parent>
<parent>
<groupId>
org.springframework.boot
</groupId>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-parent
</artifactId>
<artifactId>
spring-boot-starter-parent
</artifactId>
<version>
2.2.4.RELEASE
</version>
<version>
2.2.4.RELEASE
</version>
<relativePath/>
<!-- lookup parent from repository -->
<relativePath
/>
<!-- lookup parent from repository -->
</parent>
</parent>
<groupId>
com.voter.verification
</groupId>
<groupId>
com.voter.verification
</groupId>
<artifactId>
VoterProducerApi
</artifactId>
<artifactId>
VoterProducerApi
</artifactId>
...
@@ -45,6 +46,10 @@
...
@@ -45,6 +46,10 @@
</exclusions>
</exclusions>
</dependency>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-log4j2
</artifactId>
</dependency>
<dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<groupId>
org.springframework.boot
</groupId>
...
...
VoterProducerApi/src/main/java/com/voter/verification/controller/VoterVerificationController.java
View file @
9e85d20c
...
@@ -4,8 +4,6 @@ import java.util.HashMap;
...
@@ -4,8 +4,6 @@ import java.util.HashMap;
import
java.util.Map
;
import
java.util.Map
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.messaging.Message
;
import
org.springframework.messaging.Message
;
import
org.springframework.messaging.MessageHeaders
;
import
org.springframework.messaging.MessageHeaders
;
import
org.springframework.messaging.support.MessageBuilder
;
import
org.springframework.messaging.support.MessageBuilder
;
...
@@ -35,8 +33,8 @@ public class VoterVerificationController {
...
@@ -35,8 +33,8 @@ public class VoterVerificationController {
* to verify whether the employee is eligible for voting or not.
* to verify whether the employee is eligible for voting or not.
* @return
* @return
*/
*/
@RequestMapping
(
value
=
"/sendVoterInfo"
,
method
=
RequestMethod
.
POST
,
produces
=
{
"application/xml"
}
)
@RequestMapping
(
value
=
"/sendVoterInfo"
,
method
=
RequestMethod
.
POST
)
public
ResponseEntity
<?>
publishVoterInfo
(
@RequestBody
String
personString
)
{
public
String
publishVoterInfo
(
@RequestBody
String
personString
)
{
Map
<
String
,
Object
>
headers
=
new
HashMap
<>();
Map
<
String
,
Object
>
headers
=
new
HashMap
<>();
headers
.
put
(
"content-type"
,
"application/json"
);
headers
.
put
(
"content-type"
,
"application/json"
);
...
@@ -44,8 +42,6 @@ public class VoterVerificationController {
...
@@ -44,8 +42,6 @@ public class VoterVerificationController {
MessageHeaders
header
=
new
MessageHeaders
(
headers
);
MessageHeaders
header
=
new
MessageHeaders
(
headers
);
Message
<
String
>
msg
=
MessageBuilder
.
createMessage
(
personString
,
header
);
Message
<
String
>
msg
=
MessageBuilder
.
createMessage
(
personString
,
header
);
voterInputGateway
.
sendToInputQ
(
msg
);
voterInputGateway
.
sendToInputQ
(
msg
);
return
personString
;
return
new
ResponseEntity
<
String
>(
"Published successfully"
,
HttpStatus
.
ACCEPTED
);
}
}
}
}
VoterProducerApi/src/main/resources/application.properties
View file @
9e85d20c
...
@@ -4,4 +4,6 @@ spring.activemq.user=admin
...
@@ -4,4 +4,6 @@ spring.activemq.user=admin
spring.activemq.password
=
admin
spring.activemq.password
=
admin
spring.data.mongodb.uri
=
mongodb://voter:admin@localhost:27017/admin
spring.data.mongodb.uri
=
mongodb://voter:admin@localhost:27017/admin
###Adding Logging information
logging.level.root
=
info
VoterProducerApi/src/test/java/com/voter/verification/VoterProducerApiApplicationTests.java
View file @
9e85d20c
package
com
.
voter
.
verification
;
package
com
.
voter
.
verification
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.Test
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.client.RestTemplate
;
@SpringBootTest
@SpringBootTest
class
VoterProducerApiApplicationTests
{
class
VoterProducerApiApplicationTests
{
Logger
logger
=
LogManager
.
getLogger
(
VoterProducerApiApplicationTests
.
class
);
@Test
@Test
void
contextLoads
()
{
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"
+
"}"
;
RestTemplate
restCall
=
new
RestTemplate
();
String
url
=
"http://localhost:8080/voter/verificationapp/sendVoterInfo"
;
String
response
=
restCall
.
postForObject
(
url
,
voterInput
,
String
.
class
);
if
(
response
!=
null
)
{
logger
.
info
(
"Response achieved is:: "
+
response
);
}
}
}
}
}
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