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
8fecc34b
Commit
8fecc34b
authored
4 years ago
by
adityab3
Browse files
Options
Downloads
Patches
Plain Diff
Updated JUnit tests for preregistration health information
parent
895cf4b6
No related branches found
Branches containing commit
No related tags found
1 merge request
!6
Uc91v2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
iTrust/test/edu/ncsu/csc/itrust/unit/action/AddPreRegisterPatientActionTest.java
+29
-7
29 additions, 7 deletions
...c/itrust/unit/action/AddPreRegisterPatientActionTest.java
with
29 additions
and
7 deletions
iTrust/test/edu/ncsu/csc/itrust/unit/action/AddPreRegisterPatientActionTest.java
+
29
−
7
View file @
8fecc34b
...
...
@@ -7,9 +7,12 @@ package edu.ncsu.csc.itrust.unit.action;
import
junit.framework.TestCase
;
import
edu.ncsu.csc.itrust.action.AddPreRegisteredPatientAction
;
import
edu.ncsu.csc.itrust.beans.PatientBean
;
import
edu.ncsu.csc.itrust.beans.HealthRecord
;
import
edu.ncsu.csc.itrust.beans.forms.HealthRecordForm
;
import
edu.ncsu.csc.itrust.dao.DAOFactory
;
import
edu.ncsu.csc.itrust.dao.mysql.AuthDAO
;
import
edu.ncsu.csc.itrust.dao.mysql.PatientDAO
;
import
edu.ncsu.csc.itrust.dao.mysql.HealthRecordsDAO
;
import
edu.ncsu.csc.itrust.unit.datagenerators.TestDataGenerator
;
import
edu.ncsu.csc.itrust.unit.testutils.TestDAOFactory
;
import
edu.ncsu.csc.itrust.exception.FormValidationException
;
...
...
@@ -21,16 +24,24 @@ public class AddPreRegisterPatientActionTest extends TestCase {
private
DAOFactory
factory
=
TestDAOFactory
.
getTestInstance
();
private
PatientDAO
patientDAO
=
TestDAOFactory
.
getTestInstance
().
getPatientDAO
();
private
AuthDAO
authDAO
=
TestDAOFactory
.
getTestInstance
().
getAuthDAO
();
private
HealthRecordsDAO
healthDAO
=
TestDAOFactory
.
getTestInstance
().
getHealthRecordsDAO
();
private
TestDataGenerator
gen
=
new
TestDataGenerator
();
private
AddPreRegisteredPatientAction
action
;
private
HealthRecordForm
defaultHRF
;
/**
* Sets up defaults
*/
@Override
protected
void
setUp
()
throws
Exception
{
gen
.
clearAllTables
();
action
=
new
AddPreRegisteredPatientAction
(
factory
,
0L
);
action
=
new
AddPreRegisteredPatientAction
(
factory
,
0L
);
defaultHRF
=
new
HealthRecordForm
();
defaultHRF
.
setIsSmoker
(
"1"
);
defaultHRF
.
setHeight
(
""
);
defaultHRF
.
setWeight
(
""
);
}
/**
...
...
@@ -55,7 +66,12 @@ public class AddPreRegisterPatientActionTest extends TestCase {
p
.
setIcState
(
"AK"
);
p
.
setIcPhone
(
"1122334455"
);
long
mid
=
action
.
addPatient
(
p
);
HealthRecordForm
h
=
new
HealthRecordForm
();
h
.
setHeight
(
"100"
);
h
.
setWeight
(
"100"
);
h
.
setIsSmoker
(
"1"
);
long
mid
=
action
.
addPatient
(
p
,
h
);
PatientBean
p2
=
patientDAO
.
getPatient
(
mid
);
assertEquals
(
p
.
getFirstName
(),
p2
.
getFirstName
());
...
...
@@ -73,6 +89,11 @@ public class AddPreRegisterPatientActionTest extends TestCase {
assertEquals
(
p
.
getIcCity
(),
p2
.
getIcCity
());
assertEquals
(
p
.
getIcState
(),
p
.
getIcState
());
assertEquals
(
p
.
getIcPhone
(),
p
.
getIcPhone
());
HealthRecord
h2
=
healthDAO
.
getAllHealthRecords
(
mid
).
get
(
0
);
assertEquals
(
Double
.
parseDouble
(
h
.
getHeight
()),
h2
.
getHeight
());
assertEquals
(
Double
.
parseDouble
(
h
.
getWeight
()),
h2
.
getWeight
());
assertEquals
(
h
.
getIsSmoker
()
==
"1"
,
h2
.
isSmoker
());
assertEquals
(
Role
.
PREREGISTEREDPATIENT
,
authDAO
.
getUserRole
(
mid
));
}
...
...
@@ -89,7 +110,7 @@ public class AddPreRegisterPatientActionTest extends TestCase {
// maybe not needed
try
{
action
.
addPatient
(
p
);
action
.
addPatient
(
p
,
defaultHRF
);
fail
(
"Invalid email"
);
}
catch
(
FormValidationException
e
)
{
...
...
@@ -105,8 +126,9 @@ public class AddPreRegisterPatientActionTest extends TestCase {
p2
.
setLastName
(
"Cricket"
);
p2
.
setEmail
(
"make.awish@gmail.com"
);
p2
.
setPassword
(
"password"
);
action
.
addPatient
(
p2
);
try
{
action
.
addPatient
(
p2
,
defaultHRF
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();}
PatientBean
p3
=
new
PatientBean
();
p3
.
setFirstName
(
"Make"
);
...
...
@@ -115,7 +137,7 @@ public class AddPreRegisterPatientActionTest extends TestCase {
p3
.
setPassword
(
"password"
);
try
{
action
.
addPatient
(
p3
);
action
.
addPatient
(
p3
,
defaultHRF
);
fail
(
"Duplicate email"
);
}
catch
(
ITrustException
e
)
{
}
}
...
...
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