22
33import static org .junit .Assert .assertEquals ;
44
5- import javax .validation .ConstraintViolationException ;
5+ import java .util .Arrays ;
6+ import java .util .List ;
67
78import org .junit .After ;
89import org .junit .Test ;
1415import org .springframework .test .context .web .WebAppConfiguration ;
1516
1617import edu .tamu .app .WebServerInit ;
18+ import edu .tamu .app .enums .NotificationLocation ;
1719import edu .tamu .app .model .repo .NotificationRepo ;
1820
1921@ WebAppConfiguration
@@ -25,40 +27,32 @@ public class NotificationTest {
2527 protected static final String TEST_NOTIFICATION_BODY = "Test Notification Body" ;
2628 protected static final String TEST_ALTERNATE_NOTIFICATION_NAME = "Different Notification Name" ;
2729 protected static final String TEST_ALTERNATE_NOTIFICATION_BODY = "Different Notification Body" ;
30+ protected static final boolean TEST_IS_ACTIVE = true ;
31+ protected static final List <NotificationLocation > TEST_LOCATIONS = Arrays .asList (new NotificationLocation [] {NotificationLocation .CUSHING });
2832
2933 @ Autowired
3034 NotificationRepo notificationRepo ;
3135
3236 @ Test
3337 public void testCreate () {
3438 long initialCount = notificationRepo .count ();
35- notificationRepo .create (TEST_NOTIFICATION_NAME , TEST_NOTIFICATION_BODY );
39+ notificationRepo .create (TEST_NOTIFICATION_NAME , TEST_NOTIFICATION_BODY , TEST_IS_ACTIVE , TEST_LOCATIONS );
3640 assertEquals ("The number of Notifications did not increase by one" , initialCount + 1 , notificationRepo .count ());
3741 }
3842
3943 @ Test (expected = DataIntegrityViolationException .class )
4044 public void testNameNotNull () {
41- notificationRepo .create (null , TEST_NOTIFICATION_BODY );
45+ notificationRepo .create (null , TEST_NOTIFICATION_BODY , TEST_IS_ACTIVE , TEST_LOCATIONS );
4246 }
4347
4448 @ Test (expected = DataIntegrityViolationException .class )
4549 public void testBodyNotNull () {
46- notificationRepo .create (TEST_NOTIFICATION_NAME , null );
47- }
48-
49- @ Test (expected = ConstraintViolationException .class )
50- public void testNameNotEmpty () {
51- notificationRepo .create ("" , TEST_NOTIFICATION_BODY );
52- }
53-
54- @ Test (expected = ConstraintViolationException .class )
55- public void testBodyNotEmpty () {
56- notificationRepo .create (TEST_NOTIFICATION_NAME , "" );
50+ notificationRepo .create (TEST_NOTIFICATION_NAME , null , TEST_IS_ACTIVE , TEST_LOCATIONS );
5751 }
5852
5953 @ Test
6054 public void testUpdateName () {
61- Notification notification = notificationRepo .create (TEST_NOTIFICATION_NAME , TEST_NOTIFICATION_BODY );
55+ Notification notification = notificationRepo .create (TEST_NOTIFICATION_NAME , TEST_NOTIFICATION_BODY , TEST_IS_ACTIVE , TEST_LOCATIONS );
6256 notification .setName (TEST_ALTERNATE_NOTIFICATION_NAME );
6357 notificationRepo .save (notification );
6458 notification = notificationRepo .findOne (notification .getId ());
@@ -67,17 +61,17 @@ public void testUpdateName() {
6761
6862 @ Test
6963 public void testUpdateBody () {
70- Notification notification = notificationRepo .create (TEST_NOTIFICATION_NAME , TEST_NOTIFICATION_BODY );
64+ Notification notification = notificationRepo .create (TEST_NOTIFICATION_NAME , TEST_NOTIFICATION_BODY , TEST_IS_ACTIVE , TEST_LOCATIONS );
7165 notification .setBody (TEST_ALTERNATE_NOTIFICATION_BODY );
72- notificationRepo .save (notification );
66+ notificationRepo .update (notification );
7367 notification = notificationRepo .findOne (notification .getId ());
7468 assertEquals ("Notification body was not changed" , TEST_ALTERNATE_NOTIFICATION_BODY , notification .getBody ());
7569 }
7670
7771 @ Test
7872 public void testDelete () {
7973 long initialCount = notificationRepo .count ();
80- Notification notification = notificationRepo .create (TEST_NOTIFICATION_NAME , TEST_NOTIFICATION_BODY );
74+ Notification notification = notificationRepo .create (TEST_NOTIFICATION_NAME , TEST_NOTIFICATION_BODY , TEST_IS_ACTIVE , TEST_LOCATIONS );
8175 assertEquals ("Notification not created" , initialCount + 1 , notificationRepo .count ());
8276 notificationRepo .delete (notification );
8377 assertEquals ("Notification was not deleted" , initialCount , notificationRepo .count ());
0 commit comments