@@ -40,12 +40,15 @@ public class NotificationControllerTest {
4040 protected static final String TEST_NOTIFICATION2_BODY = "Test Notification Body 2" ;
4141 protected static final String TEST_NOTIFICATION3_BODY = "Test Notification Body 3" ;
4242 protected static final String TEST_MODIFIED_NOTIFICATION_BODY = "Test Modified Notification Body" ;
43+ protected static final String TEST_QUERY_PARAM = "CUSHING" ;
44+ protected static final String TEST_NOTIFICATION_TEXT = "<p>Test Notification Body 1</p><p>Test Notification Body 2</p><p>Test Notification Body 3</p>" ;
4345 protected static final boolean TEST_IS_ACTIVE = true ;
46+ protected static final boolean TEST_ALTERNATIVE_IS_ACTIVE = false ;
4447 protected static final List <NotificationLocation > TEST_LOCATIONS = Arrays .asList (new NotificationLocation [] {NotificationLocation .CUSHING });
4548
4649 protected static Notification TEST_NOTIFICATION1 = new Notification (TEST_NOTIFICATION1_NAME , TEST_NOTIFICATION1_BODY , TEST_IS_ACTIVE , TEST_LOCATIONS );
4750 protected static Notification TEST_NOTIFICATION2 = new Notification (TEST_NOTIFICATION2_NAME ,TEST_NOTIFICATION2_BODY , TEST_IS_ACTIVE , TEST_LOCATIONS );
48- protected static Notification TEST_NOTIFICATION3 = new Notification (TEST_NOTIFICATION3_NAME , TEST_NOTIFICATION3_BODY , TEST_IS_ACTIVE , TEST_LOCATIONS );
51+ protected static Notification TEST_NOTIFICATION3 = new Notification (TEST_NOTIFICATION3_NAME , TEST_NOTIFICATION3_BODY , TEST_ALTERNATIVE_IS_ACTIVE , TEST_LOCATIONS );
4952 protected static Notification TEST_MODIFIED_NOTIFICATION = new Notification (TEST_MODIFIED_NOTIFICATION_NAME , TEST_NOTIFICATION2_BODY , TEST_IS_ACTIVE , TEST_LOCATIONS );
5053
5154 protected static List <Notification > mockNotificationList = new ArrayList <Notification >(Arrays .asList (new Notification [] { TEST_NOTIFICATION1 , TEST_NOTIFICATION2 , TEST_NOTIFICATION3 }));
@@ -69,6 +72,7 @@ public void setUp() {
6972 when (notificationRepo .findOne (any (Long .class ))).thenReturn (TEST_NOTIFICATION1 );
7073 when (notificationRepo .create (any (String .class ), any (String .class ), any (boolean .class ), anyListOf (NotificationLocation .class ))).thenReturn (TEST_NOTIFICATION1 );
7174 when (notificationRepo .update (any (Notification .class ))).thenReturn (TEST_MODIFIED_NOTIFICATION );
75+ when (notificationRepo .findByIsActiveAndLocations (any (boolean .class ), any (NotificationLocation .class ))).thenReturn (mockNotificationList );
7276 doNothing ().when (notificationRepo ).delete (any (Notification .class ));
7377 }
7478
@@ -112,6 +116,12 @@ public void testRemove() {
112116 assertEquals ("Not successful at removing Notification" , SUCCESS , response .getMeta ().getType ());
113117 }
114118
119+ @ Test
120+ public void testActiveNotifications () {
121+ String notifications = notificationController .getActiveNotifications (TEST_QUERY_PARAM );
122+ assertEquals ("Active Notifications not returned correctly" , TEST_NOTIFICATION_TEXT , notifications );
123+ }
124+
115125 @ After
116126 public void cleanUp () {
117127 response = null ;
0 commit comments