Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cs427fa20team22
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
htmoss2
cs427fa20team22
Commits
02591b31
Commit
02591b31
authored
4 years ago
by
ahmadaldhalaan
Browse files
Options
Downloads
Patches
Plain Diff
added DB Exception tests - reached 91% code coverage
parent
12cf09bf
No related branches found
No related tags found
2 merge requests
!7
Uc20
,
!2
UC20 Data Access Object Completed
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
iTrust/test/edu/ncsu/csc/itrust/unit/dao/deaths/CauseOfDeathTrendsReportTest.java
+41
-24
41 additions, 24 deletions
.../itrust/unit/dao/deaths/CauseOfDeathTrendsReportTest.java
with
41 additions
and
24 deletions
iTrust/test/edu/ncsu/csc/itrust/unit/dao/deaths/CauseOfDeathTrendsReportTest.java
+
41
−
24
View file @
02591b31
package
edu.ncsu.csc.itrust.
UC20
;
package
edu.ncsu.csc.itrust.
unit.dao.CauseOfDeathTrendsReportDAO
;
import
java.util.List
;
import
java.util.ArrayList
;
...
...
@@ -8,6 +8,7 @@ import junit.framework.TestCase;
import
edu.ncsu.csc.itrust.dao.mysql.CauseOfDeathTrendsReportDAO
;
import
edu.ncsu.csc.itrust.unit.datagenerators.TestDataGenerator
;
import
edu.ncsu.csc.itrust.unit.testutils.TestDAOFactory
;
import
edu.ncsu.csc.itrust.unit.testutils.EvilDAOFactory
;
import
edu.ncsu.csc.itrust.exception.DBException
;
...
...
@@ -15,21 +16,23 @@ public class CauseOfDeathTrendsReportTest extends TestCase {
private
TestDataGenerator
gen
=
new
TestDataGenerator
();
private
CauseOfDeathTrendsReportDAO
cod
;
private
CauseOfDeathTrendsReportDAO
evilDAO
=
new
CauseOfDeathTrendsReportDAO
(
EvilDAOFactory
.
getEvilInstance
());
@Override
protected
void
setUp
()
throws
Exception
{
gen
=
new
TestDataGenerator
();
gen
.
clearAllTables
();
gen
.
dead
p
atient1
();
gen
.
dead
p
atient2
();
gen
.
dead
p
atient3
();
gen
.
dead
p
atient4
();
gen
.
dead
p
atient5
();
gen
.
dead
p
atient6
();
gen
.
dead
p
atient7
();
gen
.
dead
p
atient8
();
gen
.
dead
p
atient9
();
gen
.
dead
p
atient10
();
gen
.
dead
P
atient1
();
gen
.
dead
P
atient2
();
gen
.
dead
P
atient3
();
gen
.
dead
P
atient4
();
gen
.
dead
P
atient5
();
gen
.
dead
P
atient6
();
gen
.
dead
P
atient7
();
gen
.
dead
P
atient8
();
gen
.
dead
P
atient9
();
gen
.
dead
P
atient10
();
gen
.
icd9cmCodes
();
cod
=
new
CauseOfDeathTrendsReportDAO
(
TestDAOFactory
.
getTestInstance
());
...
...
@@ -46,37 +49,51 @@ public class CauseOfDeathTrendsReportTest extends TestCase {
assertEquals
(
Long
.
valueOf
(
86
),
deaths
.
get
(
5
));
}
/*
public void testPatientsForHCP
InvalidID
() throws Exception {
public
void
testPatientsForHCP
Exception
()
throws
Exception
{
try
{
cod.getPatientsForHCP(Long("0"));
fail("Should have failed but didn't");
} catch (FormValidationException e) {
assertEquals(1, e.getErrorList().size());
assertEquals("HCP ID must be valid!", e.getErrorList().get(0));
evilDAO
.
getPatientsForHCP
(
Long
.
parseLong
(
"0000000000"
));
fail
(
"DBException should have been thrown"
);
}
catch
(
DBException
e
)
{
assertEquals
(
EvilDAOFactory
.
MESSAGE
,
e
.
getSQLException
().
getMessage
());
}
}
*/
public
void
testTopTwoCorrectForHCPValid
()
throws
Exception
{
}
public
void
testTopTwoDeathsForHCPValid
()
throws
Exception
{
List
<
String
>
deaths
=
cod
.
getTopTwoDeathsForHCP
(
Long
.
parseLong
(
"9000000000"
),
"All"
,
Date
.
valueOf
(
"2018-01-01"
),
Date
.
valueOf
(
"2020-12-31"
));
assertEquals
(
2
,
deaths
.
size
());
assertEquals
(
"Name: Tuberculosis of the lung, Code: 11.40, Deaths: 3"
,
deaths
.
get
(
0
));
assertEquals
(
"Name: Malaria, Code: 84.50, Deaths: 2"
,
deaths
.
get
(
1
));
}
public
void
testTopTwo
CorrectMale
ForHCPValid
()
throws
Exception
{
public
void
testTopTwo
Deaths
ForHCP
Male
Valid
()
throws
Exception
{
List
<
String
>
deaths
=
cod
.
getTopTwoDeathsForHCP
(
Long
.
parseLong
(
"9000000000"
),
"Male"
,
Date
.
valueOf
(
"2018-01-01"
),
Date
.
valueOf
(
"2020-12-31"
));
assertEquals
(
2
,
deaths
.
size
());
assertEquals
(
"Name: Malaria, Code: 84.50, Deaths: 2"
,
deaths
.
get
(
0
));
assertEquals
(
"Name: Tuberculosis of the lung, Code: 11.40, Deaths: 2"
,
deaths
.
get
(
1
));
}
/*public void testTopTwoCorrectForAllValid() throws Exception {
public
void
testTopTwoDeathsForHCPException
()
throws
Exception
{
try
{
evilDAO
.
getTopTwoDeathsForHCP
(
Long
.
parseLong
(
"0000000000"
),
"All"
,
Date
.
valueOf
(
"2018-01-01"
),
Date
.
valueOf
(
"2020-12-31"
));
fail
(
"DBException should have been thrown"
);
}
catch
(
DBException
e
)
{
assertEquals
(
EvilDAOFactory
.
MESSAGE
,
e
.
getSQLException
().
getMessage
());
}
}
public
void
testTopTwoDeathsForAllValid
()
throws
Exception
{
List
<
String
>
deaths
=
cod
.
getTopTwoDeathsForAll
(
"All"
,
Date
.
valueOf
(
"2018-01-01"
),
Date
.
valueOf
(
"2020-12-31"
));
assertEquals
(
2
,
deaths
.
size
());
assertEquals
(
"Name: Influenza, Code: 487.00, Deaths: 5"
,
deaths
.
get
(
0
));
assertEquals
(
"Name: Tuberculosis of the lung, Code: 11.40, Deaths: 3"
,
deaths
.
get
(
1
));
}*/
}
public
void
testTopTwoDeathsForAllFemaleValid
()
throws
Exception
{
List
<
String
>
deaths
=
cod
.
getTopTwoDeathsForAll
(
"Female"
,
Date
.
valueOf
(
"2018-01-01"
),
Date
.
valueOf
(
"2020-12-31"
));
assertEquals
(
2
,
deaths
.
size
());
assertEquals
(
"Name: Influenza, Code: 487.00, Deaths: 2"
,
deaths
.
get
(
0
));
assertEquals
(
"Name: Tuberculosis of the lung, Code: 11.40, Deaths: 1"
,
deaths
.
get
(
1
));
}
public
void
testCodeNameExists
()
throws
Exception
{
String
deaths
=
cod
.
getCodeName
(
"84.50"
);
...
...
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