Skip to content

Commit

Permalink
test a few more methods IQSS#7492
Browse files Browse the repository at this point in the history
  • Loading branch information
pdurbin committed May 16, 2022
1 parent 51521ca commit 6427be1
Showing 1 changed file with 41 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
*/
package edu.harvard.iq.dataverse.authorization.users;

import edu.harvard.iq.dataverse.UserNotification;
import edu.harvard.iq.dataverse.UserNotification.Type;
import edu.harvard.iq.dataverse.UserNotificationServiceBean;
import edu.harvard.iq.dataverse.authorization.AuthenticatedUserDisplayInfo;
import edu.harvard.iq.dataverse.authorization.AuthenticatedUserLookup;
import edu.harvard.iq.dataverse.mocks.MocksFactory;
import edu.harvard.iq.dataverse.settings.SettingsServiceBean;
import java.sql.Timestamp;
import java.util.Date;
import java.util.EnumSet;
Expand All @@ -21,14 +24,24 @@

import javax.json.JsonObject;
import javax.json.JsonString;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;

/**
* Tested class: AuthenticatedUser.java
*
* @author bsilverstein
*/
@RunWith(MockitoJUnitRunner.class)
public class AuthenticatedUserTest {

@Mock
private SettingsServiceBean settingsServiceBean;
@InjectMocks
private UserNotificationServiceBean userNotificationService;

public AuthenticatedUserTest() {
}

Expand Down Expand Up @@ -393,6 +406,34 @@ public void testTypeTokenizer() {
assertTrue("typeSet contains REVOKEROLE", typeSet.contains(Type.REVOKEROLE));
}

@Test
public void testIsEmailMuted() {
testUser.setMutedEmails(mutedTypes);
UserNotification userNotification = new UserNotification();
userNotification.setUser(testUser);
userNotification.setSendDate(null);
userNotification.setObjectId(null);
userNotification.setRequestor(null);
userNotification.setType(Type.ASSIGNROLE); // muted
assertTrue(userNotificationService.isEmailMuted(userNotification));
userNotification.setType(Type.APIGENERATED); // not muted
assertFalse(userNotificationService.isEmailMuted(userNotification));
}

@Test
public void isNotificationMuted() {
testUser.setMutedNotifications(mutedTypes);
UserNotification userNotification = new UserNotification();
userNotification.setUser(testUser);
userNotification.setSendDate(null);
userNotification.setObjectId(null);
userNotification.setRequestor(null);
userNotification.setType(Type.ASSIGNROLE); // muted
assertTrue(userNotificationService.isNotificationMuted(userNotification));
userNotification.setType(Type.APIGENERATED); // not muted
assertFalse(userNotificationService.isNotificationMuted(userNotification));
}

/**
* All commented tests below have only been generated / are not complete for
* AuthenticatedUser.java The tests above should all run fine, due to time
Expand Down

0 comments on commit 6427be1

Please sign in to comment.