Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TS_1
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lukáš Panchartek
TS_1
Commits
71e897eb
Commit
71e897eb
authored
10 months ago
by
Lukáš Panchartek
Browse files
Options
Downloads
Patches
Plain Diff
ehsop-controller
parent
1dbbf9ca
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/test/java/cz/cvut/fel/ts1/homework4/TestPurchasesArchive.java
+39
-0
39 additions, 0 deletions
.../java/cz/cvut/fel/ts1/homework4/TestPurchasesArchive.java
with
39 additions
and
0 deletions
src/test/java/cz/cvut/fel/ts1/homework4/TestPurchasesArchive.java
+
39
−
0
View file @
71e897eb
package
cz.cvut.fel.ts1.homework4
;
import
cz.cvut.fel.ts1.homework4.shop.Item
;
import
cz.cvut.fel.ts1.homework4.shop.ItemPurchaseArchiveEntry
;
import
cz.cvut.fel.ts1.homework4.shop.OrderArchive
;
import
cz.cvut.fel.ts1.homework4.shop.PurchasesArchive
;
import
org.junit.jupiter.api.BeforeEach
;
import
org.junit.jupiter.api.Test
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.*;
import
static
org
.
mockito
.
Mockito
.*;
public
class
TestPurchasesArchive
{
private
PurchasesArchive
purchasesArchive
;
private
OrderArchive
orderArchive
;
private
ItemPurchaseArchiveEntry
itemPurchaseArchiveEntry
;
@BeforeEach
void
setUp
()
{
orderArchive
=
mock
(
OrderArchive
.
class
);
itemPurchaseArchiveEntry
=
mock
(
ItemPurchaseArchiveEntry
.
class
);
purchasesArchive
=
new
PurchasesArchive
(
orderArchive
);
}
@Test
void
testPutOrderToPurchasesArchive
()
{
Item
item
=
new
Item
(
1
,
"Test Item"
,
100
,
"Category"
,
10
);
purchasesArchive
.
putOrderToPurchasesArchive
(
item
,
5
);
verify
(
orderArchive
,
times
(
1
)).
addOrder
(
item
,
5
);
}
@Test
void
testGetHowManyTimesHasBeenItemSold
()
{
Item
item
=
new
Item
(
1
,
"Test Item"
,
100
,
"Category"
,
10
);
when
(
orderArchive
.
getHowManyTimesHasBeenItemSold
(
item
)).
thenReturn
(
5
);
assertEquals
(
5
,
purchasesArchive
.
getHowManyTimesHasBeenItemSold
(
item
));
}
@Test
void
testPrintItemPurchaseStatistics
()
{
// This test verifies that the printItemPurchaseStatistics method does not throw an exception
assertDoesNotThrow
(()
->
purchasesArchive
.
printItemPurchaseStatistics
());
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment