Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
demo_rshka_mcs
Overview
Overview
Details
Activity
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jorge Ariel Caceres
demo_rshka_mcs
Commits
f3df7ca0
Commit
f3df7ca0
authored
Jan 17, 2020
by
jorgecacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test implements
parent
12833a46
Pipeline
#4
failed with stages
in 0 seconds
Changes
7
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
116 additions
and
1 deletions
+116
-1
pom.xml
+14
-0
src/main/java/com/rshka/mcs/service/CustomerServiceImpl.java
+8
-0
src/test/java/com/rshka/mcs/services/CustomerServiceImplTest.java
+68
-0
src/test/java/com/rshka/mcs/utils/TestUtils.java
+11
-0
target/classes/com/rshka/mcs/service/CustomerServiceImpl.class
+0
-0
target/m2e-wtp/web-resources/META-INF/maven/com.rshk.demo.mcs/demo_mcs/pom.properties
+1
-1
target/m2e-wtp/web-resources/META-INF/maven/com.rshk.demo.mcs/demo_mcs/pom.xml
+14
-0
No files found.
pom.xml
View file @
f3df7ca0
...
@@ -55,6 +55,20 @@
...
@@ -55,6 +55,20 @@
<artifactId>
mssql-jdbc
</artifactId>
<artifactId>
mssql-jdbc
</artifactId>
<version>
6.1.0.jre8
</version>
<version>
6.1.0.jre8
</version>
</dependency>
</dependency>
<!-- https://mvnrepository.com/artifact/org.mockito/mockito-all -->
<dependency>
<groupId>
org.mockito
</groupId>
<artifactId>
mockito-all
</artifactId>
<version>
1.9.5
</version>
<scope>
test
</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
<version>
4.12
</version>
<scope>
test
</scope>
</dependency>
</dependencies>
</dependencies>
<build>
<build>
<plugins>
<plugins>
...
...
src/main/java/com/rshka/mcs/service/CustomerServiceImpl.java
View file @
f3df7ca0
...
@@ -14,6 +14,14 @@ public class CustomerServiceImpl implements CustomerService {
...
@@ -14,6 +14,14 @@ public class CustomerServiceImpl implements CustomerService {
@Autowired
@Autowired
private
CustomerDao
customerDao
;
private
CustomerDao
customerDao
;
public
CustomerServiceImpl
()
{
}
public
CustomerServiceImpl
(
CustomerDao
customerDao
)
{
this
.
customerDao
=
customerDao
;
}
public
Customer
getCustomer
(
String
document
)
{
public
Customer
getCustomer
(
String
document
)
{
return
customerDao
.
getCustomer
(
document
);
return
customerDao
.
getCustomer
(
document
);
...
...
src/test/java/com/rshka/mcs/services/CustomerServiceImplTest.java
0 → 100644
View file @
f3df7ca0
package
com
.
rshka
.
mcs
.
services
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
javax.ws.rs.ext.ExceptionMapper
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.junit.rules.ExpectedException
;
import
org.junit.runner.RunWith
;
import
org.mockito.InjectMocks
;
import
org.mockito.Matchers
;
import
org.mockito.Mock
;
import
org.mockito.Mockito
;
import
org.mockito.runners.MockitoJUnitRunner
;
import
org.springframework.dao.EmptyResultDataAccessException
;
import
com.rshka.mcs.beans.Customer
;
import
com.rshka.mcs.dao.CustomerDaoImpl
;
import
com.rshka.mcs.service.CustomerServiceImpl
;
import
static
com
.
rshka
.
mcs
.
utils
.
TestUtils
.
getCustomerByDocument
;
@RunWith
(
MockitoJUnitRunner
.
class
)
public
class
CustomerServiceImplTest
{
@InjectMocks
CustomerServiceImpl
customerServiceImpl
;
@Mock
private
CustomerDaoImpl
customerDaoImpl
;
@Rule
public
ExpectedException
thrown
=
ExpectedException
.
none
();
public
CustomerServiceImplTest
()
{
}
@Test
public
void
testGetCustomerOk
()
{
Mockito
.
when
(
this
.
customerDaoImpl
.
getCustomer
(
Mockito
.
anyString
())).
thenReturn
(
getCustomerByDocument
());
this
.
customerServiceImpl
=
new
CustomerServiceImpl
(
customerDaoImpl
);
Customer
customer
=
this
.
customerServiceImpl
.
getCustomer
(
Mockito
.
anyString
());
assertNotNull
(
customer
);
}
@Test
public
void
testGetCustomerNotOk
()
{
this
.
customerServiceImpl
=
new
CustomerServiceImpl
(
customerDaoImpl
);
Mockito
.
when
(
this
.
customerDaoImpl
.
getCustomer
(
Mockito
.
anyString
())).
thenThrow
(
new
EmptyResultDataAccessException
(
"Cannot find customer"
,
1
));
EmptyResultDataAccessException
expectedException
=
new
EmptyResultDataAccessException
(
"Cannot find customer"
,
1
);
thrown
.
expect
(
EmptyResultDataAccessException
.
class
);
Customer
customer
=
this
.
customerServiceImpl
.
getCustomer
(
Mockito
.
anyString
());
}
}
\ No newline at end of file
src/test/java/com/rshka/mcs/utils/TestUtils.java
0 → 100644
View file @
f3df7ca0
package
com
.
rshka
.
mcs
.
utils
;
import
com.rshka.mcs.beans.Customer
;
public
class
TestUtils
{
public
static
Customer
getCustomerByDocument
()
{
return
new
Customer
(
1
,
"Persona Nombre"
,
"Avenida 1"
,
"133 443"
,
"12312312"
);
}
}
target/classes/com/rshka/mcs/service/CustomerServiceImpl.class
View file @
f3df7ca0
No preview for this file type
target/m2e-wtp/web-resources/META-INF/maven/com.rshk.demo.mcs/demo_mcs/pom.properties
View file @
f3df7ca0
#Generated by Maven Integration for Eclipse
#Generated by Maven Integration for Eclipse
#
Thu Jan 16 22:35:34
PYST 2020
#
Fri Jan 17 07:51:57
PYST 2020
version
=
0.0.1-SNAPSHOT
version
=
0.0.1-SNAPSHOT
groupId
=
com.rshk.demo.mcs
groupId
=
com.rshk.demo.mcs
m2e.projectName
=
demo_mcs
m2e.projectName
=
demo_mcs
...
...
target/m2e-wtp/web-resources/META-INF/maven/com.rshk.demo.mcs/demo_mcs/pom.xml
View file @
f3df7ca0
...
@@ -55,6 +55,20 @@
...
@@ -55,6 +55,20 @@
<artifactId>
mssql-jdbc
</artifactId>
<artifactId>
mssql-jdbc
</artifactId>
<version>
6.1.0.jre8
</version>
<version>
6.1.0.jre8
</version>
</dependency>
</dependency>
<!-- https://mvnrepository.com/artifact/org.mockito/mockito-all -->
<dependency>
<groupId>
org.mockito
</groupId>
<artifactId>
mockito-all
</artifactId>
<version>
1.9.5
</version>
<scope>
test
</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
<version>
4.12
</version>
<scope>
test
</scope>
</dependency>
</dependencies>
</dependencies>
<build>
<build>
<plugins>
<plugins>
...
...
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