Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @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");
- }
- }
Add Comment
Please, Sign In to add comment