Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
eShop
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jan Novák
eShop
Commits
9db57a1f
Commit
9db57a1f
authored
Oct 30, 2018
by
Jan Novák
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
basics of DiscountedItemTest.java
parent
d5dbf2a5
Pipeline
#4029
passed with stage
in 29 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
118 additions
and
0 deletions
+118
-0
src/test/java/cz/cvut/eshop/shop/DiscountedItemTest.java
src/test/java/cz/cvut/eshop/shop/DiscountedItemTest.java
+118
-0
No files found.
src/test/java/cz/cvut/eshop/shop/DiscountedItemTest.java
0 → 100644
View file @
9db57a1f
package
cz.cvut.eshop.shop
;
import
org.junit.*
;
import
org.junit.runners.MethodSorters
;
import
java.util.Date
;
@FixMethodOrder
(
MethodSorters
.
NAME_ASCENDING
)
public
class
DiscountedItemTest
{
private
Date
fromDate
;
private
Date
toDate
;
private
int
id
;
private
float
price
;
private
int
discountValid
,
discountInvalidSmall
,
discountInvalidLarge
;
private
String
itemName
,
itemCategory
;
@BeforeClass
public
static
void
setUpClass
()
{
}
@Before
public
void
setUp
()
{
/*
Creating Date object using different constructor than Date() and Date(long milisSinceEpochBegining)
is deprecated!
*/
fromDate
=
new
Date
(
1538352000L
);
// Oct-01-2018
toDate
=
new
Date
(
1541030399L
);
// Oct-30-2018
id
=
1
;
price
=
50.0f
;
discountValid
=
45
;
discountInvalidSmall
=
-
2
;
discountInvalidLarge
=
250
;
itemName
=
"TestName"
;
itemCategory
=
"TestCategory"
;
}
@Test
public
void
Test001CreateDiscountedItemWithDateRangeByDateObject
()
{
/*
Creating Date object using different constructor than Date() and Date(long milisSinceEpochBegining)
is deprecated!
*/
DiscountedItem
d
=
new
DiscountedItem
(
id
,
itemName
,
price
,
itemCategory
,
discountValid
,
fromDate
,
toDate
);
Assert
.
assertNotNull
(
d
);
}
@Test
public
void
Test002CreateDiscountedItemWithDateRangeByValidDateString
()
{
/*
Creating Date object using different constructor than Date() and Date(long milisSinceEpochBegining)
is deprecated!
*/
String
fromDate
=
"03.05.2002"
;
String
toDate
=
"03.05.2003"
;
DiscountedItem
d
=
new
DiscountedItem
(
id
,
itemName
,
price
,
itemCategory
,
discountInvalidLarge
,
fromDate
,
toDate
);
Assert
.
assertNotNull
(
d
);
}
@Test
public
void
Test003CreateDiscountedItemWithDateRangeByInvalidFromDateString
()
{
/*
Creating Date object using different constructor than Date() and Date(long milisSinceEpochBegining)
is deprecated!
*/
// expected valid date format is dd.mm.yyyy, let's do an invalid one and await null upon object creation attempt
String
fromDate
=
"3.2002"
;
String
toDate
=
"03.05.2003"
;
DiscountedItem
d
=
new
DiscountedItem
(
id
,
itemName
,
price
,
itemCategory
,
discountInvalidSmall
,
fromDate
,
toDate
);
Assert
.
assertNull
(
d
.
getDiscountFrom
());
}
@Test
public
void
Test004CreateDiscountedItemWithDateRangeByInvalidFromDateString
()
{
/*
Creating Date object using different constructor than Date() and Date(long milisSinceEpochBegining)
is deprecated!
*/
// expected valid date format is dd.mm.yyyy, let's do an invalid one and await null upon object creation attempt
String
fromDate
=
"3.5.2002"
;
String
toDate
=
"03..2003"
;
int
id
=
2
;
float
price
=
105.0f
;
int
discount
=
200
;
String
name
=
"TestName"
;
String
category
=
"TestCategory"
;
DiscountedItem
d
=
new
DiscountedItem
(
id
,
name
,
price
,
category
,
discount
,
fromDate
,
toDate
);
Assert
.
assertNull
(
d
.
getDiscountTo
());
}
@Test
public
void
Test0053DiscountedItemsAreEqual
()
{
}
@Test
public
void
Test006DiscountedItemsAreNotEqual
()
{
}
}
\ No newline at end of file
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