This repository has been archived by the owner on Feb 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding unit tests for NotificationsCache (#492)
- Loading branch information
Philip Liew
authored and
GitHub Enterprise
committed
Jun 21, 2019
1 parent
7419d58
commit e1cf4b1
Showing
2 changed files
with
73 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
ArgusCore/src/test/java/com/salesforce/dva/argus/service/alert/NotificationsCacheTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package com.salesforce.dva.argus.service.alert; | ||
|
||
import com.google.common.collect.ImmutableMap; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.mockito.Matchers; | ||
import org.mockito.Mock; | ||
|
||
import java.math.BigInteger; | ||
import java.util.Map; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertSame; | ||
import static org.mockito.ArgumentMatchers.eq; | ||
import static org.mockito.Mockito.verify; | ||
|
||
@RunWith(org.mockito.junit.MockitoJUnitRunner.class) | ||
public class NotificationsCacheTest { | ||
@Mock | ||
private NotificationsCacheRefresherThread thread; | ||
private NotificationsCache cache; | ||
|
||
@Before | ||
public void setUp() { | ||
cache = new NotificationsCache(thread); | ||
} | ||
|
||
@Test | ||
public void initCacheAndStartRefresherThread_test() { | ||
verify(thread).runOnce(); | ||
verify(thread).start(); | ||
} | ||
|
||
@Test | ||
public void setNotificationCooldownExpirationMap_test() { | ||
Map<BigInteger, Map<String, Long>> notificationCooldownExpirationMap = ImmutableMap.of(BigInteger.TEN, | ||
ImmutableMap.of("TEST", Long.MIN_VALUE)); | ||
cache.setNotificationCooldownExpirationMap(notificationCooldownExpirationMap); | ||
assertSame(notificationCooldownExpirationMap, cache.getNotificationCooldownExpirationMap()); | ||
} | ||
|
||
@Test | ||
public void setNotificationActiveStatusMap_test() { | ||
Map<BigInteger, Map<String, Boolean>> notificationActiveStatusMap = ImmutableMap.of(BigInteger.TEN, | ||
ImmutableMap.of("TEST", Boolean.TRUE)); | ||
cache.setNotificationActiveStatusMap(notificationActiveStatusMap); | ||
assertSame(notificationActiveStatusMap, cache.getNotificationActiveStatusMap()); | ||
} | ||
|
||
@Test | ||
public void setNotificationsCacheRefreshed_test() { | ||
boolean refreshed = false; | ||
cache.setNotificationsCacheRefreshed(refreshed); | ||
assertEquals(refreshed, cache.isNotificationsCacheRefreshed()); | ||
refreshed = true; | ||
cache.setNotificationsCacheRefreshed(refreshed); | ||
assertEquals(refreshed, cache.isNotificationsCacheRefreshed()); | ||
} | ||
} |