Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Khalid Ali
bookshare-backend
Commits
2f5aea4b
Commit
2f5aea4b
authored
Dec 17, 2018
by
Khalid Ali
Browse files
GetAll service request test added
parent
548281a6
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/test/java/com/gmu/bookshare/service/ListingEntityServiceIntegrationTest.java
View file @
2f5aea4b
...
@@ -14,6 +14,7 @@ import org.springframework.test.context.junit4.SpringRunner;
...
@@ -14,6 +14,7 @@ import org.springframework.test.context.junit4.SpringRunner;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
...
@@ -41,21 +42,39 @@ public class ListingEntityServiceIntegrationTest {
...
@@ -41,21 +42,39 @@ public class ListingEntityServiceIntegrationTest {
@Before
@Before
public
void
setUp
()
{
public
void
setUp
()
{
ListingEntity
listingEntity1
=
new
ListingEntity
(
123456
,
3
,
14.99
,
ListingEntity
listingEntity1
=
new
ListingEntity
(
1234567
,
3
,
14.99
,
new
Date
(),
192838079872L
,
2879878394L
,
"Title Calc 3"
);
ListingEntity
listingEntity2
=
new
ListingEntity
(
1234568
,
3
,
14.99
,
new
Date
(),
192838079872L
,
2879878394L
,
"Title Calc 3"
);
ListingEntity
listingEntity3
=
new
ListingEntity
(
1234569
,
3
,
14.99
,
new
Date
(),
192838079872L
,
2879878394L
,
"Title Calc 3"
);
new
Date
(),
192838079872L
,
2879878394L
,
"Title Calc 3"
);
ArrayList
<
ListingEntity
>
l
=
new
ArrayList
<>();
ArrayList
<
ListingEntity
>
l
=
new
ArrayList
<>();
l
.
add
(
listingEntity1
);
l
.
add
(
listingEntity1
);
ArrayList
<
ListingEntity
>
allListings
=
new
ArrayList
<>();
allListings
.
add
(
listingEntity1
);
allListings
.
add
(
listingEntity2
);
allListings
.
add
(
listingEntity3
);
Mockito
.
when
(
EmployeeServiceImplTestContextConfiguration
.
listingRepository
.
findByIsbn
(
listingEntity1
.
getIsbn
()))
Mockito
.
when
(
EmployeeServiceImplTestContextConfiguration
.
listingRepository
.
findByIsbn
(
listingEntity1
.
getIsbn
()))
.
thenReturn
(
l
);
.
thenReturn
(
l
);
Mockito
.
when
(
EmployeeServiceImplTestContextConfiguration
.
listingRepository
.
findAll
()).
thenReturn
(
allListings
);
}
}
@Test
@Test
public
void
whenValidIsbn_thenListingShouldBeFound
()
{
public
void
whenValidIsbn_thenListingShouldBeFound
()
{
int
isbn
=
123456
;
int
isbn
=
123456
7
;
ListingEntity
found
=
listingService
.
getIsbn
(
isbn
);
ListingEntity
found
=
listingService
.
getIsbn
(
isbn
);
assertThat
(
found
.
getIsbn
()).
isEqualTo
(
isbn
);
assertThat
(
found
.
getIsbn
()).
isEqualTo
(
isbn
);
}
}
@Test
public
void
whenGetAll_thenAllListingsShouldBeFound
()
{
List
<
ListingEntity
>
listings
=
listingService
.
getAll
();
assertThat
(
listings
.
size
()).
isEqualTo
(
3
);
}
}
}
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