Last active
November 17, 2017 15:19
-
-
Save Romeh/ffcd4263f55e7c464388d75263288473 to your computer and use it in GitHub Desktop.
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
@RunWith(MockitoJUnitRunner.class) | |
public class IgniteAlertsSoreTest { | |
@Mock | |
private Ignite ignite; | |
@Mock | |
Cache<String, List<AlertEntry>> cache; | |
@Mock | |
IgniteCache IgniteCache; | |
@InjectMocks | |
private IgniteAlertsStore igniteAlertsStore; | |
//simulate the needed behaviour for the mocked ignite cache | |
@Before | |
public void setUp() throws Exception { | |
when(ignite.getOrCreateCache(anyString())).thenReturn(IgniteCache); | |
List<AlertEntry> entries=new ArrayList<>(); | |
entries.add(AlertEntry.builder().errorCode("errorCode").build()); | |
when(IgniteCache.get(anyString())).thenReturn(entries); | |
} | |
@Test | |
public void getAllAlerts() throws Exception { | |
assertEquals(igniteAlertsStore.getAlertForServiceId("serviceId").get(0).getErrorCode(),"errorCode"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment